K8s 서비스 ClusterIP None


개요

ClusterIP None
a.yaml
apiVersion: v1
kind: Service
metadata:
  name: myservice
spec:
  ports:
  - name: http
    port: 8080
  selector:
    app: myapp
  type: ClusterIP
b.yaml
apiVersion: v1
kind: Service
metadata:
  name: myservice
spec:
  clusterIP: None
  ports:
  - name: http
    port: 8080
  selector:
    app: myapp
  type: ClusterIP
$ diff a.yaml b.yaml 
5a6
>   clusterIP: None

테스트 1

$ kubectl apply -f a.yaml 
service/myservice created
$ kubectl get svc myservice -oyaml | grep '^  clusterIP' -A1
  clusterIP: 10.0.15.235
  clusterIPs:
  - 10.0.15.235
$ kubectl apply -f b.yaml 
The Service "myservice" is invalid: spec.clusterIPs[0]: Invalid value: []string{"None"}: may not change once set
$ kubectl delete -f a.yaml 
service "myservice" deleted

테스트 2

$ kubectl apply -f b.yaml 
service/myservice created
$ kubectl get svc myservice -oyaml | grep '^  clusterIP' -A1
  clusterIP: None
  clusterIPs:
  - None
$ kubectl apply -f a.yaml 
service/myservice configured
$ kubectl get svc myservice -oyaml | grep '^  clusterIP' -A1
  clusterIP: None
  clusterIPs:
  - None

같이 보기