From 1a033e3af2b17944390a7ebbe12c82c1ae04925f Mon Sep 17 00:00:00 2001 From: Kurt Madel Date: Sat, 12 Oct 2024 12:03:43 -0400 Subject: [PATCH 01/11] Update GitHub Actions to use setup-vcluster Examples are currently using the loft cli that will not work with v4.x of the vCluster Platform --- .../github-actions/preview-environments.mdx | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/platform/integrations/github-actions/preview-environments.mdx b/platform/integrations/github-actions/preview-environments.mdx index 78864782c..43388876c 100644 --- a/platform/integrations/github-actions/preview-environments.mdx +++ b/platform/integrations/github-actions/preview-environments.mdx @@ -75,12 +75,11 @@ jobs: uses: actions/checkout@v3 - name: Install vCluster CLI - uses: loft-sh/setup-loft@v2 + uses: loft-sh/setup-vcluster@main with: - version: v3.0.0 - url: https://url-to-your-loft-instance.com + url: ${{ secrets.VCLUSTER_PLATFORM_URL }} # Specify your vCluster Platform access key here - access-key: ${{ secrets.LOFT_PREVIEW_ACCESS_KEY }} + access-key: ${{ secrets.VCLUSTER_PLATFORM_ACCESS_KEY }} # Optional if your vCluster Platform domain certificate is insecure #insecure: true @@ -89,7 +88,7 @@ jobs: INGRESS_HOST=loft-preview-${{ github.event.pull_request.number }}.my-preview-environments.com # Make sure to recreate if there is an already existing environment - vcluster pro create loft-preview-${{ github.event.pull_request.number }} --project preview --recreate + vcluster plaltform create vcluster loft-preview-${{ github.event.pull_request.number }} --project preview --recreate # Deploy the application here with an ingress helm repo add argo https://argoproj.github.io/argo-helm @@ -129,17 +128,16 @@ jobs: uses: actions/checkout@v3 - name: Install vCluster CLI - uses: loft-sh/setup-loft@v2 + uses: loft-sh/setup-vcluster@main with: - version: v3.0.0 - url: https://url-to-your-loft-instance.com + url: ${{ secrets.VCLUSTER_PLATFORM_URL }} # Specify your vCluster Platform access key here - access-key: ${{ secrets.LOFT_PREVIEW_ACCESS_KEY }} + access-key: ${{ secrets.VCLUSTER_PLATFORM_ACCESS_KEY }} #insecure: true - name: Destroy Preview Environment run: | - loft delete vcluster loft-preview-${{ github.event.pull_request.number }} --project preview + vcluster platform delete vcluster loft-preview-${{ github.event.pull_request.number }} --project preview ``` ## Conclusion From b3cc7a19b0547613a52cd533ed43d2dd111fcee1 Mon Sep 17 00:00:00 2001 From: Kurt Madel Date: Sat, 12 Oct 2024 12:07:27 -0400 Subject: [PATCH 02/11] Update github-actions-pull-request-devspace.mdx --- .../github-actions-pull-request-devspace.mdx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/platform/_partials/integrations/github-actions-pull-request-devspace.mdx b/platform/_partials/integrations/github-actions-pull-request-devspace.mdx index a8aeab0a4..7889a2663 100644 --- a/platform/_partials/integrations/github-actions-pull-request-devspace.mdx +++ b/platform/_partials/integrations/github-actions-pull-request-devspace.mdx @@ -15,15 +15,14 @@ jobs: uses: loft-sh/setup-devspace@main - name: Install vCluster CLI uses: loft-sh/setup-vcluster@main - - name: Login to vCluster Platform instance - env: - LOFT_URL: ${{ secrets.LOFT_URL }} - ACCESS_KEY: ${{ secrets.ACCESS_KEY }} - run: vcluster login $LOFT_URL --access-key $ACCESS_KEY + with: + url: ${{ secrets.VCLUSTER_PLATFORM_URL }} + # Specify your vCluster Platform access key here + access-key: ${{ secrets.VCLUSTER_PLATFORM_ACCESS_KEY }} - name: Create PR Virtual Cluster env: NAME: pr-${{ github.event.pull_request.number }}-${{ github.sha }}-${{ github.run_id }} - run: vcluster create $NAME --project default + run: vcluster platform create vcluster $NAME --project default - name: Run Tests run: devspace run e2e ``` From 239a8920f15f3789b0d9183d86e31354d01b051a Mon Sep 17 00:00:00 2001 From: Kurt Madel Date: Sat, 12 Oct 2024 12:08:48 -0400 Subject: [PATCH 03/11] Update github-actions-spaces-pull-request-automatic.mdx --- .../github-actions-spaces-pull-request-automatic.mdx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/platform/_partials/integrations/github-actions-spaces-pull-request-automatic.mdx b/platform/_partials/integrations/github-actions-spaces-pull-request-automatic.mdx index b05e5a630..361071d92 100644 --- a/platform/_partials/integrations/github-actions-spaces-pull-request-automatic.mdx +++ b/platform/_partials/integrations/github-actions-spaces-pull-request-automatic.mdx @@ -12,10 +12,11 @@ jobs: runs-on: ubuntu-latest steps: - name: Install vCluster CLI - uses: loft-sh/setup-loft@main + uses: loft-sh/setup-vcluster@main with: - url: ${{ secrets.LOFT_URL }} - access-key: ${{ secrets.LOFT_ACCESS_KEY }} + url: ${{ secrets.VCLUSTER_PLATFORM_URL }} + # Specify your vCluster Platform access key here + access-key: ${{ secrets.VCLUSTER_PLATFORM_ACCESS_KEY }} - name: Create Space for PR uses: loft-sh/create-space@main with: From c7fe2efff7b5f1edc682d8cd3b66410d54e896dd Mon Sep 17 00:00:00 2001 From: Kurt Madel Date: Sat, 12 Oct 2024 12:09:08 -0400 Subject: [PATCH 04/11] Update github-actions-spaces-pull-request-manual.mdx --- .../github-actions-spaces-pull-request-manual.mdx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/platform/_partials/integrations/github-actions-spaces-pull-request-manual.mdx b/platform/_partials/integrations/github-actions-spaces-pull-request-manual.mdx index 57d57b200..4fde92fd3 100644 --- a/platform/_partials/integrations/github-actions-spaces-pull-request-manual.mdx +++ b/platform/_partials/integrations/github-actions-spaces-pull-request-manual.mdx @@ -12,10 +12,11 @@ jobs: runs-on: ubuntu-latest steps: - name: Install vCluster CLI - uses: loft-sh/setup-loft@main + uses: loft-sh/setup-vcluster@main with: - url: ${{ secrets.LOFT_URL }} - access-key: ${{ secrets.LOFT_ACCESS_KEY }} + url: ${{ secrets.VCLUSTER_PLATFORM_URL }} + # Specify your vCluster Platform access key here + access-key: ${{ secrets.VCLUSTER_PLATFORM_ACCESS_KEY }} - name: Create Space for PR uses: loft-sh/create-space@main with: From 2c8436b2ea165757d7df02323e22f8114319fb69 Mon Sep 17 00:00:00 2001 From: Kurt Madel Date: Sat, 12 Oct 2024 12:09:46 -0400 Subject: [PATCH 05/11] Update github-actions-spaces-pull-request-reuse.mdx --- .../github-actions-spaces-pull-request-reuse.mdx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/platform/_partials/integrations/github-actions-spaces-pull-request-reuse.mdx b/platform/_partials/integrations/github-actions-spaces-pull-request-reuse.mdx index 66d45a0de..7ca930f18 100644 --- a/platform/_partials/integrations/github-actions-spaces-pull-request-reuse.mdx +++ b/platform/_partials/integrations/github-actions-spaces-pull-request-reuse.mdx @@ -12,10 +12,11 @@ jobs: runs-on: ubuntu-latest steps: - name: Install vCluster CLI - uses: loft-sh/setup-loft@main + uses: loft-sh/setup-vcluster@main with: - url: ${{ secrets.LOFT_URL }} - access-key: ${{ secrets.LOFT_ACCESS_KEY }} + url: ${{ secrets.VCLUSTER_PLATFORM_URL }} + # Specify your vCluster Platform access key here + access-key: ${{ secrets.VCLUSTER_PLATFORM_ACCESS_KEY }} - name: Create Space for PR uses: loft-sh/create-space@main with: From 8a26b03ba7680f422decab792a084782a9ad55c3 Mon Sep 17 00:00:00 2001 From: Kurt Madel Date: Sat, 12 Oct 2024 12:26:34 -0400 Subject: [PATCH 06/11] Update pull-requests.mdx --- platform/integrations/github-actions/pull-requests.mdx | 4 ---- 1 file changed, 4 deletions(-) diff --git a/platform/integrations/github-actions/pull-requests.mdx b/platform/integrations/github-actions/pull-requests.mdx index 565546699..458ebc4d1 100644 --- a/platform/integrations/github-actions/pull-requests.mdx +++ b/platform/integrations/github-actions/pull-requests.mdx @@ -7,7 +7,6 @@ sidebar_position: 1 import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem' -import PartialIntegrationsVclusterPullRequestAutomatic from '../../_partials/integrations/github-actions-vclusters-pull-request-automatic.mdx' import PartialIntegrationsVclusterPullRequestManual from '../../_partials/integrations/github-actions-vclusters-pull-request-manual.mdx' import PartialIntegrationsVclusterPullRequestUse from '../../_partials/integrations/github-actions-vclusters-pull-request-use.mdx' @@ -40,9 +39,6 @@ These examples show how to create and delete Virtual Clusters for pull requests. - - - ## Deploying Spaces on Pull Requests From 8b1c91c12d0837736fad1ac6c0ded274465b3653 Mon Sep 17 00:00:00 2001 From: Kurt Madel Date: Sat, 12 Oct 2024 12:26:58 -0400 Subject: [PATCH 07/11] Delete platform/_partials/integrations/github-actions-vclusters-pull-request-automatic.mdx --- ...tions-vclusters-pull-request-automatic.mdx | 37 ------------------- 1 file changed, 37 deletions(-) delete mode 100644 platform/_partials/integrations/github-actions-vclusters-pull-request-automatic.mdx diff --git a/platform/_partials/integrations/github-actions-vclusters-pull-request-automatic.mdx b/platform/_partials/integrations/github-actions-vclusters-pull-request-automatic.mdx deleted file mode 100644 index 03b40d831..000000000 --- a/platform/_partials/integrations/github-actions-vclusters-pull-request-automatic.mdx +++ /dev/null @@ -1,37 +0,0 @@ -This example shows how to automatically delete a Virtual Cluster after testing an application named my-app for pull requests. - -```yaml {20} -# .github/workflows/vclusters.yaml -name: Pull Request Checks -on: - pull_request: - branches: - - 'main' -jobs: - e2e: - runs-on: ubuntu-latest - steps: - - name: Install vCluster CLI - uses: loft-sh/setup-loft@main - with: - url: ${{ secrets.LOFT_URL }} - access-key: ${{ secrets.LOFT_ACCESS_KEY }} - - name: Create Virtual Cluster for PR - uses: loft-sh/create-vcluster@main - with: - name: pr-${{ github.event.pull_request.number }}-${{ github.sha }}-${{ github.run_id }} - auto-cleanup: true - - name: Deploy Application - run: kubectl apply -Rf ./kubernetes - - name: Wait for Deployment - run: kubectl rollout status deployments/my-app - - name: Run Tests - run: make e2e -``` - -**Explanation:** -1. The [Setup Loft](https://github.com/loft-sh/setup-loft) action is used to install the vCluster CLI and login using the provided `url` and `access-key`. -2. The [Create Virtual Cluster](https://github.com/loft-sh/create-vcluster) action is used to create a unique virtual cluster using information about the pull request. This will automatically configure the kube context for the following steps. Additionally, we have enabled the `auto-cleanup` option, which will delete the virtual cluster after the job completes. -3. The next step deploys the application using the runner provided `kubectl` and manifests located under `./kubernetes`. -4. Before running tests, we use `kubectl` to wait for the `my-app` deployment to become ready. -5. Finally we run the end-to-end tests. In this example we're using `make` to run tests, but the command should be customized for your testing framework. There's no need to delete the virtual cluster since the `auto-cleanup` option was used when creating the virtual cluster. From a21d93d321e2e902991baaf4904a7e5b448c128e Mon Sep 17 00:00:00 2001 From: Kurt Madel Date: Sat, 12 Oct 2024 12:33:24 -0400 Subject: [PATCH 08/11] Update github-actions-vclusters-pull-request-manual.mdx --- ...-actions-vclusters-pull-request-manual.mdx | 36 +++++++++---------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/platform/_partials/integrations/github-actions-vclusters-pull-request-manual.mdx b/platform/_partials/integrations/github-actions-vclusters-pull-request-manual.mdx index 555a6073c..ed5929873 100644 --- a/platform/_partials/integrations/github-actions-vclusters-pull-request-manual.mdx +++ b/platform/_partials/integrations/github-actions-vclusters-pull-request-manual.mdx @@ -7,21 +7,22 @@ on: pull_request: branches: - "main" + +env: + VCLUSTER_NAME: pr-${{ github.event.pull_request.number }}-${{ github.sha }}-${{ github.run_id }} + jobs: e2e: runs-on: ubuntu-latest steps: - name: Install vCluster CLI - uses: loft-sh/setup-vcluster@main - - name: Login to vCluster Platform instance - env: - LOFT_URL: ${{ secrets.LOFT_URL }} - ACCESS_KEY: ${{ secrets.ACCESS_KEY }} - run: vcluster login $LOFT_URL --access-key $ACCESS_KEY + uses: loft-sh/setup-vcluster@main + with: + url: ${{ secrets.VCLUSTER_PLATFORM_URL }} + # Specify your vCluster Platform access key here + access-key: ${{ secrets.VCLUSTER_PLATFORM_ACCESS_KEY }} - name: Create PR Virtual Cluster - env: - NAME: pr-${{ github.event.pull_request.number }}-${{ github.sha }}-${{ github.run_id }} - run: vcluster create $NAME --project default + run: vcluster platform create vcluster $VCLUSTER_NAME --project default - name: Deploy Application run: kubectl apply -Rf ./kubernetes - name: Wait for Deployment @@ -29,17 +30,14 @@ jobs: - name: Run Tests run: make e2e - name: Delete PR Virtual Cluster - env: - NAME: pr-${{ github.event.pull_request.number }}-${{ github.sha }}-${{ github.run_id }} - run: vcluster delete $NAME --project default + run: vcluster platform delete vcluster $VCLUSTER_NAME --project default ``` **Explanation:** -1. The [Setup vCluster Platform](https://github.com/loft-sh/setup-vcluster) action is used to install the vCluster CLI. -2. The `vcluster login` command is used to log in to the organization's vCluster Platform instance. Environment variables `LOFT_URL` and `ACCESS_KEY` are populated using [GitHub secrets](https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions). -3. The `vcluster create` command is used to create a unique virtual cluster using information about the pull request in the `default` project. This will automatically configure the kube context for the next steps. -4. The next step deploys the application using the runner provided `kubectl` and manifests located under `./kubernetes`. -5. Before running tests, we use `kubectl` to wait for the `my-app` deployment to become ready. -6. Now we run the end-to-end tests. In this example we're using `make` to run tests, but the command should be customized for your testing framework. -7. Finally, the `vcluster delete` command is used to delete the virtual cluster. +1. The [Setup vCluster Platform](https://github.com/loft-sh/setup-vcluster) action is used to install the vCluster CLI and log in to the organization's vCluster Platform instance. Environment variables `LOFT_URL` and `ACCESS_KEY` are populated using [GitHub secrets](https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions). +2. The `vcluster platform create vclsuter` command is used to create a unique virtual cluster using information about the pull request in the `default` project. This will automatically configure the kube context for the next steps. +3. The next step deploys the application using the runner provided `kubectl` and manifests located under `./kubernetes`. +4. Before running tests, we use `kubectl` to wait for the `my-app` deployment to become ready. +5. Now we run the end-to-end tests. In this example we're using `make` to run tests, but the command should be customized for your testing framework. +6. Finally, the `vcluster platform delete vcluster` command is used to delete the virtual cluster. From 5b99283634273f92bd4b272c48528598a7628c1d Mon Sep 17 00:00:00 2001 From: Kurt Madel Date: Sat, 12 Oct 2024 12:36:37 -0400 Subject: [PATCH 09/11] Update github-actions-vclusters-pull-request-use.mdx --- ...hub-actions-vclusters-pull-request-use.mdx | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/platform/_partials/integrations/github-actions-vclusters-pull-request-use.mdx b/platform/_partials/integrations/github-actions-vclusters-pull-request-use.mdx index 05a10baf3..6bf722b88 100644 --- a/platform/_partials/integrations/github-actions-vclusters-pull-request-use.mdx +++ b/platform/_partials/integrations/github-actions-vclusters-pull-request-use.mdx @@ -7,21 +7,21 @@ on: pull_request: branches: - "main" + jobs: e2e: runs-on: ubuntu-latest steps: - - name: Install vCluster CLI - uses: loft-sh/setup-vcluster@main - - name: Login to vCluster Platform instance - env: - LOFT_URL: ${{ secrets.LOFT_URL }} - ACCESS_KEY: ${{ secrets.ACCESS_KEY }} - run: vcluster login $LOFT_URL --access-key $ACCESS_KEY + - name: Setup vCluster Platform + uses: loft-sh/setup-vcluster@main + with: + url: ${{ secrets.VCLUSTER_PLATFORM_URL }} + # Specify your vCluster Platform access key here + access-key: ${{ secrets.VCLUSTER_PLATFORM_ACCESS_KEY }} - name: Create PR Virtual Cluster env: NAME: pr-${{ github.event.pull_request.number }}-${{ github.sha }}-${{ github.run_id }} - run: vcluster create $NAME --project default --upgrade + run: vcluster platform create vcluster $NAME --project default --upgrade - name: Deploy Application run: kubectl apply -Rf ./kubernetes - name: Wait for Deployment @@ -32,9 +32,8 @@ jobs: **Explanation:** -1. The [Setup vCluster Platform](https://github.com/loft-sh/setup-vcluster) action is used to install the vCluster CLI. -2. The `vcluster login` command is used to log in to the organization's vCluster Platform instance. Environment variables `LOFT_URL` and `ACCESS_KEY` are populated using [GitHub secrets](https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions). -3. The `vcluster create` command is used to create a unique virtual cluster using information about the pull request in the `default` project. This will automatically configure the kube context for the next steps. The `--upgrade` flag has been added to reuse the existing virtual cluster and upgrade it to the latest version. Additional flags may be used to control the desired virtual cluster version. -4. The next step deploys the application using the runner provided `kubectl` and manifests located under `./kubernetes`. -5. Before running tests, we use `kubectl` to wait for the `my-app` deployment to become ready. -6. Now we run the end-to-end tests. In this example we're using `make` to run tests, but the command should be customized for your testing framework. +1. The [Setup vCluster Platform](https://github.com/loft-sh/setup-vcluster) action is used to install the vCluster CLI and to log in to the organization's vCluster Platform instance. Environment variables `VCLUSTER_PLATFORM_URL` and `VCLUSTER_PLATFORM_ACCESS_KEY` are populated using [GitHub secrets](https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions). +2. The `vcluster platform create vcluster` command is used to create a unique virtual cluster using information about the pull request in the `default` project. This will automatically configure the kube context for the next steps. The `--upgrade` flag has been added to reuse the existing virtual cluster and upgrade it to the latest version. Additional flags may be used to control the desired virtual cluster version. +3. The next step deploys the application using the runner provided `kubectl` and manifests located under `./kubernetes`. +4. Before running tests, we use `kubectl` to wait for the `my-app` deployment to become ready. +5. Now we run the end-to-end tests. In this example we're using `make` to run tests, but the command should be customized for your testing framework. From 01ca6aa0c70adafdbff45a162ff813534492895a Mon Sep 17 00:00:00 2001 From: Kurt Madel Date: Sat, 12 Oct 2024 12:37:25 -0400 Subject: [PATCH 10/11] Update github-actions-vclusters-pull-request-manual.mdx --- .../github-actions-vclusters-pull-request-manual.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/_partials/integrations/github-actions-vclusters-pull-request-manual.mdx b/platform/_partials/integrations/github-actions-vclusters-pull-request-manual.mdx index ed5929873..fa377a27e 100644 --- a/platform/_partials/integrations/github-actions-vclusters-pull-request-manual.mdx +++ b/platform/_partials/integrations/github-actions-vclusters-pull-request-manual.mdx @@ -35,8 +35,8 @@ jobs: **Explanation:** -1. The [Setup vCluster Platform](https://github.com/loft-sh/setup-vcluster) action is used to install the vCluster CLI and log in to the organization's vCluster Platform instance. Environment variables `LOFT_URL` and `ACCESS_KEY` are populated using [GitHub secrets](https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions). -2. The `vcluster platform create vclsuter` command is used to create a unique virtual cluster using information about the pull request in the `default` project. This will automatically configure the kube context for the next steps. +1. The [Setup vCluster Platform](https://github.com/loft-sh/setup-vcluster) action is used to install the vCluster CLI and log in to the organization's vCluster Platform instance. Environment variables `VCLUSTER_PLATFORM_URL` and `VCLUSTER_PLATFORM_ACCESS_KEY` are populated using [GitHub secrets](https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions). +2. The `vcluster platform create vcluster` command is used to create a unique virtual cluster using information about the pull request in the `default` project. This will automatically configure the kube context for the next steps. 3. The next step deploys the application using the runner provided `kubectl` and manifests located under `./kubernetes`. 4. Before running tests, we use `kubectl` to wait for the `my-app` deployment to become ready. 5. Now we run the end-to-end tests. In this example we're using `make` to run tests, but the command should be customized for your testing framework. From f343d182183e04388acd26c1093c07b7ac22676e Mon Sep 17 00:00:00 2001 From: Kurt Madel Date: Sat, 12 Oct 2024 12:40:02 -0400 Subject: [PATCH 11/11] Update pull-requests.mdx --- platform/integrations/github-actions/pull-requests.mdx | 1 - 1 file changed, 1 deletion(-) diff --git a/platform/integrations/github-actions/pull-requests.mdx b/platform/integrations/github-actions/pull-requests.mdx index 458ebc4d1..9f821a53c 100644 --- a/platform/integrations/github-actions/pull-requests.mdx +++ b/platform/integrations/github-actions/pull-requests.mdx @@ -30,7 +30,6 @@ These examples show how to create and delete Virtual Clusters for pull requests. defaultValue="manual" values={[ {label: 'Basic', value: 'manual',}, - {label: 'Automatic Cleanup', value: 'automatic',}, {label: 'Reuse', value: 'use',}, ]}>