
초보를 위한 쿠버네티스 안내서를 수강하며 정리한 내용입니다.
global:
scrape_interval: 15s
scrape_configs:
- job_name: prometheus
metrics_path: /prometheus/metrics
static_configs:
- targets:
- localhost: 9090
--from-file 옵션을 사용하여 파일을 설정으로 만듦# ConfigMap 생성 configmap -> cm
kubectl create cm my-config --from-file=config-file.yaml
# ConfigMap 조회
kubectl get cm
# ConfigMap 내용 상세 조회
kubectl describe cm/my-config
/etc/config 디렉터리에 연결apiVersion: v1
kind: Pod
metadata:
name: alpine
spec:
containers:
- name: alpine
image: alpine
command: ["sleep"]
args: ["10000"]
volumeMounts:
- name: config-vol
mountPath: /etc/config
volumes:
- name: config-vol
configMap:
name: my-config
hello=world
haha=hoho
--from-env-file 옵션을 사용하여 파일을 설정으로 만듦# env 형식으로 생성
kubectl create cm env-config --from-env-file=config-env.yaml
# env-config 조회
kubectl describe cm/env-config
apiVersion: v1
kind: ConfigMap
metadata:
name: my-config
data:
hello: world
kuber: netes
multiline: |-
first
second
thrid
# configmap 생성
kubectl apply -f config-map.yaml
apiVersion: v1
kind: Pod
metadata:
name: alpine-env
spec:
containers:
- name: alpine
image: alpine
command: ["sleep"]
args: ["10000"]
env:
- name: hello
valueFrom:
configMapKeyRef:
name: my-config
key: hello