전자책 출간 알림 [마이크로서비스패턴 쉽게 개발하기]

티스토리 뷰

docker.io의 공식 이미지인 curimages/curl을 이용하여, 한 줄로 Pod를 생성하는 방법입니다. 

테스트를 위해 pod, service를 생성합니다. 

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: hostnames
  name: hostnames
spec:
  selector:
    matchLabels:
      app: hostnames
  replicas: 1
  template:
    metadata:
      labels:
        app: hostnames
    spec:
      containers:
      - name: hostnames
        image: k8s.gcr.io/serve_hostname

---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: hostnames
  name: hostnames
spec:
  selector:
    app: hostnames
  ports:
  - name: default
    protocol: TCP
    port: 80
    targetPort: 9376

$ kubectl run curl -it --rm --image curlimages/curl -- sh

/ $ nslookup hostnames
Server:         10.96.0.10
Address:        10.96.0.10:53

** server can't find hostnames.cluster.local: NXDOMAIN

Name:   hostnames.default.svc.cluster.local
Address: 10.104.72.145

Shell을 나가면 옵션이 --rm이므로 Pod와 deployment가 자동으로 사라집니다.

 

댓글

전자책 출간 알림 [마이크로서비스패턴 쉽게 개발하기]