6.2. 制限された環境でのアーティファクトリーポジトリーの有効化

テクノロジースタックを設定することで、自己署名証明書を使用して、インハウスリポジトリーからアーティファクトを扱うことができます。

6.2.1. Maven

制限された環境で実行される Maven ワークスペースで Maven アーティファクトリーポジトリを有効にできます。

前提条件

  • Maven ワークスペースを実行していない。
  • ユーザー名前空間は <username> -devspaces であり、<username> は OpenShift Dev Spaces ユーザー名です。

手順

  1. <username> -devspaces 名前空間で、TLS 証明書のシークレットを適用します。

    kind: Secret
    apiVersion: v1
    metadata:
      name: tls-cer
      annotations:
        controller.devfile.io/mount-path: /home/user/certs
        controller.devfile.io/mount-as: file
      labels:
        controller.devfile.io/mount-to-devworkspace: 'true'
        controller.devfile.io/watch-secret: 'true'
    data:
      tls.cer: >-
        <Base64_encoded_content_of_public_cert> 1
    1
    行の折り返しが無効になっている Base64 エンコーディング。
  2. <username> -devspaces 名前空間で、ConfigMap を適用して settings.xml ファイルを作成します。

    kind: ConfigMap
    apiVersion: v1
    metadata:
      name: settings-xml
      annotations:
        controller.devfile.io/mount-as: subpath
        controller.devfile.io/mount-path: /home/user/.m2
      labels:
        controller.devfile.io/mount-to-devworkspace: 'true'
        controller.devfile.io/watch-configmap: 'true'
    data:
      settings.xml: |
        <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
          <localRepository/>
          <interactiveMode/>
          <offline/>
          <pluginGroups/>
          <servers/>
          <mirrors>
            <mirror>
              <id>redhat-ga-mirror</id>
              <name>Red Hat GA</name>
              <url>https://<maven_artifact_repository_route>/repository/redhat-ga/</url>
              <mirrorOf>redhat-ga</mirrorOf>
            </mirror>
            <mirror>
              <id>maven-central-mirror</id>
              <name>Maven Central</name>
              <url>https://<maven_artifact_repository_route>/repository/maven-central/</url>
              <mirrorOf>maven-central</mirrorOf>
            </mirror>
            <mirror>
              <id>jboss-public-repository-mirror</id>
              <name>JBoss Public Maven Repository</name>
              <url>https://<maven_artifact_repository_route>/repository/jboss-public/</url>
              <mirrorOf>jboss-public-repository</mirrorOf>
            </mirror>
          </mirrors>
          <proxies/>
          <profiles/>
          <activeProfiles/>
        </settings>
  3. オプション: EAP ベースの devfile を使用する場合は、2 つ目 の settings-xml ConfigMap を <username> -devspaces 名前空間に、同じ内容、別の名前、および /home/jboss/.m2 マウントパスで適用します。
  4. <username> -devspaces 名前空間で、TrustStore 初期化スクリプトの ConfigMap を適用します。

    Java 8

    kind: ConfigMap
    apiVersion: v1
    metadata:
      name: init-truststore
      annotations:
        controller.devfile.io/mount-as: subpath
        controller.devfile.io/mount-path: /home/user/
      labels:
        controller.devfile.io/mount-to-devworkspace: 'true'
        controller.devfile.io/watch-configmap: 'true'
    data:
      init-java8-truststore.sh: |
        #!/usr/bin/env bash
    
        keytool -importcert -noprompt -file /home/user/certs/tls.cer -trustcacerts -keystore ~/.java/current/jre/lib/security/cacerts -storepass changeit

    Java 11

    kind: ConfigMap
    apiVersion: v1
    metadata:
      name: init-truststore
      annotations:
        controller.devfile.io/mount-as: subpath
        controller.devfile.io/mount-path: /home/user/
      labels:
        controller.devfile.io/mount-to-devworkspace: 'true'
        controller.devfile.io/watch-configmap: 'true'
    data:
      init-java11-truststore.sh: |
        #!/usr/bin/env bash
    
        keytool -importcert -noprompt -file /home/user/certs/tls.cer -cacerts -storepass changeit

  5. Maven ワークスペースを開始します。
  6. tools コンテナーで新しいターミナルを開きます。
  7. ~/init-truststore.sh を実行します。

6.2.2. Gradle

制限された環境で実行される Gradle ワークスペースで Gradle アーティファクトリーポジトリを有効にできます。

前提条件

  • Gradle ワークスペースを実行していない。

手順

  1. TLS 証明書のシークレットを適用します。

    kind: Secret
    apiVersion: v1
    metadata:
      name: tls-cer
      annotations:
        controller.devfile.io/mount-path: /home/user/certs
        controller.devfile.io/mount-as: file
      labels:
        controller.devfile.io/mount-to-devworkspace: 'true'
        controller.devfile.io/watch-secret: 'true'
    data:
      tls.cer: >-
        <Base64_encoded_content_of_public_cert> 1
    1
    行の折り返しが無効になっている Base64 エンコーディング。
  2. TrustStore 初期化スクリプトに ConfigMap を適用します。

    kind: ConfigMap
    apiVersion: v1
    metadata:
      name: init-truststore
      annotations:
        controller.devfile.io/mount-as: subpath
        controller.devfile.io/mount-path: /home/user/
      labels:
        controller.devfile.io/mount-to-devworkspace: 'true'
        controller.devfile.io/watch-configmap: 'true'
    data:
      init-truststore.sh: |
        #!/usr/bin/env bash
    
        keytool -importcert -noprompt -file /home/user/certs/tls.cer -cacerts -storepass changeit
  3. Gradleinit スクリプトに ConfigMap を適用します。

    kind: ConfigMap
    apiVersion: v1
    metadata:
      name: init-gradle
      annotations:
        controller.devfile.io/mount-as: subpath
        controller.devfile.io/mount-path: /home/user/.gradle
      labels:
        controller.devfile.io/mount-to-devworkspace: 'true'
        controller.devfile.io/watch-configmap: 'true'
    data:
      init.gradle: |
        allprojects {
          repositories {
            mavenLocal ()
            maven {
              url "https://<gradle_artifact_repository_route>/repository/maven-public/"
              credentials {
                username "admin"
                password "passwd"
              }
            }
          }
        }
  4. Gradle ワークスペースを開始します。
  5. tools コンテナーで新しいターミナルを開きます。
  6. ~/init-truststore.sh を実行します。

6.2.3. npm

制限された環境で実行される npm ワークスペースで npm アーティファクトリーポジトリを有効にできます。

前提条件

  • npm ワークスペースを実行していない。
警告

環境変数を設定する ConfigMap を適用すると、ワークスペースのブートループが発生する可能性があります。

この動作が発生した場合は、ConfigMap を削除し、devfile を直接編集してください。

手順

  1. TLS 証明書のシークレットを適用します。

    kind: Secret
    apiVersion: v1
    metadata:
      name: tls-cer
      annotations:
        controller.devfile.io/mount-path: /home/user/certs
        controller.devfile.io/mount-as: file
      labels:
        controller.devfile.io/mount-to-devworkspace: 'true'
        controller.devfile.io/watch-secret: 'true'
    data:
      tls.cer: >-
        <Base64_encoded_content_of_public_cert> 1
    1
    行の折り返しが無効になっている Base64 エンコーディング。
  2. ConfigMap を適用して、tools コンテナーに次の環境変数を設定します。

    kind: ConfigMap
    apiVersion: v1
    metadata:
      name: disconnected-env
      annotations:
        controller.devfile.io/mount-as: env
      labels:
        controller.devfile.io/mount-to-devworkspace: 'true'
        controller.devfile.io/watch-configmap: 'true'
    data:
      NODE_EXTRA_CA_CERTS: /home/user/certs/tls.cer
      NPM_CONFIG_REGISTRY: >-
        https://<npm_artifact_repository_route>/repository/npm-all/

6.2.4. Python

制限された環境で実行される Python ワークスペースで Python アーティファクトリーポジトリを有効にできます。

前提条件

  • Python ワークスペースを実行していない。
警告

環境変数を設定する ConfigMap を適用すると、ワークスペースのブートループが発生する可能性があります。

この動作が発生した場合は、ConfigMap を削除し、devfile を直接編集してください。

手順

  1. TLS 証明書のシークレットを適用します。

    kind: Secret
    apiVersion: v1
    metadata:
      name: tls-cer
      annotations:
        controller.devfile.io/mount-path: /home/user/certs
        controller.devfile.io/mount-as: file
      labels:
        controller.devfile.io/mount-to-devworkspace: 'true'
        controller.devfile.io/watch-secret: 'true'
    data:
      tls.cer: >-
        <Base64_encoded_content_of_public_cert> 1
    1
    行の折り返しが無効になっている Base64 エンコーディング。
  2. ConfigMap を適用して、tools コンテナーに次の環境変数を設定します。

    kind: ConfigMap
    apiVersion: v1
    metadata:
      name: disconnected-env
      annotations:
        controller.devfile.io/mount-as: env
      labels:
        controller.devfile.io/mount-to-devworkspace: 'true'
        controller.devfile.io/watch-configmap: 'true'
    data:
      PIP_INDEX_URL: >-
        https://<python_artifact_repository_route>/repository/pypi-all/
      PIP_CERT: /home/user/certs/tls.cer

6.2.5. Go

制限された環境で実行される Go ワークスペースで Go アーティファクトリーポジトリを有効にできます。

前提条件

  • Go ワークスペースを実行していない。
警告

環境変数を設定する ConfigMap を適用すると、ワークスペースのブートループが発生する可能性があります。

この動作が発生した場合は、ConfigMap を削除し、devfile を直接編集してください。

手順

  1. TLS 証明書のシークレットを適用します。

    kind: Secret
    apiVersion: v1
    metadata:
      name: tls-cer
      annotations:
        controller.devfile.io/mount-path: /home/user/certs
        controller.devfile.io/mount-as: file
      labels:
        controller.devfile.io/mount-to-devworkspace: 'true'
        controller.devfile.io/watch-secret: 'true'
    data:
      tls.cer: >-
        <Base64_encoded_content_of_public_cert> 1
    1
    行の折り返しが無効になっている Base64 エンコーディング。
  2. ConfigMap を適用して、tools コンテナーに次の環境変数を設定します。

    kind: ConfigMap
    apiVersion: v1
    metadata:
      name: disconnected-env
      annotations:
        controller.devfile.io/mount-as: env
      labels:
        controller.devfile.io/mount-to-devworkspace: 'true'
        controller.devfile.io/watch-configmap: 'true'
    data:
      GOPROXY: >-
        http://<athens_proxy_route>
      SSL_CERT_FILE: /home/user/certs/tls.cer

6.2.6. NuGet

制限された環境で実行される NuGet ワークスペースで NuGet アーティファクトリーポジトリを有効にできます。

前提条件

  • NuGet ワークスペースを実行していない。
警告

環境変数を設定する ConfigMap を適用すると、ワークスペースのブートループが発生する可能性があります。

この動作が発生した場合は、ConfigMap を削除し、devfile を直接編集してください。

手順

  1. TLS 証明書のシークレットを適用します。

    kind: Secret
    apiVersion: v1
    metadata:
      name: tls-cer
      annotations:
        controller.devfile.io/mount-path: /home/user/certs
        controller.devfile.io/mount-as: file
      labels:
        controller.devfile.io/mount-to-devworkspace: 'true'
        controller.devfile.io/watch-secret: 'true'
    data:
      tls.cer: >-
        <Base64_encoded_content_of_public_cert> 1
    1
    行の折り返しが無効になっている Base64 エンコーディング。
  2. ConfigMap を適用して、tools コンテナー内の TLS 証明書ファイルのパスの環境変数を設定します。

    kind: ConfigMap
    apiVersion: v1
    metadata:
      name: disconnected-env
      annotations:
        controller.devfile.io/mount-as: env
      labels:
        controller.devfile.io/mount-to-devworkspace: 'true'
        controller.devfile.io/watch-configmap: 'true'
    data:
      SSL_CERT_FILE: /home/user/certs/tls.cer
  3. ConfigMap を適用して、nuget.config ファイルを作成します。

    kind: ConfigMap
    apiVersion: v1
    metadata:
      name: init-nuget
      annotations:
        controller.devfile.io/mount-as: subpath
        controller.devfile.io/mount-path: /projects
      labels:
        controller.devfile.io/mount-to-devworkspace: 'true'
        controller.devfile.io/watch-configmap: 'true'
    data:
      nuget.config: |
        <?xml version="1.0" encoding="UTF-8"?>
        <configuration>
          <packageSources>
            <add key="nexus2" value="https://<nuget_artifact_repository_route>/repository/nuget-group/"/>
          </packageSources>
          <packageSourceCredentials>
            <nexus2>
                <add key="Username" value="admin" />
                <add key="Password" value="passwd" />
            </nexus2>
          </packageSourceCredentials>
        </configuration>