Use KUBERNETES_VERSION variable to set k8s cluster version #754
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 | |
azure: | |
environment: AKS | |
name: Azure Kubernetes Service | |
runs-on: ubuntu-latest | |
steps: | |
- name: Install azure-cli | |
uses: azure/CLI@v1 | |
with: | |
inlineScript: | | |
az version | |
- name: Set up azure permissions | |
run: | | |
sudo chmod -R 777 ~/.azure | |
- name: Set up /bin permissions | |
run: | | |
sudo chmod -R 777 /bin | |
- name: Set up go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: 1.20.5 | |
- name: Checkout files | |
uses: actions/checkout@v4 | |
with: | |
path: ${{ github.repository }} | |
- name: Setup AKS cluster | |
working-directory: ${{ github.repository }} | |
run: | | |
az login --service-principal --username ${AZURE_SERVICE_PRINCIPAL} --password ${AZURE_SERVICE_PRINCIPAL_SECRET} --tenant ${AZURE_TENANT} | |
K8S_VERSION=$(echo ${{ vars.NSM_KUBERNETES_VERSION }} | cut -d '.' -f 1,2 | cut -c 2-) | |
K8S_VERSION=1.28 | |
az aks get-versions --location westus | |
AKS_K8S_VERSION=$(az aks get-versions --location westus | jq '.orchestrators[].orchestratorVersion' | grep -m 1 "${K8S_VERSION}") | |
echo $K8S_VERSION | |
echo $AKS_K8S_VERSION | |
az aks create \ | |
--resource-group "$AZURE_RESOURCE_GROUP" \ | |
--name "$AZURE_CLUSTER_NAME" \ | |
--node-count 2 \ | |
--node-vm-size Standard_B2ms \ | |
--generate-ssh-keys \ | |
--kubernetes-version $AKS_K8S_VERSION\ | |
--debug | |
az aks wait \ | |
--name "$AZURE_CLUSTER_NAME" \ | |
--resource-group "$AZURE_RESOURCE_GROUP" \ | |
--created > /dev/null | |
az aks get-credentials \ | |
--name "$AZURE_CLUSTER_NAME" \ | |
--resource-group "$AZURE_RESOURCE_GROUP" \ | |
--file "/tmp/config" \ | |
--overwrite-existing | |
kubectl version | |
env: | |
AZURE_SERVICE_PRINCIPAL: ${{ secrets.AZURE_SERVICE_PRINCIPAL }} | |
AZURE_SERVICE_PRINCIPAL_SECRET: ${{ secrets.AZURE_SERVICE_PRINCIPAL_SECRET }} | |
AZURE_TENANT: ${{ secrets.AZURE_TENANT }} | |
AZURE_CLUSTER_NAME: aks-${{ github.run_id }}-${{ github.run_number }} | |
AZURE_RESOURCE_GROUP: nsm-ci | |
- name: Run tests | |
working-directory: ${{ github.repository }} | |
run: | | |
go test -count 1 -timeout 1h55m -race -v ./... -parallel 4 | |
env: | |
KUBECONFIG: /tmp/config | |
- name: Cleanup AKS cluster | |
if: ${{ always() }} | |
working-directory: ${{ github.repository }} | |
run: | | |
az aks delete \ | |
--name "$AZURE_CLUSTER_NAME" \ | |
--resource-group "$AZURE_RESOURCE_GROUP" \ | |
--yes | |
env: | |
AZURE_CLUSTER_NAME: aks-${{ github.run_id }}-${{ github.run_number }} | |
AZURE_RESOURCE_GROUP: nsm-ci | |
- name: Upload logs | |
uses: actions/upload-artifact@v4 | |
if: ${{ always() }} | |
with: | |
name: logs-${{ github.run_number }} | |
path: ${{ github.repository }}/logs | |
azure-tanzu: | |
needs: azure | |
environment: Azure Tanzu | |
name: Azure Tanzu | |
runs-on: ubuntu-latest | |
env: | |
AZURE_CLIENT_ID: ${{ secrets.AZURE_SERVICE_PRINCIPAL }} | |
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_SERVICE_PRINCIPAL_SECRET }} | |
AZURE_TENANT: ${{ secrets.AZURE_TENANT }} | |
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | |
AZURE_SSH_PUBLIC_KEY_B64: ${{ secrets.AZURE_SSH_PUBLIC_KEY_B64}} | |
AZURE_RESOURCE_GROUP: nsm-ci | |
steps: | |
- name: Checkout files | |
uses: actions/checkout@v4 | |
- name: Install kind | |
uses: engineerd/[email protected] | |
with: | |
version: v0.20.0 | |
image: kindest/node:v1.27.0 | |
skipClusterCreation: true | |
- name: Install Tanzu | |
run: | | |
sudo mkdir -p /etc/apt/keyrings | |
curl -fsSL https://packages.vmware.com/tools/keys/VMWARE-PACKAGING-GPG-RSA-KEY.pub | sudo gpg --dearmor -o /etc/apt/keyrings/tanzu-archive-keyring.gpg | |
echo "deb [signed-by=/etc/apt/keyrings/tanzu-archive-keyring.gpg] https://storage.googleapis.com/tanzu-cli-os-packages/apt tanzu-cli-jessie main" | sudo tee /etc/apt/sources.list.d/tanzu.list | |
sudo apt update | |
sudo apt install tanzu-cli=1.1.0 | |
tanzu version | |
tanzu config eula accept | |
tanzu ceip-participation set false | |
tanzu plugin install all --group vmware-tanzucli/essentials:v1.0.0 | |
tanzu plugin install --group vmware-tkg/default:v2.3.0 | |
- name: Setup envs (CI ONLY) | |
run: | | |
tanzu config set env.AZURE_TENANT_ID ${AZURE_TENANT} | |
tanzu config set env.AZURE_CLIENT_ID ${AZURE_CLIENT_ID} | |
tanzu config set env.AZURE_SUBSCRIPTION_ID ${AZURE_SUBSCRIPTION_ID} | |
tanzu config set env.AZURE_SSH_PUBLIC_KEY_B64 ${AZURE_SSH_PUBLIC_KEY_B64} | |
tanzu config set env.AZURE_RESOURCE_GROUP ${AZURE_RESOURCE_GROUP} | |
tanzu config set env.AZURE_CLIENT_SECRET ${AZURE_CLIENT_SECRET} | |
- name: Setup AKS management cluster | |
run: | | |
tanzu management-cluster create -f management-cluster.yaml --timeout 30m --yes | |
kubectl config use-context nsm-tanzu-mg-admin@nsm-tanzu-mg | |
- name: Setup AKS worker cluster | |
run: | | |
tanzu cluster create --file worker-cluster.yaml --timeout 30m --yes || true | |
SKIP_MULTI_AZ_VERIFY=true tanzu cluster create --file $HOME/.config/tanzu/tkg/clusterconfigs/nsm-tanzu-worker.yaml --timeout 30m | |
tanzu cluster kubeconfig get nsm-tanzu-worker --admin | |
kubectl config use-context nsm-tanzu-worker-admin@nsm-tanzu-worker | |
- name: Setup go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: 1.20.5 | |
- name: Run integration tests | |
run: | | |
go test -run TestRunBasicSuite -count 1 -timeout 30m -race -v -parallel 4 | |
- name: Delete NSM tanzu workload cluster | |
if: ${{ always() }} | |
run: | | |
tanzu cluster delete nsm-tanzu-worker --yes | |
kubectl config use-context nsm-tanzu-mg-admin@nsm-tanzu-mg | |
kubectl wait --for=delete clusters/nsm-tanzu-worker --timeout=20m | |
- name: Delete NSM tanzu management cluster | |
if: ${{ always() }} | |
run: | | |
tanzu management-cluster delete --yes | |
- name: Upload logs | |
uses: actions/upload-artifact@v4 | |
if: ${{ always() }} | |
with: | |
name: tanzu-logs-${{ github.run_number }} | |
path: logs |