Updated:

less than 1 minute read

설명

  • key-value 형태로 데이터를 저장하는 API 오브젝트
  • Pod에서 환경변수, 설정 파일 등으로 사용

설정

  • yaml 작성
    • 숫자의 경우 “로 감싸야 한다
       apiVersion: v1
       kind: ConfigMap
       metadata:
       name: config-v1
       data:
       key-1: value-1
       key-2: value-2
      
  • 환경 변수
     ...
         spec:
           containers:
             - env:
                 - name: KEY_1
                   valueFrom:
                     configMapKeyRef:
                       name: config-v1
                       key: key-1
     ...
    
  • 파일
    • mountPath에 파일 이름이 key이고 내용이 value인 파일들이 생성
       ...
         spec:
           containers:
             - volumeMounts:
                 - name: config-volumes
                   mountPath: /etc/config
       ...
           volumes:
             - name: config-volumes
               configMap:
                 name: config-v1