Skip to content

Commit

Permalink
Add antctl check installation to conduct connectivity checks (#6133)
Browse files Browse the repository at this point in the history
We introduce a new antctl subcommand (antctl check) which can be used to
run sanity checks on a K8s cluster / Antrea deployment.
At the moment, we have "antctl check installation", which can be used to
validate an Antrea installation, by running some connectivity checks. We
only have a limited number of tests for now (inter-Node & intra-Node Pod
connectivity, Pod connectivity to the Internet), but the frameowk should
make it straightforward to add additional tests in the future.
We validate the antctl command in CI using a Github workflow.

For #6061

Signed-off-by: Kanha gupta <[email protected]>
  • Loading branch information
kanha-gupta authored Apr 29, 2024
1 parent 89363ac commit dc97a83
Show file tree
Hide file tree
Showing 9 changed files with 699 additions and 1 deletion.
42 changes: 42 additions & 0 deletions .github/workflows/kind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,48 @@ jobs:
path: log.tar.gz
retention-days: 30

run-post-installation-checks:
name: Test connectivity using 'antctl check' command
needs: [ build-antrea-coverage-image ]
runs-on: [ ubuntu-latest ]
steps:
- name: Free disk space
run: |
sudo apt-get clean
df -h
- uses: actions/checkout@v4
with:
show-progress: false
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Download Antrea image from previous job
uses: actions/download-artifact@v4
with:
name: antrea-ubuntu-cov
- name: Load Antrea image
run: |
docker load -i antrea-ubuntu.tar
- name: Install Kind
run: |
KIND_VERSION=$(head -n1 ./ci/kind/version)
curl -Lo ./kind https://github.com/kubernetes-sigs/kind/releases/download/${KIND_VERSION}/kind-$(uname)-amd64
chmod +x ./kind
sudo mv kind /usr/local/bin
- name: Create Kind Cluster
run: |
kind create cluster --config ci/kind/config-3nodes.yml
- name: Load Docker images and deploy Antrea
run: |
kind load docker-image antrea/antrea-controller-ubuntu-coverage:latest antrea/antrea-agent-ubuntu-coverage:latest
kubectl apply -f build/yamls/antrea.yml
- name: Build antctl binary
run: |
make antctl-linux
- name: Run antctl command
run: |
./bin/antctl-linux check installation
validate-prometheus-metrics-doc:
name: Validate metrics in Prometheus document match running deployment's
needs: build-antrea-coverage-image
Expand Down
7 changes: 7 additions & 0 deletions pkg/antctl/antctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (

agentapis "antrea.io/antrea/pkg/agent/apis"
fallbackversion "antrea.io/antrea/pkg/antctl/fallback/version"
checkinstallation "antrea.io/antrea/pkg/antctl/raw/check/installation"
"antrea.io/antrea/pkg/antctl/raw/featuregates"
"antrea.io/antrea/pkg/antctl/raw/multicluster"
"antrea.io/antrea/pkg/antctl/raw/proxy"
Expand Down Expand Up @@ -633,6 +634,12 @@ $ antctl get podmulticaststats pod -n namespace`,
},
},
rawCommands: []rawCommand{
{
cobraCommand: checkinstallation.Command(),
supportAgent: false,
supportController: false,
commandGroup: check,
},
{
cobraCommand: supportbundle.Command,
supportAgent: true,
Expand Down
5 changes: 5 additions & 0 deletions pkg/antctl/command_definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const (
query
mc
upgrade
check
)

var groupCommands = map[commandGroup]*cobra.Command{
Expand All @@ -93,6 +94,10 @@ var groupCommands = map[commandGroup]*cobra.Command{
Short: "Sub-commands for upgrade operations",
Long: "Sub-commands for upgrade operations",
},
check: {
Use: "check",
Short: "Performs pre and post installation checks",
},
}

type endpointResponder interface {
Expand Down
3 changes: 2 additions & 1 deletion pkg/antctl/command_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ func (cl *commandList) applyToRootCommand(root *cobra.Command, client AntctlClie
(runtime.Mode == runtime.ModeController && cmd.supportController) ||
(runtime.Mode == runtime.ModeFlowAggregator && cmd.supportFlowAggregator) ||
(!runtime.InPod && cmd.commandGroup == mc) ||
(!runtime.InPod && cmd.commandGroup == upgrade) {
(!runtime.InPod && cmd.commandGroup == upgrade) ||
(!runtime.InPod && cmd.commandGroup == check) {
if groupCommand, ok := groupCommands[cmd.commandGroup]; ok {
groupCommand.AddCommand(cmd.cobraCommand)
} else {
Expand Down
Loading

0 comments on commit dc97a83

Please sign in to comment.