From 95e3c70043773c411166bea52ead5ca6ad4f731e Mon Sep 17 00:00:00 2001 From: pieter Date: Wed, 3 Dec 2025 10:52:34 +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 | 143 +++++++++++++++++++++++++++----------- 1 file changed, 102 insertions(+), 41 deletions(-) diff --git a/templates/deployment.yaml b/templates/deployment.yaml index 0200f92..75cb335 100644 --- a/templates/deployment.yaml +++ b/templates/deployment.yaml @@ -1,69 +1,130 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: {{ include "{{ .Chart.Name }}.fullname" . }} + name: {{ include "yourls-nginx.fullname" . }} labels: - {{- include "{{ .Chart.Name }}.labels" . | nindent 4 }} + {{- include "yourls-nginx.labels" . | nindent 4 }} spec: replicas: {{ .Values.replicaCount }} selector: matchLabels: - {{- include "{{ .Chart.Name }}.selectorLabels" . | nindent 6 }} + {{- include "yourls-nginx.selectorLabels" . | nindent 6 }} template: metadata: labels: - {{- include "{{ .Chart.Name }}.selectorLabels" . | nindent 8 }} + {{- include "yourls-nginx.selectorLabels" . | nindent 8 }} spec: + initContainers: + - name: wait-for-mysql + image: busybox:1.36 + command: + - sh + - -c + - | + until nc -z {{ include "yourls-nginx.fullname" . }}-mysql 3306; do + echo "Waiting for MySQL..." + sleep 2 + done containers: + # NGINX Container - 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 - 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: /etc/nginx/conf.d + - name: yourls-data mountPath: /var/www/html - subPath: html + resources: + {{- toYaml .Values.resources.nginx | nindent 12 }} + livenessProbe: + httpGet: + path: / + port: http + initialDelaySeconds: 30 + periodSeconds: 10 + readinessProbe: + httpGet: + path: / + port: http + initialDelaySeconds: 5 + periodSeconds: 5 + + # YOURLS PHP-FPM Container + - name: yourls + image: "{{ .Values.image.yourls.registry }}/{{ .Values.image.yourls.repository }}:{{ .Values.image.yourls.tag }}" + imagePullPolicy: {{ .Values.image.yourls.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: YOURLS_DB_HOST + value: "{{ include "yourls-nginx.fullname" . }}-mysql" + - name: YOURLS_DB_USER + value: {{ .Values.mysql.auth.username | quote }} + - name: YOURLS_DB_PASS 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 "yourls-nginx.fullname" . }}-mysql + key: mysql-password + - name: YOURLS_DB_NAME + value: {{ .Values.mysql.auth.database | quote }} + - name: YOURLS_SITE + value: {{ .Values.yourls.config.site | quote }} + - name: YOURLS_USER + value: {{ .Values.yourls.config.username | quote }} + - name: YOURLS_PASS + valueFrom: + secretKeyRef: + name: {{ include "yourls-nginx.fullname" . }}-secret + key: yourls-password + - name: YOURLS_COOKIEKEY + valueFrom: + secretKeyRef: + name: {{ include "yourls-nginx.fullname" . }}-secret + key: yourls-cookiekey + - name: YOURLS_HOURS_OFFSET + value: {{ .Values.yourls.config.hours_offset | quote }} + - name: YOURLS_LANG + value: {{ .Values.yourls.config.lang | quote }} + volumeMounts: + - name: yourls-data + mountPath: /var/www/html + resources: + {{- toYaml .Values.resources.yourls | nindent 12 }} + livenessProbe: + tcpSocket: + port: 9000 + initialDelaySeconds: 30 + periodSeconds: 10 + readinessProbe: + tcpSocket: + port: 9000 + initialDelaySeconds: 5 + periodSeconds: 5 + volumes: - - name: app-storage - {{- if .Values.persistence.enabled }} + - name: nginx-config + configMap: + name: {{ include "yourls-nginx.fullname" . }}-nginx-config + - name: yourls-data + {{- if .Values.yourls.persistence.enabled }} persistentVolumeClaim: - claimName: {{ include "{{ .Chart.Name }}.fullname" . }}-pvc + claimName: {{ include "yourls-nginx.fullname" . }}-pvc {{- else }} emptyDir: {} {{- end }} - - name: nginx-config - configMap: - name: {{ include "{{ .Chart.Name }}.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