UiPath Documentation
automation-suite
2.2510
true
Guía de instalación de Automation Suite en Linux
Importante :
Este contenido se ha localizado parcialmente a partir de un sistema de traducción automática. La localización de contenidos recién publicados puede tardar entre una y dos semanas en estar disponible.

Cómo enviar una imagen de Docker local al registro en el clúster

Inserte una imagen de Docker disponible localmente en todos los pods de registro en un registro en clúster de Automation Suite High Availability (HA) utilizando un script bash proporcionado.

Utiliza este script para enviar una imagen de Docker disponible localmente a todos los pods de registro en un registro en clúster de Automation Suite High Availability (HA).

Nota:

El registro en clúster tiene varias réplicas en entornos de alta disponibilidad. Enviar una imagen de Docker a través de registry.FQDN no funciona. Para insertar una imagen de Docker en todos los pods de registro, utiliza el siguiente script en su lugar.

Requisitos previos

La imagen de Docker que deseas enviar debe estar presente en el almacén local de Podman en localhost:30071.

Pasos

  1. Guarda el siguiente script en un archivo, por ejemplo 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. Haz que el script sea ejecutable:

    chmod +x push-to-registry.sh
    chmod +x push-to-registry.sh
    
  3. Ejecuta el script, pasando el nombre de tu imagen como argumento:

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

Resultado

Cuando el script se completa correctamente, muestra un mensaje similar al siguiente:

[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
  • Requisitos previos
  • Pasos
  • Resultado

¿Te ha resultado útil esta página?

Conectar

¿Necesita ayuda? Soporte

¿Quiere aprender? UiPath Academy

¿Tiene alguna pregunta? Foro de UiPath

Manténgase actualizado