This documentation is for a release that is no longer maintained
See documentation for the latest supported version 3 or the latest supported version 4.22.2. ConfigMap 생성
다음 명령을 사용하여 디렉터리, 특정 파일 또는 리터럴 값에서 ConfigMap
을 쉽게 생성할 수 있습니다.
oc create configmap <configmap_name> [options]
$ oc create configmap <configmap_name> [options]
다음 섹션에서는 ConfigMap
을 생성할 수 있는 다양한 방법을 다룹니다.
22.2.1. Directories에서 생성
ConfigMap
을 채우려는 데이터가 이미 포함된 일부 파일이 있는 디렉토리를 고려하십시오.
ls example-files cat example-files/game.properties cat example-files/ui.properties
$ ls example-files
game.properties
ui.properties
$ cat example-files/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
$ cat example-files/ui.properties
color.good=purple
color.bad=yellow
allow.textmode=true
how.nice.to.look=fairlyNice
다음 명령을 사용하여 이 디렉터리의 각 파일의 콘텐츠를 포함하는 ConfigMap
을 생성할 수 있습니다.
oc create configmap game-config \ --from-file=example-files/
$ oc create configmap game-config \
--from-file=example-files/
--from-file
옵션이 디렉토리를 가리키는 경우 해당 디렉터리의 각 파일은 ConfigMap
의 키를 채우는 데 사용됩니다. 여기서 키 이름은 파일 이름이고 키의 값은 파일의 내용입니다.
예를 들어 위의 명령은 다음 ConfigMap
을 생성합니다.
oc describe configmaps game-config
$ oc describe configmaps game-config
Name: game-config
Namespace: default
Labels: <none>
Annotations: <none>
Data
game.properties: 121 bytes
ui.properties: 83 bytes
맵에 있는 두 개의 키는 명령에 지정된 디렉터리의 파일 이름에서 생성되는 것을 확인할 수 있습니다. 해당 키의 콘텐츠가 커질 수 있으므로 oc describe
의 출력은 키와 크기의 이름만 표시합니다.
키 값을 표시하려면 oc에서
수 있습니다.
-o
옵션을 사용하여 오브젝트를 가져올
oc get configmaps game-config -o yaml
$ oc get configmaps game-config -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:34:05Z
name: game-config
namespace: default
resourceVersion: "407"-
selflink: /api/v1/namespaces/default/configmaps/game-config
uid: 30944725-d66e-11e5-8cd0-68f728db1985