하나의 파일을 포드에 공유 / 마운트하는 가장 좋은 방법은 무엇입니까?
비밀을 사용하여 단일 파일을 마운트하려고했지만 다른 모든 콘텐츠를 덮어 쓰는 디렉토리 만 마운트 할 수있는 것 같습니다. 디렉토리를 마운트하지 않고 단일 구성 파일을 공유하려면 어떻게해야합니까?
예를 들어 2 개의 구성 파일이 포함 된 구성 맵이 있습니다.
kubectl create configmap config --from-file <file1> --from-file <file2>
다음과 같은 subPath를 사용하여 단일 파일을 기존 디렉토리에 마운트 할 수 있습니다.
---
volumeMounts:
- name: "config"
mountPath: "/<existing folder>/<file1>"
subPath: "<file1>"
- name: "config"
mountPath: "/<existing folder>/<file2>"
subPath: "<file2>"
restartPolicy: Always
volumes:
- name: "config"
configMap:
name: "config"
---
여기에 전체 예
이 작업 예제부터 시작 하겠습니다 . Kubernetes 1.3 이상을 사용하고 있는지 확인하십시오.
다음과 같이 ConfigMap을 생성하기 만하면됩니다.
apiVersion: v1
kind: ConfigMap
metadata:
name: test-pd-plus-cfgmap
data:
file-from-cfgmap: file data
그런 다음 다음과 같이 포드를 만듭니다.
apiVersion: v1
kind: Pod
metadata:
name: test-pd-plus-cfgmap
spec:
containers:
- image: ubuntu
name: bash
stdin: true
stdinOnce: true
tty: true
volumeMounts:
- mountPath: /mnt
name: pd
- mountPath: /mnt/file-from-cfgmap
name: cfgmap
subPath: file-from-cfgmap
volumes:
- name: pd
gcePersistentDisk:
pdName: testdisk
- name: cfgmap
configMap:
name: test-pd-plus-cfgmap
현재 (v1.0, v1.1) 단일 구성 파일을 볼륨 마운트하는 방법이 없습니다. 비밀 구조는 자연스럽게 여러 비밀을 나타낼 수 있습니다. 즉, 디렉터리 여야합니다.
When we get config objects, single files should be supported.
In the mean time you can mount a directory and symlink to it from your image, maybe?
Do use secrets. This is considered to be a best practice. If you're unsure how to use them, have a look at what I did here.
참고URL : https://stackoverflow.com/questions/33415913/whats-the-best-way-to-share-mount-one-file-into-a-pod
'Programing' 카테고리의 다른 글
mongodb의 저널 파일을 삭제해도 안전합니까? (0) | 2020.11.20 |
---|---|
컴파일러 오류가없는 여러 반환 문 (0) | 2020.11.20 |
MySQL 변경 테이블 추가 필드 이전 또는 이후 필드가 이미 존재 (0) | 2020.11.20 |
문자열로 구성된 벡터 배열 초기화 (0) | 2020.11.20 |
EditText에서 Enter 키를 방지하지만 텍스트는 여러 줄로 표시됩니다. (0) | 2020.11.20 |