My init container keeps failing and the error I get is - "Init:RunContainerError"

9/23/2019

My idea was to use a busybox container to create a mysql configuration file and save it in the persistent volume to enable logs on the MySQL container! The init container keeps restarting with the Init:RunContainerError error. After checking the container logs for errors, I get the following message - error: only one of -c or an inline [CONTAINER] arg is allowed

apiVersion: apps/v1
kind: Deployment
metadata:
  name: mysql-deployment
  namespace: elastic
  labels:
    app: mysql
spec:
  selector:
    matchLabels:
       app: mysql
  template:
    metadata:
      labels:
        app: mysql
    spec:
     initContainers:
     - name: "remove-lost-found"
       image: busybox
       imagePullPolicy: "IfNotPresent"
       resources:
         requests:
            cpu: 10m
            memory: 10Mi
       command: ['rm', '-fr', '/var/lib/mysql/lost+found']
       volumeMounts:
         - name: data
           mountPath: /var/lib/mysql
     - name: "add-logging-configuration"
       image: busybox
       imagePullPolicy: "IfNotPresent"
       resources:
         requests:
            cpu: 100m
            memory: 100Mi
       command: ['sh', '-c', 'cat <<\"EOF\" > /etc/mysql/mysql.cnf\n [mysqld]\n log_error=/var/log/mysql/error.log\n general_log_file=/var/log/mysql/mysql.log\n general_log=1\n EOF\n']
       volumeMounts:
         - name: conf
           mountPath: /etc/mysql
     containers:
       - name: mysql
         image: "mysql:5.7.14"
         imagePullPolicy: "IfNotPresent"
         resources:
           requests:
             cpu: 100m
             memory: 1Gi
         env:
          - name: MYSQL_ROOT_PASSWORD
            value: Test1234
          - name: MYSQL_PASSWORD
            value: "Test1234"
          - name: MYSQL_USER
            value: "sysuser"
         ports:
          - name: mysql
            containerPort: 3306
         livenessProbe:
           exec:
             command:
             - sh
             - -c
             - "mysqladmin ping -u root -p${MYSQL_ROOT_PASSWORD}"
           initialDelaySeconds: 30
           periodSeconds: 10
           timeoutSeconds: 5
           successThreshold: 1
           failureThreshold: 3
         readinessProbe:
          exec:
            command:
            - sh
            - -c
            - "mysqladmin ping -u root -p${MYSQL_ROOT_PASSWORD}"
          initialDelaySeconds: 5
          periodSeconds: 10
          timeoutSeconds: 1
          successThreshold: 1
          failureThreshold: 3
         volumeMounts:
          - name: data
            mountPath: /var/lib/mysql
          - name: conf
            mountPath: /etc/mysql
          - name: logs
            mountPath: /var/log/mysql
     volumes:
      - name: data
        persistentVolumeClaim:
          claimName: mysql-pvclaim
      - name: conf
        persistentVolumeClaim:
          claimName: mysqlconf-pvclaim
      - name: logs
        persistentVolumeClaim:
          claimName: mysqllog-pvclaim
-- Kalyan
kubernetes-pod

0 Answers