kubernets部署微服務電商平臺

 1、準備條件

1) 確保kubernetes能夠訪問:reg.yunwei.edu鏡像庫(vim /etc/hosts)
[root@cicd yml]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         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) 須要準備鏡像:

 

 4) 而後進入sock-shop目錄下下載所需鏡像到sock-shop命名空間。
[root@cicd yml]# cd /root/kubernetes/sock-shop/
[root@cicd sock-shop]# ls
complete-demo.yaml

 

2、部署微服務

 
編輯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          1/1       Running   0          2h
carts-db-56ffbd7b87-rlkkg       1/1       Running   0          2h
catalogue-68bd49fd6d-s484q      1/1       Running   0          2h
catalogue-db-867b859dd5-5cdwv   1/1       Running   0          2h
front-end-868c9c5965-xjvcr      1/1       Running   0 2h
orders-56dd9f89d8-5jcmx         1/1       Running   0          2h
orders-db-677c4864ff-mdqp8      1/1       Running   0          2h
payment-6548fcccc8-vlhds        1/1       Running   0          2h
queue-master-7d7dd4bd9b-lbvmv   1/1       Running   0          2h
rabbitmq-74cc7558bc-c44ln       1/1       Running   0          2h
shipping-9f757f4f8-2nrq7        1/1       Running   0          2h
user-5d5b5c655f-2n47l           1/1       Running   0          2h
user-db-99f788995-xglhz         1/1       Running   1          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>        80/TCP         2h
carts-db       ClusterIP   10.68.165.206   <none>        27017/TCP      2h
catalogue      ClusterIP   10.68.143.207   <none>        80/TCP         2h
catalogue-db   ClusterIP   10.68.70.95     <none>        3306/TCP       2h
front-end      NodePort    10.68.128.49    <none>        80:30001/TCP 2h
orders         ClusterIP   10.68.155.168   <none>        80/TCP         2h
orders-db      ClusterIP   10.68.56.165    <none>        27017/TCP      2h
payment        ClusterIP   10.68.83.6      <none>        80/TCP         2h
queue-master   ClusterIP   10.68.255.236   <none>        80/TCP         2h
rabbitmq       ClusterIP   10.68.16.109    <none>        5672/TCP       2h
shipping       ClusterIP   10.68.185.79    <none>        80/TCP         2h
user           ClusterIP   10.68.1.194     <none>        80/TCP         2h
user-db        ClusterIP   10.68.31.241    <none>        27017/TCP      2h

 

 3、登陸瀏覽器驗證(集羣節點ip+端口:192.168.253.10:30001)

相關文章
相關標籤/搜索