3.6.4. 입력 보안 및 구성 맵 추가

일부 시나리오에서는 빌드 작업을 수행하려면 종속 리소스에 액세스하기 위해 자격 증명 또는 기타 구성 데이터가 필요합니다. 그러나 이러한 정보가 소스 제어에 배치되는 것은 바람직하지 않습니다. 이러한 용도를 위해 입력 보안 및 입력 구성 맵을 정의할 수 있습니다.

프로세스

입력 보안이나 구성 맵 또는 둘 다를 기존 BuildConfig 오브젝트에 추가하려면 다음을 수행합니다.

  1. ConfigMap 오브젝트가 없는 경우 해당 오브젝트를 생성합니다.

    $ oc create configmap settings-mvn \
        --from-file=settings.xml=<path/to/settings.xml>

    그러면 settings-mvn이라는 새 구성 맵이 생성됩니다. 이 맵에는 settings.xml 파일의 일반 텍스트 내용이 포함됩니다.

  2. Secret 오브젝트가 없는 경우 해당 오브젝트를 생성합니다.

    $ oc create secret generic secret-mvn \
        --from-file=id_rsa=<path/to/.ssh/id_rsa>

    그러면 secret-mvn이라는 새 보안이 생성됩니다. 이 보안에는 id_rsa 개인 키의 base64 인코딩 콘텐츠가 포함됩니다.

  3. 다음과 같이 기존 BuildConfig 오브젝트의 source 섹션에 구성 맵과 보안을 추가합니다.

    source:
      git:
        uri: https://github.com/wildfly/quickstart.git
      contextDir: helloworld
      configMaps:
        - configMap:
            name: settings-mvn
      secrets:
        - secret:
            name: secret-mvn

BuildConfig 오브젝트에 구성 맵과 보안을 포함하려면 다음 명령을 실행합니다.

$ oc new-build \
    openshift/wildfly-101-centos7~https://github.com/wildfly/quickstart.git \
    --context-dir helloworld --build-secret “secret-mvn” \
    --build-config-map "settings-mvn"

빌드 중 settings.xmlid_rsa 파일이 소스 코드가 있는 디렉터리로 복사됩니다. OpenShift Container Platform S2I 빌더 이미지의 경우 이 디렉터리는 DockerfileWORKDIR 명령을 사용하여 설정하는 이미지 작업 디렉터리입니다. 다른 디렉터리를 지정하려면 정의에 destinationDir을 추가합니다.

source:
  git:
    uri: https://github.com/wildfly/quickstart.git
  contextDir: helloworld
  configMaps:
    - configMap:
        name: settings-mvn
      destinationDir: ".m2"
  secrets:
    - secret:
        name: secret-mvn
      destinationDir: ".ssh"

BuildConfig 오브젝트를 생성할 때 대상 디렉터리를 지정할 수도 있습니다.

$ oc new-build \
    openshift/wildfly-101-centos7~https://github.com/wildfly/quickstart.git \
    --context-dir helloworld --build-secret “secret-mvn:.ssh” \
    --build-config-map "settings-mvn:.m2"

두 경우 모두 settings.xml 파일은 빌드 환경의 ./.m2 디렉터리에 추가되고 id_rsa 키는 ./.ssh 디렉터리에 추가됩니다.