kubernets之service测试

部署nginx service做测试。
部署nginx:
kubectl run nginx --image=nginx --replicas=2 --labels="run=load-nginx-example" --port=80 ##端口一定是80要不然访问不成功,提示拒绝连接

查看信息: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:
Selector: run=load-nginx-example
Type: NodePort
IP: 10.98.153.124
Port: 80/TCP
TargetPort: 80/TCP
NodePort: 32197/TCP
Endpoints: 10.244.1.4:80,10.244.1.5:80
Session Affinity: None
External Traffic Policy: Cluster
Events:

测试以下几个地址:
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

转载于:https://blog.51cto.com/mrdeng/2105179

你可能感兴趣的:(kubernets之service测试)