apiVersion: apps/v1 kind: Deployment metadata: name: {{ taskserv.name }} namespace: {{ taskserv.namespace }} labels: app.kubernetes.io/name: {{ taskserv.name }} app.kubernetes.io/managed-by: provisioning spec: replicas: 1 strategy: type: Recreate selector: matchLabels: app.kubernetes.io/name: {{ taskserv.name }} template: metadata: labels: app.kubernetes.io/name: {{ taskserv.name }} app.kubernetes.io/managed-by: provisioning spec: {% if taskserv.placement is defined and taskserv.placement.node_class %} affinity: nodeAffinity: {% if taskserv.placement.mode == "require" %} requiredDuringSchedulingIgnoredDuringExecution: nodeSelectorTerms: - matchExpressions: - key: node-class.{{ taskserv.placement.node_class.0 }} operator: In values: ["true"] {% else %} preferredDuringSchedulingIgnoredDuringExecution: {% for c in taskserv.placement.node_class %} - weight: {{ 100 - loop.index0 * 10 }} preference: matchExpressions: - key: node-class.{{ c }} operator: In values: ["true"] {% endfor %} {% endif %} {% endif %} imagePullSecrets: - name: {{ taskserv.registry_secret }} terminationGracePeriodSeconds: 30 volumes: - name: wp-data persistentVolumeClaim: claimName: {{ taskserv.name }}-data - name: nginx-config configMap: name: {{ taskserv.name }}-nginx items: - key: nginx.conf path: nginx.conf - key: default.conf path: conf.d/default.conf - name: nginx-cache emptyDir: {} - name: htpasswd secret: secretName: {{ taskserv.name }}-htpasswd items: - key: htpasswd path: htpasswd - name: mu-smtp configMap: name: {{ taskserv.name }}-mu-smtp items: - key: smtp-config.php path: smtp-config.php {% if taskserv.fpm_pool_extra %} - name: fpm-pool configMap: name: {{ taskserv.name }}-fpm-pool items: - key: zz-custom.conf path: zz-custom.conf {% endif %} containers: - name: fpm image: {{ taskserv.image }}:{{ taskserv.image_tag }} imagePullPolicy: IfNotPresent ports: - name: fpm containerPort: 9000 protocol: TCP env: - name: WORDPRESS_DB_HOST value: "{{ taskserv.db_host }}" - name: WORDPRESS_DB_NAME value: "{{ taskserv.db_name }}" - name: WORDPRESS_DB_USER value: "{{ taskserv.db_user }}" - name: WORDPRESS_DB_PASSWORD valueFrom: secretKeyRef: name: {{ taskserv.name }}-credentials key: WORDPRESS_DB_PASSWORD - name: WORDPRESS_TABLE_PREFIX value: "{{ taskserv.db_table_prefix }}" - name: WORDPRESS_HOME value: "{{ taskserv.wordpress_home }}" - name: WORDPRESS_SITEURL value: "{{ taskserv.wordpress_siteurl }}" - name: SMTP_HOST value: "{{ taskserv.smtp_host }}" - name: SMTP_PORT value: "{{ taskserv.smtp_port }}" - name: SMTP_FROM value: "{{ taskserv.smtp_from }}" - name: SMTP_FROM_NAME value: "{{ taskserv.smtp_from_name }}" - name: SMTP_USER valueFrom: secretKeyRef: name: {{ taskserv.name }}-credentials key: SMTP_USER - name: SMTP_PASS valueFrom: secretKeyRef: name: {{ taskserv.name }}-credentials key: SMTP_PASS volumeMounts: - name: wp-data mountPath: /var/www/html - name: mu-smtp mountPath: /var/www/html/wp-content/mu-plugins/smtp-config.php subPath: smtp-config.php {% if taskserv.fpm_pool_extra %} - name: fpm-pool mountPath: /usr/local/etc/php-fpm.d/zz-custom.conf subPath: zz-custom.conf {% endif %} {% if taskserv.resources_effective is defined %} resources: requests: cpu: "{{ taskserv.resources_effective.cpu.request }}" memory: "{{ taskserv.resources_effective.memory.request }}" limits: cpu: "{{ taskserv.resources_effective.cpu.limit }}" memory: "{{ taskserv.resources_effective.memory.limit }}" {% else %} resources: requests: cpu: "100m" memory: "256Mi" limits: cpu: "1000m" memory: "512Mi" {% endif %} {% if taskserv.probes is defined and taskserv.probes.readiness is defined %} readinessProbe: {% if taskserv.probes.readiness.type == "tcp" %} tcpSocket: port: {{ taskserv.probes.readiness.port | default(value=9000) }} {% else %} httpGet: path: {{ taskserv.probes.readiness.path }} port: {{ taskserv.probes.readiness.port | default(value=9000) }} {% endif %} initialDelaySeconds: {{ taskserv.probes.readiness.initial_delay }} periodSeconds: {{ taskserv.probes.readiness.period }} failureThreshold: {{ taskserv.probes.readiness.failure_threshold }} {% else %} readinessProbe: tcpSocket: port: 9000 initialDelaySeconds: 15 periodSeconds: 10 failureThreshold: 6 {% endif %} - name: nginx image: {{ taskserv.nginx_image }} imagePullPolicy: IfNotPresent ports: - name: http containerPort: 80 protocol: TCP volumeMounts: - name: wp-data mountPath: /var/www/html - name: nginx-config mountPath: /etc/nginx/nginx.conf subPath: nginx.conf - name: nginx-config mountPath: /etc/nginx/conf.d/default.conf subPath: conf.d/default.conf - name: nginx-cache mountPath: /tmp/nginx-cache - name: htpasswd mountPath: /etc/nginx/htpasswd subPath: htpasswd {% if taskserv.nginx_resources_effective is defined %} resources: requests: cpu: "{{ taskserv.nginx_resources_effective.cpu.request }}" memory: "{{ taskserv.nginx_resources_effective.memory.request }}" limits: cpu: "{{ taskserv.nginx_resources_effective.cpu.limit }}" memory: "{{ taskserv.nginx_resources_effective.memory.limit }}" {% else %} resources: requests: cpu: "50m" memory: "64Mi" limits: cpu: "500m" memory: "128Mi" {% endif %} {% if taskserv.nginx_probes is defined and taskserv.nginx_probes.readiness is defined %} readinessProbe: {% if taskserv.nginx_probes.readiness.type == "tcp" %} tcpSocket: port: {{ taskserv.nginx_probes.readiness.port | default(value=80) }} {% else %} httpGet: path: {{ taskserv.nginx_probes.readiness.path }} port: {{ taskserv.nginx_probes.readiness.port | default(value=80) }} {% endif %} initialDelaySeconds: {{ taskserv.nginx_probes.readiness.initial_delay }} periodSeconds: {{ taskserv.nginx_probes.readiness.period }} failureThreshold: {{ taskserv.nginx_probes.readiness.failure_threshold }} {% else %} readinessProbe: httpGet: path: /health_check port: 80 initialDelaySeconds: 10 periodSeconds: 10 failureThreshold: 6 {% endif %} {% if taskserv.nginx_probes is defined and taskserv.nginx_probes.liveness is defined %} livenessProbe: {% if taskserv.nginx_probes.liveness.type == "tcp" %} tcpSocket: port: {{ taskserv.nginx_probes.liveness.port | default(value=80) }} {% else %} httpGet: path: {{ taskserv.nginx_probes.liveness.path }} port: {{ taskserv.nginx_probes.liveness.port | default(value=80) }} {% endif %} initialDelaySeconds: {{ taskserv.nginx_probes.liveness.initial_delay }} periodSeconds: {{ taskserv.nginx_probes.liveness.period }} failureThreshold: {{ taskserv.nginx_probes.liveness.failure_threshold }} {% else %} livenessProbe: httpGet: path: /health_check port: 80 initialDelaySeconds: 30 periodSeconds: 30 failureThreshold: 3 {% endif %}