diff --git a/.github/workflows/cleanup.yml b/.github/workflows/cleanup.yml index 44e3c5add2..0fe833103d 100644 --- a/.github/workflows/cleanup.yml +++ b/.github/workflows/cleanup.yml @@ -1,10 +1,7 @@ name: push cleanup-bare-metal image on: - pull_request: - paths: - - .github/workflows/cleaup.yml - - packages/** + workflow_dispatch: env: container_registry: ghcr.io/edgelesssys diff --git a/.github/workflows/e2e_openssl.yml b/.github/workflows/e2e_openssl.yml index 81d55533fa..e7ca6bd1c9 100644 --- a/.github/workflows/e2e_openssl.yml +++ b/.github/workflows/e2e_openssl.yml @@ -1,13 +1,7 @@ name: e2e test on: - pull_request: - paths-ignore: - - dev-docs/** - - docs/** - - rfc/** - - tools/asciinema/** - - tools/vale/** + workflow_dispatch: jobs: test_matrix: diff --git a/.github/workflows/e2e_peerpods.yml b/.github/workflows/e2e_peerpods.yml new file mode 100644 index 0000000000..bfac9aa6bc --- /dev/null +++ b/.github/workflows/e2e_peerpods.yml @@ -0,0 +1,49 @@ +name: e2e peer-pods + +on: + workflow_dispatch: + inputs: + image-id: + description: "ID of the guest VM image to test (default: build a fresh image)" + required: false + pull_request: + paths: + - .github/workflows/e2e_peerpods.yml + - packages/test-peerpods.sh + - packages/by-name/cloud-api-adaptor/** + - packages/by-name/kata/** + - packages/by-name/image-podvm/** + - packages/nixos + +jobs: + test: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - uses: ./.github/actions/setup_nix + with: + githubToken: ${{ secrets.GITHUB_TOKEN }} + cachixToken: ${{ secrets.CACHIX_AUTH_TOKEN }} + - name: Login to Azure + uses: azure/login@a65d910e8af852a8061c627c456678983e180302 # v2.2.0 + with: + creds: ${{ secrets.CONTRAST_CI_INFRA_AZURE }} + - name: Test peer-pods + env: + azure_subscription_id: ${{ vars.AZURE_SUBSCRIPTION_ID }} + azure_image_id: ${{ inputs.image-id }} + azure_resource_group: contrast-ci + azure_location: germanywestcentral + CONTRAST_CACHE_DIR: "./workspace.cache" + run: | + ssh-keygen -t rsa -f ./infra/azure-peerpods/id_rsa -N "" + cat >infra/azure-peerpods/iam.auto.tfvars < infra/azure-peerpods-iam/just.auto.tfvars + echo "subscription_id = \"${azure_subscription_id}\"" >> infra/azure-peerpods-iam/just.auto.tfvars + nix run -L .#terraform -- -chdir=infra/azure-peerpods-iam init + nix run -L .#terraform -- -chdir=infra/azure-peerpods-iam apply --auto-approve + nix run -L .#terraform -- -chdir=infra/azure-peerpods-iam output -raw client_secret_env > infra/azure-peerpods/iam.auto.tfvars + ;; + *) + echo "Unsupported platform: {{ platform }}" + exit 1 + ;; + esac + # Create a CoCo-enabled AKS cluster. create platform=default_platform: #!/usr/bin/env bash @@ -197,11 +219,11 @@ create platform=default_platform: # Populate Terraform variables. echo "name_prefix = \"$azure_resource_group\"" > infra/azure-peerpods/just.auto.tfvars - echo "image_resource_group_name = \"$azure_resource_group\"" >> infra/azure-peerpods/just.auto.tfvars + echo "resource_group = \"$azure_resource_group\"" >> infra/azure-peerpods/just.auto.tfvars echo "subscription_id = \"$azure_subscription_id\"" >> infra/azure-peerpods/just.auto.tfvars nix run -L .#terraform -- -chdir=infra/azure-peerpods init - nix run -L .#terraform -- -chdir=infra/azure-peerpods apply + nix run -L .#terraform -- -chdir=infra/azure-peerpods apply --auto-approve ;; *) echo "Unsupported platform: {{ platform }}" @@ -330,12 +352,12 @@ destroy platform=default_platform: : ;; "AKS-PEER-SNP") - nix run -L .#terraform -- -chdir=infra/azure-peerpods destroy + nix run -L .#terraform -- -chdir=infra/azure-peerpods destroy --auto-approve # Clean-up cached image ids. rm -f ${CONTRAST_CACHE_DIR}/image-upload/*.image-id - az group delete --name "${azure_resource_group}_caa_cluster" --yes + az group delete --name "${azure_resource_group}" --yes ;; *) echo "Unsupported platform: {{ platform }}" diff --git a/packages/scripts.nix b/packages/scripts.nix index 830181a100..bb8fa527b1 100644 --- a/packages/scripts.nix +++ b/packages/scripts.nix @@ -69,7 +69,7 @@ subscriptionID = "''${subscriptionId}" location = "''${location}" resourceGroup = "''${resourceGroup}" - sharedImageGallery = "''${resourceGroup}_contrast" + sharedImageGallery = "''${resourceGroup//-/_}_contrast" sharingProfile = "private" EOF @@ -402,7 +402,9 @@ newContext=$(yq -r '.contexts.[0].name' "$1") declare -x newContext yq -i '.current-context = env(newContext)' "$mergedConfig" - mv "$mergedConfig" "''${KUBECONFIG_BAK%%:*}" + targetFile="''${KUBECONFIG_BAK%%:*}" + mkdir -p "$(dirname "$targetFile")" + mv "$mergedConfig" "$targetFile" ''; }; @@ -463,10 +465,6 @@ kustomizationFile="''${i#*=}" shift ;; - --workload-identity=*) - workloadIdentityFile="''${i#*=}" - shift - ;; --pub-key=*) pubKeyFile="''${i#*=}" shift @@ -482,7 +480,6 @@ cp -r ${pkgs.cloud-api-adaptor.src}/src/cloud-api-adaptor/install/* "$tmpdir" chmod -R +w "$tmpdir" cp "$kustomizationFile" "$tmpdir/overlays/azure/kustomization.yaml" - cp "$workloadIdentityFile" "$tmpdir/overlays/azure/workload-identity.yaml" cp "$pubKeyFile" "$tmpdir/overlays/azure/id_rsa.pub" kubectl apply -k "github.com/confidential-containers/operator/config/release?ref=v${pkgs.cloud-api-adaptor.version}" @@ -511,4 +508,14 @@ ]; text = builtins.readFile ./cleanup-images.sh; }; + + test-peerpods = writeShellApplication { + name = "test-peerpods"; + runtimeInputs = with pkgs; [ + just + azure-cli + kubectl + ]; + text = builtins.readFile ./test-peerpods.sh; + }; } diff --git a/packages/test-peerpods.sh b/packages/test-peerpods.sh new file mode 100644 index 0000000000..6f4126a972 --- /dev/null +++ b/packages/test-peerpods.sh @@ -0,0 +1,63 @@ +#!/usr/bin/env bash +# Copyright 2024 Edgeless Systems GmbH +# SPDX-License-Identifier: AGPL-3.0-only + +set -euo pipefail + +set -x + +if [ -z "${azure_image_id}" ]; then + nix run -L .#scripts.upload-image -- \ + --subscription-id="${azure_subscription_id:?}" \ + --location="${azure_location:?}" \ + --resource-group="${azure_resource_group:?}" +else + echo "image_id = \"${azure_image_id}\"" > infra/azure-peerpods/image_id.auto.tfvars +fi + + +cat >infra/azure-peerpods/just.auto.tfvars <