Browse Source

Update Nginx version and config for mailproxy

master
parent
commit
577f371e25
  1. 23
      charts/mailproxy/v0.2.0/.helmignore
  2. 9
      charts/mailproxy/v0.2.0/Chart.yaml
  3. 1
      charts/mailproxy/v0.2.0/templates/NOTES.txt
  4. 62
      charts/mailproxy/v0.2.0/templates/_helpers.tpl
  5. 83
      charts/mailproxy/v0.2.0/templates/mailauth-deployment.yaml
  6. 17
      charts/mailproxy/v0.2.0/templates/mailauth-service.yaml
  7. 13
      charts/mailproxy/v0.2.0/templates/nginx-certificate.yaml
  8. 84
      charts/mailproxy/v0.2.0/templates/nginx-configmap.yaml
  9. 108
      charts/mailproxy/v0.2.0/templates/nginx-deployment.yaml
  10. 57
      charts/mailproxy/v0.2.0/templates/nginx-mailhosts-conf.yaml
  11. 21
      charts/mailproxy/v0.2.0/templates/nginx-service.yaml
  12. 86
      charts/mailproxy/v0.2.0/values.yaml

23
charts/mailproxy/v0.2.0/.helmignore

@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/

9
charts/mailproxy/v0.2.0/Chart.yaml

@ -0,0 +1,9 @@
apiVersion: v2
name: mailproxy
description: A Mail Proxy using Nginx and a PHP script
type: application
version: 0.2.0
appVersion: "1.30.7"

1
charts/mailproxy/v0.2.0/templates/NOTES.txt

@ -0,0 +1 @@
Mailproxy instalado!

62
charts/mailproxy/v0.2.0/templates/_helpers.tpl

@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "mailproxy.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "mailproxy.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "mailproxy.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Common labels
*/}}
{{- define "mailproxy.common.selectorLabels" -}}
app.kubernetes.io/name: {{ include "mailproxy.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{- define "mailproxy.labels" -}}
helm.sh/chart: {{ include "mailproxy.chart" . }}
{{ include "mailproxy.common.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
{{/*
Selector labels
*/}}
{{- define "mailproxy.nginx.selectorLabels" -}}
{{ include "mailproxy.common.selectorLabels" . }}
app.kubernetes.io/component: nginx
{{- end }}
{{- define "mailproxy.mailauth.selectorLabels" -}}
{{ include "mailproxy.common.selectorLabels" . }}
app.kubernetes.io/component: mailauth
{{- end }}

83
charts/mailproxy/v0.2.0/templates/mailauth-deployment.yaml

@ -0,0 +1,83 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "mailproxy.fullname" . }}-mailauth
labels:
{{- include "mailproxy.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.mailauth.replicaCount }}
selector:
matchLabels:
{{- include "mailproxy.mailauth.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "mailproxy.mailauth.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.mailauth.image.repository }}:{{ .Values.mailauth.image.tag }}"
imagePullPolicy: {{ .Values.mailauth.image.pullPolicy }}
ports:
{{- range $i, $port := .Values.mailauth.service.ports }}
- name: {{ $port.name }}
containerPort: {{ $port.number }}
protocol: {{ $port.protocol }}
{{- end }}
{{- if .Values.mailauth.relayHost }}
env:
- name: RELAY_HOST
value: {{ .Values.mailauth.relayHost | quote }}
{{- end }}
livenessProbe:
tcpSocket:
port: {{ (index .Values.mailauth.service.ports 0).number }}
initialDelaySeconds: 5
periodSeconds: 10
readinessProbe:
tcpSocket:
port: {{ (index .Values.mailauth.service.ports 0).number }}
initialDelaySeconds: 5
periodSeconds: 10
resources:
{{- toYaml .Values.mailauth.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
labelSelector:
matchExpressions:
- key: app.kubernetes.io/name
operator: In
values:
- {{ include "mailproxy.name" . }}
- key: app.kubernetes.io/instance
operator: In
values:
- {{ .Release.Name }}
- key: app.kubernetes.io/component
operator: In
values:
- mailauth
topologyKey: "kubernetes.io/hostname"
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}

17
charts/mailproxy/v0.2.0/templates/mailauth-service.yaml

@ -0,0 +1,17 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "mailproxy.fullname" . }}-mailauth
labels:
{{- include "mailproxy.labels" . | nindent 4 }}
spec:
type: {{ .Values.mailauth.service.type }}
ports:
{{- range $i, $port := .Values.mailauth.service.ports }}
- port: {{ $port.number }}
targetPort: {{ $port.number }}
protocol: {{ $port.protocol }}
name: {{ $port.name }}
{{- end }}
selector:
{{- include "mailproxy.mailauth.selectorLabels" . | nindent 4 }}

13
charts/mailproxy/v0.2.0/templates/nginx-certificate.yaml

@ -0,0 +1,13 @@
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: {{ include "mailproxy.fullname" . }}
labels:
{{- include "mailproxy.labels" . | nindent 4 }}
spec:
secretName: {{ include "mailproxy.fullname" . }}-tls
issuerRef:
name: {{ .Values.nginx.certificate.issuer }}
kind: {{ .Values.nginx.certificate.issuerKind }}
dnsNames:
{{- toYaml .Values.nginx.certificate.dnsNames | nindent 4 }}

84
charts/mailproxy/v0.2.0/templates/nginx-configmap.yaml

@ -0,0 +1,84 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "mailproxy.fullname" . }}-nginx-conf
labels:
{{- include "mailproxy.labels" . | nindent 4 }}
data:
nginx-conf: |-
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile off;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
mail {
include /etc/nginx/mailhosts/*.conf;
}
phpfpm-conf: |-
upstream backend {
server {{ include "mailproxy.fullname" . }}-mailauth:9000;
}
server {
listen 8080 default_server;
server_name localhost;
access_log /dev/stdout;
error_log /dev/stderr;
root /var/www/html;
index index.php;
location ~ /\.ht {
deny all;
}
location ~* ^.+.(css|js|jpeg|jpg|gif|png|ico) {
expires 30d;
}
location ~ \.php$ {
fastcgi_pass backend;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
{{ if .Values.nginx.noAuthSmtpServerIP -}}
location = /noauth {
add_header Auth-Status OK;
add_header Auth-Server {{ .Values.nginx.noAuthSmtpServerIP }};
add_header Auth-Port 25;
return 204;
}
{{- end }}
}

108
charts/mailproxy/v0.2.0/templates/nginx-deployment.yaml

@ -0,0 +1,108 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "mailproxy.fullname" . }}-nginx
labels:
{{- include "mailproxy.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.nginx.replicaCount }}
selector:
matchLabels:
{{- include "mailproxy.nginx.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "mailproxy.nginx.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
args:
- timeout
- --preserve-status
- --foreground
- {{ .Values.nginx.restartEvery }}
- /usr/sbin/nginx
- -g
- daemon off;
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.nginx.image.repository }}:{{ .Values.nginx.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.nginx.image.pullPolicy }}
ports:
{{- range $i, $port := .Values.nginx.service.ports }}
- name: {{ $port.name }}
containerPort: {{ $port.number }}
protocol: {{ $port.protocol }}
{{- end }}
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
tcpSocket:
port: {{ (index .Values.nginx.service.ports 0).number }}
initialDelaySeconds: 10
periodSeconds: 15
volumeMounts:
- mountPath: /etc/nginx/nginx.conf
subPath: nginx-conf
name: nginx-conf
- mountPath: /etc/nginx/conf.d/phpfpm.conf
subPath: phpfpm-conf
name: nginx-conf
- mountPath: /etc/nginx/mailhosts
name: mailhosts-conf
readOnly: true
- mountPath: /etc/nginx/ssl
name: mailproxy-tls
readOnly: true
resources:
{{- toYaml .Values.nginx.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
labelSelector:
matchExpressions:
- key: app.kubernetes.io/name
operator: In
values:
- {{ include "mailproxy.name" . }}
- key: app.kubernetes.io/instance
operator: In
values:
- {{ .Release.Name }}
- key: app.kubernetes.io/component
operator: In
values:
- nginx
topologyKey: "kubernetes.io/hostname"
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: nginx-conf
configMap:
name: {{ include "mailproxy.fullname" . }}-nginx-conf
- name: mailhosts-conf
configMap:
name: {{ include "mailproxy.fullname" . }}-mailhosts-conf
- name: mailproxy-tls
secret:
secretName: {{ include "mailproxy.fullname" . }}-tls

57
charts/mailproxy/v0.2.0/templates/nginx-mailhosts-conf.yaml

@ -0,0 +1,57 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "mailproxy.fullname" . }}-mailhosts-conf
labels:
{{- include "mailproxy.labels" . | nindent 4 }}
data:
imap.conf: |-
server {
listen 993 ssl;
server_name localhost;
protocol imap;
auth_http localhost:8080/auth-mail.php;
proxy_pass_error_message on;
}
pop.conf: |-
server {
listen 995 ssl;
server_name localhost;
protocol pop3;
auth_http localhost:8080/auth-mail.php;
proxy_pass_error_message on;
}
smtp.conf: |-
server {
listen 587;
server_name localhost;
protocol smtp;
auth_http localhost:8080/auth-mail.php;
starttls only;
xclient on;
proxy_pass_error_message on;
}
{{ if .Values.nginx.noAuthSmtpServerIP -}}
noauthsmtp.conf: |-
server {
listen 25;
server_name localhost;
protocol smtp;
smtp_auth none;
smtp_capabilities none;
auth_http localhost:8080/noauth;
xclient on;
starttls on;
}
{{- end }}
ssl.conf: |-
ssl_certificate /etc/nginx/ssl/tls.crt;
ssl_certificate_key /etc/nginx/ssl/tls.key;
ssl_session_timeout 4h;
ssl_session_cache shared:MAIL:10m;
ssl_session_tickets off;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH;
ssl_prefer_server_ciphers on;

21
charts/mailproxy/v0.2.0/templates/nginx-service.yaml

@ -0,0 +1,21 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "mailproxy.fullname" . }}-nginx
labels:
{{- include "mailproxy.labels" . | nindent 4 }}
annotations:
{{- toYaml .Values.nginx.service.annotations | nindent 4 }}
spec:
type: {{ .Values.nginx.service.type }}
ports:
{{- range $i, $port := .Values.nginx.service.ports }}
- port: {{ $port.number }}
targetPort: {{ $port.number }}
protocol: {{ $port.protocol }}
name: {{ $port.name }}
{{- end }}
externalTrafficPolicy: {{ .Values.nginx.service.externalTrafficPolicy }}
selector:
{{- include "mailproxy.nginx.selectorLabels" . | nindent 4 }}
loadBalancerIP: {{ .Values.nginx.service.loadBalancerIP }}

86
charts/mailproxy/v0.2.0/values.yaml

@ -0,0 +1,86 @@
# Default values for mailproxy.
nginx:
image:
repository: nginx
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: ""
replicaCount: 2
service:
type: ClusterIP
externalTrafficPolicy: Cluster
ports:
- name: imaps
number: 993
protocol: TCP
- name: pops
number: 995
protocol: TCP
- name: smtp
number: 587
protocol: TCP
- name: noauthsmtp
number: 25
protocol: TCP
annotations: {}
loadBalancerIP: ""
noAuthSmtpServerIP: ""
# Restart container to reload periodically. A number with a suffix:
# 's' for seconds (default) , 'm' for minutes, 'h' for hours or 'd' for days.
# Specifying 0 disables the timeout.
restartEvery: 30d
certificate:
issuer: letsencrypt-staging
issuerKind: ClusterIssuer
dnsNames:
- mail.com
resources: {}
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi
mailauth:
image:
repository: porto.interlegis.leg.br/seit/rancher-nginx-mailproxy
pullPolicy: IfNotPresent
tag: "0.1.0"
replicaCount: 2
service:
type: ClusterIP
ports:
- name: php-fpm
number: 9000
protocol: TCP
relayHost: ""
resources: {}
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi
imagePullSecrets: []
podAnnotations: {}
podSecurityContext: {}
# fsGroup: 2000
securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000
nodeSelector: {}
tolerations: []
affinity: {}
Loading…
Cancel
Save