Iurie Muradu
Iurie Muradu

Reputation: 11

MySQL single pod Kubernetes won't run

Hi guys I have an error and I can't find the answer. I am trying to deploy a very simple MySQL deployment:

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: mysql
  name: mysql
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mysql
  template:
    metadata:
      labels:
        app: mysql
    spec:
      containers:
      - image: mysql:8.0.25
        name: mysql
        ports:
        - containerPort: 3306
          name: mysql
        volumeMounts:
        - name: mysql
          mountPath: /var/lib/mysql
        env:
        - name: MYSQL_USER
          value: weazel
        - name: MYSQL_DATABASE
          value: weazel
        - name: MYSQL_PASSWORD
          value: weazel
        - name: MYSQL_ROOT_PASSWORD
          valueFrom:
            secretKeyRef:
              name: mysql
              key: rootPassword
      volumes:
      - name: mysql
        persistentVolumeClaim:
          claimName: mysql

---

apiVersion: v1
kind: Service
metadata:
  name: mysql
spec:
  ports:
  - port: 3306
  selector:
    app: mysql
  clusterIP: None

The deployment starts running and the pod after few minutes of initialization gives me that error:

2021-06-20 21:19:58+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.25-1debian10 started.
2021-06-20 21:19:59+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2021-06-20 21:19:59+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.25-1debian10 started.
2021-06-20 21:19:59+00:00 [Note] [Entrypoint]: Initializing database files
2021-06-20T21:19:59.461650Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.25) initializing of server in progress as process 43
2021-06-20T21:19:59.510070Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2021-06-20T21:21:15.206744Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2021-06-20T21:24:18.876746Z 6 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
2021-06-20 21:28:29+00:00 [Note] [Entrypoint]: Database files initialized
2021-06-20 21:28:29+00:00 [Note] [Entrypoint]: Starting temporary server
2021-06-20T21:28:30.333051Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.25) starting as process 126
2021-06-20T21:28:30.538635Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2021-06-20T21:28:32.723573Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2021-06-20T21:28:33.273688Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: /var/run/mysqld/mysqlx.sock
2021-06-20T21:28:39.828471Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2021-06-20T21:28:39.828950Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2021-06-20T21:28:40.155589Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
2021-06-20T21:28:40.215423Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.25'  socket: '/var/run/mysqld/mysqld.sock'  port: 0  MySQL Community Server - GPL.
2021-06-20 21:28:40+00:00 [Note] [Entrypoint]: Temporary server started.
Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it.
2021-06-20 21:31:13+00:00 [Note] [Entrypoint]: Creating database weazel
mysql: [ERROR] unknown option '--"'.

Then it will restart the pod, but I will not be able to reconnect to the database anymore with the provided credentials. I have tried to do the same in a docker container, and everything works very well as expected. No matter what I do, I will always get that error. I suppose it can be related to my kubernetes cluster which is a three master on-premise cluster.

Please help.

SOLUTION

My secret variable was encoded with new line at the end of the variable, after encoding the secret variable without a new space all went smooth. Thank you

Upvotes: 1

Views: 685

Answers (1)

coderanger
coderanger

Reputation: 54181

Answered in comments, the password was corrupted which threw off the setup scripts.

Upvotes: 2

Related Questions