UiPath Documentation
automation-suite
2.2510
true
Linux の Automation Suite のインストール ガイド
重要 :
このコンテンツの一部は機械翻訳によって処理されており、完全な翻訳を保証するものではありません。 新しいコンテンツの翻訳は、およそ 1 ~ 2 週間で公開されます。

ローカルの Docker イメージをクラスター内のレジストリにプッシュする方法

提供された bash スクリプトを使用して、ローカルで利用可能な Docker イメージを Automation Suite 高可用性 (HA) クラスター内レジストリ内のすべてのレジストリ ポッドにプッシュします。

このスクリプトを使用して、ローカルで利用可能な Docker イメージを、Automation Suite 高可用性 (HA) クラスター内レジストリ内のすべてのレジストリ ポッドにプッシュします。

注:

クラスター内のレジストリには、HA 環境に複数のレプリカがあります。registry.FQDN 経由で Docker イメージをプッシュしても機能しません。Docker イメージをすべてのレジストリ ポッドにプッシュするには、代わりに次のスクリプトを使用します。

前提条件

プッシュする Docker イメージが、ローカルの Podman ストアの localhost:30071の下に存在している必要があります。

手順

  1. 次のスクリプトをファイルに保存します (例: push-to-registry.sh

    #!/bin/bash
    # Image must already be present in the local Podman store under localhost:30071
    # run command as ./script.sh localhost:30071/myimage:1.0.0
    set -euo pipefail
    [[ $# -lt 1 ]] && { echo "Usage: $0 <image-name>"; exit 1; }
    IMAGE=$1
    DOCKER_REGISTRY_NODEPORT=30071
    function error() {
      echo -e "\e[0;31m[ERROR][$(date +'%Y-%m-%dT%H:%M:%S%z')]:\e[0m $*" >&2
      exit 1
    }
    function info() {
      echo "[INFO] [$(date +'%Y-%m-%dT%H:%M:%S%z')]: $*"
    }
    function warn() {
      echo -e "\e[0;33m[WARN] [$(date +'%Y-%m-%dT%H:%M:%S%z')]:\e[0m $*" >&2
    }
    function get_registry_addresses() {
      local namespace="docker-registry"
      local lh_registry
      local server_node_count
      lh_registry=$(kubectl get deployment -n "${namespace}" docker-registry --ignore-not-found --no-headers | wc -l)
      server_node_count=$(kubectl get nodes -l "node-role.kubernetes.io/master=true" --no-headers | wc -l)
      IFS=" " read -r -a registry_addresses <<< \
        "$(kubectl get pods -n "${namespace}" -o jsonpath="{.items[*].status.podIP}" -l app=docker-registry)"
      if [[ "${lh_registry}" -eq 1 ]]; then
        [[ "${#registry_addresses[@]}" -eq 1 ]] || error "Expected 1 registry pod; found ${#registry_addresses[@]}."
      else
        [[ "${#registry_addresses[@]}" -eq "${server_node_count}" ]] || \
          error "Expected ${server_node_count} registry pods; found ${#registry_addresses[@]}."
      fi
      echo "${registry_addresses[@]}"
    }
    podman image exists "localhost:${DOCKER_REGISTRY_NODEPORT}/${IMAGE}" \
      || error "Image not found locally: localhost:${DOCKER_REGISTRY_NODEPORT}/${IMAGE}"
    IFS=" " read -r -a registry_addresses <<< "$(get_registry_addresses)"
    info "Found ${#registry_addresses[@]} registry pod(s)"
    for ip in "${registry_addresses[@]}"; do
      local_ref="localhost:${DOCKER_REGISTRY_NODEPORT}/${IMAGE}"
      remote_ref="${ip}:5000/${IMAGE}"
      local try=0
      local max_tries=10
      local pushed=false
      info "Tagging ${local_ref} → ${remote_ref}"
      podman tag "${local_ref}" "${remote_ref}"
      podman login "${ip}:5000" --tls-verify=false
      while [[ "${pushed}" == false ]] && (( try < max_tries )); do
        try=$(( try + 1 ))
        info "Pushing ${IMAGE} → ${ip}:5000 (attempt ${try}/${max_tries})"
        if podman push "${remote_ref}" --tls-verify=false; then
          pushed=true
        else
          warn "Push failed — retrying in 60s"
          sleep 60
        fi
      done
      [[ "${pushed}" == true ]] || error "Failed to push ${IMAGE} to ${ip}:5000 after ${max_tries} attempts"
    done
    info "Done — ${IMAGE} pushed to all registry pods"
    #!/bin/bash
    # Image must already be present in the local Podman store under localhost:30071
    # run command as ./script.sh localhost:30071/myimage:1.0.0
    set -euo pipefail
    [[ $# -lt 1 ]] && { echo "Usage: $0 <image-name>"; exit 1; }
    IMAGE=$1
    DOCKER_REGISTRY_NODEPORT=30071
    function error() {
      echo -e "\e[0;31m[ERROR][$(date +'%Y-%m-%dT%H:%M:%S%z')]:\e[0m $*" >&2
      exit 1
    }
    function info() {
      echo "[INFO] [$(date +'%Y-%m-%dT%H:%M:%S%z')]: $*"
    }
    function warn() {
      echo -e "\e[0;33m[WARN] [$(date +'%Y-%m-%dT%H:%M:%S%z')]:\e[0m $*" >&2
    }
    function get_registry_addresses() {
      local namespace="docker-registry"
      local lh_registry
      local server_node_count
      lh_registry=$(kubectl get deployment -n "${namespace}" docker-registry --ignore-not-found --no-headers | wc -l)
      server_node_count=$(kubectl get nodes -l "node-role.kubernetes.io/master=true" --no-headers | wc -l)
      IFS=" " read -r -a registry_addresses <<< \
        "$(kubectl get pods -n "${namespace}" -o jsonpath="{.items[*].status.podIP}" -l app=docker-registry)"
      if [[ "${lh_registry}" -eq 1 ]]; then
        [[ "${#registry_addresses[@]}" -eq 1 ]] || error "Expected 1 registry pod; found ${#registry_addresses[@]}."
      else
        [[ "${#registry_addresses[@]}" -eq "${server_node_count}" ]] || \
          error "Expected ${server_node_count} registry pods; found ${#registry_addresses[@]}."
      fi
      echo "${registry_addresses[@]}"
    }
    podman image exists "localhost:${DOCKER_REGISTRY_NODEPORT}/${IMAGE}" \
      || error "Image not found locally: localhost:${DOCKER_REGISTRY_NODEPORT}/${IMAGE}"
    IFS=" " read -r -a registry_addresses <<< "$(get_registry_addresses)"
    info "Found ${#registry_addresses[@]} registry pod(s)"
    for ip in "${registry_addresses[@]}"; do
      local_ref="localhost:${DOCKER_REGISTRY_NODEPORT}/${IMAGE}"
      remote_ref="${ip}:5000/${IMAGE}"
      local try=0
      local max_tries=10
      local pushed=false
      info "Tagging ${local_ref} → ${remote_ref}"
      podman tag "${local_ref}" "${remote_ref}"
      podman login "${ip}:5000" --tls-verify=false
      while [[ "${pushed}" == false ]] && (( try < max_tries )); do
        try=$(( try + 1 ))
        info "Pushing ${IMAGE} → ${ip}:5000 (attempt ${try}/${max_tries})"
        if podman push "${remote_ref}" --tls-verify=false; then
          pushed=true
        else
          warn "Push failed — retrying in 60s"
          sleep 60
        fi
      done
      [[ "${pushed}" == true ]] || error "Failed to push ${IMAGE} to ${ip}:5000 after ${max_tries} attempts"
    done
    info "Done — ${IMAGE} pushed to all registry pods"
    
  2. スクリプトを実行可能にします。

    chmod +x push-to-registry.sh
    chmod +x push-to-registry.sh
    
  3. イメージ名を引数として渡してスクリプトを実行します。

    ./push-to-registry.sh localhost:30071/<image-name>:<tag>
    ./push-to-registry.sh localhost:30071/<image-name>:<tag>
    

結果の

スクリプトが正常に完了すると、次のようなメッセージが出力されます。

[INFO] [2024-01-01T00:00:00+0000]: Done — localhost:30071/myimage:1.0.0 pushed to all registry pods
[INFO] [2024-01-01T00:00:00+0000]: Done — localhost:30071/myimage:1.0.0 pushed to all registry pods
  • 前提条件
  • 手順
  • 結果

このページは役に立ちましたか?

接続

ヘルプ リソース サポート

学習する UiPath アカデミー

質問する UiPath フォーラム

最新情報を取得