https://kubernetes.io/docs/tutorials/stateful-application/mysql-wordpress-persistent-volume/
kubectl apply -k .
service/wordpress created
service/wordpress-mysql created
persistentvolumeclaim/mysql-pv-claim created
persistentvolumeclaim/wp-pv-claim created
deployment.apps/wordpress created
deployment.apps/wordpress-mysql created
kubectl get pods
NAME READY STATUS RESTARTS AGE
wordpress-7f7bf85b9c-7wmcq 0/1 CreateContainerConfigError 0 14m
wordpress-mysql-7d5f9bb46c-fqd6p 0/1 CreateContainerConfigError 0 14m
kubectl describe pods
Name: wordpress-7f7bf85b9c-7wmcq
Namespace: default
Priority: 0
Service Account: default
Node: docker-desktop/192.168.65.4
Start Time: Thu, 18 May 2023 12:53:21 -0700
Labels: app=wordpress
pod-template-hash=7f7bf85b9c
tier=frontend
Annotations: <none>
Status: Pending
IP: 10.1.0.47
IPs:
IP: 10.1.0.47
Controlled By: ReplicaSet/wordpress-7f7bf85b9c
Containers:
wordpress:
Container ID:
Image: wordpress:4.8-apache
Image ID:
Port: 80/TCP
Host Port: 0/TCP
State: Waiting
Reason: CreateContainerConfigError
Ready: False
Restart Count: 0
Environment:
WORDPRESS_DB_HOST: wordpress-mysql
WORDPRESS_DB_PASSWORD: <set to the key 'password' in secret 'mysql-pass'> Optional: false
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-v2dq2 (ro)
/var/www/html from wordpress-persistent-storage (rw)
Conditions:
Type Status
Initialized True
Ready False
ContainersReady False
PodScheduled True
Volumes:
wordpress-persistent-storage:
Type: PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
ClaimName: wp-pv-claim
ReadOnly: false
kube-api-access-v2dq2:
Type: Projected (a volume that contains injected data from multiple sources)
TokenExpirationSeconds: 3607
ConfigMapName: kube-root-ca.crt
ConfigMapOptional: <nil>
DownwardAPI: true
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning FailedScheduling 15m default-scheduler 0/1 nodes are available: 1 pod has unbound immediate PersistentVolumeClaims. preemption: 0/1 nodes are available: 1 Preemption is not helpful for scheduling.
Normal Scheduled 15m default-scheduler Successfully assigned default/wordpress-7f7bf85b9c-7wmcq to docker-desktop
Warning Failed 12m (x12 over 15m) kubelet Error: secret "mysql-pass" not found
Normal Pulled 8s (x70 over 15m) kubelet Container image "wordpress:4.8-apache" already present on machine
Name: wordpress-mysql-7d5f9bb46c-fqd6p
Namespace: default
Priority: 0
Service Account: default
Node: docker-desktop/192.168.65.4
Start Time: Thu, 18 May 2023 12:53:20 -0700
Labels: app=wordpress
pod-template-hash=7d5f9bb46c
tier=mysql
Annotations: <none>
Status: Pending
IP: 10.1.0.48
IPs:
IP: 10.1.0.48
Controlled By: ReplicaSet/wordpress-mysql-7d5f9bb46c
Containers:
mysql:
Container ID:
Image: mysql:5.6
Image ID:
Port: 3306/TCP
Host Port: 0/TCP
State: Waiting
Reason: CreateContainerConfigError
Ready: False
Restart Count: 0
Environment:
MYSQL_ROOT_PASSWORD: <set to the key 'password' in secret 'mysql-pass'> Optional: false
Mounts:
/var/lib/mysql from mysql-persistent-storage (rw)
/var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-dpj4p (ro)
Conditions:
Type Status
Initialized True
Ready False
ContainersReady False
PodScheduled True
Volumes:
mysql-persistent-storage:
Type: PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
ClaimName: mysql-pv-claim
ReadOnly: false
kube-api-access-dpj4p:
Type: Projected (a volume that contains injected data from multiple sources)
TokenExpirationSeconds: 3607
ConfigMapName: kube-root-ca.crt
ConfigMapOptional: <nil>
DownwardAPI: true
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 15m default-scheduler Successfully assigned default/wordpress-mysql-7d5f9bb46c-fqd6p to docker-desktop
Normal SandboxChanged 15m kubelet Pod sandbox changed, it will be killed and re-created.
Warning Failed 13m (x12 over 15m) kubelet Error: secret "mysql-pass" not found
Normal Pulled 4s (x74 over 15m) kubelet Container image "mysql:5.6" already present on machine
Error: secret "mysql-pass" not found
kubectl get secrets
NAME TYPE DATA AGE
mysql-pass-kkcc2b926b Opaque 1 3h36m
kubectl describe secrets
Name: mysql-pass-kkcc2b926b
Namespace: default
Labels: <none>
Annotations: <none>
Type: Opaque
Data
====
password: 6 bytes
The secret was created by:
secretGenerator:
- name: mysql-pass
literals:
- password=123456
This is how you should declare the secret to avoid the suffix:
kind: Kustomization
generatorOptions:
disableNameSuffixHash: true
labels:
foo: bar
secretGenerator:
- name: mysql-pass
literals:
- foo=bar