apiVersion: v1 kind: ConfigMap metadata: name: postgres data: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres POSTGRES_DB: nextcloud --- apiVersion: v1 kind: ConfigMap metadata: name: postgres-init data: init-user-db.sh: | #!/bin/bash set -e psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL CREATE USER nextcloud PASSWORD 'nextcloud'; GRANT ALL PRIVILEGES ON DATABASE nextcloud TO nextcloud; GRANT USAGE, CREATE ON SCHEMA public TO nextcloud; EOSQL --- apiVersion: v1 kind: ConfigMap metadata: name: nextcloud data: NEXTCLOUD_TRUSTED_DOMAINS: "nextcloud.reeseapps.com" OVERWRITEPROTOCOL: https NEXTCLOUD_ADMIN_USER: admin NEXTCLOUD_ADMIN_PASSWORD: 9quirky4 POSTGRES_USER: nextcloud POSTGRES_PASSWORD: nextcloud POSTGRES_HOST: localhost POSTGRES_DB: nextcloud REDIS_HOST: localhost REDIS_HOST_PASSWORD: redis --- apiVersion: apps/v1 kind: Deployment metadata: name: nextcloud spec: selector: matchLabels: app.kubernetes.io/name: nextcloud strategy: type: Recreate template: metadata: labels: app.kubernetes.io/name: nextcloud spec: containers: - name: nextcloud image: nextcloud:26 ports: - containerPort: 80 name: http envFrom: - configMapRef: name: nextcloud volumeMounts: - mountPath: /var/www/html name: html - mountPath: /var/www/html/data name: data resources: requests: memory: "1Gi" cpu: "1m" limits: memory: "1Gi" cpu: "1" - name: postgres image: postgres:15 envFrom: - configMapRef: name: postgres volumeMounts: - name: postgres mountPath: /var/lib/postgresql/data - name: postgres-init mountPath: /docker-entrypoint-initdb.d/init-user-db.sh subPath: init-user-db.sh ports: - containerPort: 5432 name: postgres resources: requests: memory: "1Gi" cpu: "1m" limits: memory: "1Gi" cpu: "1" - name: redis image: redis:7 ports: - containerPort: 6379 name: redis volumeMounts: - mountPath: /data name: redis command: - redis-server - --save - "60" - "1" - --loglevel - warning - --requirepass - redis resources: requests: memory: "1Gi" cpu: "1m" limits: memory: "1Gi" cpu: "1" volumes: - name: html emptyDir: sizeLimit: 500Mi - name: data emptyDir: sizeLimit: 500Mi - name: postgres emptyDir: sizeLimit: 500Mi - name: redis emptyDir: sizeLimit: 500Mi - name: postgres-init configMap: name: postgres-init --- apiVersion: v1 kind: Service metadata: name: nextcloud spec: type: ClusterIP selector: app.kubernetes.io/name: nextcloud ports: - name: http protocol: TCP port: 80 targetPort: http --- apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: nextcloud annotations: cert-manager.io/cluster-issuer: letsencrypt kubernetes.io/ingress.class: nginx nginx.ingress.kubernetes.io/proxy-body-size: "0" nginx.org/client-max-body-size: "0" spec: rules: - host: nextcloud.reeseapps.com http: paths: - path: / pathType: Prefix backend: service: name: nextcloud port: name: http tls: - hosts: - nextcloud.reeseapps.com secretName: nextcloud-tls-cert