查看信息:kubectl get pods --all-namespaces -o wide |grep nginx
定义service:
kubectl expose deployment nginx --type=NodePort --name=test-service
详细信息:
kubectl describe svc test-service
[root@k8s ~]# kubectl describe svc test-service
Name: test2-service
Namespace: default
Labels: run=load-nginx-example
Annotations: <none>
Selector: run=load-nginx-example
Type: NodePort
IP: 10.98.153.124
Port: <unset> 80/TCP
TargetPort: 80/TCP
NodePort: <unset> 32197/TCP
Endpoints: 10.244.1.4:80,10.244.1.5:80
Session Affinity: None
External Traffic Policy: Cluster
Events: <none>
测试以下几个地址:
curl http://10.98.153.124:80
curl: http://10.244.1.5:80
curl http://192.168.147.191:32197
curl http://192.168.147.192:32197
原文地址:http://blog.51cto.com/mrdeng/2105179