UiPath Documentation
automation-suite
2.2510
true
Automation Suite unter Linux – Installationsanleitung
Wichtig :
Bitte beachten Sie, dass dieser Inhalt teilweise mithilfe von maschineller Übersetzung lokalisiert wurde. Es kann 1–2 Wochen dauern, bis die Lokalisierung neu veröffentlichter Inhalte verfügbar ist.

So pushen Sie ein lokales Docker-Image in die Registrierung innerhalb des Clusters

Pushen Sie ein lokal verfügbares Docker-Image mithilfe eines bereitgestellten Bash-Skripts an alle Registrierungspods in einer Automation Suite High Availability (HA)-in-Cluster-Registrierung.

Verwenden Sie dieses Skript, um ein lokal verfügbares Docker-Image per Push an alle Registrierungspods in einer Automation Suite High Availability (HA)-Cluster-Registrierung zu pushen.

Hinweis:

Die clusterinterne Registrierung hat mehrere Replikate in HA-Umgebungen. Das Pushen eines Docker-Images über registry.FQDN funktioniert nicht. Um ein Docker-Image in alle Registrierungspods zu pushen, verwenden Sie stattdessen das folgende Skript.

Voraussetzungen

Das Docker-Image, das Sie pushen möchten, muss im lokalen Podman-Speicher unter localhost:30071 vorhanden sein.

Schritte

  1. Speichern Sie das folgende Skript in einer Datei, z. B. 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. Machen Sie das Skript ausführbar:

    chmod +x push-to-registry.sh
    chmod +x push-to-registry.sh
    
  3. Führen Sie das Skript aus und übergeben Sie Ihren Image-Namen als Argument:

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

Ergebnis

Wenn das Skript erfolgreich abgeschlossen wird, gibt es eine Meldung ähnlich der folgenden aus:

[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
  • Voraussetzungen
  • Schritte
  • Ergebnis

War diese Seite hilfreich?

Verbinden

Benötigen Sie Hilfe? Support

Möchten Sie lernen? UiPath Academy

Haben Sie Fragen? UiPath-Forum

Auf dem neuesten Stand bleiben