use NSM_KUBERNETES_VERSION variable to specify k8s version for clusters #725
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 | |
interdomain: | |
runs-on: ubuntu-latest | |
env: | |
KUBERNETES_VERSION: ${{ secrets.NSM_KUBERNETES_VERSION }} | |
steps: | |
- name: Cancel Previous Runs | |
uses: styfle/cancel-workflow-action@0.12.1 | |
with: | |
access_token: ${{ github.token }} | |
- name: Checkout files | |
uses: actions/checkout@v4 | |
with: | |
path: ${{ github.repository }} | |
- name: Install azure-cli | |
uses: azure/CLI@v1 | |
with: | |
inlineScript: | | |
az version | |
- name: Set up azure permissions | |
run: | | |
sudo chmod -R 777 ~/.azure | |
- uses: 'google-github-actions/auth@v2' | |
with: | |
project_id: ${{ secrets.GOOGLE_PROJECT_ID }} | |
credentials_json: ${{ secrets.GCLOUD_SERVICE_KEY }} | |
- name: Install gcloud-sdk | |
uses: google-github-actions/setup-gcloud@v2 | |
- name: Set up /bin permissions | |
run: | | |
sudo chmod -R 777 /bin | |
- uses: actions/setup-go@v5 | |
with: | |
go-version: 1.20.5 | |
token: ${{ github.token }} | |
- name: setup env | |
run: | | |
echo GOPATH=$GITHUB_WORKSPACE >> $GITHUB_ENV | |
echo GO111MODULE=on >> $GITHUB_ENV | |
echo $GITHUB_WORKSPACE/bin >> $GITHUB_PATH | |
- name: Check out code | |
uses: actions/checkout@v4 | |
with: | |
path: ${{ github.workspace }}/src/github.com/${{ github.repository }} | |
- 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 }} | |
GCLOUD_PROJECT_ID: ${{ secrets.GOOGLE_PROJECT_ID }} | |
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: 1 | |
KUBECONFIG: /tmp/config1 | |
USE_GKE_GCLOUD_AUTH_PLUGIN: true | |
working-directory: ${{ github.workspace }}/src/github.com/${{ github.repository }} | |
- name: Setup aws | |
run: | | |
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 | |
AWS_REGION: us-east-2 | |
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 | |
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} ${AKS_K8S_VERSION} | |
env: | |
KUBECONFIG: /tmp/config3 | |
AZURE_RESOURCE_GROUP: nsm-ci | |
AZURE_CLUSTER_NAME: aks-${{ github.run_id }}-${{ github.run_number }} | |
AZURE_SERVICE_PRINCIPAL: ${{ secrets.AZURE_SERVICE_PRINCIPAL }} | |
AZURE_SERVICE_PRINCIPAL_SECRET: ${{ secrets.AZURE_SERVICE_PRINCIPAL_SECRET }} | |
AZURE_TENANT: ${{ secrets.AZURE_TENANT }} | |
working-directory: ${{ github.workspace }}/src/github.com/${{ github.repository }} | |
- 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 | |
KUBECONFIG2: /tmp/config2 | |
KUBECONFIG3: /tmp/config3 | |
AZURE_SERVICE_PRINCIPAL: ${{ secrets.AZURE_SERVICE_PRINCIPAL }} | |
AZURE_SERVICE_PRINCIPAL_SECRET: ${{ secrets.AZURE_SERVICE_PRINCIPAL_SECRET }} | |
AZURE_TENANT: ${{ secrets.AZURE_TENANT }} | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_REGION: "us-west-2" | |
USE_GKE_GCLOUD_AUTH_PLUGIN: true | |
PACKET_AUTH_TOKEN: ${{ secrets.PACKET_AUTH_TOKEN }} | |
PACKET_PROJECT_ID: ${{ secrets.PACKET_PROJECT_ID }} | |
KUBERNETES_VERSION: ${{ secrets.NSM_KUBERNETES_VERSION }} | |
GCLOUD_SERVICE_KEY: ${{ secrets.GCLOUD_SERVICE_KEY }} | |
GCLOUD_PROJECT_ID: ${{ secrets.GOOGLE_PROJECT_ID }} | |
working-directory: ${{ github.workspace }}/src/github.com/${{ github.repository }} | |
- name: Cleanup GKE | |
if: ${{ always() }} | |
working-directory: ${{ github.workspace }}/src/github.com/${{ 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: Cleanup AWS | |
if: ${{ always() }} | |
working-directory: ${{ github.workspace }}/src/github.com/${{ github.repository }} | |
run: | | |
scripts/aws/aws-destroy.sh | |
env: | |
AWS_REGION: us-east-2 | |
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 }} | |
- name: Cleanup AKS | |
if: ${{ always() }} | |
working-directory: ${{ github.workspace }}/src/github.com/${{ github.repository }} | |
run: | | |
scripts/aks/aks-destroy.sh ${AZURE_RESOURCE_GROUP} ${AZURE_CLUSTER_NAME} | |
env: | |
AZURE_CLUSTER_NAME: aks-${{ github.run_id }}-${{ github.run_number }} | |
AZURE_SERVICE_PRINCIPAL: ${{ secrets.AZURE_SERVICE_PRINCIPAL }} | |
AZURE_SERVICE_PRINCIPAL_SECRET: ${{ secrets.AZURE_SERVICE_PRINCIPAL_SECRET }} | |
AZURE_TENANT: ${{ secrets.AZURE_TENANT }} | |
AZURE_RESOURCE_GROUP: nsm-ci | |
- name: Upload logs | |
uses: actions/upload-artifact@v4 | |
if: ${{ always() }} | |
with: | |
name: logs-${{ github.run_number }} | |
path: ${{ github.workspace }}/src/github.com/${{ github.repository }}/logs |