open-horizon / anax

Horizon agent control system
https://open-horizon.github.io/docs/anax/docs/
Apache License 2.0
73 stars 98 forks source link

Feature Request: Let agent-install.sh automatically substitute in the cluster architecture if IMAGE_ON_EDGE_CLUSTER_REGISTRY is specified #4126

Open dlarson04 opened 2 months ago

dlarson04 commented 2 months ago

Is your feature request related to a problem? Please describe.

Currently a user sets

IMAGE_ON_EDGE_CLUSTER_REGISTRY=icr.io/my-repo/amd64_anax_k8s

before running agent-install.sh for a cluster.. But if the target cluster is not amd64, this part of agent-install.sh won't work

        # REMOTE_IMAGE_REGISTRY_PATH is parts before /{arch}_anax_k8s, for example if using quay.io, this value will be quay.io/<username>
        local image_arch=$(get_cluster_image_arch)
        REMOTE_IMAGE_REGISTRY_PATH="${IMAGE_ON_EDGE_CLUSTER_REGISTRY%%/${image_arch}*}"
        log_info "REMOTE_IMAGE_REGISTRY_PATH: $REMOTE_IMAGE_REGISTRY_PATH"
        sed -i -e "s#__ImagePath__#${IMAGE_FULL_PATH_ON_EDGE_CLUSTER_REGISTRY}#g" deployment.yml
        sed -i -e "s#__ImageRegistryHost__#${REMOTE_IMAGE_REGISTRY_PATH}#g" deployment.yml

agent-install.sh should intelligently build the path with the correct cluster architecture

Describe the solution you'd like.

No response

Describe alternatives you've considered

No response

Additional context.

No response

dlarson04 commented 2 months ago

We do some validation now but we can change this

            # need to validate image arch in IMAGE_ON_EDGE_CLUSTER_REGISTRY
            if [[ -z $IMAGE_ON_EDGE_CLUSTER_REGISTRY ]]; then
                log_fatal 1 "A value for \$IMAGE_ON_EDGE_CLUSTER_REGISTRY must be specified"
            fi
            lastpart=$(echo $IMAGE_ON_EDGE_CLUSTER_REGISTRY | cut -d "/" -f 3) # <arch>_anax_k8s
            image_arch_in_param=$(echo $lastpart | cut -d "_" -f 1)
            if [[ "$image_arch" != "$image_arch_in_param" ]]; then
                log_fatal 1 "Cannot use agent image with $image_arch_in_param arch to install on $image_arch cluster, please use agent image with '$image_arch'"
            fi