Skip to content

Commit

Permalink
fix: properly propagate flags used for kubeproxyreplacement
Browse files Browse the repository at this point in the history
Signed-off-by: Jonathan Grahl <[email protected]>
  • Loading branch information
bittermandel committed Oct 16, 2023
1 parent 951eb91 commit 5106a98
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
15 changes: 12 additions & 3 deletions install/autodetect.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,20 @@ func (k *K8sInstaller) autodetectAndValidate(ctx context.Context, helmValues map
return fmt.Errorf("invalid encryption mode")
}

k.autodetectKubeProxy(ctx)
var apiServerHost, apiServerPort string

if host, ok := helmValues["k8sServiceHost"].(string); !ok {
apiServerHost = host
}
if port, ok := helmValues["k8sServicePort"].(string); !ok {
apiServerPort = port
}

k.autodetectKubeProxy(ctx, apiServerHost, apiServerPort)
return k.autoEnableBPFMasq()
}

func (k *K8sInstaller) autodetectKubeProxy(ctx context.Context) error {
func (k *K8sInstaller) autodetectKubeProxy(ctx context.Context, apiServerHost string, apiServerPort string) error {
if k.params.UserSetKubeProxyReplacement {
return nil
} else if k.flavor.Kind == k8s.KindK3s {
Expand All @@ -223,7 +232,7 @@ func (k *K8sInstaller) autodetectKubeProxy(ctx context.Context) error {
return nil
}
}
apiServerHost, apiServerPort := k.client.GetAPIServerHostAndPort()

if k.flavor.Kind == k8s.KindKind {
k.Log("ℹ️ Detecting real Kubernetes API server addr and port on Kind")

Expand Down
12 changes: 11 additions & 1 deletion internal/cli/cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ cilium install --context kind-cluster1 --cluster-id 1 --cluster-name cluster1
params.Namespace = namespace

cmd.Flags().Visit(func(f *pflag.Flag) {
if f.Name == "helm-set" && strings.Contains(f.Value.String(), "kubeProxyReplacement") {
if f.Name == "set" && strings.Contains(f.Value.String(), "kubeProxyReplacement") {
params.UserSetKubeProxyReplacement = true
}
})
Expand Down Expand Up @@ -266,6 +266,11 @@ cilium install
cilium install --context kind-cluster1 --set cluster.id=1 --set cluster.name=cluster1
`,
RunE: func(cmd *cobra.Command, args []string) error {
cmd.Flags().Visit(func(f *pflag.Flag) {
if f.Name == "set" && strings.Contains(f.Value.String(), "kubeProxyReplacement") {
params.UserSetKubeProxyReplacement = true
}
})
params.Namespace = namespace
// Don't log anything if it's a dry run so that the dry run output can easily be piped to other commands.
if params.DryRun || params.DryRunHelmValues {
Expand Down Expand Up @@ -344,6 +349,11 @@ cilium upgrade
cilium upgrade --helm-set cluster.id=1 --helm-set cluster.name=cluster1
`,
RunE: func(cmd *cobra.Command, args []string) error {
cmd.Flags().Visit(func(f *pflag.Flag) {
if f.Name == "set" && strings.Contains(f.Value.String(), "kubeProxyReplacement") {
params.UserSetKubeProxyReplacement = true
}
})
params.Namespace = namespace
// Don't log anything if it's a dry run so that the dry run output can easily be piped to other commands.
if params.DryRun || params.DryRunHelmValues {
Expand Down

0 comments on commit 5106a98

Please sign in to comment.