Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql: unknown option '--"' in Kubernetes

I am trying to run mysql 5.7 in kubernetes and got this error mysql: unknown option '--"'

My database.yaml looks like this

apiVersion: v1
kind: Pod
metadata:
  name: app-db
  labels:
    app: app-db
spec:
  containers:
  - name: mysql
    image: mysql:5.7
    ports:
    - name: mysql-port
      containerPort: 3306
    env:
    - name: MYSQL_ROOT_PASSWORD
      valueFrom:
        secretKeyRef:
          name: app-secrets
          key: rootPassword
    - name: MYSQL_USER
      valueFrom:
        secretKeyRef:
          name: app-secrets
          key: username
    - name: MYSQL_ROOT_PASSWORD
      valueFrom:
        secretKeyRef:
          name: app-secrets
          key: password
    - name: MYSQL_DATABASE
      valueFrom:
        secretKeyRef:
          name: app-secrets
          key: defaultDatabase

Maybe I missed something?

I tried to switch versions, tried to use samples from the official Kubernetes site - nothing works for me.

The last logs with error:

2020-07-19 20:51:01 100 [Note] Event Scheduler: Loaded 0 events
2020-07-19 20:51:01 100 [Note] mysqld: ready for connections.
Version: '5.6.49'  socket: '/var/run/mysqld/mysqld.sock'  port: 0  MySQL Community Server (GPL)
2020-07-19 20:51:01+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.
2020-07-19 20:51:04 100 [Warning] 'proxies_priv' entry '@ root@app-db' ignored in --skip-name-resolve mode.
2020-07-19 20:51:04+00:00 [Note] [Entrypoint]: Creating database app_db

mysql: unknown option '--"'
like image 396
Squeez Avatar asked Mar 03 '23 06:03

Squeez


1 Answers

I ran into the same issue and after a lot of frustrating debugging I finally solved it.

The problem was that I created my secrets with the echo 'secret' | base64 command and the echo command automatically inserts a trailing newline.

Use echo -n 'secret' | base64 instead. ✔️

Unfortunately this was not at all what I expected and therefore I didn't notice that there was a line break in the log output. Hopefully this can help some people who also use the echo command to encode to base64.

like image 70
Tom Böttger Avatar answered Mar 05 '23 16:03

Tom Böttger