Context: I'm using Kubernetes to create a deployment (a pod) via kubectl apply command that has a MySql container inside. The deployment file also configs a cluster IP and a load balancer to use for the same pod.
apiVersion: apps/v1
kind: Deployment
metadata:
name: fplms-discussiondb-deployment
spec:
replicas: 1
selector:
matchLabels:
app: fplms-discussiondb
strategy:
type: Recreate
template:
metadata:
labels:
app: fplms-discussiondb
spec:
terminationGracePeriodSeconds: 30
securityContext:
fsGroup: 1000
containers:
- name: fplms-discussiondb
image: mysql
ports:
- containerPort: 3306
resources:
limits:
memory: 128Mi
cpu: 500m
env:
- name: MYSQL_ROOT_PASSWORD
value: "fplms"
- name: MYSQL_DATABASE
value: "discussiondb"
volumeMounts:
- mountPath: /var/lib/mysql
name: fplms-discussiondb
volumes:
- name: fplms-discussiondb
persistentVolumeClaim:
claimName: fplms-discussiondb-claim
---
apiVersion: v1
kind: Service
metadata:
name: fplms-discussiondb-clusterip
spec:
type: ClusterIP
selector:
app: fplms-discussiondb
ports:
- name: fplms-discussiondb
protocol: TCP
port: 3306
targetPort: 3306
---
apiVersion: v1
kind: Service
metadata:
name: fplms-discussiondb-loadbalancer
spec:
type: LoadBalancer
selector:
app: fplms-discussiondb
ports:
- protocol: TCP
port: 3306
targetPort: 3306
Problem: When I applied the deployment file, it keeps getting the CrashLoopBackOff status (see last image).
Can anyone help me fix this problem? Thank you so much.