I'm trying to deploy a multi-container docker app (https://github.com/shadowHawkeye/eramba). This is the yaml file I'm using to kubectl apply -f
The two images I have (one for DB and one for app) are built docker build -t <> .
from the GitHub repo.
The DB_ENV_MYSQL_HOST, I've tried both and <eramba-db.eramba-1>
apiVersion: apps/v1
kind: Deployment
metadata:
name: eramba
namespace: eramba-1
labels:
app: eramba
spec:
replicas: 1
selector:
matchLabels:
app: eramba
template:
metadata:
labels:
app: eramba
spec:
containers:
- name: eramba
image: docker.io/deveramba/eramba:latest
ports:
- containerPort: 80
env:
- name: DB_ENV_MYSQL_DATABASE
value: "eramba-db"
- name: DB_ENV_MYSQL_HOST
value: "eramba-host"
- name: DB_ENV_MYSQL_USER
value: "eramba"
- name: DB_ENV_MYSQL_PASSWORD
value: "password"
- name: DB_ENV_MYSQL_ROOT_PASSWORD
value: "password"
- name: ERAMBA_HOSTNAME
value: localhost
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: eramba-db
namespace: eramba-1
labels:
app: eramba-db
spec:
replicas: 1
selector:
matchLabels:
app: eramba-db
template:
metadata:
labels:
app: eramba-db
spec:
containers:
- name: eramba-db
image: docker.io/deveramba/eramba-db:latest
ports:
- containerPort: 3306
env:
- name: MYSQL_DATABASE
value: "eramba-db"
- name: MYSQL_USER
value: "eramba"
- name: MYSQL_PASSWORD
value: "password"
- name: MYSQL_ROOT_PASSWORD
value: "password"
---
apiVersion: v1
kind: Service
metadata:
name: db
namespace: eramba-1
spec:
selector:
app: eramba-db
ports:
- name: sql
port: 3306
targetPort: 3306
---
apiVersion: v1
kind: Service
metadata:
name: eramba-np
namespace: eramba-1
spec:
type: NodePort
selector:
app: eramba
ports:
- name: http
port: 80
targetPort: 80
nodePort: 30045
The deployment looks like (pods and services output)
root@osboxes:/home/osboxes/manifests# kubectl get pods -n eramba-1
NAME READY STATUS RESTARTS AGE
eramba-7f7c88c9d6-zqnzr 1/1 Running 2 (73s ago) 7m47s
eramba-db-6c5fdfb7b8-wtgqd 1/1 Running 0 7m47s
root@osboxes:/home/osboxes/manifests# kubectl get service -o wide -n eramba-1
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
db ClusterIP 10.98.169.229 <none> 3306/TCP 3h31m app=eramba-db
eramba-np NodePort 10.97.149.116 <none> 80:30045/TCP 3h31m app=eramba
The problem is that kubectl logs <> is complaining unknown host Eramba-host. I've defined DB_ENV_MYSQL_HOST and MYSQL_HOST in both app and db deployments, respectively.
root@osboxes:/home/osboxes/manifests# kubectl logs eramba-7f7c88c9d6-zqnzr -n eramba-1
[i] pre-exec.d - processing /scripts/pre-exec.d/010-apache.sh
tail: can't open '/var/log/apache2/*log': No such file or directory
[i] pre-exec.d - processing /scripts/pre-exec.d/020-eramba-initdb.sh
[i] Waiting for database to setup...
[i] Trying to connect to database: try 1...
ERROR 2005 (HY000): Unknown MySQL server host 'eramba-host' (-3)
[i] Trying to connect to database: try 2...
ERROR 2005 (HY000): Unknown MySQL server host 'eramba-host' (-3)
[i] Trying to connect to database: try 3...
ERROR 2005 (HY000): Unknown MySQL server host 'eramba-host' (-3)
[i] Trying to connect to database: try 4...
ERROR 2005 (HY000): Unknown MySQL server host 'eramba-host' (-3)
[i] Trying to connect to database: try 5...
ERROR 2005 (HY000): Unknown MySQL server host 'eramba-host' (-3)
[i] Trying to connect to database: try 6...
ERROR 2005 (HY000): Unknown MySQL server host 'eramba-host' (-3)
[i] Trying to connect to database: try 7...
ERROR 2005 (HY000): Unknown MySQL server host 'eramba-host' (-3)
Here's the kubectl logs
output for the db
root@osboxes:/home/osboxes/manifests# kubectl logs eramba-db-6c5fdfb7b8-wtgqd -n eramba-1
2022-01-07 19:17:00+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.6.5+maria~focal started.
2022-01-07 19:17:00+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2022-01-07 19:17:00+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.6.5+maria~focal started.
2022-01-07 19:17:00+00:00 [Note] [Entrypoint]: Initializing database files
2022-01-07 19:17:00 0 [Warning] You need to use --log-bin to make --expire-logs-days or --binlog-expire-logs-seconds work.
PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
To do so, start the server, then issue the following command:
'/usr/bin/mysql_secure_installation'
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the MariaDB Knowledgebase at https://mariadb.com/kb or the
MySQL manual for more instructions.
Please report any problems at https://mariadb.org/jira
The latest information about MariaDB is available at https://mariadb.org/.
You can find additional information about the MySQL part at:
https://dev.mysql.com
Consider joining MariaDB's strong and vibrant community:
https://mariadb.org/get-involved/
2022-01-07 19:17:01+00:00 [Note] [Entrypoint]: Database files initialized
2022-01-07 19:17:01+00:00 [Note] [Entrypoint]: Starting temporary server
2022-01-07 19:17:01+00:00 [Note] [Entrypoint]: Waiting for server startup
2022-01-07 19:17:01 0 [Note] mariadbd (server 10.6.5-MariaDB-1:10.6.5+maria~focal) starting as process 96 ...
2022-01-07 19:17:01 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2022-01-07 19:17:01 0 [Note] InnoDB: Number of pools: 1
2022-01-07 19:17:01 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
2022-01-07 19:17:01 0 [Note] mariadbd: O_TMPFILE is not supported on /tmp (disabling future attempts)
2022-01-07 19:17:01 0 [Note] InnoDB: Using Linux native AIO
2022-01-07 19:17:01 0 [Note] InnoDB: Initializing buffer pool, total size = 134217728, chunk size = 134217728
2022-01-07 19:17:01 0 [Note] InnoDB: Completed initialization of buffer pool
2022-01-07 19:17:01 0 [Note] InnoDB: 128 rollback segments are active.
2022-01-07 19:17:01 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2022-01-07 19:17:01 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2022-01-07 19:17:01 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2022-01-07 19:17:01 0 [Note] InnoDB: 10.6.5 started; log sequence number 41361; transaction id 14
2022-01-07 19:17:01 0 [Note] Plugin 'FEEDBACK' is disabled.
2022-01-07 19:17:01 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2022-01-07 19:17:01 0 [Warning] You need to use --log-bin to make --expire-logs-days or --binlog-expire-logs-seconds work.
2022-01-07 19:17:01 0 [Warning] 'user' entry 'root@eramba-db-6c5fdfb7b8-wtgqd' ignored in --skip-name-resolve mode.
2022-01-07 19:17:01 0 [Warning] 'proxies_priv' entry '@% root@eramba-db-6c5fdfb7b8-wtgqd' ignored in --skip-name-resolve mode.
2022-01-07 19:17:01 0 [Note] InnoDB: Buffer pool(s) load completed at 220107 19:17:01
2022-01-07 19:17:01 0 [Note] mariadbd: ready for connections.
Version: '10.6.5-MariaDB-1:10.6.5+maria~focal' socket: '/run/mysqld/mysqld.sock' port: 0 mariadb.org binary distribution
2022-01-07 19:17:02+00:00 [Note] [Entrypoint]: Temporary server started.
Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/leapseconds' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/tzdata.zi' as time zone. Skipping it.
2022-01-07 19:17:03 5 [Warning] 'proxies_priv' entry '@% root@eramba-db-6c5fdfb7b8-wtgqd' ignored in --skip-name-resolve mode.
2022-01-07 19:17:03+00:00 [Note] [Entrypoint]: Creating database eramba-db
2022-01-07 19:17:03+00:00 [Note] [Entrypoint]: Creating user eramba
2022-01-07 19:17:03+00:00 [Note] [Entrypoint]: Giving user eramba access to schema eramba-db
2022-01-07 19:17:03+00:00 [Note] [Entrypoint]: Stopping temporary server
2022-01-07 19:17:03 0 [Note] mariadbd (initiated by: root[root] @ localhost []): Normal shutdown
2022-01-07 19:17:03 0 [Note] InnoDB: FTS optimize thread exiting.
2022-01-07 19:17:03 0 [Note] InnoDB: Starting shutdown...
2022-01-07 19:17:03 0 [Note] InnoDB: Dumping buffer pool(s) to /var/lib/mysql/ib_buffer_pool
2022-01-07 19:17:03 0 [Note] InnoDB: Buffer pool(s) dump completed at 220107 19:17:03
2022-01-07 19:17:04 0 [Note] InnoDB: Removed temporary tablespace data file: "./ibtmp1"
2022-01-07 19:17:04 0 [Note] InnoDB: Shutdown completed; log sequence number 42335; transaction id 15
2022-01-07 19:17:04 0 [Note] mariadbd: Shutdown complete
2022-01-07 19:17:04+00:00 [Note] [Entrypoint]: Temporary server stopped
2022-01-07 19:17:04+00:00 [Note] [Entrypoint]: MariaDB init process done. Ready for start up.
2022-01-07 19:17:04 0 [Note] mariadbd (server 10.6.5-MariaDB-1:10.6.5+maria~focal) starting as process 1 ...
2022-01-07 19:17:04 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2022-01-07 19:17:04 0 [Note] InnoDB: Number of pools: 1
2022-01-07 19:17:04 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
2022-01-07 19:17:04 0 [Note] mariadbd: O_TMPFILE is not supported on /tmp (disabling future attempts)
2022-01-07 19:17:05 0 [Note] InnoDB: Using Linux native AIO
2022-01-07 19:17:05 0 [Note] InnoDB: Initializing buffer pool, total size = 134217728, chunk size = 134217728
2022-01-07 19:17:05 0 [Note] InnoDB: Completed initialization of buffer pool
2022-01-07 19:17:05 0 [Note] InnoDB: 128 rollback segments are active.
2022-01-07 19:17:05 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2022-01-07 19:17:05 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2022-01-07 19:17:05 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2022-01-07 19:17:05 0 [Note] InnoDB: 10.6.5 started; log sequence number 42335; transaction id 14
2022-01-07 19:17:05 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2022-01-07 19:17:05 0 [Note] Plugin 'FEEDBACK' is disabled.
2022-01-07 19:17:05 0 [Warning] You need to use --log-bin to make --expire-logs-days or --binlog-expire-logs-seconds work.
2022-01-07 19:17:05 0 [Note] InnoDB: Buffer pool(s) load completed at 220107 19:17:05
2022-01-07 19:17:05 0 [Note] Server socket created on IP: '0.0.0.0'.
2022-01-07 19:17:05 0 [Note] Server socket created on IP: '::'.
2022-01-07 19:17:05 0 [Warning] 'proxies_priv' entry '@% root@eramba-db-6c5fdfb7b8-wtgqd' ignored in --skip-name-resolve mode.
2022-01-07 19:17:05 0 [Note] mariadbd: ready for connections.
Version: '10.6.5-MariaDB-1:10.6.5+maria~focal' socket: '/run/mysqld/mysqld.sock' port: 3306 mariadb.org binary distribution