创建2个pod的nginx service
[root@node1 data]# kubectl run nginx –replicas=2 –labels="run=load-balancer-example" –image=nginx:1.9 –port=80
deployment "nginx" created
[root@node1 yaml]# kubectl get pod –all-namespaces -o wide|grep nginx
default nginx-3431010723-6kv1z 1/1 Running 2 1h 10.244.5.6 node5
default nginx-3431010723-bw22q 1/1 Running 2 1h 10.244.3.14 node4
[root@node1 kube-config]# kubectl expose deployment nginx –type=NodePort –name=example-service
service "example-service" exposed
[root@node1 kube-config]# kubectl describe svc example-service
Name: example-service
Namespace: default
Labels: run=load-balancer-example
Annotations:
Selector: run=load-balancer-example
Type: NodePort
IP: 10.105.170.116
Port: 80/TCP
NodePort: 3