k8s
initContainers 사용하기
바리새인
2024. 4. 28. 21:57
spec:
initContainers:
- name: init
image: busybox:latest
command:
- sh
- "-c"
- |
addgroup -g {gid} {group}
adduser -u {uid} {user} -G {group} -D
# 없는 계정:그룹을 지정하면 root:root로 지정됨
# volumeMounts와 연계되서 minikube의 실제 디렉토리에 계정:그룹이 지정됨
chown -R {user}:{group} {directory}
volumeMounts:
- name: data
mountPath: {directory}
containers:
- name: postgres
# init 로그 확인
# 에러가 나더라도 다음으로 진행되는 경우가 있기 때문에 꼭 로그 확인 필요
kubectl logs -f {pod} -n {namespace} -c init
# volumes 확인
minikube ssh
cd {volume directory}