kubernetes headless service

cloud2000·2023년 12월 20일
apiVersion: v1 [api버전: v1] 
kind: Service [종류: 서비스] 
metadata: [metadata:] 
  labels:
    app: show-hostname-headless
  name: show-hostname-headless
spec:
  ports:
  - name: 80-80
    port: 80
    protocol: TCP
    targetPort: 80
  selector:
    app: show-hostname-pod
  clusterIP: None코드를 입력하세요
apiVersion: v1
kind: Service
metadata:
  labels:
    app: show-hostname-regular
  name: show-hostname-regular
spec:
  ports:
  - name: 80-80
    port: 80
    protocol: TCP
    targetPort: 80
  selector:
    app: show-hostname-pod
kubectl run dns-client -it --image=tutum/dnsutils

// headless 서비스는 해당 Pod IP를 반환
root@dns-client:/# dig show-hostname-headless +search +short
192.168.63.71
192.168.57.84

// 일반 service는 service ip를 반환
root@dns-client:/# dig show-hostname-regular +search +short
10.100.54.41
  • 일반 서비스로는 ping이 안되지만, headless 서비스는 가능함.
profile
클라우드쟁이

0개의 댓글