How to publish K8S service svc, direct access to external network services K8S, access POD, through a simple example to understand what

How to publish K8S service svc, through a simple example to understand what

Simulation environment is as follows:

The MASTER-K8S: 192.168.250.100
K8S-NODE01: 192.168.250.101
K8S-NODE02: 192.168.250.102
above assumptions have been installed environment

aims

192.168.250.200 achieved through service access to our real K8s of svc, thus achieving our visit Pod

Specific operation

Enter the Master node, start the deployment with the following command, and add a realization we needed svc

docker pull nginx
kubectl run http --image=nginx --port=80 --replicas=3
kubectl expose deployment http --type=NodePort \
    --external-ip=192.168.250.200 --name=http-svc --port=80 --target-port=80
#到这里应该是完成了,我们查看一下
kubectl get svc 
kubectl get deployment
kubectl get pods -o wide

test

curl 192.168.250.200
#成功
Published 48 original articles · won praise 3 · views 20000 +

Guess you like

Origin blog.csdn.net/chscomfaner/article/details/105003579
Recommended