diff --git a/.github/workflows/e2e_aks_runtime.yml b/.github/workflows/e2e_aks_runtime.yml new file mode 100644 index 000000000..064e4a3cb --- /dev/null +++ b/.github/workflows/e2e_aks_runtime.yml @@ -0,0 +1,107 @@ +name: e2e test aks runtime + +on: + workflow_dispatch: + schedule: + - cron: "16 6 * * 6" # 6:16 on Saturdays + pull_request: + paths: + - e2e/aks-runtime/** + +env: + container_registry: ghcr.io/edgelesssys + azure_resource_group: contrast-ci + DO_NOT_TRACK: 1 + +jobs: + test: + runs-on: ubuntu-22.04 + permissions: + contents: read + packages: write + 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: Log in to ghcr.io Container registry + uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Create justfile.env + run: | + cat < justfile.env + container_registry=${{ env.container_registry }} + azure_resource_group=${{ env.azure_resource_group }} + EOF + - name: Get credentials for CI cluster + run: | + nix run .#just -- get-credentials + - name: Set sync environment + run: | + sync_ip=$(kubectl get svc sync -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo "SYNC_ENDPOINT=http://$sync_ip:8080" | tee -a "$GITHUB_ENV" + sync_uuid=$(kubectl get configmap sync-server-fifo -o jsonpath='{.data.uuid}') + echo "SYNC_FIFO_UUID=$sync_uuid" | tee -a "$GITHUB_ENV" + - name: Build and prepare deployments + run: | + nix shell .#just --command just coordinator initializer port-forwarder openssl cryptsetup service-mesh-proxy node-installer AKS-CLH-SNP + # steps taken from https://learn.microsoft.com/en-us/cli/azure/install-azure-cli-linux?pivots=apt#option-2-step-by-step-installation-instructions + - name: Install `az` with extensions + run: | + sudo apt-get update + sudo apt-get -y install apt-transport-https ca-certificates curl gnupg lsb-release + sudo mkdir -p /etc/apt/keyrings + curl -sLS https://packages.microsoft.com/keys/microsoft.asc | + gpg --dearmor | sudo tee /etc/apt/keyrings/microsoft.gpg > /dev/null + sudo chmod go+r /etc/apt/keyrings/microsoft.gpg + AZ_DIST=$(lsb_release -cs) + + sudo tee /etc/apt/sources.list.d/azure-cli.sources <`. +func KataPolicyGen(resourcePath string) error { + cmd := exec.Command("az", "confcom", "katapolicygen", "--yaml", resourcePath) + cmd.Stderr = os.Stderr + return cmd.Run() +} diff --git a/e2e/internal/contrasttest/contrasttest.go b/e2e/internal/contrasttest/contrasttest.go index 2718f58fc..249bf3c04 100644 --- a/e2e/internal/contrasttest/contrasttest.go +++ b/e2e/internal/contrasttest/contrasttest.go @@ -52,7 +52,7 @@ type ContrastTest struct { // New creates a new contrasttest.T object bound to the given test. func New(t *testing.T, imageReplacements, namespaceFile string, platform platforms.Platform, skipUndeploy bool) *ContrastTest { return &ContrastTest{ - Namespace: makeNamespace(t), + Namespace: MakeNamespace(t), WorkDir: t.TempDir(), ImageReplacementsFile: imageReplacements, Platform: platform, @@ -372,7 +372,8 @@ func (ct *ContrastTest) FactorPlatformTimeout(timeout time.Duration) time.Durati } } -func makeNamespace(t *testing.T) string { +// MakeNamespace creates a namespace string using a given *testing.T. +func MakeNamespace(t *testing.T) string { buf := make([]byte, 4) re := regexp.MustCompile("[a-z0-9-]+") n, err := rand.Reader.Read(buf) diff --git a/flake.nix b/flake.nix index bf61d2b5e..d22f74496 100644 --- a/flake.nix +++ b/flake.nix @@ -31,6 +31,10 @@ overlays = [ (import ./overlays/nixpkgs.nix) ]; config.allowUnfree = true; config.nvidia.acceptLicense = true; + # TODO(miampf): REMOVE AGAIN ONCE UNNEEDED + config.permittedInsecurePackages = [ + "openssl-1.1.1w" + ]; }; inherit (pkgs) lib; treefmtEval = treefmt-nix.lib.evalModule pkgs ./treefmt.nix; diff --git a/overlays/nixpkgs.nix b/overlays/nixpkgs.nix index 84db71bc9..b4f4fdeb6 100644 --- a/overlays/nixpkgs.nix +++ b/overlays/nixpkgs.nix @@ -1,7 +1,61 @@ # Copyright 2024 Edgeless Systems GmbH # SPDX-License-Identifier: AGPL-3.0-only -final: prev: { +final: prev: +# TODO(miampf): Remove unneccessary block once https://github.com/NixOS/nixpkgs/pull/345326 is merged into unstable nixpkgs +let + # Builder for Azure CLI extensions. Extensions are Python wheels that + # outside of nix would be fetched by the CLI itself from various sources. + mkAzExtension = + { + pname, + url, + sha256, + description, + ... + }@args: + prev.python3.pkgs.buildPythonPackage ( + { + format = "wheel"; + src = prev.fetchurl { inherit url sha256; }; + meta = { + inherit description; + inherit (prev.azure-cli.meta) platforms maintainers; + homepage = "https://github.com/Azure/azure-cli-extensions"; + changelog = "https://github.com/Azure/azure-cli-extensions/blob/main/src/${pname}/HISTORY.rst"; + license = prev.lib.licenses.mit; + sourceProvenance = [ prev.lib.sourceTypes.fromSource ]; + } // args.meta or { }; + } + // (removeAttrs args [ + "url" + "sha256" + "description" + "meta" + ]) + ); + + confcom = mkAzExtension rec { + pname = "confcom"; + version = "1.0.0"; + url = "https://azcliprod.blob.core.windows.net/cli-extensions/confcom-${version}-py3-none-any.whl"; + sha256 = "73823e10958a114b4aca84c330b4debcc650c4635e74c568679b6c32c356411d"; + description = "Microsoft Azure Command-Line Tools Confidential Container Security Policy Generator Extension"; + nativeBuildInputs = [ prev.autoPatchelfHook ]; + buildInputs = [ prev.openssl_1_1 ]; + propagatedBuildInputs = with prev.python3Packages; [ + pyyaml + deepdiff + docker + tqdm + ]; + postInstall = '' + chmod +x $out/${prev.python3.sitePackages}/azext_confcom/bin/genpolicy-linux + ''; + meta.maintainers = with prev.lib.maintainers; [ miampf ]; + }; +in +{ # Use when a version of Go is needed that is not available in the nixpkgs yet. # go_1_xx = prev.go_1_xx.overrideAttrs (finalAttrs: _prevAttrs: { # version = ""; @@ -13,7 +67,10 @@ final: prev: { # Add the required extensions to the Azure CLI. azure-cli = prev.azure-cli.override { - withExtensions = with final.azure-cli.extensions; [ aks-preview ]; + withExtensions = with final.azure-cli.extensions; [ + aks-preview + confcom + ]; }; # Use a newer uplosi that has fixes for private galleries. diff --git a/packages/by-name/contrast/package.nix b/packages/by-name/contrast/package.nix index 1326394ea..1c84eee50 100644 --- a/packages/by-name/contrast/package.nix +++ b/packages/by-name/contrast/package.nix @@ -26,8 +26,6 @@ let tags = [ "e2e" ]; - ldflags = [ "-s" ]; - subPackages = [ "e2e/genpolicy" "e2e/getdents" @@ -38,6 +36,7 @@ let "e2e/workloadsecret" "e2e/volumestatefulset" "e2e/regression" + "e2e/aks-runtime" ]; };