2.7.3.2. 파일에서 구성 맵 생성
파일에서 구성 맵을 생성할 수 있습니다.
절차
다음 예제 절차에서는 파일에서 구성 맵을 생성하는 방법을 간략하게 설명합니다.
파일에서 구성 맵을 생성하는 경우 UTF8이 아닌 데이터를 손상시키지 않고 이 필드에 배치된 UTF8이 아닌 데이터가 포함된 파일을 포함할 수 있습니다. OpenShift Container Platform에서는 바이너리 파일을 감지하고 파일을 MIME
로 투명하게 인코딩합니다. 서버에서 MIME
페이로드는 데이터 손상 없이 디코딩되어 저장됩니다.
--from-file
옵션을 CLI에 여러 번 전달할 수 있습니다. 다음 예제에서는 디렉토리 예제에서 생성되는 것과 동일한 결과를 보여줍니다.
특정 파일을 지정하여 구성 맵을 생성합니다.
$ oc create configmap game-config-2 \ --from-file=example-files/game.properties \ --from-file=example-files/ui.properties
결과 확인:
$ oc get configmaps game-config-2 -o yaml
출력 예
apiVersion: v1 data: game.properties: |- enemies=aliens lives=3 enemies.cheat=true enemies.cheat.level=noGoodRotten secret.code.passphrase=UUDDLRLRBABAS secret.code.allowed=true secret.code.lives=30 ui.properties: | color.good=purple color.bad=yellow allow.textmode=true how.nice.to.look=fairlyNice kind: ConfigMap metadata: creationTimestamp: 2016-02-18T18:52:05Z name: game-config-2 namespace: default resourceVersion: "516" selflink: /api/v1/namespaces/default/configmaps/game-config-2 uid: b4952dc3-d670-11e5-8cd0-68f728db1985
파일에서 가져온 콘텐츠의 구성 맵에 설정할 키를 지정할 수 있습니다. 이는 key=value
표현식을 --from-file
옵션에 전달하여 설정할 수 있습니다. 예를 들면 다음과 같습니다.
키-값 쌍을 지정하여 구성 맵을 생성합니다.
$ oc create configmap game-config-3 \ --from-file=game-special-key=example-files/game.properties
결과 확인:
$ oc get configmaps game-config-3 -o yaml
출력 예
apiVersion: v1 data: game-special-key: |- 1 enemies=aliens lives=3 enemies.cheat=true enemies.cheat.level=noGoodRotten secret.code.passphrase=UUDDLRLRBABAS secret.code.allowed=true secret.code.lives=30 kind: ConfigMap metadata: creationTimestamp: 2016-02-18T18:54:22Z name: game-config-3 namespace: default resourceVersion: "530" selflink: /api/v1/namespaces/default/configmaps/game-config-3 uid: 05f8da22-d671-11e5-8cd0-68f728db1985
- 1
- 이전 단계에서 설정한 키입니다.