diff --git a/apps/templates/snappymail-folder.yaml b/apps/templates/sogo-folder.yaml similarity index 70% rename from apps/templates/snappymail-folder.yaml rename to apps/templates/sogo-folder.yaml index a897856..01e2940 100644 --- a/apps/templates/snappymail-folder.yaml +++ b/apps/templates/sogo-folder.yaml @@ -1,22 +1,22 @@ apiVersion: argoproj.io/v1alpha1 kind: Application metadata: - name: snappymail-folder + name: sogo namespace: argocd finalizers: - - resources-finalizer.argocd.argoproj.io + - resources-finalizer.argocd.argoproj.io spec: project: default source: repoURL: https://github.com/rubenhensen/k8scd.git targetRevision: HEAD - path: snappymail + path: sogo destination: server: https://kubernetes.default.svc - namespace: snappymail + namespace: sogo syncPolicy: + syncOptions: + - CreateNamespace=true automated: selfHeal: true prune: true - syncOptions: - - CreateNamespace=true diff --git a/snappymail/deployment.yaml b/snappymail/deployment.yaml deleted file mode 100644 index e6c6a5b..0000000 --- a/snappymail/deployment.yaml +++ /dev/null @@ -1,53 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: snappymail - labels: - app: snappymail -spec: - replicas: 1 - strategy: - type: Recreate - selector: - matchLabels: - app: snappymail - template: - metadata: - labels: - app: snappymail - spec: - containers: - - name: snappymail - image: djmaze/snappymail:latest - ports: - - containerPort: 8888 - protocol: TCP - env: - - name: TZ - value: Europe/Amsterdam - volumeMounts: - - name: snappymail-data - mountPath: /var/lib/snappymail - livenessProbe: - httpGet: - path: / - port: 8888 - initialDelaySeconds: 30 - periodSeconds: 10 - readinessProbe: - httpGet: - path: / - port: 8888 - initialDelaySeconds: 10 - periodSeconds: 5 - resources: - requests: - memory: "128Mi" - cpu: "100m" - limits: - memory: "512Mi" - cpu: "500m" - volumes: - - name: snappymail-data - persistentVolumeClaim: - claimName: snappymail-data diff --git a/snappymail/ingress.yaml b/snappymail/ingress.yaml deleted file mode 100644 index a0dc103..0000000 --- a/snappymail/ingress.yaml +++ /dev/null @@ -1,27 +0,0 @@ -apiVersion: networking.k8s.io/v1 -kind: Ingress -metadata: - name: snappymail - labels: - app: snappymail - annotations: - cert-manager.io/cluster-issuer: prod-cluster-issuer - nginx.ingress.kubernetes.io/backend-protocol: "HTTP" - nginx.ingress.kubernetes.io/proxy-body-size: "50m" -spec: - ingressClassName: nginx - tls: - - hosts: - - post.hensen.io - secretName: snappymail-tls - rules: - - host: post.hensen.io - http: - paths: - - path: / - pathType: Prefix - backend: - service: - name: snappymail - port: - number: 80 diff --git a/snappymail/service.yaml b/snappymail/service.yaml deleted file mode 100644 index 2126068..0000000 --- a/snappymail/service.yaml +++ /dev/null @@ -1,14 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: snappymail - labels: - app: snappymail -spec: - type: ClusterIP - ports: - - port: 80 - targetPort: 8888 - protocol: TCP - selector: - app: snappymail diff --git a/sogo/configmap.yaml b/sogo/configmap.yaml new file mode 100644 index 0000000..f3e7570 --- /dev/null +++ b/sogo/configmap.yaml @@ -0,0 +1,66 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: sogo-config + namespace: sogo +data: + sogo.yaml: | + # Mail Server Configuration + SOGoIMAPServer: stalwart.stalwart.svc.cluster.local:143 + SOGoSMTPServer: stalwart.stalwart.svc.cluster.local:587 + SOGoMailDomain: hensen.io + SOGoForceIMAPLoginWithEmail: true + + # Database Configuration + SOGoProfileURL: "postgresql://sogo:${POSTGRES_PASSWORD}@sogo-postgres-rw.sogo.svc.cluster.local:5432/sogo/sogo_user_profile?sslmode=require" + OCSFolderInfoURL: "postgresql://sogo:${POSTGRES_PASSWORD}@sogo-postgres-rw.sogo.svc.cluster.local:5432/sogo/sogo_folder_info?sslmode=require" + OCSSessionsFolderURL: "postgresql://sogo:${POSTGRES_PASSWORD}@sogo-postgres-rw.sogo.svc.cluster.local:5432/sogo/sogo_sessions_folder?sslmode=require" + OCSAclURL: "postgresql://sogo:${POSTGRES_PASSWORD}@sogo-postgres-rw.sogo.svc.cluster.local:5432/sogo/sogo_acl?sslmode=require" + + # General Settings + SOGoTimeZone: Europe/Amsterdam + SOGoLanguage: English + SOGoSuperUsername: admin@hensen.io + + # Modules + SOGoModules: + - Mail + - Calendar + - Contacts + - Tasks + + # Calendar Settings + SOGoCalendarDefaultRoles: + - PublicViewer + - ConfidentialDAndTViewer + SOGoFirstDayOfWeek: 1 + SOGoFirstWeekOfYear: January1 + SOGoDayStartTime: 8 + SOGoDayEndTime: 18 + + # Authentication + SOGoAuthenticationType: IMAP + + # WebUI Settings + SOGoPageTitle: "SOGo @ hensen.io" + SOGoLoginModule: Mail + SOGoRefreshViewCheck: every_5_minutes + SOGoMailMessageCheck: every_5_minutes + + # Mail Preferences + SOGoMailAuxiliaryUserAccountsEnabled: true + SOGoMailComposeMessageType: html + SOGoMailReplyPlacement: below + SOGoMailSignaturePlacement: below + + # Security + SOGoPasswordChangeEnabled: false + SOGoXSRFValidationEnabled: true + + # Performance + SOGoMemcachedHost: "" + WOWorkersCount: 3 + WOListenQueueSize: 5 + WONoDetach: true + WOLogFile: "-" + WOPidFile: /var/run/sogo/sogo.pid diff --git a/sogo/deployment.yaml b/sogo/deployment.yaml new file mode 100644 index 0000000..f00964d --- /dev/null +++ b/sogo/deployment.yaml @@ -0,0 +1,86 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: sogo + namespace: sogo + labels: + app: sogo +spec: + replicas: 1 + strategy: + type: Recreate + selector: + matchLabels: + app: sogo + template: + metadata: + labels: + app: sogo + spec: + initContainers: + - name: config-init + image: alpine:latest + command: + - sh + - -c + - | + apk add --no-cache python3 + ENCODED_PASSWORD=$(python3 -c "import urllib.parse; print(urllib.parse.quote('${POSTGRES_PASSWORD}', safe=''))") + export POSTGRES_PASSWORD="${ENCODED_PASSWORD}" + cat /config-template/sogo.yaml | sed "s|\${POSTGRES_PASSWORD}|${POSTGRES_PASSWORD}|g" > /config/sogo.yaml + echo "Configuration file prepared with URL-encoded password" + env: + - name: POSTGRES_PASSWORD + valueFrom: + secretKeyRef: + name: sogo-postgres-credentials + key: password + volumeMounts: + - name: config-template + mountPath: /config-template + - name: config + mountPath: /config + containers: + - name: sogo + image: sonroyaalmerol/docker-sogo:latest + ports: + - containerPort: 80 + name: http + env: + - name: TZ + value: "Europe/Amsterdam" + volumeMounts: + - name: config + mountPath: /etc/sogo/sogo.conf.d/ + - name: data + mountPath: /srv/lib/sogo + resources: + requests: + memory: "512Mi" + cpu: "200m" + limits: + memory: "1Gi" + cpu: "1000m" + livenessProbe: + httpGet: + path: /SOGo + port: 80 + initialDelaySeconds: 60 + periodSeconds: 30 + timeoutSeconds: 5 + readinessProbe: + httpGet: + path: /SOGo + port: 80 + initialDelaySeconds: 30 + periodSeconds: 10 + timeoutSeconds: 5 + volumes: + - name: config-template + configMap: + name: sogo-config + - name: config + emptyDir: {} + - name: data + persistentVolumeClaim: + claimName: sogo-data diff --git a/sogo/external-secret.yaml b/sogo/external-secret.yaml new file mode 100644 index 0000000..101d895 --- /dev/null +++ b/sogo/external-secret.yaml @@ -0,0 +1,22 @@ +apiVersion: external-secrets.io/v1beta1 +kind: ExternalSecret +metadata: + name: sogo-postgres-credentials + namespace: sogo +spec: + refreshInterval: 15m + secretStoreRef: + name: vault-backend + kind: ClusterSecretStore + target: + name: sogo-postgres-credentials + creationPolicy: Owner + template: + data: + username: "sogo" + password: "{{ .postgres_pw }}" + data: + - secretKey: postgres_pw + remoteRef: + key: kv/sogo + property: postgres_pw diff --git a/sogo/ingress.yaml b/sogo/ingress.yaml new file mode 100644 index 0000000..490bd4c --- /dev/null +++ b/sogo/ingress.yaml @@ -0,0 +1,26 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: sogo + namespace: sogo + annotations: + cert-manager.io/cluster-issuer: prod-cluster-issuer + nginx.ingress.kubernetes.io/backend-protocol: HTTP + nginx.ingress.kubernetes.io/proxy-body-size: "50m" +spec: + ingressClassName: nginx + tls: + - hosts: + - post.hensen.io + secretName: sogo-tls + rules: + - host: post.hensen.io + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: sogo + port: + number: 80 diff --git a/sogo/postgresql-cluster.yaml b/sogo/postgresql-cluster.yaml new file mode 100644 index 0000000..e2394e7 --- /dev/null +++ b/sogo/postgresql-cluster.yaml @@ -0,0 +1,25 @@ +apiVersion: postgresql.cnpg.io/v1 +kind: Cluster +metadata: + name: sogo-postgres + namespace: sogo +spec: + instances: 1 + + storage: + size: 10Gi + storageClass: longhorn + + bootstrap: + initdb: + database: sogo + owner: sogo + secret: + name: sogo-postgres-credentials + postInitSQL: + - CREATE EXTENSION IF NOT EXISTS pg_trgm; + + postgresql: + parameters: + max_connections: "100" + shared_buffers: "256MB" diff --git a/snappymail/pvc.yaml b/sogo/pvc.yaml similarity index 66% rename from snappymail/pvc.yaml rename to sogo/pvc.yaml index 0fe58ba..d1063a9 100644 --- a/snappymail/pvc.yaml +++ b/sogo/pvc.yaml @@ -1,12 +1,11 @@ apiVersion: v1 kind: PersistentVolumeClaim metadata: - name: snappymail-data - labels: - app: snappymail + name: sogo-data + namespace: sogo spec: accessModes: - - ReadWriteOnce + - ReadWriteOnce storageClassName: longhorn resources: requests: diff --git a/sogo/service.yaml b/sogo/service.yaml new file mode 100644 index 0000000..f21ee74 --- /dev/null +++ b/sogo/service.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: Service +metadata: + name: sogo + namespace: sogo + labels: + app: sogo +spec: + type: ClusterIP + ports: + - port: 80 + targetPort: 80 + protocol: TCP + name: http + selector: + app: sogo