Skip to content

Commit

Permalink
Add command 'antctl upgrade api-storage' in antctl to upgrade
Browse files Browse the repository at this point in the history
existing objects of Antrea CRDs to the latest API version.

Signed-off-by: Hongliang Liu <[email protected]>
  • Loading branch information
hongliangl committed Jul 26, 2023
1 parent 7c98770 commit 4a66a72
Show file tree
Hide file tree
Showing 6 changed files with 522 additions and 4 deletions.
38 changes: 35 additions & 3 deletions docs/antctl.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Antctl

Antctl is the command-line tool for Antrea. At the moment, antctl supports
antctl is the command-line tool for Antrea. At the moment, antctl supports
running in three different modes:

* "controller mode": when run out-of-cluster or from within the Antrea
Expand Down Expand Up @@ -36,6 +36,7 @@ running in three different modes:
- [Multi-cluster commands](#multi-cluster-commands)
- [Multicast commands](#multicast-commands)
- [Showing memberlist state](#showing-memberlist-state)
- [Upgrade existing objects of CRDs](#upgrade-existing-objects-of-crds)
<!-- /toc -->

## Installation
Expand Down Expand Up @@ -484,7 +485,7 @@ $ antctl traceflow -D pod1 -f tcp,tcp_dst=80 --live-traffic --dropped-only -t 10

### Antctl Proxy

Antctl can run as a reverse proxy for the Antrea API (Controller or arbitrary
antctl can run as a reverse proxy for the Antrea API (Controller or arbitrary
Agent). Usage is very similar to `kubectl proxy` and the implementation is
essentially the same.

Expand Down Expand Up @@ -656,7 +657,8 @@ testmulticast-vw7gx5b9 test3-sender-1 0 10

### Showing memberlist state

`antctl` agent command `get memberlist` (or `get ml`) prints the state of memberlist cluster of Antrea Agent.
`antctl` agent command `get memberlist` (or `get ml`) prints the state of memberlist
cluster of Antrea Agent.

```bash
$ antctl get memberlist
Expand All @@ -666,3 +668,33 @@ worker1 172.18.0.4 Alive
worker2 172.18.0.3 Alive
worker3 172.18.0.2 Dead
```

### Upgrade existing objects of CRDs

antctl supports upgrading existing objects of Antrea CRDs to the latest version.
The related sub-commands should be run out-of-cluster.

This command performs a dry-run to upgrade all existing objects of Antrea CRDs to
the latest API version:

```bash
antctl upgrade api-storage --dry-run
```

This command upgrades all existing objects of Antrea CRDs to the latest API version:

```bash
antctl upgrade api-storage
```

This command upgrades existing AntreaAgentInfo objects to the latest API version:

```bash
antctl upgrade api-storage --crds=antreaagentinfos.crd.antrea.io
```

This command upgrades existing Egress and Group objects to the latest API version:

```bash
antctl upgrade api-storage --crds=egresses.crd.antrea.io,groups.crd.antrea.io
```
7 changes: 7 additions & 0 deletions pkg/antctl/antctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"antrea.io/antrea/pkg/antctl/raw/set"
"antrea.io/antrea/pkg/antctl/raw/supportbundle"
"antrea.io/antrea/pkg/antctl/raw/traceflow"
"antrea.io/antrea/pkg/antctl/raw/upgrade/apistorage"
"antrea.io/antrea/pkg/antctl/transform/addressgroup"
"antrea.io/antrea/pkg/antctl/transform/appliedtogroup"
"antrea.io/antrea/pkg/antctl/transform/controllerinfo"
Expand Down Expand Up @@ -660,6 +661,12 @@ $ antctl get podmulticaststats pod -n namespace`,
supportController: false,
supportFlowAggregator: true,
},
{
cobraCommand: apistorage.NewCommand(),
supportAgent: false,
supportController: false,
commandGroup: upgrade,
},
},
codec: scheme.Codecs,
}
Expand Down
6 changes: 6 additions & 0 deletions pkg/antctl/command_definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ const (
get
query
mc
upgrade
)

var groupCommands = map[commandGroup]*cobra.Command{
Expand All @@ -94,6 +95,11 @@ var groupCommands = map[commandGroup]*cobra.Command{
Short: "Sub-commands of multi-cluster feature",
Long: "Sub-commands of multi-cluster feature",
},
upgrade: {
Use: "upgrade",
Short: "Upgrade Antrea CRD resources to the latest API version",
Long: "Upgrade Antrea CRD resources to the latest API version",
},
}

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 @@ -63,7 +63,8 @@ func (cl *commandList) applyToRootCommand(root *cobra.Command, client AntctlClie
if (runtime.Mode == runtime.ModeAgent && cmd.supportAgent) ||
(runtime.Mode == runtime.ModeController && cmd.supportController) ||
(runtime.Mode == runtime.ModeFlowAggregator && cmd.supportFlowAggregator) ||
(!runtime.InPod && cmd.commandGroup == mc) {
(!runtime.InPod && cmd.commandGroup == mc) ||
(!runtime.InPod && cmd.commandGroup == upgrade) {
if groupCommand, ok := groupCommands[cmd.commandGroup]; ok {
groupCommand.AddCommand(cmd.cobraCommand)
} else {
Expand Down
Loading

0 comments on commit 4a66a72

Please sign in to comment.