标签:run nbsp master Kubernete size clu ted tcp extern
Kubernetes 命令的方式运行应用:
~$ kubectl run blogtest --image=18524637652/blog_test:firsttry --port=15672 deployment.apps "blogtest" created
外部访问Kubernetes内部的应用:
默认情况下,所有Pod只能在集群内部访问,为了能够外部访问应用,需要将容器端口映射到节点的端口,15672 就是容器中端口。15672端口已经映射到了12732端口,端口号是随机分配的
~$ kubectl get service NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 6d ~$ kubectl expose deployment/blogtest --type="NodePort" --port="15672" service "blogtest" exposed ~$ kubectl get service NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE blogtest NodePort 10.111.225.14 <none> 15672:12732/TCP 6s kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 6d ~$ hostname galaxy-k8s-test-master-02 ~$ curl galaxy-k8s-test-master-02:12732
标签:run nbsp master Kubernete size clu ted tcp extern
原文地址:https://www.cnblogs.com/Lyh1997/p/10230145.html