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

Improvements for kube-proxy detection and replacement #1162

Merged
merged 1 commit into from
Nov 10, 2022
Merged
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
9 changes: 8 additions & 1 deletion install/autodetect.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,17 @@ func (k *K8sInstaller) autodetectAndValidate(ctx context.Context) error {
}

func (k *K8sInstaller) autodetectKubeProxy(ctx context.Context) error {
if k.params.UserSetKubeProxyReplacement {
return nil
} else if k.flavor.Kind == k8s.KindK3s {
tklauser marked this conversation as resolved.
Show resolved Hide resolved
return nil
}

kubeSysNameSpace := "kube-system"

dsList, err := k.client.ListDaemonSet(ctx, kubeSysNameSpace, metav1.ListOptions{})
if err != nil {
k.Log("⏭️ Skipping auto kube-proxy detction")
k.Log("⏭️ Skipping auto kube-proxy detection")
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion install/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ func (k *K8sInstaller) generateManifests(ctx context.Context) error {

// TODO: remove when removing "kube-proxy-replacement" flag (marked as
// deprecated), kept for backwards compatibility
if k.params.KubeProxyReplacement != "" {
if k.params.KubeProxyReplacement != "" && k.params.UserSetKubeProxyReplacement {
helmMapOpts["kubeProxyReplacement"] = k.params.KubeProxyReplacement
}

Expand Down
2 changes: 2 additions & 0 deletions install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,8 @@ type Parameters struct {
// APIVersions defines extra kubernetes api resources that can be passed to helm for capabilities validation,
// specifically for CRDs.
APIVersions []string
// UserSetKubeProxyReplacement will be set as true if user passes helm opt or commadline flag for the Kube-Proxy replacement.
UserSetKubeProxyReplacement bool
}

type rollbackStep func(context.Context)
Expand Down
10 changes: 10 additions & 0 deletions internal/cli/cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ import (
"context"
"fmt"
"os"
"strings"
"time"

"github.com/spf13/cobra"
"github.com/spf13/pflag"

"github.com/cilium/cilium-cli/defaults"
"github.com/cilium/cilium-cli/hubble"
Expand All @@ -35,6 +37,14 @@ cilium install --context kind-cluster1 --cluster-id 1 --cluster-name cluster1
RunE: func(cmd *cobra.Command, args []string) error {
params.Namespace = namespace

cmd.Flags().Visit(func(f *pflag.Flag) {
if f.Name == "kube-proxy-replacement" {
params.UserSetKubeProxyReplacement = true
} else if f.Name == "helm-set" && strings.Contains(f.Value.String(), "kubeProxyReplacement") {
params.UserSetKubeProxyReplacement = true
}
})

installer, err := install.NewK8sInstaller(k8sClient, params)
if err != nil {
return err
Expand Down