"templates" にファイルをアップロード
This commit is contained in:
60
templates/configmap.yaml
Normal file
60
templates/configmap.yaml
Normal file
@@ -0,0 +1,60 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: {{ include "phpfpm.fullname" . }}-nginx-config
|
||||
labels:
|
||||
{{- include "phpfpm.labels" . | nindent 4 }}
|
||||
data:
|
||||
nginx.conf: |
|
||||
user nginx;
|
||||
worker_processes 1;
|
||||
|
||||
error_log /var/log/nginx/error.log warn;
|
||||
pid /var/run/nginx.pid;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||
'$status $body_bytes_sent "$http_referer" '
|
||||
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||
|
||||
access_log /var/log/nginx/access.log main;
|
||||
|
||||
sendfile on;
|
||||
keepalive_timeout 65;
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
|
||||
root /var/www/html;
|
||||
index index.php index.html index.htm;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.php?$query_string;
|
||||
}
|
||||
|
||||
location ~ \.php$ {
|
||||
include fastcgi_params;
|
||||
fastcgi_pass 127.0.0.1:9000;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
}
|
||||
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
root /usr/share/nginx/html;
|
||||
}
|
||||
|
||||
{{- if .Values.nginx.customConfig.enabled }}
|
||||
{{ .Values.nginx.customConfig.snippet | indent 12 }}
|
||||
{{- end }}
|
||||
|
||||
}
|
||||
}
|
||||
102
templates/deployment.yaml
Normal file
102
templates/deployment.yaml
Normal file
@@ -0,0 +1,102 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ include "phpfpm.fullname" . }}
|
||||
labels:
|
||||
{{- include "phpfpm.labels" . | nindent 4 }}
|
||||
spec:
|
||||
replicas: {{ .Values.replicaCount }}
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "phpfpm.selectorLabels" . | nindent 6 }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
{{- include "phpfpm.selectorLabels" . | nindent 8 }}
|
||||
spec:
|
||||
containers:
|
||||
- name: nginx
|
||||
image: "{{ .Values.image.nginx.registry }}/{{ .Values.image.nginx.repository }}:{{ .Values.image.nginx.tag }}"
|
||||
imagePullPolicy: {{ .Values.image.nginx.pullPolicy }}
|
||||
ports:
|
||||
- containerPort: 80
|
||||
volumeMounts:
|
||||
- name: app-storage
|
||||
mountPath: /var/www/html
|
||||
subPath: html
|
||||
- name: nginx-config
|
||||
mountPath: /etc/nginx/nginx.conf
|
||||
subPath: nginx.conf
|
||||
- name: php-fpm
|
||||
image: "{{ .Values.image.php.registry }}/{{ .Values.image.php.repository }}:{{ .Values.image.php.tag }}"
|
||||
imagePullPolicy: {{ .Values.image.php.pullPolicy }}
|
||||
command:
|
||||
- sh
|
||||
- -c
|
||||
- |
|
||||
echo "Starting PHP-FPM with conditional logic..."
|
||||
{{- if or .Values.selenium.enabled .Values.externalDatabase.enabled }}
|
||||
(
|
||||
{{- if .Values.selenium.enabled }}
|
||||
echo "Installing selenium dependencies..."
|
||||
apk add --no-cache curl zip libzip-dev && \
|
||||
docker-php-ext-install zip && \
|
||||
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && \
|
||||
composer require php-webdriver/webdriver
|
||||
{{- end }}
|
||||
{{- if .Values.externalDatabase.enabled }}
|
||||
echo "Installing pdo_mysql for PHP 8.3 Alpine..."
|
||||
apk add --no-cache php83 php83-pdo_mysql
|
||||
{{- end }}
|
||||
)
|
||||
{{- end }}
|
||||
php-fpm
|
||||
ports:
|
||||
- containerPort: 9000 # PHP-FPMは9000ポートでリッスン
|
||||
volumeMounts:
|
||||
- name: app-storage
|
||||
mountPath: /var/www/html
|
||||
subPath: html
|
||||
env:
|
||||
{{- if .Values.externalDatabase.enabled }}
|
||||
- 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_PASS
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ include "phpfpm.fullname" . }}-db-secret
|
||||
key: {{ include "phpfpm.fullname" . }}-db-key
|
||||
{{- end }}
|
||||
{{- if .Values.selenium.enabled }}
|
||||
- name: selenium
|
||||
image: "{{ .Values.image.selenium.registry }}/{{ .Values.image.selenium.repository }}:{{ .Values.image.selenium.tag }}"
|
||||
imagePullPolicy: {{ .Values.image.selenium.pullPolicy }}
|
||||
ports:
|
||||
- containerPort: 4444 # Selenium用ポート
|
||||
volumeMounts:
|
||||
- name: app-storage
|
||||
mountPath: /var/www/html
|
||||
subPath: html
|
||||
{{- end }}
|
||||
dnsPolicy: ClusterFirst
|
||||
dnsConfig:
|
||||
options:
|
||||
- name: ndots
|
||||
value: "1"
|
||||
volumes:
|
||||
- name: app-storage
|
||||
{{- if .Values.persistence.enabled }}
|
||||
persistentVolumeClaim:
|
||||
claimName: {{ include "phpfpm.fullname" . }}-pvc
|
||||
{{- else }}
|
||||
emptyDir: {}
|
||||
{{- end }}
|
||||
- name: nginx-config
|
||||
configMap:
|
||||
name: {{ include "phpfpm.fullname" . }}-nginx-config
|
||||
39
templates/ingress.yaml
Normal file
39
templates/ingress.yaml
Normal file
@@ -0,0 +1,39 @@
|
||||
{{- if .Values.ingress.enabled }}
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: {{ include "phpfpm.fullname" . }}
|
||||
labels:
|
||||
{{- include "phpfpm.labels" . | nindent 4 }}
|
||||
annotations:
|
||||
{{- toYaml .Values.ingress.annotations | nindent 4 }}
|
||||
spec:
|
||||
{{- if .Values.ingress.className }}
|
||||
ingressClassName: {{ .Values.ingress.className }}
|
||||
{{- end }}
|
||||
rules:
|
||||
{{- range .Values.ingress.hosts }}
|
||||
- host: {{ .host }}
|
||||
http:
|
||||
paths:
|
||||
{{- range .paths }}
|
||||
- path: {{ .path }}
|
||||
pathType: {{ .pathType }}
|
||||
backend:
|
||||
service:
|
||||
name: {{ include "phpfpm.fullname" $ }}
|
||||
port:
|
||||
number: {{ $.Values.service.port }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if .Values.ingress.tls }}
|
||||
tls:
|
||||
{{- range .Values.ingress.tls }}
|
||||
- secretName: {{ .secretName }}
|
||||
hosts:
|
||||
{{- range .hosts }}
|
||||
- {{ . }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
14
templates/pvc.yaml
Normal file
14
templates/pvc.yaml
Normal file
@@ -0,0 +1,14 @@
|
||||
{{- if .Values.persistence.enabled }}
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: {{ include "phpfpm.fullname" . }}-pvc
|
||||
labels:
|
||||
{{- include "phpfpm.labels" . | nindent 4 }}
|
||||
spec:
|
||||
accessModes:
|
||||
- {{ .Values.persistence.accessMode }}
|
||||
resources:
|
||||
requests:
|
||||
storage: {{ .Values.persistence.size }}
|
||||
{{- end }}
|
||||
15
templates/service.yaml
Normal file
15
templates/service.yaml
Normal file
@@ -0,0 +1,15 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ include "phpfpm.fullname" . }}
|
||||
labels:
|
||||
{{- include "phpfpm.labels" . | nindent 4 }}
|
||||
spec:
|
||||
type: {{ .Values.service.type }}
|
||||
ports:
|
||||
- port: {{ .Values.service.port }}
|
||||
targetPort: 80
|
||||
protocol: TCP
|
||||
name: http
|
||||
selector:
|
||||
{{- include "phpfpm.selectorLabels" . | nindent 4 }}
|
||||
Reference in New Issue
Block a user