- 创建一个deployment,运行nginx程序
kubectl run test-nginx --image=nginx:latest
- 查看pod
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
test-nginx-68d7bfd7bd-x2btj 1/1 Running 0 41s
- 创建service expose deployment 端口
kubectl expose deployment/test-nginx --type="NodePort" --port=80
查看service
$ kubectl get services
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 1h
test-nginx NodePort 10.109.106.7 <none> 80:30647/TCP 31m
- 访问nginx
$ minikube ip
192.168.99.100