openshift cli sample
configmap 생성
configmap을 파일 형태로 마운트 할 경우 등록된 key 이름이 파일명으로 마운트 됨
bash-3.2$ ls -alh
total 8
drwxr-xr-x 3 seoungwon wheel 96B 9 4 00:40 .
drwxr-xr-x 14 seoungwon wheel 448B 9 4 00:40 ..
-rw-r--r-- 1 seoungwon wheel 43B 9 4 00:40 test-application.yml
### 파일명을 키로 해서 파일이 등록됨
bash-3.2$ oc create cm test-app-yaml --from-file=./test-application.yml
### 파일명을 변경해서 마운트 할 경우는 key 까지 설정해서 생성함.
### test-application.yml 파일을 application.yml 파일명으로 사용
bash-3.2$ oc create cm test-app-yaml --from-file=application.yml=./test-application.yml
### /tmp/src/src/main/resources 하위에 test-application.yml이 application.yml 파일명으로 마운트됨
bash-3.2$ oc set volumes dc/sample-app \
> --add \
> --overwrite \
> --name=app-yaml \
> --configmap-name=test-app-yaml \
> --mount-path='/tmp/src/src/main/resources'
deploymentconfig.apps.openshift.io/sample-app volume updated
# definitions.json 파일을 rabbitmq-definitions-json 이름으로 configmap 생성
$ oc create configmap rabbitmq-definitions-json --from-file=./definitions.json
# rabbitmq-definitions-json명의 configmap을 /etc/rabbitmq/definitions.json 로 볼륨 마운트
$ oc set volumes statefulsets rabbitmq \
--add \
--name=rabbitmq-definitions-json \
--configmap-name=rabbitmq-definitions-json \
--mount-path='/etc/rabbitmq/definitions.json' \
--sub-path=definitions.json