K8s暴露内部服务的多种方式

hostNetWork:true

测试yaml:

apiVersion: v1
kind: Pod
metadata:
  name: nginx-hostnetwork
spec:
  hostNetwork: true
  containers:
  - name: nginx-hostnetwork
    image: nginx:1.7.9
# 创建pod并测试
$ kubectl create -f nginx-hostnetwork.yaml
$ kubectl get pod --all-namespaces -o=wide | grep nginx-hostnetwork
default       nginx-hostnetwork                                1/1     Running   0          15m     172.30.3.222   k8s-n3              
# 测试
$ curl http://k8s-n3



Welcome to nginx!