Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use NSM_KUBERNETES_VERSION variable to specify k8s version for clusters #256

Merged
merged 9 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ 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 }}
Expand All @@ -89,6 +90,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 }}
K8S_VERSION: ${{ vars.NSM_KUBERNETES_VERSION }}
working-directory: ${{ github.workspace }}/src/github.com/${{ github.repository }}

- name: Setup aks
Expand All @@ -102,8 +104,14 @@ 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: 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: |
go test -count 1 -timeout 2h -race -v ./... -parallel 4
Expand Down
3 changes: 3 additions & 0 deletions scripts/aks/aks-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ if [[ -z "$1" ]] || [[ -z "$2" ]] || [[ -z "$3" ]]; then
exit 1
fi

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 \
--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 \
Expand Down
10 changes: 3 additions & 7 deletions scripts/aws/aws-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,19 @@ 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
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; \
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

AWS_K8S_VERSION=$(echo "$K8S_VERSION" | cut -d "." -f 1-2 | cut -c 2-)
eksctl create cluster \
--name "${AWS_CLUSTER_NAME}" \
--version 1.27 \
--version "${AWS_K8S_VERSION}" \
--nodegroup-name "${AWS_CLUSTER_NAME}-workers" \
--node-type t3.xlarge \
--nodes 1
Expand Down
16 changes: 15 additions & 1 deletion scripts/gke/gke-start.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
#!/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

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)"
Expand Down
Loading