Cluster information:
Kubernetes version:
Client Version: v1.29.2
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.29.2
Installation method: Integrate with docker desktop
Host OS: WSL in Windows 10
Hi all i m currently learning kubernetes. Currently i m learning how to use persistent volume and persistent volume claim. My manifest currently using mysql as the image (i know this is not what people usually do) but this is just for my learning. My mysql-deployment keep crashing for no reason. I will attach the screenshot of the describe
and logs
.
This is my persistent volume claim manifest
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pvc-app
spec:
storageClassName: local-storage
accessModes:
- ReadWriteMany
resources:
requests:
storage: 1Gi
This is my mysql deployment manifest
apiVersion: apps/v1
kind: Deployment
metadata:
name: mysql-deployment
labels:
app: mysql
spec:
replicas: 1
selector:
matchLabels:
app: mysql
template:
metadata:
labels:
app: mysql
spec:
volumes:
- name: test-app
persistentVolumeClaim:
claimName: pvc-app
containers:
- name: mysql
image: mysql:lts
volumeMounts:
- mountPath: /var/lib/mysql
name: test-app
subPath: mysql
resources:
requests:
cpu: "500m"
memory: "256Mi"
limits:
cpu: "600m"
memory: "512Mi"
env:
- name: MYSQL_USER
valueFrom:
secretKeyRef:
name: my-secret
key: MYSQL_USER
- name: MYSQL_PASSWORD
valueFrom:
secretKeyRef:
name: my-secret
key: MYSQL_PASSWORD
- name: MYSQL_DATABASE
valueFrom:
secretKeyRef:
name: my-secret
key: MYSQL_DATABASE
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: my-secret
key: MYSQL_ROOT_PASSWORD
ports:
- containerPort: 3306
This is my mysql-service
apiVersion: v1
kind: Service
metadata:
name: mysql-service
spec:
type: ClusterIP
selector:
app: mysql
ports:
- name: name-of-service-port
protocol: TCP
port: 3306
targetPort: 3306
This is my persistent volume manifest
apiVersion: v1
kind: PersistentVolume
metadata:
name: testapp-pv
spec:
capacity:
storage: 1Gi
volumeMode: Filesystem
accessModes:
- ReadWriteMany
persistentVolumeReclaimPolicy: Delete
storageClassName: local-storage
hostPath:
path: /
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- docker-desktop