방법1. 정의 파일로 생성
#정의파일 생성
apiVersion: v1
kind: ConfigMap
metadata:
name: app-config-map
data:
username: admin
password: password1234
#확인
kubectl get configmap app-config-map -o yaml
apiVersion: v1
items:
- apiVersion: v1
data:
password: password1234
username: admin
kind: ConfigMap
.
.
.
방법2. cli에서 생성
#평문으로 생성
kubectl create configmap app-config-map \
--from-literal=username=admin \
--from-literal=password=password1234
#확인
k get configmap -o yaml
apiVersion: v1
items:
- apiVersion: v1
data:
password: password1234
username: admin
kind: ConfigMap
.
.
.
방법3. 파일로부터 생성
#파일을 옵션으로 지정 (파일에는 value에 해당하는 값만 작성)
kubectl create configmap app-config-map \
--from-file=username=username.txt \
--from-file=password=password.txt
#확인
kubectl get configmap app-config-map -o yaml
apiVersion: v1
data:
password: |
password1234
username: |
admin
kind: ConfigMap
metadata:
.
.
.
https://kubernetes.io/docs/reference/kubectl/generated/kubectl_create/kubectl_create_configmap/
kubectl create configmap
Synopsis Create a config map based on a file, directory, or specified literal value. A single config map may package one or more key/value pairs. When creating a config map based on a file, the key will default to the basename of the file, and the value wi
kubernetes.io
'ops > kubernetes' 카테고리의 다른 글
| kubectl명령어 결과에서 헤더 제외하고 출력하기 (0) | 2026.01.07 |
|---|---|
| 리소스 정의파일에서 configmap 사용하기 (0) | 2026.01.07 |
| 리소스 정의파일에서 secret사용하기 (0) | 2026.01.07 |
| secret 생성하기 (0) | 2026.01.07 |
| 실행중인 컨테이너 접속 (0) | 2026.01.02 |