上QQ阅读APP看书,第一时间看更新
3.8 安装
前面介绍了那么多知识点,最后我们来实际安装一下。
[root@iZ8vb0qditk1qw27yu4k5nZ ~]# helm install wordpress/ --name wordpress NAME: wordpress LAST DEPLOYED: Mon Sep 16 21:53:45 2019 NAMESPACE: default STATUS: DEPLOYED RESOURCES: ==> v1/ConfigMap NAME DATA AGE wordpress-mariadb 1 0s wordpress-mariadb-tests 1 0s ==> v1/Deployment NAME READY UP-TO-DATE AVAILABLE AGE wordpress-wordpress 0/1 1 0 0s ==> v1/PersistentVolumeClaim NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE wordpress-wordpress Pending 0s ==> v1/Pod(related) NAME READY STATUS RESTARTS AGE wordpress-mariadb-0 0/1 Pending 0 0s wordpress-wordpress-7f7b79b977-dtjf7 0/1 Pending 0 0s ==> v1/Secret NAME TYPE DATA AGE wordpress-mariadb Opaque 2 0s wordpress-wordpress Opaque 1 0s ==> v1/Service NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE wordpress-mariadb ClusterIP 172.26.5.92 <none> 3306/TCP 0s wordpress-wordpress LoadBalancer 172.26.14.199 <pending> 80:31571/TCP,443:32659/TCP 0s ==> v1beta1/StatefulSet NAME READY AGE wordpress-mariadb 0/1 0s NOTES: 1. Get the WordPress URL: NOTE: It may take a few minutes for the LoadBalancer IP to be available. Watch the status with: 'kubectl get svc --namespace default -w wordpress-wordpress' export SERVICE_IP=$(kubectl get svc --namespace default wordpress-wordpress --template "{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}") echo "WordPress URL: http://$SERVICE_IP/" echo "WordPress Admin URL: http://$SERVICE_IP/admin" 2. Login with the following credentials to see your blog echo Username: user echo Password: $(kubectl get secret --namespace default wordpress-wordpress -o jsonpath="{.data.wordpress-password}" | base64 --decode)
可以看到,安装命令返回了如何访问Wordpress的信息,我们获取一下对应的svc访问IP。
[root@iZ8vb0qditk1qw27yu4k5nZ ~]# kubectl get svc --namespace default -w wordpress-wordpress NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE wordpress-wordpress LoadBalancer 172.26.14.168 39.98.21.16 80:31376/TCP,443:32570/TCP 111s172.26.14.199 39.100.178.126 80:31571/TCP,443:32659/TCP 74s
同时获取默认的用户名和密码。
[root@iZ8vb0qditk1qw27yu4k5nZ ~]# kubectl get secret --namespace default wordpress-wordpress -o jsonpath="{.data.wordpress-password}" | base64 --decode 1Ria5Wdaxd
可以看到目前两个pod都已经RUNNING,我们同时运行一下测试用例。
[root@iZ8vb0qditk1qw27yu4k5nZ ~]# kubectl get pods NAME READY STATUS RESTARTS AGE wordpress-mariadb-0 1/1 Running 0 104s wordpress-wordpress-7f7b79b977-sc6sq 1/1 Running 0 104s [root@iZ8vb0qditk1qw27yu4k5nZ tests]# helm test wordpress RUNNING: wordpress-mariadb-test-ouh72 PASSED: wordpress-mariadb-test-ouh72 RUNNING: wordpress-credentials-test PASSED: wordpress-credentials-test
测试用例运行成功,最后我们访问一下页面,效果如图3-1~图3-3所示。
图3-1 Wordpress访问页面
图3-2 Wordpress登录页面
图3-3 Wordpress详情页面