Hi all,
I’m kubernetes newbie, I started to learn about K8S, I’m trying AKS trial I try to deploy a webdevops/php-nginx container, but I get problem, this is my deployment manifest :
apiVersion: apps/v1
kind: Deployment
metadata:
name: web-frontend-deploy
labels:
app: php-nginx
spec:
selector:
matchLabels:
app: php-nginx
tier: frontend
replicas: 1
template:
metadata:
labels:
app: php-nginx
tier: frontend
spec:
containers:
- name: php-nginx
image: webdevops/php-nginx:8.0-alpine
volumeMounts:
- name: nginx-config
mountPath: /opt/docker/etc/nginx/conf.d/web-frontend.conf
subPath: web-frontend.conf
- name: phpfpm-config
mountPath: /opt/docker/etc/php/fpm/pool.d/application.conf
subPath: application.conf
- name: phpini-config
mountPath: /opt/docker/etc/php/php.ini
subPath: php.ini
resources:
requests:
cpu: 200m
memory: 400Mi
ports:
- containerPort: 80
volumes:
- name: nginx-config
configMap:
name: nginx-config
- name: phpfpm-config
configMap:
name: phpfpm-config
- name: phpini-config
configMap:
name: phpini-config
As webdevops/php-nginx document, I want to customize nginx, php-fpm, phi.ini by:
- mount nginx-config to /opt/docker/etc/nginx/conf.d/web-frontend.conf
- mount phpfpm-config to /opt/docker/etc/php/fpm/pool.d/application.conf
- mount phpini-config to /opt/docker/etc/php/php.ini
in my container, I have created these configmaps already, I run manifest but deployment and pod cannot be created
kubectl get deployments
NAME READY UP-TO-DATE AVAILABLE AGE
web-frontend-deploy 0/1 1 0 6m45s
kubectl get pods
NAME READY STATUS RESTARTS AGE
web-frontend-deploy-6c994cb79b-t9pd2 0/1 CrashLoopBackOff 6 6m51s
kubectl describe pod/web-frontend-deploy-6c994cb79b-t9pd2
…
State: Waiting
Reason: CrashLoopBackOff
Last State: Terminated
Reason: Error
Exit Code: 1
Started: Wed, 07 Jul 2021 14:29:00 +0700
Finished: Wed, 07 Jul 2021 14:29:00 +0700
Ready: False
Restart Count: 6
Requests:
cpu: 200m
memory: 400Mi
Environment: <none>
Mounts:
/opt/docker/etc/nginx/conf.d/web-frontend.conf from nginx-config (rw,path="web-frontend.conf")
/opt/docker/etc/php/fpm/pool.d/application.conf from phpfpm-config (rw,path="application.conf")
/opt/docker/etc/php/php.ini from phpini-config (rw,path="php.ini")
/var/run/secrets/kubernetes.io/serviceaccount from default-token-xdrlr (ro)
Events:
Type Reason Age From Message
Normal Scheduled 7m19s default-scheduler Successfully assigned …/web-frontend-deploy-6c994cb79b-t9pd2 to aks-agentpool-19144222-vmss000000
Normal Pulled 5m45s (x5 over 7m19s) kubelet Container image “…” already present on machine
Normal Created 5m45s (x5 over 7m19s) kubelet Created container php-nginx
Normal Started 5m45s (x5 over 7m19s) kubelet Started container php-nginx
Warning BackOff 2m13s (x25 over 7m17s) kubelet Back-off restarting failed container
If I just leave 1 of them (nginx, phpfpm, phpini) in manifest file, it works fine.
How can I fix it ? I look forward to hearing from your experience , thank you very much.
My version
kubectl version --short
Client Version: v1.21.2
Server Version: v1.19.11
WARNING: version difference between client (1.21) and server (1.19) exceeds the supported minor version skew of +/-1