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 KUBERNETES_VERSION variable to set k8s cluster version #432

Closed
wants to merge 8 commits into from
Closed
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
27 changes: 26 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,36 @@ jobs:
credentials_json: ${{ secrets.GCLOUD_SERVICE_KEY }}
- name: Install gcloud-sdk
uses: google-github-actions/setup-gcloud@v2
- 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 cluster
working-directory: ${{ github.repository }}
run: |
# 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
gcloud container clusters create "${GKE_CLUSTER_NAME}" --project="${GKE_PROJECT_ID}" --machine-type="${GKE_CLUSTER_TYPE}" --num-nodes="${GKE_CLUSTER_NUM_NODES}" --zone="${GKE_CLUSTER_ZONE}" --enable-gvnic -q

gcloud container clusters create "${GKE_CLUSTER_NAME}" \
--project="${GKE_PROJECT_ID}" \
--machine-type="${GKE_CLUSTER_TYPE}" \
--num-nodes="${GKE_CLUSTER_NUM_NODES}" \
--zone="${GKE_CLUSTER_ZONE}" \
--cluster-version="${GKE_CLUSTER_VERSION}" \
--enable-gvnic -q

echo "Writing config to ${KUBECONFIG}"
gcloud container clusters get-credentials "${GKE_CLUSTER_NAME}" --project="${GKE_PROJECT_ID}" --zone="${GKE_CLUSTER_ZONE}"
env:
Expand All @@ -68,6 +92,7 @@ jobs:
working-directory: ${{ github.repository }}
run: |
export KUBECONFIG=$(pwd)/config
kubectl version
go test -count 1 -timeout 1h55m -race -v ./... -parallel 4
env:
ARTIFACTS_DIR: logs
Expand Down
Loading