Setup and run load test #1
This file contains hidden or 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: Setup and run load test | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| scenario: | |
| description: The desired description like "scenario-simple" | |
| required: true | |
| type: string | |
| env: | |
| K8S_NAMESPACE: k6-load-test | |
| JOB_NAME: k6 | |
| jobs: | |
| setup-and-run-load-test: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: 'read' | |
| id-token: 'write' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v2 | |
| - name: Google auth | |
| uses: 'google-github-actions/auth@v2' | |
| with: | |
| credentials_json: ${{ secrets.AUTOMATION_SA_KEY_JSON }} | |
| - name: Get GKE creds | |
| id: get_gke_creds | |
| uses: 'google-github-actions/get-gke-credentials@v2' | |
| with: | |
| cluster_name: 'simple-autopilot-private-cluster' | |
| location: 'europe-west1' | |
| credentials: ${{ secrets.AUTOMATION_SA_KEY_JSON }} | |
| - uses: webfactory/[email protected] | |
| with: | |
| ssh-private-key: | | |
| ${{ secrets.LPT_SSH_PRIVATE_KEY }} | |
| - name: Setup load test | |
| env: | |
| BASTION_IP: ${{ secrets.SSH_BASTION_HOST_IP }} | |
| API_URL: ${{ vars.KUBE_INTERNAL_API_URL }} | |
| CLUSTER_NAME: ${{ vars.KUBE_CLUSTER_NAME }} | |
| KUBE_FLAGS: ${{ vars.KUBE_FLAGS }} | |
| CONFIG_PATH: ${{ steps.get_gke_creds.outputs.kubeconfig_path }} | |
| run: | | |
| ssh -o ExitOnForwardFailure=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -L 6443:$API_URL -i lpt lpt@$BASTION_IP -fN | |
| # use config from gke init action: | |
| export KUBECONFIG=$CONFIG_PATH | |
| kubectl config set-cluster $CLUSTER_NAME --server=https://127.0.0.1:6443 | |
| kubectl get namespace $KUBE_FLAGS | |
| - name: Cleanup | |
| if: ${{ always() }} | |
| env: | |
| BASTION_IP: ${{ secrets.SSH_BASTION_HOST_IP }} | |
| API_URL: ${{ vars.KUBE_INTERNAL_API_URL }} | |
| CLUSTER_NAME: ${{ vars.KUBE_CLUSTER_NAME }} | |
| KUBE_FLAGS: ${{ vars.KUBE_FLAGS }} | |
| CONFIG_PATH: ${{ steps.get_gke_creds.outputs.kubeconfig_path }} | |
| run: | | |
| export KUBECONFIG=$CONFIG_PATH | |
| kubectl delete namespace k6-load-test $KUBE_FLAGS | |
| # - name: Create namespace | |
| # run: | | |
| # kubectl apply -f load-test/base/namespace.yaml | |
| # sleep 5 | |
| # - name: Deploy k6 test job | |
| # run: | | |
| # kubectl apply -k load-test/${{ inputs.scenario }} |