Skip to content

Commit bd374eb

Browse files
committed
CI: test Kubernetes port forwarder
Signed-off-by: Akihiro Suda <[email protected]>
1 parent 1781032 commit bd374eb

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ jobs:
296296
- archlinux.yaml
297297
- opensuse.yaml
298298
- docker.yaml
299+
- k8s.yaml
299300
- ../hack/test-templates/alpine-iso-9p-writable.yaml # Covers alpine-iso.yaml
300301
- ../hack/test-templates/net-user-v2.yaml
301302
- ../hack/test-templates/test-misc.yaml # TODO: merge net-user-v2 into test-misc

hack/test-templates.sh

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ declare -A CHECKS=(
4444
["systemd-strict"]="1"
4545
["mount-home"]="1"
4646
["container-engine"]="1"
47+
["k8s"]=""
4748
["restart"]="1"
4849
# snapshot tests are too flaky (especially with archlinux)
4950
["snapshot-online"]=""
@@ -63,6 +64,12 @@ declare -A CHECKS=(
6364
["ssh-over-vsock"]=""
6465
)
6566

67+
clear_checks() {
68+
for k in "${!CHECKS[@]}"; do
69+
CHECKS["$k"]=""
70+
done
71+
}
72+
6673
case "$NAME" in
6774
"default")
6875
# CI failure:
@@ -76,9 +83,10 @@ case "$NAME" in
7683
CHECKS["container-engine"]=
7784
[ "$NAME" = "alpine-iso-9p-writable" ] && CHECKS["mount-path-with-spaces"]="1"
7885
;;
79-
"k3s")
80-
ERROR "File \"$FILE\" is not testable with this script"
81-
exit 1
86+
"k0s" | "k3s" | "k8s")
87+
# Disable all checks except k8s
88+
clear_checks
89+
CHECKS["k8s"]="1"
8290
;;
8391
"fedora")
8492
WARNING "Relaxing systemd tests for fedora (For avoiding CI failure)"
@@ -431,6 +439,18 @@ if [[ -n ${CHECKS["container-engine"]} ]]; then
431439
fi
432440
fi
433441

442+
if [[ -n ${CHECKS["k8s"]} ]]; then
443+
INFO "Testing Kubernetes"
444+
set -x
445+
limactl shell "$NAME" kubectl get nodes -o wide
446+
limactl shell "$NAME" kubectl create deployment nginx --image="${nginx_image}"
447+
limactl shell "$NAME" kubectl create service nodeport nginx --node-port=31080 --tcp=80:80
448+
timeout 3m bash -euxc "until curl -f --retry 30 --retry-connrefused http://127.0.0.1:31080; do sleep 3; done"
449+
limactl shell "$NAME" kubectl delete service nginx
450+
limactl shell "$NAME" kubectl delete deployment nginx
451+
set +x
452+
fi
453+
434454
if [[ -n ${CHECKS["port-forwards"]} ]]; then
435455
INFO "Testing port forwarding rules using netcat"
436456
set -x

templates/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Container orchestration:
5757
- [`faasd`](./faasd.yaml): [Faasd](https://docs.openfaas.com/deployment/edge/)
5858
- [`k0s`](./k0s.yaml): [k0s](https://k0sproject.io/) Zero Friction Kubernetes
5959
- [`k3s`](./k3s.yaml): Kubernetes via k3s
60-
- [`k8s`](./k8s.yaml): Kubernetes via kubeadm
60+
- [`k8s`](./k8s.yaml): Kubernetes via kubeadm
6161
- [`experimental/u7s`](./experimental/u7s.yaml): [Usernetes](https://github.com/rootless-containers/usernetes): Rootless Kubernetes
6262

6363
Optional feature enablers:

0 commit comments

Comments
 (0)