Skip to content

Commit a1f63f9

Browse files
authored
Add k8s join and disjoin test cases (#16141)
What is the motivation for this PR? Test the sonic device join k8s cluster and disjoin k8s cluster. How did you do it? Setup a single master node cluster on the server of testbed, make sonic device join the cluster and disjoin the cluster to check if it works, deploy a daemonset to check if the pods are able to run on sonic. How did you verify/test it? Run it in the KVM testbed and physical testbed, it works Any platform specific information? No, should be good for all platform Supported testbed topology if it's a new test case? Any Documentation In the PR md file.
1 parent df7cfc4 commit a1f63f9

File tree

3 files changed

+503
-0
lines changed

3 files changed

+503
-0
lines changed

tests/common/plugins/conditional_mark/tests_mark_conditions.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,6 +1346,15 @@ k8s/test_join_available_master.py:
13461346
conditions:
13471347
- "asic_type in ['vs']"
13481348

1349+
#######################################
1350+
##### kubesonic #####
1351+
#######################################
1352+
kubesonic/test_k8s_join_disjoin.py:
1353+
skip:
1354+
reason: "kubesonic feature is not supported in slim image"
1355+
conditions:
1356+
- "hwsku in ['Arista-7050-QX-32S', 'Arista-7050-Q16S64', 'Arista-7060CX-32S-C32', 'Arista-7060CX-32S-C32-T1', 'Arista-7060CX-32S-Q32', 'Arista-7060CX-32S-D48C8', 'Arista-7050QX-32S-S4Q31', 'Arista-7050QX32S-Q32', 'Celestica-E1031-T48S4']"
1357+
13491358
#######################################
13501359
##### lldp #####
13511360
#######################################

tests/kubesonic/kubesonic_test.md

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# KubeSonic Test Plan
2+
3+
## Rev 0.1
4+
5+
- [Revision](#revision)
6+
- [Overview](#overview)
7+
- [Scope](#scope)
8+
- [Testbed](#testbed)
9+
- [k8s version](#k8s-version)
10+
- [Supported hwsku](#supported-hwsku)
11+
- [Topology](#topology)
12+
- [Test SONIC DUT join and disjoin from k8s cluster](#test-sonic-dut-join-and-disjoin-from-k8s-cluster)
13+
- [Pre-requisite steps](#pre-requisite-steps)
14+
- [Install Minikube and start Minikube](#install-minikube-and-start-minikube)
15+
- [Update the server kernel parameter](#update-the-server-kernel-parameter)
16+
- [Update the kubelet configmap](#update-the-kubelet-configmap)
17+
- [Deploy the daemonset](#deploy-the-daemonset)
18+
- [Prepare the cert](#prepare-the-cert)
19+
- [Prepare Minikube VIP DNS](#prepare-minikube-vip-dns)
20+
- [[Case-1] Join the SONIC DUT to the Minikube cluster and check](#case-1-join-the-sonic-dut-to-the-minikube-cluster-and-check)
21+
- [[Case-2] Deploy daemonset pod on the SONIC DUT and check](#case-2-deploy-daemonset-pod-on-the-sonic-dut-and-check)
22+
- [[Case-3] Remove daemonset pod from the SONIC DUT and check](#case-3-remove-daemonset-pod-from-the-sonic-dut-and-check)
23+
- [[Case-4] Disjoin the SONIC DUT from the Minikube cluster and check](#case-4-disjoin-the-sonic-dut-from-the-minikube-cluster-and-check)
24+
- [Teardown](#teardown)
25+
- [Clean up](#clean-up)
26+
- [Keep the Minikube cluster running](#keep-the-minikube-cluster-running)
27+
- [File Lock to avoid Minikube cluster setup conflict](#file-lock-to-avoid-minikube-cluster-setup-conflict)
28+
29+
30+
## Revision
31+
32+
| Rev | Date | Author | Change Description |
33+
|:---:|:-----------:|:---------------------:|:----------------------------------:|
34+
| 0.1 | 12/25/2024 | Yun | Initial version |
35+
36+
## Overview
37+
38+
The purpose is to test the functionality of k8s feature on the SONIC DUT. The tests expect that SONIC can join a k8s cluster and k8s daemonset pod can run on SONIC.
39+
40+
## Scope
41+
42+
### Testbed
43+
44+
The test is able to run on SONIC KVM testbed and SONIC DUT testbed
45+
46+
### K8s version
47+
48+
This case only runs for k8s v1.22.2
49+
50+
### Supported hwsku
51+
52+
Arista-7060CX/Arista-7050QX/Arista-7050-Q16S64/Celestica-E1031-T48S4 is not supported, other hwskus should be supported
53+
54+
## Topology
55+
56+
Supported any topology
57+
58+
## Test SONIC DUT join and disjoin from k8s cluster
59+
60+
### Pre-requisite steps
61+
62+
Use Minikube to startup a single master k8s cluster on the server where the ptf container and simulating neighbor containers are running on in the testbed.
63+
64+
#### Install Minikube and start Minikube
65+
- Install Minikube and start Minikube on the server of the testbed by following the instructions in the [Minikube installation guide](https://minikube.sigs.k8s.io/docs/start/).
66+
67+
#### Update the server kernel parameter
68+
- Update the server kernel parameter by running the following command ```sysctl fs.protected_regular=0```. [Check the issue here](https://github.com/kubernetes/minikube/issues/7053)
69+
70+
#### Update the kubelet configmap
71+
- The Minikube cluster's pki cert root directory is `/var/lib/minikube/certs`, SONIC DUT's kubelet is using `/etc/kubernetes/pki` as the pki cert root directory. So need to update the kubelet configmap.
72+
73+
#### Deploy the daemonset
74+
- Deploy the daemonset with nodeSelector `deployDaemonset=true` so that we can control whether the daemonset pod runs on the SONIC DUT by labeling node and unlabeling node.
75+
76+
#### Prepare the cert
77+
- SONIC DUT will need a cert to join the k8s cluster, so need to prepare the cert for it. Copy the cert from the Minikube cluster to the SONIC DUT.
78+
79+
#### Prepare Minikube VIP DNS
80+
- Minikube cluster's VIP is ```control-plane.minikube.internal```, SONIC DUT will not resolve this VIP by default, so need to add the VIP to the SONIC DUT's `/etc/hosts` file.
81+
82+
### [Case-1] Join the SONIC DUT to the Minikube cluster and check
83+
84+
- ```sudo config kube server ip <server_ip> && sudo config kube server disable off``` to trigger the SONIC DUT to join the k8s cluster, check if the SONIC DUT is in the k8s cluster by running `kubectl get nodes` on the server.
85+
86+
### [Case-2] Deploy daemonset pod on the SONIC DUT and check
87+
- ```kubectl label node <node_name> deployDaemonset=true``` to control the k8s daemonset pod to run on the SONIC DUT, check if the pod is running on the SONIC DUT by running `kubectl get pods` on the server.
88+
89+
### [Case-3] Remove daemonset pod from the SONIC DUT and check
90+
- ```kubectl label node <node_name> deployDaemonset-``` to prevent the k8s daemonset pod from running on the SONIC DUT, check if the pod is removed from the SONIC DUT by running `kubectl get pods` on the server.
91+
92+
### [Case-4] Disjoin the SONIC DUT from the Minikube cluster and check
93+
- ```sudo config kube server disable on``` to trigger the SONIC DUT to disjoin the k8s cluster, check if the SONIC DUT is not in the k8s cluster by running `kubectl get nodes` on the server.
94+
95+
### Teardown
96+
97+
#### Clean up
98+
- Remove the Minikube cluster and restore all changes on the server of the testbed and the SONIC DUT.
99+
100+
#### Keep the Minikube cluster running
101+
- If the server of testbed is shared with other tests, need keep the Minikube cluster running to avoid conflict.
102+
103+
### File Lock to avoid Minikube cluster setup conflict
104+
- When the server is shared with other testbed, need to lock the server when setup the Minikube cluster to avoid conflict, otherwise, two test plans may create the Minikube cluster on the same server at the same time which is not expected. When one test plan is creating the Minikube cluster, another test plan just need to wait and directly use the Minikube cluster after it's ready. In the setup step, require a file lock to setup the Minikube cluster, after the Minikube cluster is setup, release the file lock. When the test case trys to setup the Minikube cluster, check if the file lock is acquired. If yes, wait until the file lock is released. If the wait time is longer than max wait time, re-acquire the file lock and setup the Minikube cluster again.

0 commit comments

Comments
 (0)