-2

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.

Describe 1/2

Describe 2/2

Logs

512Mi: enter image description here

quachhengtony
  • 125
  • 4
  • 17

1 Answers1

0

The reason for termination is OOMKilled (1st screenshot), that means Out Of Memory you can try by increasing the memory limits.

Preet Sindhal
  • 459
  • 4
  • 7
  • 256Mi still gives me the OOMKilled status. – quachhengtony May 22 '22 at 15:22
  • can't really say, you would have to try and check 256 or 512. once you have running pod you can then check how much memory is being used. Also you can look into the optimizations that you can do to reduce the memory consumption. – Preet Sindhal May 22 '22 at 15:27
  • 512Mi still does not fix the error, I'll update the question with logs for 512Mi, please take a look – quachhengtony May 22 '22 at 15:31