Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a restart flag to config set #151

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type K8sConfig struct {

type Parameters struct {
Namespace string
Restart bool
Writer io.Writer
}

Expand Down
35 changes: 32 additions & 3 deletions internal/cli/cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ import (
"os"

"github.com/cilium/cilium-cli/config"
"github.com/cilium/cilium-cli/defaults"

"github.com/spf13/cobra"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func newCmdConfig() *cobra.Command {
Expand Down Expand Up @@ -80,12 +82,33 @@ func newCmdConfigSet() *cobra.Command {
if err := check.Set(context.Background(), args[0], args[1]); err != nil {
fatalf("Unable to set config: %s", err)
}
if !params.Restart {
fmt.Println("⚠️ Restart Cilium pods for configmap changes to take effect")
return nil
}
if err := k8sClient.DeletePodCollection(context.Background(), params.Namespace, metav1.DeleteOptions{}, metav1.ListOptions{LabelSelector: defaults.CiliumPodSelector}); err != nil {
fmt.Printf("⚠️ Unable to restart Cilium pods: %s\n", err)
} else {
fmt.Println("♻️ Restarted Cilium pods")
}
return nil
},
}

cmd.Flags().StringVarP(&params.Namespace, "namespace", "n", "kube-system", "Namespace Cilium is running in")

cmd.Flags().StringVarP(
&params.Namespace,
"namespace",
"n",
"kube-system",
"Namespace Cilium is running in",
)
cmd.Flags().BoolVarP(
&params.Restart,
"restart",
"r",
true,
"Restart Cilium pods",
)
return cmd
}

Expand All @@ -108,7 +131,13 @@ func newCmdConfigDelete() *cobra.Command {
},
}

cmd.Flags().StringVarP(&params.Namespace, "namespace", "n", "kube-system", "Namespace Cilium is running in")
cmd.Flags().StringVarP(
&params.Namespace,
"namespace",
"n",
"kube-system",
"Namespace Cilium is running in",
)

return cmd
}