-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit is to enable multicast status check and configuration from cilium-cli by adding multicast subcommand. The list subcommand show the list of multicast groups or their subscribers on all nodes. The add subcommand joins all nodes to the specified multicast group. The del subcommand deletes the specified multicast group from all nodes. This is follow up of #2574 Signed-off-by: Yusho Yamaguchi <[email protected]>
- Loading branch information
1 parent
433f2a9
commit 61f2b6d
Showing
3 changed files
with
720 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright Authors of Cilium | ||
|
||
package cli | ||
|
||
import ( | ||
"os" | ||
"time" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
"github.com/cilium/cilium-cli/multicast" | ||
"github.com/cilium/cilium-cli/status" | ||
) | ||
|
||
func newCmdMulticast() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "multicast", | ||
Short: "Manage multicast groups", | ||
Long: ``, | ||
} | ||
cmd.AddCommand( | ||
newCmdMulticastList(), | ||
newCmdMulticastAdd(), | ||
newCmdMulticastDel(), | ||
) | ||
return cmd | ||
} | ||
|
||
func newCmdMulticastList() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "list", | ||
Short: "Show the information about multicast groups", | ||
Long: ``, | ||
} | ||
|
||
cmd.AddCommand( | ||
newCmdMulticastListGroup(), | ||
newCmdMulticastListSubscriber(), | ||
) | ||
return cmd | ||
|
||
} | ||
|
||
func newCmdMulticastListGroup() *cobra.Command { | ||
var params = multicast.Parameters{ | ||
Writer: os.Stdout, | ||
} | ||
cmd := &cobra.Command{ | ||
Use: "group", | ||
Short: "Show list of multicast groups in every node", | ||
RunE: func(_ *cobra.Command, _ []string) error { | ||
params.CiliumNamespace = namespace | ||
mc := multicast.NewMulticast(k8sClient, params) | ||
err := mc.ListGroups() | ||
if err != nil { | ||
fatalf("Unable to list multicast groups: %s", err) | ||
} | ||
return nil | ||
}, | ||
} | ||
cmd.Flags().DurationVar(¶ms.WaitDuration, "wait-duration", 1*time.Minute, "Maximum time to wait for result, default 1 minute") | ||
cmd.Flags().StringVarP(¶ms.Output, "output", "o", status.OutputSummary, "Output format. One of: json, summary") | ||
return cmd | ||
|
||
} | ||
|
||
func newCmdMulticastListSubscriber() *cobra.Command { | ||
var params = multicast.Parameters{ | ||
Writer: os.Stdout, | ||
} | ||
cmd := &cobra.Command{ | ||
Use: "subscriber", | ||
Short: "Show list of subscribers belonging to the specified multicast group", | ||
RunE: func(_ *cobra.Command, _ []string) error { | ||
params.CiliumNamespace = namespace | ||
mc := multicast.NewMulticast(k8sClient, params) | ||
err := mc.ListSubscribers() | ||
if err != nil { | ||
fatalf("Unable to list subscribers of the multicast group: %s", err) | ||
} | ||
return nil | ||
}, | ||
} | ||
cmd.Flags().StringVarP(¶ms.MulticastGroupIP, "group-ip", "g", "", "Multicast group IP address") | ||
cmd.Flags().BoolVar(¶ms.All, "all", false, "Show all subscribers") | ||
cmd.Flags().DurationVar(¶ms.WaitDuration, "wait-duration", 1*time.Minute, "Maximum time to wait for result, default 1 minute") | ||
cmd.Flags().StringVarP(¶ms.Output, "output", "o", status.OutputSummary, "Output format. One of: json, summary") | ||
return cmd | ||
|
||
} | ||
|
||
func newCmdMulticastAdd() *cobra.Command { | ||
var params = multicast.Parameters{ | ||
Writer: os.Stdout, | ||
} | ||
cmd := &cobra.Command{ | ||
Use: "add", | ||
Short: "Add all nodes to the specified multicast group as subscribers in every cilium-agent", | ||
RunE: func(_ *cobra.Command, _ []string) error { | ||
params.CiliumNamespace = namespace | ||
mc := multicast.NewMulticast(k8sClient, params) | ||
err := mc.AddAllNodes() | ||
if err != nil { | ||
fatalf("Unable to add all nodes: %s", err) | ||
} | ||
return nil | ||
}, | ||
} | ||
cmd.Flags().StringVarP(¶ms.MulticastGroupIP, "group-ip", "g", "", "Multicast group IP address") | ||
cmd.Flags().DurationVar(¶ms.WaitDuration, "wait-duration", 1*time.Minute, "Maximum time to wait for result, default 1 minute") | ||
return cmd | ||
} | ||
|
||
func newCmdMulticastDel() *cobra.Command { | ||
var params = multicast.Parameters{ | ||
Writer: os.Stdout, | ||
} | ||
cmd := &cobra.Command{ | ||
Use: "delete", | ||
Short: "Delete the specified multicast group in every cilium-agent", | ||
RunE: func(_ *cobra.Command, _ []string) error { | ||
params.CiliumNamespace = namespace | ||
mc := multicast.NewMulticast(k8sClient, params) | ||
err := mc.DelAllNodes() | ||
if err != nil { | ||
fatalf("Unable to delete all nodes: %s", err) | ||
} | ||
return nil | ||
}, | ||
} | ||
cmd.Flags().StringVarP(¶ms.MulticastGroupIP, "group-ip", "g", "", "Multicast group IP address") | ||
cmd.Flags().DurationVar(¶ms.WaitDuration, "wait-duration", 1*time.Minute, "Maximum time to wait for result, default 1 minute") | ||
return cmd | ||
} |
Oops, something went wrong.