k8s使用NodePort的方法发布业务

Step1:在master上使用kubectl get deployment -o wide查看deployment文件

[[email protected] ~]# kubectl get deployment -o wide
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
portal 1 1 1 1 1h
web 1 1 1 1 1h
[[email protected] ~]

Step2:在master上使用kubectl expose deployment deployment_name --type=NodePort创建svc

  kubectl expose deployment web --type=NodePort

 kubectl expose deployment portal --type=NodePort

Step3:在master上使用kubectl get svc -o wide查看svc的端口

[[email protected] ~]# kubectl get svc -o wide
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
kubernetes 10.254.0.1 <none> 443/TCP 2h <none>
portal 10.254.171.19 <nodes> 80:31681/TCP 22m run=portal
web 10.254.234.19 <nodes> 80:30638/TCP 22m run=web
[[email protected] ~]#

Step4:在外部使用Node:Nodeport就可以访问业务

 

猜你喜欢

转载自www.cnblogs.com/networking/p/11768739.html