From 1daf7803013234ff8de69a8c6e733b4280cd485a Mon Sep 17 00:00:00 2001 From: NikitaSkrynnik Date: Tue, 20 Aug 2024 10:47:34 +1100 Subject: [PATCH 1/9] use NSM_KUBERNETES_VERSION variable to specify k8s version for clusters Signed-off-by: NikitaSkrynnik --- .github/workflows/ci.yaml | 15 +++++++++++++++ scripts/aks/aks-start.sh | 1 + scripts/aws/aws-start.sh | 4 ++-- scripts/gke/gke-start.sh | 17 ++++++++++++++++- 4 files changed, 34 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6df72c9..b93a916 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -67,6 +67,15 @@ jobs: - name: Setup gke run: | + NSM_KUBERNETES_VERSION=$(echo ${{ vars.NSM_KUBERNETES_VERSION }} | cut -d '.' -f 1,2 | cut -c 2-) + GKE_CLUSTER_VERSION=$(gcloud container get-server-config --zone="$GKE_CLUSTER_ZONE" --format=json \ + | jq '.channels[] | select (.channel=="REGULAR") | .validVersions[]' \ + | grep -m 1 "$NSM_KUBERNETES_VERSION" | tr -d '"') + if [ -z "$GKE_CLUSTER_VERSION"]; then + echo "GKE cluster version is not valid: $GKE_CLUSTER_VERSION" + exit 1 + fi + scripts/gke/gke-start.sh env: GCLOUD_SERVICE_KEY: ${{ secrets.GCLOUD_SERVICE_KEY }} @@ -82,6 +91,8 @@ jobs: - name: Setup aws run: | + AWS_K8S_VERSION=${{ vars.NSM_KUBERNETES_VERSION }} + AWS_K8S_VERSION_SHORT=$(echo $AWS_K8S_VERSION | cut -d "." -f 1-2 | cut -c 2-) scripts/aws/aws-start.sh env: KUBECONFIG: /tmp/config2 @@ -93,6 +104,7 @@ jobs: - name: Setup aks run: | + AKS_K8S_VERSION=$(echo ${{ vars.NSM_KUBERNETES_VERSION }} | cut -d '.' -f 1,2 | cut -c 2-) az login --service-principal --username ${AZURE_SERVICE_PRINCIPAL} --password ${AZURE_SERVICE_PRINCIPAL_SECRET} --tenant ${AZURE_TENANT} scripts/aks/aks-start.sh ${AZURE_RESOURCE_GROUP} ${AZURE_CLUSTER_NAME} ${AZURE_CREDENTIALS_PATH} ${KUBECONFIG} env: @@ -106,6 +118,9 @@ jobs: - name: Run interdomain testing run: | + kubectl version --kubeconfig=$KUBECONFIG1 + kubectl version --kubeconfig=$KUBECONFIG2 + kubectl version --kubeconfig=$KUBECONFIG3 go test -count 1 -timeout 2h -race -v ./... -parallel 4 env: KUBECONFIG1: /tmp/config1 diff --git a/scripts/aks/aks-start.sh b/scripts/aks/aks-start.sh index be98349..f65402a 100755 --- a/scripts/aks/aks-start.sh +++ b/scripts/aks/aks-start.sh @@ -12,6 +12,7 @@ echo -n "Creating AKS cluster '$AZURE_CLUSTER_NAME'..." az aks create \ --resource-group "$AZURE_RESOURCE_GROUP" \ --name "$AZURE_CLUSTER_NAME" \ + --kubernetes-version $AKS_K8S_VERSION \ --node-count 1 \ --node-vm-size Standard_B2s \ --enable-node-public-ip \ diff --git a/scripts/aws/aws-start.sh b/scripts/aws/aws-start.sh index 932b1a5..cf06ccf 100755 --- a/scripts/aws/aws-start.sh +++ b/scripts/aws/aws-start.sh @@ -6,7 +6,7 @@ export IAM_NAME=ebs-csi-controller-sa apt-get update && apt-get -y install curl dnsutils -curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.23.6/bin/linux/amd64/kubectl +curl -LO https://storage.googleapis.com/kubernetes-release/release/${AWS_K8S_VERSION}/bin/linux/amd64/kubectl chmod +x kubectl mkdir -p ~/.local/bin mv ./kubectl ~/.local/bin/kubectl @@ -22,7 +22,7 @@ curl -o aws-iam-authenticator https://s3.us-west-2.amazonaws.com/amazon-eks/1.21 eksctl create cluster \ --name "${AWS_CLUSTER_NAME}" \ - --version 1.27 \ + --version ${AWS_K8S_VERSION_SHORT} \ --nodegroup-name "${AWS_CLUSTER_NAME}-workers" \ --node-type t3.xlarge \ --nodes 1 diff --git a/scripts/gke/gke-start.sh b/scripts/gke/gke-start.sh index ab5afd2..dc7ccee 100755 --- a/scripts/gke/gke-start.sh +++ b/scripts/gke/gke-start.sh @@ -1,8 +1,23 @@ #!/bin/bash + # Get a specific GKE cluster version that matches NSM_KUBERNETES_VERSION +K8S_VERSION=$(echo ${ vars.NSM_KUBERNETES_VERSION } | cut -d '.' -f 1,2 | cut -c 2-) +GKE_CLUSTER_VERSION=$(gcloud container get-server-config --zone="$GKE_CLUSTER_ZONE" --format=json \ + | jq '.channels[] | select (.channel=="REGULAR") | .validVersions[]' \ + | grep -m 1 "$K8S_VERSION" | tr -d '"') +if [ -z "$GKE_CLUSTER_VERSION"]; then + echo "GKE cluster version is not valid: $GKE_CLUSTER_VERSION" + exit 1 +fi + gcloud components install gke-gcloud-auth-plugin gcloud components update -time gcloud container clusters create "${GKE_CLUSTER_NAME}" --project="${GKE_PROJECT_ID}" --machine-type="${GKE_CLUSTER_TYPE}" --num-nodes=1 --zone="${GKE_CLUSTER_ZONE}" -q +time gcloud container clusters create "${GKE_CLUSTER_NAME}" \ +--project="${GKE_PROJECT_ID}" \ +--machine-type="${GKE_CLUSTER_TYPE}" \ +--num-nodes=1 \ +--zone="${GKE_CLUSTER_ZONE}" \ +--cluster-version="${GKE_CLUSTER_VERSION}" -q echo "Writing config to ${KUBECONFIG}" gcloud container clusters get-credentials "${GKE_CLUSTER_NAME}" --project="${GKE_PROJECT_ID}" --zone="${GKE_CLUSTER_ZONE}" kubectl create clusterrolebinding cluster-admin-binding --clusterrole cluster-admin --user "$(gcloud config get-value account)" From 918c022bf20083d56de4ae79c3ca18bc26af3237 Mon Sep 17 00:00:00 2001 From: NikitaSkrynnik Date: Tue, 20 Aug 2024 10:50:02 +1100 Subject: [PATCH 2/9] cleanup Signed-off-by: NikitaSkrynnik --- scripts/gke/gke-start.sh | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/scripts/gke/gke-start.sh b/scripts/gke/gke-start.sh index dc7ccee..d3ae627 100755 --- a/scripts/gke/gke-start.sh +++ b/scripts/gke/gke-start.sh @@ -1,15 +1,5 @@ #!/bin/bash - # Get a specific GKE cluster version that matches NSM_KUBERNETES_VERSION -K8S_VERSION=$(echo ${ vars.NSM_KUBERNETES_VERSION } | cut -d '.' -f 1,2 | cut -c 2-) -GKE_CLUSTER_VERSION=$(gcloud container get-server-config --zone="$GKE_CLUSTER_ZONE" --format=json \ - | jq '.channels[] | select (.channel=="REGULAR") | .validVersions[]' \ - | grep -m 1 "$K8S_VERSION" | tr -d '"') -if [ -z "$GKE_CLUSTER_VERSION"]; then - echo "GKE cluster version is not valid: $GKE_CLUSTER_VERSION" - exit 1 -fi - gcloud components install gke-gcloud-auth-plugin gcloud components update time gcloud container clusters create "${GKE_CLUSTER_NAME}" \ From c0b08501afce73d554a1f8de187b6a92665e4a6f Mon Sep 17 00:00:00 2001 From: NikitaSkrynnik Date: Tue, 20 Aug 2024 11:21:33 +1100 Subject: [PATCH 3/9] fix aws setup Signed-off-by: NikitaSkrynnik --- .github/workflows/ci.yaml | 4 +++- scripts/aws/aws-start.sh | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b93a916..9c06e52 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -91,7 +91,8 @@ jobs: - name: Setup aws run: | - AWS_K8S_VERSION=${{ vars.NSM_KUBERNETES_VERSION }} + AWS_K8S_VERSION1=${{ vars.NSM_KUBERNETES_VERSION }} + echo $AWS_K8S_VERSION1 AWS_K8S_VERSION_SHORT=$(echo $AWS_K8S_VERSION | cut -d "." -f 1-2 | cut -c 2-) scripts/aws/aws-start.sh env: @@ -100,6 +101,7 @@ jobs: AWS_CLUSTER_NAME: aws-${{ github.run_id }}-${{ github.run_number }} AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_K8S_VERSION: ${{ vars.NSM_KUBERNETES_VERSION }} working-directory: ${{ github.workspace }}/src/github.com/${{ github.repository }} - name: Setup aks diff --git a/scripts/aws/aws-start.sh b/scripts/aws/aws-start.sh index cf06ccf..a83b06d 100755 --- a/scripts/aws/aws-start.sh +++ b/scripts/aws/aws-start.sh @@ -6,7 +6,8 @@ export IAM_NAME=ebs-csi-controller-sa apt-get update && apt-get -y install curl dnsutils -curl -LO https://storage.googleapis.com/kubernetes-release/release/${AWS_K8S_VERSION}/bin/linux/amd64/kubectl +echo $AWS_K8S_VERSION +curl -LO https://storage.googleapis.com/kubernetes-release/release/$AWS_K8S_VERSION/bin/linux/amd64/kubectl chmod +x kubectl mkdir -p ~/.local/bin mv ./kubectl ~/.local/bin/kubectl From 5120cf93cc1a0c7e82b52bf514f276cfd3ff202a Mon Sep 17 00:00:00 2001 From: NikitaSkrynnik Date: Tue, 20 Aug 2024 12:26:18 +1100 Subject: [PATCH 4/9] debug Signed-off-by: NikitaSkrynnik --- .github/workflows/ci.yaml | 22 +++++++--------------- scripts/aks/aks-start.sh | 7 +++++-- scripts/aws/aws-start.sh | 7 ++++--- scripts/gke/gke-start.sh | 12 ++++++++++++ 4 files changed, 28 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9c06e52..91a6173 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -67,15 +67,6 @@ jobs: - name: Setup gke run: | - NSM_KUBERNETES_VERSION=$(echo ${{ vars.NSM_KUBERNETES_VERSION }} | cut -d '.' -f 1,2 | cut -c 2-) - GKE_CLUSTER_VERSION=$(gcloud container get-server-config --zone="$GKE_CLUSTER_ZONE" --format=json \ - | jq '.channels[] | select (.channel=="REGULAR") | .validVersions[]' \ - | grep -m 1 "$NSM_KUBERNETES_VERSION" | tr -d '"') - if [ -z "$GKE_CLUSTER_VERSION"]; then - echo "GKE cluster version is not valid: $GKE_CLUSTER_VERSION" - exit 1 - fi - scripts/gke/gke-start.sh env: GCLOUD_SERVICE_KEY: ${{ secrets.GCLOUD_SERVICE_KEY }} @@ -85,15 +76,13 @@ jobs: GKE_CLUSTER_ZONE: us-central1-a GKE_CLUSTER_TYPE: n1-standard-2 GKE_CLUSTER_NUM_NODES: 1 + K8S_VERSION: ${{ vars.NSM_KUBERNETES_VERSION }} KUBECONFIG: /tmp/config1 USE_GKE_GCLOUD_AUTH_PLUGIN: true working-directory: ${{ github.workspace }}/src/github.com/${{ github.repository }} - name: Setup aws run: | - AWS_K8S_VERSION1=${{ vars.NSM_KUBERNETES_VERSION }} - echo $AWS_K8S_VERSION1 - AWS_K8S_VERSION_SHORT=$(echo $AWS_K8S_VERSION | cut -d "." -f 1-2 | cut -c 2-) scripts/aws/aws-start.sh env: KUBECONFIG: /tmp/config2 @@ -101,14 +90,13 @@ jobs: AWS_CLUSTER_NAME: aws-${{ github.run_id }}-${{ github.run_number }} AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_K8S_VERSION: ${{ vars.NSM_KUBERNETES_VERSION }} + K8S_VERSION: ${{ vars.NSM_KUBERNETES_VERSION }} working-directory: ${{ github.workspace }}/src/github.com/${{ github.repository }} - name: Setup aks run: | - AKS_K8S_VERSION=$(echo ${{ vars.NSM_KUBERNETES_VERSION }} | cut -d '.' -f 1,2 | cut -c 2-) az login --service-principal --username ${AZURE_SERVICE_PRINCIPAL} --password ${AZURE_SERVICE_PRINCIPAL_SECRET} --tenant ${AZURE_TENANT} - scripts/aks/aks-start.sh ${AZURE_RESOURCE_GROUP} ${AZURE_CLUSTER_NAME} ${AZURE_CREDENTIALS_PATH} ${KUBECONFIG} + scripts/aks/aks-start.sh ${AZURE_RESOURCE_GROUP} ${AZURE_CLUSTER_NAME} ${AZURE_CREDENTIALS_PATH} ${KUBECONFIG} ${AKS_K8S_VERSION} env: KUBECONFIG: /tmp/config3 AZURE_RESOURCE_GROUP: nsm-ci @@ -116,12 +104,16 @@ jobs: AZURE_SERVICE_PRINCIPAL: ${{ secrets.AZURE_SERVICE_PRINCIPAL }} AZURE_SERVICE_PRINCIPAL_SECRET: ${{ secrets.AZURE_SERVICE_PRINCIPAL_SECRET }} AZURE_TENANT: ${{ secrets.AZURE_TENANT }} + K8S_VERSION: ${{ vars.NSM_KUBERNETES_VERSION }} working-directory: ${{ github.workspace }}/src/github.com/${{ github.repository }} - name: Run interdomain testing run: | + echo "cluster1" kubectl version --kubeconfig=$KUBECONFIG1 + echo "cluster2" kubectl version --kubeconfig=$KUBECONFIG2 + echo "cluster3" kubectl version --kubeconfig=$KUBECONFIG3 go test -count 1 -timeout 2h -race -v ./... -parallel 4 env: diff --git a/scripts/aks/aks-start.sh b/scripts/aks/aks-start.sh index f65402a..09b1560 100755 --- a/scripts/aks/aks-start.sh +++ b/scripts/aks/aks-start.sh @@ -2,17 +2,20 @@ readonly AZURE_RESOURCE_GROUP=$1 readonly AZURE_CLUSTER_NAME=$2 readonly AZURE_CREDENTIALS_PATH=$3 - if [[ -z "$1" ]] || [[ -z "$2" ]] || [[ -z "$3" ]]; then echo "Usage: aks-start.sh " exit 1 fi +AKS_K8S_VERSION=$(echo $K8S_VERSION | cut -d '.' -f 1,2 | cut -c 2-) +echo "k8s version: $K8S_VERSION" +echo "AKS K8S: $AKS_K8S_VERSION" + echo -n "Creating AKS cluster '$AZURE_CLUSTER_NAME'..." az aks create \ --resource-group "$AZURE_RESOURCE_GROUP" \ --name "$AZURE_CLUSTER_NAME" \ - --kubernetes-version $AKS_K8S_VERSION \ + --kubernetes-version "$AKS_K8S_VERSION" \ --node-count 1 \ --node-vm-size Standard_B2s \ --enable-node-public-ip \ diff --git a/scripts/aws/aws-start.sh b/scripts/aws/aws-start.sh index a83b06d..102d596 100755 --- a/scripts/aws/aws-start.sh +++ b/scripts/aws/aws-start.sh @@ -6,8 +6,7 @@ export IAM_NAME=ebs-csi-controller-sa apt-get update && apt-get -y install curl dnsutils -echo $AWS_K8S_VERSION -curl -LO https://storage.googleapis.com/kubernetes-release/release/$AWS_K8S_VERSION/bin/linux/amd64/kubectl +curl -LO https://storage.googleapis.com/kubernetes-release/release/"$K8S_VERSION"/bin/linux/amd64/kubectl chmod +x kubectl mkdir -p ~/.local/bin mv ./kubectl ~/.local/bin/kubectl @@ -21,9 +20,11 @@ curl -o aws-iam-authenticator https://s3.us-west-2.amazonaws.com/amazon-eks/1.21 chmod 755 aws-iam-authenticator; \ mv ./aws-iam-authenticator /usr/local/bin +AWS_K8S_VERSION=$(echo $K8S_VERSION | cut -d "." -f 1-2 | cut -c 2-) +echo $AWS_K8S_VERSION eksctl create cluster \ --name "${AWS_CLUSTER_NAME}" \ - --version ${AWS_K8S_VERSION_SHORT} \ + --version "${AWS_K8S_VERSION}" \ --nodegroup-name "${AWS_CLUSTER_NAME}-workers" \ --node-type t3.xlarge \ --nodes 1 diff --git a/scripts/gke/gke-start.sh b/scripts/gke/gke-start.sh index d3ae627..6ef4e0b 100755 --- a/scripts/gke/gke-start.sh +++ b/scripts/gke/gke-start.sh @@ -1,5 +1,17 @@ #!/bin/bash +K8S_VERSION=$(echo ${K8S_VERSION} | cut -d '.' -f 1,2 | cut -c 2-) +GKE_CLUSTER_VERSION=$(gcloud container get-server-config --zone="$GKE_CLUSTER_ZONE" --format=json \ + | jq '.channels[] | select (.channel=="REGULAR") | .validVersions[]' \ + | grep -m 1 "$K8S_VERSION" | tr -d '"') +if [ -z "$GKE_CLUSTER_VERSION"]; then + echo "GKE cluster version is not valid: $GKE_CLUSTER_VERSION" + exit 1 +fi + +echo $K8S_VERSION +echo $GKE_CLUSTER_VERSION + gcloud components install gke-gcloud-auth-plugin gcloud components update time gcloud container clusters create "${GKE_CLUSTER_NAME}" \ From 62cb24824dbca7ba5eaa7acb5e9b52aa08fee4b5 Mon Sep 17 00:00:00 2001 From: NikitaSkrynnik Date: Wed, 21 Aug 2024 16:09:47 +1100 Subject: [PATCH 5/9] fix aws cluster setup script Signed-off-by: NikitaSkrynnik --- scripts/aws/aws-start.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/aws/aws-start.sh b/scripts/aws/aws-start.sh index 102d596..d358fe3 100755 --- a/scripts/aws/aws-start.sh +++ b/scripts/aws/aws-start.sh @@ -16,7 +16,7 @@ curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/d mv /tmp/eksctl /usr/local/bin; \ eksctl version -curl -o aws-iam-authenticator https://s3.us-west-2.amazonaws.com/amazon-eks/1.21.2/2021-07-05/bin/linux/amd64/aws-iam-authenticator; \ +curl -Lo aws-iam-authenticator https://github.com/kubernetes-sigs/aws-iam-authenticator/releases/download/v0.6.22/aws-iam-authenticator_0.6.22_$(uname -s)_amd64; \ chmod 755 aws-iam-authenticator; \ mv ./aws-iam-authenticator /usr/local/bin From cf1ba798540c84a0d849a28bfb883ad408931366 Mon Sep 17 00:00:00 2001 From: NikitaSkrynnik Date: Wed, 21 Aug 2024 19:32:58 +1100 Subject: [PATCH 6/9] install kubectl separately Signed-off-by: NikitaSkrynnik --- .github/workflows/ci.yaml | 6 +++++- scripts/aws/aws-start.sh | 5 ----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 91a6173..83865bd 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -64,7 +64,11 @@ jobs: uses: actions/checkout@v4 with: path: ${{ github.workspace }}/src/github.com/${{ github.repository }} - + - name: Install kubectl + run: | + curl -LO https://dl.k8s.io/release/${{ vars.NSM_KUBERNETES_VERSION }}/bin/linux/amd64/kubectl + chmod +x ./kubectl + mv ./kubectl /usr/local/bin/kubectl - name: Setup gke run: | scripts/gke/gke-start.sh diff --git a/scripts/aws/aws-start.sh b/scripts/aws/aws-start.sh index d358fe3..561099e 100755 --- a/scripts/aws/aws-start.sh +++ b/scripts/aws/aws-start.sh @@ -6,11 +6,6 @@ export IAM_NAME=ebs-csi-controller-sa apt-get update && apt-get -y install curl dnsutils -curl -LO https://storage.googleapis.com/kubernetes-release/release/"$K8S_VERSION"/bin/linux/amd64/kubectl -chmod +x kubectl -mkdir -p ~/.local/bin -mv ./kubectl ~/.local/bin/kubectl - curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp; \ mv /tmp/eksctl /usr/local/bin; \ From 3fa42de10e351da09924a4855e255aca9a8f2f22 Mon Sep 17 00:00:00 2001 From: NikitaSkrynnik Date: Thu, 22 Aug 2024 09:49:41 +1100 Subject: [PATCH 7/9] install kubectl after cluster setups Signed-off-by: NikitaSkrynnik --- .github/workflows/ci.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 83865bd..fb546ad 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -64,11 +64,6 @@ jobs: uses: actions/checkout@v4 with: path: ${{ github.workspace }}/src/github.com/${{ github.repository }} - - name: Install kubectl - run: | - curl -LO https://dl.k8s.io/release/${{ vars.NSM_KUBERNETES_VERSION }}/bin/linux/amd64/kubectl - chmod +x ./kubectl - mv ./kubectl /usr/local/bin/kubectl - name: Setup gke run: | scripts/gke/gke-start.sh @@ -100,7 +95,7 @@ jobs: - name: Setup aks run: | az login --service-principal --username ${AZURE_SERVICE_PRINCIPAL} --password ${AZURE_SERVICE_PRINCIPAL_SECRET} --tenant ${AZURE_TENANT} - scripts/aks/aks-start.sh ${AZURE_RESOURCE_GROUP} ${AZURE_CLUSTER_NAME} ${AZURE_CREDENTIALS_PATH} ${KUBECONFIG} ${AKS_K8S_VERSION} + scripts/aks/aks-start.sh ${AZURE_RESOURCE_GROUP} ${AZURE_CLUSTER_NAME} ${AZURE_CREDENTIALS_PATH} ${KUBECONFIG} env: KUBECONFIG: /tmp/config3 AZURE_RESOURCE_GROUP: nsm-ci @@ -111,6 +106,11 @@ jobs: K8S_VERSION: ${{ vars.NSM_KUBERNETES_VERSION }} working-directory: ${{ github.workspace }}/src/github.com/${{ github.repository }} + - name: Install kubectl + run: | + curl -LO https://dl.k8s.io/release/${{ vars.NSM_KUBERNETES_VERSION }}/bin/linux/amd64/kubectl + chmod +x ./kubectl + mv ./kubectl /usr/local/bin/kubectl - name: Run interdomain testing run: | echo "cluster1" From c52662b7f3691bafaad044230847ef4f14e77f63 Mon Sep 17 00:00:00 2001 From: NikitaSkrynnik Date: Thu, 22 Aug 2024 11:09:44 +1100 Subject: [PATCH 8/9] cleanup + fix shell linter issues Signed-off-by: NikitaSkrynnik --- .github/workflows/ci.yaml | 7 +------ scripts/aks/aks-start.sh | 5 ++--- scripts/aws/aws-start.sh | 6 +++--- scripts/gke/gke-start.sh | 5 +---- 4 files changed, 7 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index fb546ad..85271b1 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -64,6 +64,7 @@ jobs: uses: actions/checkout@v4 with: path: ${{ github.workspace }}/src/github.com/${{ github.repository }} + - name: Setup gke run: | scripts/gke/gke-start.sh @@ -113,12 +114,6 @@ jobs: mv ./kubectl /usr/local/bin/kubectl - name: Run interdomain testing run: | - echo "cluster1" - kubectl version --kubeconfig=$KUBECONFIG1 - echo "cluster2" - kubectl version --kubeconfig=$KUBECONFIG2 - echo "cluster3" - kubectl version --kubeconfig=$KUBECONFIG3 go test -count 1 -timeout 2h -race -v ./... -parallel 4 env: KUBECONFIG1: /tmp/config1 diff --git a/scripts/aks/aks-start.sh b/scripts/aks/aks-start.sh index 09b1560..c71661a 100755 --- a/scripts/aks/aks-start.sh +++ b/scripts/aks/aks-start.sh @@ -2,14 +2,13 @@ readonly AZURE_RESOURCE_GROUP=$1 readonly AZURE_CLUSTER_NAME=$2 readonly AZURE_CREDENTIALS_PATH=$3 + if [[ -z "$1" ]] || [[ -z "$2" ]] || [[ -z "$3" ]]; then echo "Usage: aks-start.sh " exit 1 fi -AKS_K8S_VERSION=$(echo $K8S_VERSION | cut -d '.' -f 1,2 | cut -c 2-) -echo "k8s version: $K8S_VERSION" -echo "AKS K8S: $AKS_K8S_VERSION" +AKS_K8S_VERSION=$(echo "$K8S_VERSION" | cut -d '.' -f 1,2 | cut -c 2-) echo -n "Creating AKS cluster '$AZURE_CLUSTER_NAME'..." az aks create \ diff --git a/scripts/aws/aws-start.sh b/scripts/aws/aws-start.sh index 561099e..415ab5c 100755 --- a/scripts/aws/aws-start.sh +++ b/scripts/aws/aws-start.sh @@ -7,15 +7,15 @@ export IAM_NAME=ebs-csi-controller-sa apt-get update && apt-get -y install curl dnsutils -curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp; \ +curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_"$(uname -s)"_amd64.tar.gz" | tar xz -C /tmp; \ mv /tmp/eksctl /usr/local/bin; \ eksctl version -curl -Lo aws-iam-authenticator https://github.com/kubernetes-sigs/aws-iam-authenticator/releases/download/v0.6.22/aws-iam-authenticator_0.6.22_$(uname -s)_amd64; \ +curl -Lo aws-iam-authenticator https://github.com/kubernetes-sigs/aws-iam-authenticator/releases/download/v0.6.22/aws-iam-authenticator_0.6.22_"$(uname -s)"_amd64; \ chmod 755 aws-iam-authenticator; \ mv ./aws-iam-authenticator /usr/local/bin -AWS_K8S_VERSION=$(echo $K8S_VERSION | cut -d "." -f 1-2 | cut -c 2-) +AWS_K8S_VERSION=$(echo "$K8S_VERSION" | cut -d "." -f 1-2 | cut -c 2-) echo $AWS_K8S_VERSION eksctl create cluster \ --name "${AWS_CLUSTER_NAME}" \ diff --git a/scripts/gke/gke-start.sh b/scripts/gke/gke-start.sh index 6ef4e0b..2988a62 100755 --- a/scripts/gke/gke-start.sh +++ b/scripts/gke/gke-start.sh @@ -4,14 +4,11 @@ K8S_VERSION=$(echo ${K8S_VERSION} | cut -d '.' -f 1,2 | cut -c 2-) GKE_CLUSTER_VERSION=$(gcloud container get-server-config --zone="$GKE_CLUSTER_ZONE" --format=json \ | jq '.channels[] | select (.channel=="REGULAR") | .validVersions[]' \ | grep -m 1 "$K8S_VERSION" | tr -d '"') -if [ -z "$GKE_CLUSTER_VERSION"]; then +if [ -z "$GKE_CLUSTER_VERSION" ]; then echo "GKE cluster version is not valid: $GKE_CLUSTER_VERSION" exit 1 fi -echo $K8S_VERSION -echo $GKE_CLUSTER_VERSION - gcloud components install gke-gcloud-auth-plugin gcloud components update time gcloud container clusters create "${GKE_CLUSTER_NAME}" \ From 0c4823019767373de211f0cdd2cd0498562daa1f Mon Sep 17 00:00:00 2001 From: NikitaSkrynnik Date: Thu, 22 Aug 2024 12:24:21 +1100 Subject: [PATCH 9/9] fix more shell linter issues Signed-off-by: NikitaSkrynnik --- scripts/aws/aws-start.sh | 3 +-- scripts/gke/gke-start.sh | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/aws/aws-start.sh b/scripts/aws/aws-start.sh index 415ab5c..2f7314c 100755 --- a/scripts/aws/aws-start.sh +++ b/scripts/aws/aws-start.sh @@ -7,7 +7,7 @@ export IAM_NAME=ebs-csi-controller-sa apt-get update && apt-get -y install curl dnsutils -curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_"$(uname -s)"_amd64.tar.gz" | tar xz -C /tmp; \ +curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp; \ mv /tmp/eksctl /usr/local/bin; \ eksctl version @@ -16,7 +16,6 @@ curl -Lo aws-iam-authenticator https://github.com/kubernetes-sigs/aws-iam-authen mv ./aws-iam-authenticator /usr/local/bin AWS_K8S_VERSION=$(echo "$K8S_VERSION" | cut -d "." -f 1-2 | cut -c 2-) -echo $AWS_K8S_VERSION eksctl create cluster \ --name "${AWS_CLUSTER_NAME}" \ --version "${AWS_K8S_VERSION}" \ diff --git a/scripts/gke/gke-start.sh b/scripts/gke/gke-start.sh index 2988a62..061398d 100755 --- a/scripts/gke/gke-start.sh +++ b/scripts/gke/gke-start.sh @@ -1,6 +1,6 @@ #!/bin/bash -K8S_VERSION=$(echo ${K8S_VERSION} | cut -d '.' -f 1,2 | cut -c 2-) +K8S_VERSION=$(echo "$K8S_VERSION" | cut -d '.' -f 1,2 | cut -c 2-) GKE_CLUSTER_VERSION=$(gcloud container get-server-config --zone="$GKE_CLUSTER_ZONE" --format=json \ | jq '.channels[] | select (.channel=="REGULAR") | .validVersions[]' \ | grep -m 1 "$K8S_VERSION" | tr -d '"')