use KUBERNETES_VERSION variable to set k8s cluster version #1134
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: ci | |
on: | |
pull_request: | |
push: | |
branches: | |
- 'release/**' | |
jobs: | |
yamllint: | |
uses: networkservicemesh/.github/.github/workflows/yamllint.yaml@main | |
shellcheck: | |
uses: networkservicemesh/.github/.github/workflows/shellcheck.yaml@main | |
golangci-lint: | |
uses: networkservicemesh/.github/.github/workflows/golangci-lint.yaml@main | |
exclude-fmt-errorf: | |
uses: networkservicemesh/.github/.github/workflows/exclude-fmt-errorf.yaml@main | |
checkgomod: | |
uses: networkservicemesh/.github/.github/workflows/checkgomod.yaml@main | |
gke: | |
environment: GKE | |
name: Google Kubernetes Engine | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up /bin permissions | |
run: | | |
sudo chmod -R 777 /bin | |
- name: Set up go | |
uses: actions/setup-go@v1 | |
with: | |
go-version: 1.20.5 | |
- name: Install gcloud-sdk | |
uses: google-github-actions/setup-gcloud@v0 | |
with: | |
service_account_key: ${{ secrets.GCLOUD_SERVICE_KEY }} | |
project_id: ${{ secrets.GOOGLE_PROJECT_ID }} | |
- name: Checkout deployments | |
uses: actions/checkout@v2 | |
with: | |
repository: networkservicemesh/deployments-k8s | |
path: networkservicemesh/deployments-k8s | |
- name: Checkout files | |
uses: actions/checkout@v2 | |
with: | |
path: ${{ github.repository }} | |
- name: Setup cluster | |
working-directory: ${{ github.repository }} | |
run: | | |
GKE_K8S_VERSION=$(echo $GKE_K8S_VERSION | cut -c 2-) | |
gcloud components install gke-gcloud-auth-plugin | |
gcloud components install kubectl --version=${GKE_K8S_VERSION} | |
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_K8S_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: | |
GKE_PROJECT_ID: ${{ secrets.GOOGLE_PROJECT_ID }} | |
GKE_CLUSTER_NAME: gke-${{ github.run_id }}-${{ github.run_number }} | |
GKE_CLUSTER_ZONE: us-central1-a | |
GKE_CLUSTER_TYPE: n1-standard-2 | |
GKE_CLUSTER_NUM_NODES: 2 | |
GKE_K8S_VERSION: ${{ vars.NSM_KUBERNETES_VERSION }} | |
KUBECONFIG: config | |
USE_GKE_GCLOUD_AUTH_PLUGIN: true | |
- name: Run integration tests | |
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 | |
USE_GKE_GCLOUD_AUTH_PLUGIN: true | |
- name: Cleanup | |
if: ${{ always() }} | |
working-directory: ${{ github.repository }} | |
run: | | |
gcloud container clusters delete "${GKE_CLUSTER_NAME}" --project="${GKE_PROJECT_ID}" --zone="${GKE_CLUSTER_ZONE}" -q | |
env: | |
GKE_PROJECT_ID: ${{ secrets.GOOGLE_PROJECT_ID }} | |
GKE_CLUSTER_NAME: gke-${{ github.run_id }}-${{ github.run_number }} | |
GKE_CLUSTER_ZONE: us-central1-a | |
- name: Upload logs # 9. Upload logs | |
uses: actions/upload-artifact@v2 | |
if: ${{ always() }} | |
with: | |
name: logs-${{ github.run_number }} | |
path: ${{ github.repository }}/logs |