无法在minikube

时间:2017-07-21 05:55:53

标签: mysql wordpress kubernetes minikube

我想运行Wordpress&在minikube上的mySQL并不能让它工作。

命令看起来简单明了。在kubectl命令中没有看到任何错误。

mbp/~:$kubectl run mysql --image=mysql:5.7 --env MYSQL_ROOT_PASSWORD=password
deployment "mysql" created

mbp/~:$kubectl get pods
NAME                             READY     STATUS              RESTARTS   AGE
hello-minikube-938614450-82l4k   1/1       Running             7          10d
mysql-999033340-js9kf            0/1       ContainerCreating   0          1m

mbp/~:$kubectl expose deployment mysql --port=3306
service "mysql" exposed

mbp/~:$kubectl get services
NAME              CLUSTER-IP   EXTERNAL-IP   PORT(S)          AGE
hello-minikube    10.0.0.170   <nodes>       8080:30616/TCP   10d
kubernetes        10.0.0.1     <none>        443/TCP          10d
mongodb           10.0.0.183   <none>        27017/TCP        7d
mysql             10.0.0.92    <none>        3306/TCP         1m

mbp/~:$kubectl run wordpress --image=wordpress --env WORDPRESS_DB_HOST=mysql --env WORDPRESS_DB_PASSWORD=password

然而,wordpress容器一直在崩溃,说它无法连接到mySQL。

我可以登录mySQL pod并通过列出数据库来检查它是否正常工作。

以下是wordpress pod的错误消息。

MySQL Connection Error: (2002) php_network_getaddresses: getaddrinfo failed: 
Name or service not known

Warning: mysqli::mysqli(): php_network_getaddresses: getaddrinfo failed: 
Name or service not known in - on line 22

Warning: mysqli::mysqli(): (HY000/2002): php_network_getaddresses: 
getaddrinfo failed: Name or service not known in - on line 22

wordpress配置有正确的mysql条目(我通过exec进入wordpress容器检查了这个)

define(‘DB_HOST’, ‘mysql’);

我可以在另一个kubernetes集群(在IBM Bluemix中托管)上运行这些命令,我​​想知道如何解决这个问题。

我尝试了三种不同的mySQL图像(5.5,5.6和5.7),结果相同。

总的来说,我的minikube似乎运作良好。有没有办法解决这里可能发生的事情?

在我删除了pod时更新了mysql和wordpress pod的新问题。

mbp/~:$kubectl run mysql --image=mysql:5.7 --env MYSQL_ROOT_PASSWORD=password
deployment "mysql" created


mbp/~:$kubectl get pods
NAME                             READY     STATUS    RESTARTS   AGE
front-end-3033610114-b44mt       1/1       Running   7          9d
front-end-3033610114-xwb6t       1/1       Running   7          9d
hello-minikube-938614450-82l4k   1/1       Running   9          11d
mysql-999033340-l2qn6            1/1       Running   0          8s

mysql-999033340-l2qn6 pod的日志如下所示

mbp/~:$kubectl logs mysql-999033340-l2qn6
Initializing database
2017-07-21T09:33:39.779141Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-07-21T09:33:39.952670Z 0 [Warning] InnoDB: New log files created, LSN=45790
2017-07-21T09:33:39.978778Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2017-07-21T09:33:40.064819Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: adf054aa-6df7-11e7-9302-0242ac110005.
2017-07-21T09:33:40.067825Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2017-07-21T09:33:40.068942Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
2017-07-21T09:33:40.484303Z 1 [Warning] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode.
2017-07-21T09:33:40.484460Z 1 [Warning] 'user' entry 'mysql.session@localhost' ignored in --skip-name-resolve mode.
2017-07-21T09:33:40.484488Z 1 [Warning] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode.
2017-07-21T09:33:40.484519Z 1 [Warning] 'db' entry 'performance_schema mysql.session@localhost' ignored in --skip-name-resolve mode.
2017-07-21T09:33:40.484536Z 1 [Warning] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode.
2017-07-21T09:33:40.484554Z 1 [Warning] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode.
2017-07-21T09:33:40.484591Z 1 [Warning] 'tables_priv' entry 'user mysql.session@localhost' ignored in --skip-name-resolve mode.
2017-07-21T09:33:40.484614Z 1 [Warning] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode.
Database initialized
Initializing certificates
Generating a 2048 bit RSA private key
..................+++
.+++
unable to write 'random state'
writing new private key to 'ca-key.pem'
-----
Generating a 2048 bit RSA private key
...........................................................................................+++
.........+++
unable to write 'random state'
writing new private key to 'server-key.pem'
-----
Generating a 2048 bit RSA private key
.................................+++
.........................................................+++
unable to write 'random state'
writing new private key to 'client-key.pem'
-----
Certificates initialized
MySQL init process in progress...
2017-07-21T09:33:42.503349Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-07-21T09:33:42.505437Z 0 [Note] mysqld (mysqld 5.7.19) starting as process 88 ...
2017-07-21T09:33:42.509152Z 0 [Note] InnoDB: PUNCH HOLE support available
2017-07-21T09:33:42.509180Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-07-21T09:33:42.509183Z 0 [Note] InnoDB: Uses event mutexes
2017-07-21T09:33:42.509185Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2017-07-21T09:33:42.509186Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
2017-07-21T09:33:42.509188Z 0 [Note] InnoDB: Using Linux native AIO
2017-07-21T09:33:42.512107Z 0 [Note] InnoDB: Number of pools: 1
2017-07-21T09:33:42.512378Z 0 [Note] InnoDB: Using CPU crc32 instructions
2017-07-21T09:33:42.515429Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2017-07-21T09:33:42.526676Z 0 [Note] InnoDB: Completed initialization of buffer pool
2017-07-21T09:33:42.531231Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2017-07-21T09:33:42.544667Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2017-07-21T09:33:42.552331Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2017-07-21T09:33:42.552476Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2017-07-21T09:33:42.585478Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2017-07-21T09:33:42.588860Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2017-07-21T09:33:42.589061Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2017-07-21T09:33:42.589528Z 0 [Note] InnoDB: Waiting for purge to start
2017-07-21T09:33:42.639729Z 0 [Note] InnoDB: 5.7.19 started; log sequence number 2539315
2017-07-21T09:33:42.640502Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2017-07-21T09:33:42.640789Z 0 [Note] Plugin 'FEDERATED' is disabled.
2017-07-21T09:33:42.644154Z 0 [Note] InnoDB: Buffer pool(s) load completed at 170721  9:33:42
2017-07-21T09:33:42.651513Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
2017-07-21T09:33:42.651789Z 0 [Warning] CA certificate ca.pem is self signed.
2017-07-21T09:33:42.667518Z 0 [Warning] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode.
2017-07-21T09:33:42.667755Z 0 [Warning] 'user' entry 'mysql.session@localhost' ignored in --skip-name-resolve mode.
2017-07-21T09:33:42.667849Z 0 [Warning] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode.
2017-07-21T09:33:42.667933Z 0 [Warning] 'db' entry 'performance_schema mysql.session@localhost' ignored in --skip-name-resolve mode.
2017-07-21T09:33:42.667961Z 0 [Warning] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode.
2017-07-21T09:33:42.667976Z 0 [Warning] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode.
2017-07-21T09:33:42.669160Z 0 [Warning] 'tables_priv' entry 'user mysql.session@localhost' ignored in --skip-name-resolve mode.
2017-07-21T09:33:42.669219Z 0 [Warning] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode.
2017-07-21T09:33:42.673895Z 0 [Note] Event Scheduler: Loaded 0 events
2017-07-21T09:33:42.674312Z 0 [Note] mysqld: ready for connections.
Version: '5.7.19'  socket: '/var/run/mysqld/mysqld.sock'  port: 0  MySQL Community Server (GPL)
2017-07-21T09:33:42.674402Z 0 [Note] Executing 'SELECT * FROM INFORMATION_SCHEMA.TABLES;' to get a list of tables using the deprecated partition engine. You may use the startup option '--disable-partition-engine-check' to skip this check.
2017-07-21T09:33:42.674463Z 0 [Note] Beginning of list of non-natively partitioned tables
2017-07-21T09:33:42.686345Z 0 [Note] End of list of non-natively partitioned tables
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.
2017-07-21T09:33:45.261187Z 5 [Warning] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode.
2017-07-21T09:33:45.261221Z 5 [Warning] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode.
2017-07-21T09:33:45.261231Z 5 [Warning] 'db' entry 'performance_schema mysql.session@localhost' ignored in --skip-name-resolve mode.
2017-07-21T09:33:45.261289Z 5 [Warning] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode.
2017-07-21T09:33:45.261526Z 5 [Warning] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode.
2017-07-21T09:33:45.261549Z 5 [Warning] 'tables_priv' entry 'user mysql.session@localhost' ignored in --skip-name-resolve mode.
2017-07-21T09:33:45.261593Z 5 [Warning] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode.

2017-07-21T09:33:45.269788Z 0 [Note] Giving 0 client threads a chance to die gracefully
2017-07-21T09:33:45.269858Z 0 [Note] Shutting down slave threads
2017-07-21T09:33:45.269863Z 0 [Note] Forcefully disconnecting 0 remaining clients
2017-07-21T09:33:45.269867Z 0 [Note] Event Scheduler: Purging the queue. 0 events
2017-07-21T09:33:45.269939Z 0 [Note] Binlog end
2017-07-21T09:33:45.270552Z 0 [Note] Shutting down plugin 'ngram'
2017-07-21T09:33:45.270571Z 0 [Note] Shutting down plugin 'ARCHIVE'
2017-07-21T09:33:45.270573Z 0 [Note] Shutting down plugin 'partition'
2017-07-21T09:33:45.270575Z 0 [Note] Shutting down plugin 'BLACKHOLE'
2017-07-21T09:33:45.270577Z 0 [Note] Shutting down plugin 'MyISAM'
2017-07-21T09:33:45.270582Z 0 [Note] Shutting down plugin 'MRG_MYISAM'
2017-07-21T09:33:45.270584Z 0 [Note] Shutting down plugin 'INNODB_SYS_VIRTUAL'
2017-07-21T09:33:45.270586Z 0 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES'
2017-07-21T09:33:45.270587Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES'
2017-07-21T09:33:45.270588Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS'
2017-07-21T09:33:45.270590Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN'
2017-07-21T09:33:45.270591Z 0 [Note] Shutting down plugin 'INNODB_SYS_FIELDS'
2017-07-21T09:33:45.270592Z 0 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS'
2017-07-21T09:33:45.270593Z 0 [Note] Shutting down plugin 'INNODB_SYS_INDEXES'
2017-07-21T09:33:45.270595Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS'
2017-07-21T09:33:45.270596Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLES'
2017-07-21T09:33:45.270598Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE'
2017-07-21T09:33:45.270599Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE'
2017-07-21T09:33:45.270600Z 0 [Note] Shutting down plugin 'INNODB_FT_CONFIG'
2017-07-21T09:33:45.270601Z 0 [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED'
2017-07-21T09:33:45.270603Z 0 [Note] Shutting down plugin 'INNODB_FT_DELETED'
2017-07-21T09:33:45.270604Z 0 [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD'
2017-07-21T09:33:45.270605Z 0 [Note] Shutting down plugin 'INNODB_METRICS'
2017-07-21T09:33:45.270606Z 0 [Note] Shutting down plugin 'INNODB_TEMP_TABLE_INFO'
2017-07-21T09:33:45.270608Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS'
2017-07-21T09:33:45.270609Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU'
2017-07-21T09:33:45.270752Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE'
2017-07-21T09:33:45.270755Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET'
2017-07-21T09:33:45.270756Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX'
2017-07-21T09:33:45.270758Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET'
2017-07-21T09:33:45.270759Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM'
2017-07-21T09:33:45.270760Z 0 [Note] Shutting down plugin 'INNODB_CMP_RESET'
2017-07-21T09:33:45.270761Z 0 [Note] Shutting down plugin 'INNODB_CMP'
2017-07-21T09:33:45.270763Z 0 [Note] Shutting down plugin 'INNODB_LOCK_WAITS'
2017-07-21T09:33:45.270764Z 0 [Note] Shutting down plugin 'INNODB_LOCKS'
2017-07-21T09:33:45.270765Z 0 [Note] Shutting down plugin 'INNODB_TRX'
2017-07-21T09:33:45.270767Z 0 [Note] Shutting down plugin 'InnoDB'
2017-07-21T09:33:45.270910Z 0 [Note] InnoDB: FTS optimize thread exiting.
2017-07-21T09:33:45.271325Z 0 [Note] InnoDB: Starting shutdown...
2017-07-21T09:33:45.374371Z 0 [Note] InnoDB: Dumping buffer pool(s) to /var/lib/mysql/ib_buffer_pool
2017-07-21T09:33:45.375279Z 0 [Note] InnoDB: Buffer pool(s) dump completed at 170721  9:33:45
2017-07-21T09:33:46.485934Z 0 [Note] InnoDB: Shutdown completed; log sequence number 12143451
2017-07-21T09:33:46.487696Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2017-07-21T09:33:46.487765Z 0 [Note] Shutting down plugin 'CSV'
2017-07-21T09:33:46.487838Z 0 [Note] Shutting down plugin 'MEMORY'
2017-07-21T09:33:46.487865Z 0 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA'
2017-07-21T09:33:46.487889Z 0 [Note] Shutting down plugin 'sha256_password'
2017-07-21T09:33:46.487896Z 0 [Note] Shutting down plugin 'mysql_native_password'
2017-07-21T09:33:46.488080Z 0 [Note] Shutting down plugin 'binlog'
2017-07-21T09:33:46.488535Z 0 [Note] mysqld: Shutdown complete


MySQL init process done. Ready for start up.

2017-07-21T09:33:46.664213Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-07-21T09:33:46.665106Z 0 [Note] mysqld (mysqld 5.7.19) starting as process 1 ...
2017-07-21T09:33:46.667526Z 0 [Note] InnoDB: PUNCH HOLE support available
2017-07-21T09:33:46.667617Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-07-21T09:33:46.667710Z 0 [Note] InnoDB: Uses event mutexes
2017-07-21T09:33:46.667760Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2017-07-21T09:33:46.667771Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
2017-07-21T09:33:46.667779Z 0 [Note] InnoDB: Using Linux native AIO
2017-07-21T09:33:46.668064Z 0 [Note] InnoDB: Number of pools: 1
2017-07-21T09:33:46.668279Z 0 [Note] InnoDB: Using CPU crc32 instructions
2017-07-21T09:33:46.669725Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2017-07-21T09:33:46.675512Z 0 [Note] InnoDB: Completed initialization of buffer pool
2017-07-21T09:33:46.677074Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2017-07-21T09:33:46.688393Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2017-07-21T09:33:46.693981Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2017-07-21T09:33:46.694072Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2017-07-21T09:33:46.707592Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2017-07-21T09:33:46.708271Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2017-07-21T09:33:46.708324Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2017-07-21T09:33:46.708703Z 0 [Note] InnoDB: 5.7.19 started; log sequence number 12143451
2017-07-21T09:33:46.709030Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2017-07-21T09:33:46.709232Z 0 [Note] Plugin 'FEDERATED' is disabled.
2017-07-21T09:33:46.711545Z 0 [Note] InnoDB: Buffer pool(s) load completed at 170721  9:33:46
2017-07-21T09:33:46.712057Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
2017-07-21T09:33:46.712235Z 0 [Warning] CA certificate ca.pem is self signed.
2017-07-21T09:33:46.713492Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
2017-07-21T09:33:46.713542Z 0 [Note] IPv6 is available.
2017-07-21T09:33:46.713554Z 0 [Note]   - '::' resolves to '::';
2017-07-21T09:33:46.713569Z 0 [Note] Server socket created on IP: '::'.
2017-07-21T09:33:46.715228Z 0 [Warning] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode.
2017-07-21T09:33:46.715275Z 0 [Warning] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode.
2017-07-21T09:33:46.715296Z 0 [Warning] 'db' entry 'performance_schema mysql.session@localhost' ignored in --skip-name-resolve mode.
2017-07-21T09:33:46.715305Z 0 [Warning] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode.
2017-07-21T09:33:46.715317Z 0 [Warning] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode.
2017-07-21T09:33:46.716836Z 0 [Warning] 'tables_priv' entry 'user mysql.session@localhost' ignored in --skip-name-resolve mode.
2017-07-21T09:33:46.716872Z 0 [Warning] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode.
2017-07-21T09:33:46.720011Z 0 [Note] Event Scheduler: Loaded 0 events
2017-07-21T09:33:46.720281Z 0 [Note] mysqld: ready for connections.
Version: '5.7.19'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server (GPL)
2017-07-21T09:33:46.720314Z 0 [Note] Executing 'SELECT * FROM INFORMATION_SCHEMA.TABLES;' to get a list of tables using the deprecated partition engine. You may use the startup option '--disable-partition-engine-check' to skip this check.
2017-07-21T09:33:46.720322Z 0 [Note] Beginning of list of non-natively partitioned tables
2017-07-21T09:33:46.726423Z 0 [Note] End of list of non-natively partitioned tables

日志不会显示任何错误。

我登录mysql数据库列出数据库。

mbp/~:$kubectl exec -it mysql-999033340-l2qn6  /bin/bash
root@mysql-999033340-l2qn6:/# mysql -uroot -ppassword
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.19 MySQL Community Server (GPL)

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

创建了服务mysql并检查服务看起来不错。

mbp/~:$kubectl expose deployment mysql --port=3306
service "mysql" exposed
mbp/~:$kubectl get services
NAME              CLUSTER-IP   EXTERNAL-IP   PORT(S)          AGE
hello-minikube    10.0.0.170   <nodes>       8080:30616/TCP   11d
kubernetes        10.0.0.1     <none>        443/TCP          11d
mongodb           10.0.0.183   <none>        27017/TCP        9d
mysql             10.0.0.35    <none>        3306/TCP         6s

创建了wordpress pod

mbp/~:$kubectl run wordpress --image=wordpress --env WORDPRESS_DB_HOST=mysql --env WORDPRESS_DB_PASSWORD=password
deployment "wordpress" created

mbp/~:$kubectl get pods
NAME                             READY     STATUS    RESTARTS   AGE
front-end-3033610114-b44mt       1/1       Running   7          9d
front-end-3033610114-xwb6t       1/1       Running   7          9d
hello-minikube-938614450-82l4k   1/1       Running   9          11d
mysql-999033340-l2qn6            1/1       Running   0          10m
rsvp-db-1731340865-m0b73         1/1       Running   7          9d
wordpress-170470044-cvl8w        1/1       Running   0          19s

wordpress的日志如下所示

Manglu-mbp/~:$kubectl logs wordpress-170470044-cvl8w
WordPress not found in /var/www/html - copying now...
Complete! WordPress has been successfully copied to /var/www/html

Warning: mysqli::mysqli(): php_network_getaddresses: getaddrinfo failed: Name or service not known in - on line 22

Warning: mysqli::mysqli(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: Name or service not known in - on line 22

MySQL Connection Error: (2002) php_network_getaddresses: getaddrinfo failed: Name or service not known

Warning: mysqli::mysqli(): php_network_getaddresses: getaddrinfo failed: Name or service not known in - on line 22

Warning: mysqli::mysqli(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: Name or service not known in - on line 22

MySQL Connection Error: (2002) php_network_getaddresses: getaddrinfo failed: Name or service not known

1 个答案:

答案 0 :(得分:1)

由于这些命令在其他Kubernetes集群中工作(除了我的minikube),我怀疑我的minikube设置有问题。我不记得在minikube安装过程中发现任何错误。

我删除了本地Kubernetest群集(使用minikube delete)并删除了“ .minikube ”目录下的所有内容(在用户的主目录中)

启动minikube,这创建了一个新的minikube VM,并运行相同的命令,并且工作正常。

我想当事情没有按预期发挥作用时,这可能是我们在迷你世界中需要做的事情。这比尝试解决问题容易得多!