From 41a99f29ac6a9ec725d3d75e2ecd4fe46d0628a6 Mon Sep 17 00:00:00 2001 From: pieter Date: Thu, 20 Nov 2025 07:57:52 +0000 Subject: [PATCH] =?UTF-8?q?templates/deployment.yaml=20=E3=82=92=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/deployment.yaml | 104 ++++++++++++++++++++++++-------------- 1 file changed, 66 insertions(+), 38 deletions(-) diff --git a/templates/deployment.yaml b/templates/deployment.yaml index 0200f92..e6bf23d 100644 --- a/templates/deployment.yaml +++ b/templates/deployment.yaml @@ -1,69 +1,97 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: {{ include "{{ .Chart.Name }}.fullname" . }} + name: {{ include "wordpress-nginx.fullname" . }} labels: - {{- include "{{ .Chart.Name }}.labels" . | nindent 4 }} + {{- include "wordpress-nginx.labels" . | nindent 4 }} spec: replicas: {{ .Values.replicaCount }} selector: matchLabels: - {{- include "{{ .Chart.Name }}.selectorLabels" . | nindent 6 }} + {{- include "wordpress-nginx.selectorLabels" . | nindent 6 }} template: metadata: labels: - {{- include "{{ .Chart.Name }}.selectorLabels" . | nindent 8 }} + {{- include "wordpress-nginx.selectorLabels" . | nindent 8 }} spec: + initContainers: + - name: wordpress-init + image: "{{ .Values.image.wordpress.registry }}/{{ .Values.image.wordpress.repository }}:{{ .Values.image.wordpress.tag }}" + imagePullPolicy: {{ .Values.image.wordpress.pullPolicy }} + command: ["/bin/sh", "-c"] + args: + - | + if [ ! -f /var/www/html/wp-config.php ]; then + cp -r /usr/src/wordpress/* /var/www/html/ + chown -R www-data:www-data /var/www/html + fi + volumeMounts: + - name: wordpress-data + mountPath: /var/www/html containers: - name: nginx image: "{{ .Values.image.nginx.registry }}/{{ .Values.image.nginx.repository }}:{{ .Values.image.nginx.tag }}" imagePullPolicy: {{ .Values.image.nginx.pullPolicy }} ports: - - containerPort: 80 + - name: http + containerPort: 80 + protocol: TCP volumeMounts: - - name: app-storage + - name: wordpress-data mountPath: /var/www/html - subPath: html - name: nginx-config - mountPath: /etc/nginx/nginx.conf - subPath: nginx.conf - - name: app-fpm - image: "{{ .Values.image.php.registry }}/{{ .Values.image.php.repository }}:{{ .Values.image.php.tag }}" - imagePullPolicy: {{ .Values.image.php.pullPolicy }} - ports: - - name: fpm - containerPort: 9000 # PHP-FPMは9000ポートでリッスン - volumeMounts: - - name: app-storage - mountPath: /var/www/html - subPath: html + mountPath: /etc/nginx/conf.d/default.conf + subPath: default.conf + {{- if .Values.healthCheck.enabled }} + livenessProbe: + {{- toYaml .Values.healthCheck.livenessProbe | nindent 12 }} + readinessProbe: + {{- toYaml .Values.healthCheck.readinessProbe | nindent 12 }} + {{- end }} + resources: + {{- toYaml .Values.resources.nginx | nindent 12 }} + - name: wordpress + image: "{{ .Values.image.wordpress.registry }}/{{ .Values.image.wordpress.repository }}:{{ .Values.image.wordpress.tag }}" + imagePullPolicy: {{ .Values.image.wordpress.pullPolicy }} env: - - name: DB_HOST - value: {{ .Values.externalDatabase.host | quote }} - - name: DB_PORT - value: {{ .Values.externalDatabase.port | quote }} - - name: DB_NAME - value: {{ .Values.externalDatabase.database | quote }} - - name: DB_USER - value: {{ .Values.externalDatabase.username | quote }} - - name: DB_PASSWORD + - name: WORDPRESS_DB_HOST + value: {{ .Values.wordpress.dbHost | quote }} + - name: WORDPRESS_DB_NAME + value: {{ .Values.wordpress.dbName | quote }} + - name: WORDPRESS_DB_USER + value: {{ .Values.wordpress.dbUser | quote }} + - name: WORDPRESS_DB_PASSWORD valueFrom: secretKeyRef: - name: {{ include "{{ .Chart.Name }}.fullname" . }}-db-secret - key: {{ include "{{ .Chart.Name }}.fullname" . }}-db-key - dnsPolicy: ClusterFirst - dnsConfig: - options: - - name: ndots - value: "1" + name: {{ include "wordpress-nginx.fullname" . }}-secret + key: db-password + - name: WORDPRESS_TABLE_PREFIX + value: {{ .Values.wordpress.tablePrefix | quote }} + volumeMounts: + - name: wordpress-data + mountPath: /var/www/html + resources: + {{- toYaml .Values.resources.wordpress | nindent 12 }} volumes: - - name: app-storage + - name: wordpress-data {{- if .Values.persistence.enabled }} persistentVolumeClaim: - claimName: {{ include "{{ .Chart.Name }}.fullname" . }}-pvc + claimName: {{ include "wordpress-nginx.fullname" . }}-pvc {{- else }} emptyDir: {} {{- end }} - name: nginx-config configMap: - name: {{ include "{{ .Chart.Name }}.fullname" . }}-nginx-config + name: {{ include "wordpress-nginx.fullname" . }}-nginx-config + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} \ No newline at end of file