UiPath Documentation
automation-suite
2.2510
true
Guia de instalação do Automation Suite no Linux
Importante :
A tradução automática foi aplicada parcialmente neste conteúdo. A localização de um conteúdo recém-publicado pode levar de 1 a 2 semanas para ficar disponível.

Como enviar uma imagem do Docker local para o registro no cluster

Envie uma imagem do Docker disponível localmente para todos os pods de registro em um registro no cluster de Alta Disponibilidade (HA) do Automation Suite usando um script bash fornecido.

Use esse script para enviar uma imagem do Docker disponível localmente para todos os pods de registro em um registro no cluster de Alta Disponibilidade (HA) do Automation Suite.

Observação:

O registro no cluster tem várias réplicas em ambientes de alta disponibilidade. Enviar uma imagem do Docker por meio de registry.FQDN não funciona. Para enviar uma imagem do Docker para todos os pods de registro, use o script a seguir.

Pré-requisitos

A imagem do Docker que você deseja enviar deve estar presente no armazenamento local do Podman localhost:30071.

Etapas

  1. Salve o seguinte script em um arquivo, por 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. Torne o script executável:

    chmod +x push-to-registry.sh
    chmod +x push-to-registry.sh
    
  3. Execute o script, passando o nome de sua imagem como um argumento:

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

Resultado

Quando o script é concluído com sucesso, ele gera uma mensagem semelhante à seguinte:

[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
  • Pré-requisitos
  • Etapas
  • Resultado

Esta página foi útil?

Conectar

Precisa de ajuda? Suporte

Quer aprender? Academia UiPath

Tem perguntas? Fórum do UiPath

Fique por dentro das novidades