Commit Graph

1661 Commits

Author SHA1 Message Date
Fabiano Fidêncio
e782d1ad50 ci: k8s: Test experimental_force_guest_pull
Now that we have added the ability to deploy kata-containers with
experimental_force_guest_pull configured, let's make sure we test it to
avoid any kind of regressions.

Signed-off-by: Fabiano Fidêncio <ffidencio@nvidia.com>
2025-10-10 20:08:10 +02:00
Fabiano Fidêncio
1bc89d09ae tests: Consider SNAPSHOTTER in the cluster name
Otherwise we have no way to differentiate running tests on qemu-coco-dev
with different snapshotters.

Signed-off-by: Fabiano Fidêncio <ffidencio@nvidia.com>
2025-10-10 20:08:10 +02:00
Fabiano Fidêncio
a1f90fe350 tests: k8s: Unify k8s TEE tests
There's no reason to have the code duplication between the SNP / TDX
tests for CoCo, as those are basically using the same configuration
nowadays.

Note that for the TEEs case, as the nydus-snapshotter is deployed by the
admin, once, instead of deploying it on every run ... I'm actually
removing the nydus-snapshotter steps so we make it clear that those
steps are not performed by the CI.

Signed-off-by: Fabiano Fidêncio <ffidencio@nvidia.com>
2025-10-10 09:51:59 +02:00
Dan Mihai
364d3cded0 tests: k8s-nested-configmap-secret policy
Add auto-generated agent policy in k8s-nested-configmap-secret.bats.

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2025-10-08 23:37:54 +00:00
Fabiano Fidêncio
544f688104 tests: Add ability to deploy vanilla k8s with erofs
As done in the previous commit, let's expand the vanilla k8s deployment
to also allow the erofs host side configuration.

Signed-off-by: Fabiano Fidêncio <ffidencio@nvidia.com>
2025-10-08 10:34:09 +02:00
Fabiano Fidêncio
3ac6579ca6 tests: Add support for deploying vanilla k8s
We already have support for deploying a few flavours of k8s that are
required for different tests we perform.

Let's also add the ability to deploy vanilla k8s, as that will be very
useful in the next commits in this series.

Signed-off-by: Fabiano Fidêncio <ffidencio@nvidia.com>
2025-10-08 10:34:09 +02:00
Fabiano Fidêncio
287db1865f tests: Relax regex used to install containerd
Let's make sure that we can get non-official releases as well, otherwise
we won't be able to test a coming release of containerd, to know whether
it solves issues that we face or not, before it's actually released.

Signed-off-by: Fabiano Fidêncio <ffidencio@nvidia.com>
2025-10-08 10:34:09 +02:00
Dan Mihai
08272ab673 Merge pull request #11884 from kata-containers/sprt/priv-test
tests/k8s: Add test for privileged containers
2025-10-07 19:18:06 -07:00
Dan Mihai
650863039b tests: k8s-volume: auto-generate policy
Auto-generate the agent policy, instead of using the insecure
"allow all" policy.

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2025-10-07 23:35:06 +02:00
Dan Mihai
5ed76b3c91 tests: k8s-volume: retry failed exec
Use grep_pod_exec_output to retry possible failing "kubectl exec"
commands. Other tests have been hitting such errors during CI in
the past.

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2025-10-07 23:35:06 +02:00
Aurélien Bombo
6e451e3da0 tests/k8s: Add test for privileged containers
This adds an integration test to verify that privileged containers work
properly when deploying Kata with kata-deploy.

This is a follow-up to #11878.

Signed-off-by: Aurélien Bombo <abombo@microsoft.com>
2025-10-07 09:59:05 -05:00
Fabiano Fidêncio
6f17125ea4 tests: Allow using the new way to deploy nydus-snapshotter
This allows us to stop setting up the snapshotter ourselves, and just
rely con kata-deploy to do so.

Signed-off-by: Fabiano Fidêncio <ffidencio@nvidia.com>
2025-10-07 10:32:46 +02:00
Fabiano Fidêncio
e1269afe8a tests: Only use Authorization when GH_TOKEN is available
The code, how it was, would lead to the following broke command:
`--header "Authorization: Bearer: "`

Let's only expand that part of the command if ${GH_TOKEN} is passed,
otherwise we don't even bother adding it.

Signed-off-by: Fabiano Fidêncio <ffidencio@nvidia.com>
2025-10-07 10:32:46 +02:00
Dan Mihai
5e46f814dd Merge pull request #11832 from kata-containers/sprt/dev-hostpath
runtime: Simplify mounting guest devices when using hostPath volumes
2025-10-06 12:36:36 -07:00
Manuel Huber
4b7c1db064 ci: Add test case for openvpn
Introduce new test case which verifies that openvpn clients and servers
can run as Kata pods and can successfully establish a connection.
Volatile certificates and keys are generated by an initialization
container and injected into the client and server containers.
This scenario requires TUN/TAP support for the UVM kernel.

Signed-off-by: Manuel Huber <mahuber@microsoft.com>
Co-authored-by: Manuel Huber <manuelh@nvidia.com>
2025-10-02 11:40:49 +02:00
Manuel Huber
34ecb11b35 tests: ease add_allow_all_policy_to_yaml if case
No need to die when a Kind that does not require a policy annotation is
found in a pod manifest. Print an informational message instead.

Signed-off-by: Manuel Huber <mahuber@microsoft.com>
2025-10-02 11:40:49 +02:00
Aurélien Bombo
a9fc501c08 check-spelling: Add hostPath to dictionary
Manually added "hostPath" to main.txt then regenerated the dictionary
with `./kata-spell-check.sh make-dict`.

Signed-off-by: Aurélien Bombo <abombo@microsoft.com>
2025-10-01 15:32:21 -05:00
Aurélien Bombo
c7a478662f check-spelling: Run make-dict
This simply ran `./kata-spell-check.sh make-dict` as documented in [1].
Unclear why it leads to changes - maybe it hadn't been run in a while.

[1] https://github.com/kata-containers/kata-containers/tree/main/tests/cmd/check-spelling#create-the-master-dictionary-files

Signed-off-by: Aurélien Bombo <abombo@microsoft.com>
2025-10-01 15:32:21 -05:00
Aurélien Bombo
5c21b1faf3 runtime: Simplify mounting guest devices when using hostPath volumes
This change crystallizes and simplifies the current handling of /dev
hostPath mounts with virtually no functional change.

Before this change:

 - If a mount DESTINATION is in /dev and it is a non-regular file on the HOST,
   the shim passes the OCI bind mount as is to the guest (e.g.
   /dev/kmsg:/dev/kmsg). The container rightfully sees the GUEST device.

 - If the mount DESTINATION does not exist on the host, the shim relies on
   k8s/containerd to automatically create a directory (ie. non-regular file) on
   the HOST. The shim then also passes the OCI bind mount as is to the guest.  The
   container rightfully sees the GUEST device.

 - For other /dev mounts, the shim passes the device major/minor to the guest
   over virtio-fs. The container rightfully sees the GUEST device.

After this change:

 - If a mount SOURCE is in /dev and it is a non-regular file on the HOST,
   the shim passes the OCI bind mount as is to the guest. The container
   rightfully sees the GUEST device.

 - The shim does not anymore rely on k8s/containerd to create missing mount
   directories. Instead it explicitely handles missing mount SOURCES, and
   treats them like the previous bullet point.

 - The shim no longer uses virtio-fs to pass /dev device major/minor to the
   guest, instead it passes the OCI bind mount as is.

Signed-off-by: Aurélien Bombo <abombo@microsoft.com>
2025-10-01 15:32:21 -05:00
Aurélien Bombo
20c60b21bd Merge pull request #11839 from Sumynwa/sumsharma/agent-ctl-vm-container
agent-ctl: Add fs sharing using virtio-fs when booting a pod vm.
2025-09-30 15:45:10 -05:00
Xuewei Niu
ca11a7387d Merge pull request #11636 from burgerdev/darwin-ci
ci: add genpolicy build for Darwin
2025-09-30 13:52:39 +08:00
Aurélien Bombo
575381cb7e Merge pull request #11846 from kata-containers/sprt/reinstate-mariner
Revert "ci: temporarily avoid using the Mariner Host image"
2025-09-29 15:49:53 -05:00
Aurélien Bombo
693a1461d2 tests: policy: Set oci_version to 1.2.0 for Mariner
Mariner recently upgraded to containerd 2.0.

Signed-off-by: Aurélien Bombo <abombo@microsoft.com>
2025-09-29 12:14:51 -05:00
Aurélien Bombo
756f3a73df Revert "ci: temporarily avoid using the Mariner Host image"
This reverts commit e8405590c1.

Signed-off-by: Aurélien Bombo <abombo@microsoft.com>
2025-09-29 12:14:51 -05:00
Markus Rudy
369124b180 ci: build genpolicy on darwin
genpolicy is a developer tool that should be usable on MacOS. Adding it
to the darwin CI job ensures that it can still be built after changes.

On an Apple M2, the output of `uname -m` is `arm64`, which is why a new
case is needed in the arch_to_* functions.

We're not going to cross-compile binaries on darwin, so don't install
any additional Rust targets.

Fixes: #11635

Signed-off-by: Markus Rudy <mr@edgeless.systems>
2025-09-29 09:48:32 +02:00
Sumedh Alok Sharma
c94e65e982 agent-ctl: Add fs sharing using virtio-fs when booting a pod vm.
This commit adds changes to enable fs sharing between host/guest
using virtio-fs when booting a pod VM for testing. This primarily
enables sharing container rootfs for testing container lifecycle
commands.

Summary of changes is as below:
- adds minimal virtiofsd code to start userspace daemon (based on
`runtime-rs/crates/resource/src/share_fs`)
- adds the virtiofs device to the test vm
- prepares and mounts the container rootfs on host
- modifies container storage & oci specs

Signed-off-by: Sumedh Alok Sharma <sumsharma@microsoft.com>
2025-09-29 07:20:42 +00:00
Markus Rudy
63515242c5 tests: fix shellcheck findings in install_rust.sh
Fixing the shellcheck issues first so that they are not coupled to the
subsequent commit introducing Darwin support to the script.

Signed-off-by: Markus Rudy <mr@edgeless.systems>
2025-09-28 12:01:23 +02:00
Dan Mihai
ef0f8723cf tests: k8s-nginx-connectivity: auto-generated policy
Auto-generate policy for nginx-deployment pods, instead of hard-coding
the "allow all" policy.

Note that the `busybox_pod` - created using `kubectl run` - still
doesn't have an Init Data annotation, so it is using the default policy
built into the Kata Guest rootfs image file.

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2025-09-26 20:24:13 +00:00
Dan Mihai
8943f0d9b2 tests: k8s-liveness-probes: auto-generate policy
Auto-generate agent policy in k8s-liveness-probes.bats, instead of using
the non-confidential "allow all" policy.

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2025-09-26 20:23:12 +00:00
Dan Mihai
d9bc7e2b76 tests: k8s-credentials-secrets: auto-generate policy
Auto-generate the agent policy for pod-secret-env.yaml, using
"genpolicy -c inject_secret.yaml".

Support for passing Secret specification files as "-c" arguments of
genpolicy has been added when fixing #10033 with PR #10986.

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2025-09-26 20:23:12 +00:00
Dan Mihai
32453a576f Merge pull request #11845 from microsoft/danmihai/policy-tests-upstream
tests: k8s: auto-generate policy for additional tests
2025-09-26 11:32:23 -07:00
Aurélien Bombo
282e20bc37 tests/k8s: Add set -euo pipefail to lib.sh
-o pipefail in particular ensures that exec_host() returns the right exit
code.

-u is also added for good measure. Note that $BATS_TEST_DIRNAME is set by
bats so we move its usage inside the function.

Signed-off-by: Aurélien Bombo <abombo@microsoft.com>
2025-09-25 23:05:05 -05:00
Hyounggyu Choi
c961f70b7e ci: Remove DL3007 ignore comment for base image
The Hadolint warning DL3007 (pin the version explicitly) is no
longer applicable.

We have updated the base image to use a specific version
digest, which satisfies the linter's requirement for reproducible
builds. This commit removes the corresponding inline ignore comment.

Signed-off-by: Hyounggyu Choi <Hyounggyu.Choi@ibm.com>
2025-09-25 15:46:39 +02:00
Dan Mihai
fe5ee803a8 tests: k8s-sysctls.bats auto-generated policy
Auto-generate policy in k8s-sysctls.bats, instead of hard-coding the
"allow all" policy.

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2025-09-25 13:03:19 +00:00
Dan Mihai
9d3d3c9b0f tests: k8s-pod-quota.bats auto-generated policy
Auto-generate policy in k8s-pod-quota.bats, instead of hard-coding the
"allow all" policy.

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2025-09-25 13:03:19 +00:00
Dan Mihai
0008ecd18b tests: k8s-inotify.bats auto-generated policy
Auto-generate policy for k8s-inotify.bats, instead of hard-coding the
"allow all" policy.

Fixes: #8889

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2025-09-25 13:03:19 +00:00
Dan Mihai
711e7b8014 tests: k8s-hostname.bats auto-generated policy
Auto-generate policy for k8s-hostname.bats, instead of hard-coding the
"allow all" policy.

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2025-09-25 13:03:19 +00:00
Dan Mihai
566e1abb09 tests: k8s-empty-dirs.bats generated policy
Auto-generated policy for k8s-empty-dirs.bats, instead of hard-coding
the "allow all" policy.

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2025-09-25 13:03:19 +00:00
Hyounggyu Choi
e9653eae6e GHA: Pin Alpine to 3.20 for tee-unencrypted image
We recently hit the following error during build:

```
RUN ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -P ""
OpenSSL version mismatch. Built against 3050003f, you have 30500010
```

This happened because `alpine:latest` moved forward and the `ssh-keygen`
binary in the base image was compiled against a newer OpenSSL version
that is not available at runtime.
Pinning the base image to the stable release (3.20) avoids the mismatch
and ensures consistent builds.

Signed-off-by: Hyounggyu Choi <Hyounggyu.Choi@ibm.com>
2025-09-25 11:49:04 +02:00
Sumedh Alok Sharma
1be3785fa0 tests: agent-ctl: Fix cleanup for testing with qemu
This change fixes clean up logic when running tests
in a vm booted with qemu wrt to qmp.sock & console.sock
files, and no longer assumes any path for them.

Signed-off-by: Sumedh Alok Sharma <sumsharma@microsoft.com>
2025-09-25 07:30:17 +00:00
Dan Mihai
e9f69ce321 tests: k8s: add test duration information
Log how much time "kubectl get pods" and each test case are taking,
just in case that will reveal unusually slow test clusters, and/or
opportunities to improve tests.

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2025-09-23 19:24:38 +00:00
Steve Horsman
bcd0c0085c Merge pull request #11821 from mythi/coco-guest-update
Confidential containers version updates
2025-09-23 12:45:38 +01:00
Mikko Ylinen
e878d4a90a versions: bump guest-components and trustee for CoCo v0.16.0
Pick the latest CoCo components targeted for the next release.

Signed-off-by: Mikko Ylinen <mikko.ylinen@intel.com>
2025-09-23 12:38:32 +03:00
Fupan Li
a27009012c Merge pull request #11834 from Apokleos/fix-initdata-whitespace
CI: Keep base64 output of initdata annotation is a single line
2025-09-23 15:16:35 +08:00
Alex Lyn
f254eeb0e9 CI: Keep base64 output is a single line
This commit addresses an issue where base64 output, when used with a
default configuration, would introduce newlines, causing decoding to
fail on the runtime.

The fix ensures base64 output is a single, continuous line using the -w0
flag. This guarantees the encoded string is a valid Base64 sequence,
preventing potential runtime errors caused by invalid characters.

Note that: When you use the base64 command without any parameters, it
typically automatically adds newlines to the output, usually every 76 chars.

In contrast, base64 -w0 explicitly tells the command not to add any
newlines (-w for wrap, and 0 for a width of zero), which results in a
continuous string with no whitespace.

This is a critical distinction because if you pass a Base64 string with
newlines to a runtime, it may be treated as an invalid string, causing
the decoding process to fail.

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2025-09-23 11:58:53 +08:00
Dan Mihai
524bf66cbc tests: k8s-credentials-secrets: retry on exec error
Retry after "kubectl exec" failure, instead of aborting the test
immediately.

Example of recent error:

https://github.com/kata-containers/kata-containers/actions/runs/17828061309/job/50693999052?pr=11822

not ok 1 Credentials using secrets
 (in test file k8s-credentials-secrets.bats, line 59)
  `kubectl exec $pod_name -- "${pod_exec_command[@]}" | grep -w "username"' failed

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2025-09-19 17:45:05 +00:00
Dan Mihai
01c7949bfd tests: k8s-number-cpus: retry on kubectl exec error
Retry after "kubectl exec" failure, instead of aborting the test
immediately.

Example of recent error:

https://github.com/kata-containers/kata-containers/actions/runs/17813996758/job/50644372056

not ok 1 Check number of cpus
...
error: Internal error occurred: error sending request: Post
"https://10.224.0.4:10250/exec/kata-containers-k8s-tests/cpu-test/c1?command=sh&command=-c&command=
cat+%!F(MISSING)proc%!F(MISSING)cpuinfo+%!C(MISSING)grep+processor%!C(MISSING)wc+-l&error=1&output=1": EOF

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2025-09-19 17:44:55 +00:00
Dan Mihai
91c3804959 tests: k8s: add container_exec_with_retries()
Add container_exec_with_retries(), useful for retrying if needed
commands similar to:

kubectl exec <pod_name> -c <container_name> -- <command>

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2025-09-19 17:42:59 +00:00
Dan Mihai
eec6c8b0c4 tests: k8s: retry after kubectl exec error
Some of the k8s tests were already retrying if `kubectl exec` succeeded
but produced empty output. Perform the same retries on `kubectl exec`
error exit code too, instead of aborting the test immediately.

Example of recent exec error:

https://github.com/kata-containers/kata-containers/actions/runs/17813996758/job/50644372056

not ok 1 Check number of cpus
...
error: Internal error occurred: error sending request: Post
"https://10.224.0.4:10250/exec/kata-containers-k8s-tests/cpu-test/c1?command=sh&command=-c&command=
cat+%!F(MISSING)proc%!F(MISSING)cpuinfo+%!C(MISSING)grep+processor%!C(MISSING)wc+-l&error=1&output=1": EOF

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2025-09-19 15:43:39 +00:00
Dan Mihai
e2992b51ad tests: k8s-job debug information
Log the output of "kubectl logs", to hopefully help understand test
failures similar to:

https://github.com/kata-containers/kata-containers/actions/runs/17709473340/job/50326984605?pr=11753

not ok 1 Run a job to completion
 (in test file k8s-job.bats, line 37)
   `kubectl logs "$pod_name" | grep "$pi_number"' failed

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2025-09-16 22:36:31 +02:00