一、准备条件

1) 确保kubernetes可以访问:reg.yunwei.edu镜像库(vim /etc/hosts)
[root@cicd yml]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
:: localhost localhost.localdomain localhost6 localhost6.localdomain6
172.16.254.20 reg.yunwei.edu
#192.168.253.9 reg.yunwei.edu
192.168.253.9 cicd
192.168.253.14 node1
192.168.253.11 node2
192.168.253.10 node3
 
 2) 然后创建sock-shop的名称空间。
  kubectl create namespace sock-shop
[root@cicd yml]# kubectl get ns
NAME STATUS AGE
default Active 3d
kube-public Active 3d
kube-system Active 3d
sock-shop Active 3h
weave Active 2h
  3) 需要准备镜像:
kubernets部署微服务电商平台-LMLPHP

 4) 然后进入sock-shop目录下下载所需镜像到sock-shop命名空间。
[root@cicd yml]# cd /root/kubernetes/sock-shop/
[root@cicd sock-shop]# ls
complete-demo.yaml

二、部署微服务

 
编辑complete-demo.yaml后,执行
kubectl apply -f complete-demo.yaml
 
查看前端service的访问端口:
kubectl get pod -n sock-shop
kubectl get service -n sock-shop
 
[root@cicd sock-shop]# kubectl get pod -n sock-shop          sock-shop内pod状态
NAME READY STATUS RESTARTS AGE
carts-5486c9cc4f-k9j4p / Running 2h
carts-db-56ffbd7b87-rlkkg / Running 2h
catalogue-68bd49fd6d-s484q / Running 2h
catalogue-db-867b859dd5-5cdwv / Running 2h
front-end-868c9c5965-xjvcr / Running 2h
orders-56dd9f89d8-5jcmx / Running 2h
orders-db-677c4864ff-mdqp8 / Running 2h
payment-6548fcccc8-vlhds / Running 2h
queue-master-7d7dd4bd9b-lbvmv / Running 2h
rabbitmq-74cc7558bc-c44ln / Running 2h
shipping-9f757f4f8-2nrq7 / Running 2h
user-5d5b5c655f-2n47l / Running 2h
user-db-99f788995-xglhz / Running 2h [root@cicd sock-shop]# kubectl get svc -n sock-shop        #sock-shop内svc状态
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
carts ClusterIP 10.68.221.36 <none> /TCP 2h
carts-db ClusterIP 10.68.165.206 <none> /TCP 2h
catalogue ClusterIP 10.68.143.207 <none> /TCP 2h
catalogue-db ClusterIP 10.68.70.95 <none> /TCP 2h
front-end NodePort 10.68.128.49 <none> :/TCP 2h
orders ClusterIP 10.68.155.168 <none> /TCP 2h
orders-db ClusterIP 10.68.56.165 <none> /TCP 2h
payment ClusterIP 10.68.83.6 <none> /TCP 2h
queue-master ClusterIP 10.68.255.236 <none> /TCP 2h
rabbitmq ClusterIP 10.68.16.109 <none> /TCP 2h
shipping ClusterIP 10.68.185.79 <none> /TCP 2h
user ClusterIP 10.68.1.194 <none> /TCP 2h
user-db ClusterIP 10.68.31.241 <none> /TCP 2h

三、登录浏览器验证(集群节点ip+端口:192.168.253.10:30001)

kubernets部署微服务电商平台-LMLPHP

 
05-27 12:53