使用Minishift v1.28.0,在Pod上部署WordPress和MariaDB

从红帽容器目录(RHCC)中获取基于Docker的镜像。

从可信赖的Red Hat容器目录(RHCC)作为源获取基本的Docker镜像。

01.png

这次我想借这个机会,在项目中获取WordPress的Docker镜像和MariaDB的Docker镜像,并设置引用连接。

获取WordPress的Docker镜像。

在红帽容器目录(RHCC)中搜索“WordPress”。

02.png

从列出的各种图像中,我选择了“WordPress与Nginx和PHP7(bitnami/wordpress-nginx-php7)”。

04-1.png

注册表似乎是registry.connect.redhat.com。
WordPress与Nginx和PHP7(registry.connect.redhat.com/bitnami/wordpress-nginx-php7)

在构建Docker镜像时,会使用环境变量作为参数来进行环境设置,因此需要确认配置。

根据Overview中的「README & Configuration Options」进行参考

VariableDescriptionDefaultMARIADB_HOSTHostname for MariaDB server.mariadbMARIADB_PORT_NUMBERPort used by MariaDB server.3306WORDPRESS_DATABASE_NAMEDatabase name that WordPress will use to connect with the database.bitnami_wordpressWORDPRESS_TABLE_PREFIXTable prefix to use in WordPress.wp_WORDPRESS_DATABASE_USERDatabase user that WordPress will use to connect with the database.bn_wordpressWORDPRESS_DATABASE_PASSWORDDatabase password that WordPress will use to connect with the database.No defaults.ALLOW_EMPTY_PASSWORDIt can be used to allow blank passwords.no

获取MariaDB的Docker镜像

05-1.png
07.png
VariableDescriptionNoteMYSQL_USERDatabase user name
MYSQL_PASSWORDUser’s password
MYSQL_DATABASEName of the database to create
MYSQL_ROOT_PASSWORDPassword for the ‘root’ MySQL accountOptional

将基础镜像注册到Minishift中

由于收集到了信息,我们将在minishift上拉取Docker镜像。

[tak@centos76 ~]$ minishift ssh
[docker@minishift ~]$ docker login registry.connect.redhat.com --username <username>
Password:<password>
Login Succeeded
[docker@minishift ~]$ docker search registry.connect.redhat.com/wordpress
INDEX        NAME                                                        DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
redhat.com   registry.connect.redhat.com/bitnami/wordpress-apache-php5   This WordPress container solution is optim...   0
redhat.com   registry.connect.redhat.com/bitnami/wordpress-apache-php7   This WordPress container solution is optim...   0
redhat.com   registry.connect.redhat.com/bitnami/wordpress-nginx-php5    This WordPress container solution is optim...   0
redhat.com   registry.connect.redhat.com/bitnami/wordpress-nginx-php7    This WordPress container solution is optim...   0

[docker@minishift ~]$ docker pull registry.connect.redhat.com/bitnami/wordpress-nginx-php7
Using default tag: latest
Trying to pull repository registry.connect.redhat.com/bitnami/wordpress-nginx-php7 ...
latest: Pulling from registry.connect.redhat.com/bitnami/wordpress-nginx-php7
367d84554057: Pull complete
:
119b0de383d9: Pull complete
Digest: sha256:7f9bef9632f2a9a87ff4c02ded5080d4048418d26913d3dacfb9cf1c6612ae04
Status: Downloaded newer image for registry.connect.redhat.com/bitnami/wordpress-nginx-php7:latest
[docker@minishift ~]$ exit
[tak@centos76 ~]$ oc import-image my-bitnami/wordpress-nginx-php7 --from=registry.connect.redhat.com/bitnami/wordpress-nginx-php7 --confirm
[docker@minishift ~]$ docker search registry.access.redhat.com/mariadb
INDEX        NAME                                                        DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
redhat.com   registry.access.redhat.com/openshift3/mariadb-apb           Ansible Playbook Bundle application defini...   0                    
redhat.com   registry.access.redhat.com/rhosp12/openstack-mariadb        Red Hat OpenStack Container image for open...   0                    
redhat.com   registry.access.redhat.com/rhosp13/openstack-mariadb        Red Hat OpenStack Container image for open...   0                    
redhat.com   registry.access.redhat.com/rhosp14-beta/openstack-mariadb   Red Hat OpenStack Beta Container image for...   0                    
redhat.com   registry.access.redhat.com/rhscl/mariadb-100-rhel7          MariaDB 10.0 SQL database server                0                    
redhat.com   registry.access.redhat.com/rhscl/mariadb-101-rhel7          MariaDB server 10.1 for OpenShift and gene...   0                    
redhat.com   registry.access.redhat.com/rhscl/mariadb-102-rhel7          MariaDB is a multi-user, multi-threaded SQ...   0  

[docker@minishift ~]$ docker pull registry.access.redhat.com/rhscl/mariadb-101-rhel7
Using default tag: latest
Trying to pull repository registry.access.redhat.com/rhscl/mariadb-101-rhel7 ... 
latest: Pulling from registry.access.redhat.com/rhscl/mariadb-101-rhel7

23113ae36f8e: Pull complete
:
84c39a3a2476: Pull complete
sha256:eda05d7ccdd32f0993e880b8ee0d92bbd61abde6bb7450193fd4b67ea1eb0f1b
Status: Downloaded newer image for registry.access.redhat.com/rhscl/mariadb-101-rhel7:latest
[docker@minishift ~]$ exit
[tak@centos76 ~]$ oc import-image my-rhscl/mariadb-101-rhel7 --from=registry.access.redhat.com/rhscl/mariadb-101-rhel7 --confirm

我会预先检查一下已在注册表中登记过的Docker镜像。

[tak@centos76 ~]$ minishift ssh
Last login: Sat Dec 22 17:11:10 2018 from 192.168.42.1
[docker@minishift ~]$ docker images
REPOSITORY                                                 TAG                 IMAGE ID            CREATED             SIZE
docker.io/openshift/origin-node                            v3.11.0             438d61da63d1        20 hours ago        1.16 GB
docker.io/openshift/origin-control-plane                   v3.11.0             00f980c345c1        20 hours ago        825 MB
docker.io/openshift/origin-hyperkube                       v3.11.0             d65ee3cc9874        20 hours ago        506 MB
docker.io/openshift/origin-haproxy-router                  v3.11.0             316c2621011d        20 hours ago        407 MB
docker.io/openshift/origin-pod                             v3.11.0             045ddf827c75        20 hours ago        258 MB
docker.io/openshift/origin-deployer                        v3.11.0             d05e619aac21        20 hours ago        380 MB
docker.io/openshift/origin-hypershift                      v3.11.0             a777d85d24b9        20 hours ago        546 MB
docker.io/openshift/origin-cli                             v3.11.0             83d7b0b2f011        20 hours ago        380 MB
172.30.1.1:5000/openshift/mariadb                          <none>              5e784880fd90        2 weeks ago         458 MB
registry.access.redhat.com/rhscl/mariadb-101-rhel7         latest              a4deee8ed5a5        3 weeks ago         455 MB
registry.connect.redhat.com/bitnami/wordpress-nginx-php7   latest              2892cd4d344e        5 weeks ago         580 MB
docker.io/openshift/origin-web-console                     v3.11.0             be30b6cce5fa        2 months ago        339 MB
docker.io/openshift/origin-docker-registry                 v3.11.0             a0d5ad164395        2 months ago        305 MB
docker.io/openshift/origin-service-serving-cert-signer     v3.11               47dadf9d43b6        2 months ago        276 MB

创建MariaDB的Pod

12.png

我们将在下方显示的”环境变量”中输入刚刚查到的值。
就像这样(笑)。

VariableDescriptionValueMYSQL_USERDatabase user nameuserMYSQL_PASSWORDUser’s passwordpasswordMYSQL_DATABASEName of the database to createwordpress_dbMYSQL_ROOT_PASSWORDPassword for the ‘root’ MySQL accountroot_password
13.png

请点击“部署”按钮。

15.png

确认MariaDB服务

17.png

使用WordPress创建Pod

20.png
VariableDefaultValueMARIADB_HOSTmariadbmariadb-101-rhel7.myproject.svcMARIADB_PORT_NUMBER3306←WORDPRESS_DATABASE_NAMEbitnami_wordpresswordpress_dbWORDPRESS_TABLE_PREFIXwp_←WORDPRESS_DATABASE_USERbn_wordpressuserWORDPRESS_DATABASE_PASSWORDNo defaults.passwordALLOW_EMPTY_PASSWORDno←

环境变量未定义,默认将采用默认值。

22.png
24.png
$ minishift stop
$ minishift start

(-。-)y-゜゜゜ 可以用下面的方式来表达: 令我感到困惑或者惊讶。

25.png

为WordPress创建一个路由器。

26.png
27.png
28.png

在浏览器中访问的URL将与Hostname中显示的URL相同。

祝愿WordPress+MariaDB!

当您点击链接时,WordPress页面会显示出来!

30.png

如果你希望稍后更改环境变量

博客名为“用户的博客”。
当再次仔细查看“自述文件和配置选项”时,可以注意到这是一个环境变量…

VariableDescriptionDefaultWORDPRESS_USERNAMEWordPress application username.userWORDPRESS_PASSWORDWordPress application password.bitnamiWORDPRESS_EMAILWordPress application email.user@example.comWORDPRESS_FIRST_NAMEWordPress user first name.FirstNameWORDPRESS_LAST_NAMEWordPress user last name.LastNameWORDPRESS_BLOG_NAMEWordPress blog name. DefaultUser’s blog

让我们轻松地尝试更改博客名称和用户。

40.png
41.png
42.png
44.png
45.png

一次重新启动机器,然后再次部署…。如果加上电脑内存会好吗?

广告
将在 10 秒后关闭
bannerAds