GoogleCloudPlatform / anthos-service-mesh-packages

Packaged configuration for setting up a Kubernetes cluster with Anthos Service Mesh features enabled
https://cloud.google.com/anthos/service-mesh
Apache License 2.0
134 stars 169 forks source link

asmcli install is failing with dependencies error having shell script as error message #1042

Open devil47sid opened 2 years ago

devil47sid commented 2 years ago

Not sure why but asmcli working with my automation script and installing the required ASM however if I try to run the same script manually I am getting below error

asmcli: [WARNING]: Dependency not found: },fi,run_command asmcli: [WARNING]: Dependency not found: ${CMD} asmcli: [WARNING]: Dependency not found: "${@}";,else,HTTPS_PROXY="${HTTPS_PROXY}" asmcli: [WARNING]: Dependency not found: ${CMD} asmcli: [WARNING]: Dependency not found: "${@}";,if asmcli: [WARNING]: Dependency not found: [[ asmcli: [WARNING]: Dependency not found: -n asmcli: [WARNING]: Dependency not found: "${HTTPS_PROXY}" asmcli: [WARNING]: Dependency not found: ]]; asmcli: [WARNING]: Dependency not found: then,fi;,CMD="${CMD} asmcli: [WARNING]: Dependency not found: --context asmcli: [WARNING]: Dependency not found: ${KCC}";,if asmcli: [WARNING]: Dependency not found: [[ asmcli: [WARNING]: Dependency not found: -n asmcli: [WARNING]: Dependency not found: "${KCC}" asmcli: [WARNING]: Dependency not found: ]]; asmcli: [WARNING]: Dependency not found: then,fi;,CMD="${CMD} asmcli: [WARNING]: Dependency not found: --kubeconfig asmcli: [WARNING]: Dependency not found: ${KCF}";,if asmcli: [WARNING]: Dependency not found: [[ asmcli: [WARNING]: Dependency not found: -n asmcli: [WARNING]: Dependency not found: "${KCF}" asmcli: [WARNING]: Dependency not found: ]]; asmcli: [WARNING]: Dependency not found: then,CMD="${AKUBECTL}";,local asmcli: [WARNING]: Dependency not found: CMD;,fi;,KCF="$(mktemp)";,if asmcli: [WARNING]: Dependency not found: [[ asmcli: [WARNING]: Dependency not found: -z asmcli: [WARNING]: Dependency not found: "${KCF}" asmcli: [WARNING]: Dependency not found: ]]; asmcli: [WARNING]: Dependency not found: then,fi;,KCF="${KUBECONFIG}";,if asmcli: [WARNING]: Dependency not found: [[ asmcli: [WARNING]: Dependency not found: -z asmcli: [WARNING]: Dependency not found: "${KCF}" asmcli: [WARNING]: Dependency not found: ]]; asmcli: [WARNING]: Dependency not found: then,HTTPS_PROXY="$(context_get-option asmcli: [WARNING]: Dependency not found: "HTTPS_PROXY")";,KCC="$(context_get-option asmcli: [WARNING]: Dependency not found: "CONTEXT")";,KCF="$(context_get-option asmcli: [WARNING]: Dependency not found: "KUBECONFIG")";,local asmcli: [WARNING]: Dependency not found: KCF asmcli: [WARNING]: Dependency not found: KCC asmcli: [WARNING]: Dependency not found: HTTPS_PROXY;,{,kubectl asmcli: [WARNING]: Dependency not found: (),},run_command asmcli: [WARNING]: Dependency not found: "${AGCLOUD}" asmcli: [WARNING]: Dependency not found: "${@}",{,gcloud asmcli: [WARNING]: Dependency not found: () asmcli: [ERROR]: One or more dependencies were not found. Please install them and retry.

Please note that the same script have completed successfully as start-up script means there should not be any dependencies missing at all

zerobfd commented 2 years ago

Thanks for the report! Generally stuff like this is because of shell/OS incompatibilities. What OS and shell are you running on your local machine?

devil47sid commented 2 years ago

Thanks for your response. I am using Red Hat 8 (rhel-8-v20201216) and Bash

devil47sid commented 2 years ago

I also tried to run it with sh but no luck. I forget to point I am using Compute Engine to run this script, not local VM as all required permission is configured to the VM service account. I only have access to login

zerobfd commented 2 years ago

Hm, it seems to work for me with the same version of bash as RHEL8. Can you share more information about how you're downloading the script and the complete command you run from the CLI?

devil47sid commented 2 years ago

Sure! I am attaching the entire code. Please note I have tried with both bash and sh

@author Siddharth Mishra $id i$ di$

!/bin/sh

CHECKPOINT_FILE=".asm-installation" is_executed="./is_executed.sh $CHECKPOINT_FILE" checkpoint="./checkpoint.sh $CHECKPOINT_FILE" export HOME=/root

cat << "EOF" ,ggg, ,gg, ,ggg, ,ggg,_,ggg, ,a8a,
dP""8I i8""8dP""Y8dP""Y88P""Y8b ,8" "8, I8 ,dPYb,,dPYb, I8
dP 88 8,,8Yb,88' 88'88 d8 8b I8 IP'YbIP'Yb I8
dP 88 88'" 88 88 88 88 88 88888888 I8 8II8 8I 88888888gg
,8' 88 dP"8, 88 88 88 88 88 I8 I8 8'I8 8' I8 ""
d88888888 dP' 8a 88 88 88 Y8 8P ,ggg,,ggg, ,g, I8 ,gggg,gg I8 dP I8 dP ,gggg,gg I8 gg ,ggggg, ,ggg,,ggg, __ ,8" 88 dP'Yb 88 88 88 8, ,8',8" "8P" "8, ,8'8, I8 dP" "Y8I I8dP I8dP dP" "Y8I I8 88 dP" "Y8gg,8" "8P" "8, dP" ,8P Y8 _ ,dP' I8 88 88 88 8888 "8,8" I8 8I 8I ,8' Yb ,I8, i8' ,8I I8P I8P i8' ,8I ,I8, 88 i8' ,8I I8 8I 8I Yb,_,dP8b"888,,___,dP 88 88 Y8, `8b, ,d8b,,dP 8I Yb,8' 8),d88b,d8, ,d8b,d8b,,d8b,,d8, ,d8b,d88b_,88,,d8, ,d8',dP 8I Yb, "Y8P" Ya8P"Y88888P" 88 88Y8 "Y88P" "Y8P' 8I YP' "YY8P88P""YP"Y8888P"Y8P'"Y88P'"Y8P"Y8888P"Y8P""Y8P""YP"Y8888P" 8P' 8IY8 EOF echo -e "\nBy Siddharth Mishra | Enterprise Integrations" cat << "EOF" +-+-+-+ +-+-+ +-+-+-+ |$|i|d| |i|$| |d|i|$| +-+-+-+ +-+-+ +-+-+-+ EOF

if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ] then echo 'Script Usage: ./asm-installation.sh [project_id] [cluster_name] [cluster_location] (O)[asm_download_link] (O)[istio_download_link]' exit 0 fi

if [ -z "$4"] then asm_download_link="https://storage.googleapis.com/csm-artifacts/asm/asmcli_1.11" fi

if [ -z "$5"] then istio_download_link="https://storage.googleapis.com/gke-release/asm/istio-1.11.2-asm.17-linux-amd64.tar.gz" fi

fail() { echo $1 >&2 exit 1 }

retry() { local n=1 local max=5 local delay=15 while true; do "$@" && break || { if [[ $n -lt $max ]]; then ((n++)) echo "Command failed. Attempt $n/$max:" sleep $delay; else fail "The command has failed after $n attempts." fi } done }

init_kube_config(){ gcloud container clusters get-credentials $1 --region $2 --project $3 }

cluster_admin_binding(){ is_cluster_admin_bindings=$($is_executed cluster_admin_binding) if [[ "$is_cluster_admin_bindings" == "false" ]]; then USER_ACCOUNT=$(gcloud config list account --format "value(core.account)" 2> /dev/null) kubectl create clusterrolebinding cluster-admin-binding \ --clusterrole=cluster-admin \ --user=$USER_ACCOUNT if [ $? -eq 0 ]; then $checkpoint cluster_admin_binding else return 1
fi else echo -e "\nSkipping cluster_admin_binding. Remove cluster_admin_binding from $CHECKPOINT_FILE for installation\n" fi
}

download_installation_files(){ is_download_installation_files=$($is_executed download_installation_files) if [[ "$is_download_installation_files" == "false" ]]; then

Download the correct version of the asmcli script

   curl $1 > asmcli
   chmod +x asmcli

   # Download istioctl
   curl -LO $2
   if [ $? -eq 0 ]; then
      $checkpoint download_installation_files
   else
      return 1   
   fi
else
  echo -e "\nSkipping download_installation_files. Remove download_installation_files from $CHECKPOINT_FILE for installation\n"
fi

}

install_istioctl(){ is_install_istioctl=$($is_executed install_istioctl) if [[ "$is_install_istioctl" == "false" ]]; then tar xzf $(ls | grep istio.tar.gz) rm -rf $(ls | grep istio.tar.gz) mv $(ls | grep istio) /usr/local/istio chmod -R +x /usr/local/istio ln -s /usr/local/istio/bin/istioctl /usr/bin/istioctl if [ $? -eq 0 ]; then $checkpoint install_istioctl else return 1
fi else echo -e "\nSkipping install_istioctl. Remove install_istioctl from $CHECKPOINT_FILE for installation\n" fi
}

install_asm(){ is_install_asm=$($is_executed install_asm) if [[ "$is_install_asm" == "false" ]]; then ./asmcli install \ --project_id $1 \ --cluster_name $2 \ --cluster_location $3 \ --enable_gcp_components \ --enable_gcp_apis \ --enable_namespace_creation \ --enable-registration \ --output_dir $4 \ --option legacy-default-ingressgateway \ --custom_overlay gke-gp.yaml if [ $? -eq 0 ]; then $checkpoint install_asm fi else echo -e "\nSkipping install_asm. Remove install_asm from $CHECKPOINT_FILE for installation\n" fi }

istiod_upgrade(){ kubectl apply -f $1/asm/istio/istiod-service.yaml }

touch $CHECKPOINT_FILE echo "Waiting for 10 Seconds before starting ASM installation" sleep 10 asmcli_directory="$(pwd)" retry init_kube_config $2 $3 $1 cluster_admin_binding download_installation_files $asm_download_link $istio_download_link if [ $? -eq 0 ]; then install_istioctl if [ $? -eq 0 ]; then install_asm $1 $2 $3 $asmcli_directory if [ $? -eq 0 ]; then istiod_upgrade $asmcli_directory fi
fi fi

devil47sid commented 2 years ago

Anything on this? is more information required?

zerobfd commented 2 years ago

Sorry, I was out all last week and getting caught up on things today. I'll take a look soon.

zerobfd commented 2 years ago

Can you try changing the #!/bin/sh to #!/bin/bash in your script and see if that works?

devil47sid commented 2 years ago

No luck and I am using latest version of asmcli

image

devil47sid commented 2 years ago

Any updates on this ?

zerobfd commented 2 years ago

Sorry about the delay, just getting back from vacation and catching up.

I happened to run into something similar over the holidays. Can you add unalias -a on line 2 of the asmcli tool? I'm not 100% sure, but it seems that some default configurations sometimes alias things like which to include flags that break assumptions that asmcli makes.

devil47sid commented 2 years ago

No luck! Still having same issues with asmcli

zerobfd commented 2 years ago

I think this might be fixed by #1111

devil47sid commented 2 years ago

Thanks for the update. Just for your knowledge I have tried to execute same script with Red Hat 7 instead of 8 and it worked perfectly.

I will be waiting for new update and I hope this resolves this issue otherwise we will have no option but to downgrade to Red Hat 7 for sometime.

zerobfd commented 2 years ago

https://storage.googleapis.com/csm-artifacts/asm/asmcli_1.12.2-asm.0-config2 should have the fix