티스토리 뷰

728x90

오늘은 kubernetes의 오브젝트 종류 중 deployment 파일의 구조에 대해 알아보겠습니다.

728x90
# Control Plane에서 쿠버네티스 오브젝트를 관리하기 위해 사용하는 api 버전
apiVersion: apps/v1
# 오브젝트의 종류
kind: Deployment
# 오브젝트에 대한 기본적인 정보
metadata:
  # name : 오브젝트 이름 (특정 namespace에서 유일한 값)
  name: ccn-gateway-eks
  # namespace : 해당 오브젝트가 사용되는 네임스페이스
  namespace: prd-deploy
# 오브젝트의 상세 스펙
spec:
  # 파드의 레플리카 개수
  replicas: 1
  # 특정 label에 해당하는 객체를 검색할 때 사용
  selector:
    # app 이름이 다음과 일치하는 것에 적용
    matchLabels:
      app: ccn-gateway-eks
  # 배포 전략
  strategy:
    rollingUpdate:
      # 업데이트 시 추가로 생성할 수 있는 최대 파드 수
      maxSurge: 20%
      # 업데이트 시 unavailable 될 수 있는 최대 파드 수
      maxUnavailable: 20%
    # 배포 전략
    # recreate, rolling update, blue&green, canary
    type: RollingUpdate
  # 아래 템플릿에 따라 파드가 생성된다.
  template:
    # 생성될 파드 label
    metadata:
      labels:
        app: ccn-gateway-eks
    # 템플릿 상세 설명
    spec:
      # 아래 개수만큼 컨테이너가 생성된다
      containers:
      - env:
        - name: NODE_NAME
          valueFrom:
            fieldRef:
              apiVersion: v1
              fieldPath: spec.nodeName
        - name: TZ
          value: Asia/Seoul
        # 환경 변수의 출처
        envFrom:
        - configMapRef:
          name: ccn-gateway-eks-config
        - secretRef:
          name: ccn-gateway-eks-secret
        image: {이미지 주소}
        # 이미지 pull 정책 : 매번 새로 업데이트(Always), 최신 버전이 아니라면 업데이트(IfNotPresent), Never
        imagePullPolicy: Always
        # 컨테이너 템플릿 이름
        name: ccn-gateway-eks
        ports:
        - containerPort: 13002
          name: http
        # readinessProbe : 요청을 처리할 준비가 됐는지 확인하고, 확인이 안되면 서비스에서 제외
        # livenessProbe : 서버가 응답하는지 체크하고 응답 없으면 죽이고 재시작
        readinessProbe:
          # Probe가 컨테이너를 다시 시작하기 위한 실패 횟수
          failureThreshold: 5
          # Get 요청을 보내서 확인
          httpGet:
            path: /actuator/health
            port: 13002
            scheme: HTTP
          # 컨테이너가 시작된 후, 첫 프로브 시간 앞의 공백 시간
          initialDelaySeconds: 15
          # Probe를 수행하는 빈도(초)
          periodSeconds: 20
          # Probe 실패 후, 성공으로 간주되기 위한 최소 연속 성공 횟수
          successThreshold: 1
          # Probe 시간 초과 허용시간
          timeoutSeconds: 30
        # 컨테이너 자원 설정
        resources:
          limits:
            cpu: 1500m
            memory: 1500Mi
          requests:
            cpu: 500m
            memory: 500Mi
        volumeMounts:
        - mountPath: /fslog
          name: vol1
      # 클러스터 suffix와 일치하지 않는 dns 쿼리는 노드에서 상속된 업스트림 네임서버로 전달
      dnsPolicy: clusterFirst
      # 생성된 파드의 /etc/hosts에 추가될 항목
      hostAliases:
      - hostname:
        - nextlevel.deploy.com
        - nextstage.deploy.com
        ip : 10.12.23.34
      imagePullSecrets:
      - name: Ne-Xt-cred
      volumes:
      - name: vol1
        persistentVolumeClaim:
          claimName: log-volume

 

 

다른 컴포넌트 알아보러 가기

2024.01.26 - [infra/kubernetes] - [쿠버네티스] 워크 로드(1) / Pod

 

[쿠버네티스] 워크 로드(1) / Pod

1. Pod 란? - 쿠버네티스 노드 내에 최소 한 개 이상의 컨테이너를 가진 파드가 실행되고 있으며, 파드마다 다른 IP를 가지고 있고 컨테이너끼리 통신이 가능함 - 파드 내 컨테이너끼리 볼륨(저장소

coding.lifeandmoney.kr

2024.02.08 - [infra/kubernetes] - [쿠버네티스] 워크 로드(2) / ReplicaSet, Deployment, DaemonSet, Static Pod

 

[쿠버네티스] 워크 로드(2) / ReplicaSet, Deployment, DaemonSet, Static Pod

1. ReplicaSet - 파드를 생성 및 복제하고, 복제된 파드 수를 yaml 파일에서 생성된 개수만큼 항상 유지 apiVersion: apps/v1 kind: Replicaset metadata: name: nginx-rs labels: app: nginx-rs tier: nginx-rs spec: replicas: 3 selector:

coding.lifeandmoney.kr

2024.02.07 - [infra/kubernetes] - [쿠버네티스] Label & Selector

 

[쿠버네티스] Label & Selector

Label & Selector 1) Label - 객체에 연결된 key-value 쌍 값 - 리소스를 논리적인 그룹으로 나누거나 식별하기 위해 붙이는 이름 - 객체 생성 시 첨부할 수 있으며 언제든지 추가 및 수정 가능 2) Selector - 특

coding.lifeandmoney.kr

 

728x90
300x250
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크