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

Don't enable nodeinit on EKS when not needed #1428

Merged
merged 1 commit into from
May 9, 2023
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
12 changes: 5 additions & 7 deletions install/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,23 +169,21 @@ func (k *K8sInstaller) getHelmValues() (map[string]interface{}, error) {
}
}

// Set nodeinit enabled option
if needsNodeInit(k.flavor.Kind, k.chartVersion) {
helmMapOpts["nodeinit.enabled"] = "true"
}

// Set Helm options specific to the detected Kubernetes cluster type
switch k.flavor.Kind {
case k8s.KindKind:
helmMapOpts["ipam.mode"] = ipamKubernetes

case k8s.KindEKS:
helmMapOpts["nodeinit.enabled"] = "true"

case k8s.KindGKE:
helmMapOpts["nodeinit.enabled"] = "true"
helmMapOpts["nodeinit.removeCbrBridge"] = "true"
helmMapOpts["nodeinit.reconfigureKubelet"] = "true"
helmMapOpts["cni.binPath"] = "/home/kubernetes/bin"

case k8s.KindAKS:
helmMapOpts["nodeinit.enabled"] = "true"

case k8s.KindMicrok8s:
helmMapOpts["cni.binPath"] = Microk8sSnapPath + "/opt/cni/bin"
helmMapOpts["cni.confPath"] = Microk8sSnapPath + "/args/cni-network"
Expand Down
2 changes: 1 addition & 1 deletion install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,7 @@ func (k *K8sInstaller) Install(ctx context.Context) error {
})

// Create the node-init daemonset if one is required for the current kind.
if needsNodeInit(k.flavor.Kind) {
if needsNodeInit(k.flavor.Kind, k.chartVersion) {
k.Log("🚀 Creating %s Node Init DaemonSet...", k.flavor.Kind.String())
ds := k.generateNodeInitDaemonSet(k.flavor.Kind)
if _, err := k.client.CreateDaemonSet(ctx, k.params.Namespace, ds, metav1.CreateOptions{}); err != nil {
Expand Down
13 changes: 10 additions & 3 deletions install/node_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,24 @@
package install

import (
"github.com/cilium/cilium/pkg/versioncheck"
"github.com/blang/semver/v4"
appsv1 "k8s.io/api/apps/v1"

"github.com/cilium/cilium/pkg/versioncheck"

"github.com/cilium/cilium-cli/internal/utils"
"github.com/cilium/cilium-cli/k8s"
)

func needsNodeInit(k k8s.Kind) bool {
func needsNodeInit(k k8s.Kind, version semver.Version) bool {
switch k {
case k8s.KindAKS, k8s.KindEKS, k8s.KindGKE:

case k8s.KindAKS, k8s.KindGKE:
return true
case k8s.KindEKS:
if versioncheck.MustCompile("<=1.13.1")(version) {
return true
}
}
return false
}
Expand Down
23 changes: 18 additions & 5 deletions install/uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"strings"
"time"

"github.com/blang/semver/v4"
"github.com/cilium/workerpool"
"helm.sh/helm/v3/pkg/action"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -34,16 +35,28 @@ type UninstallParameters struct {
}

type K8sUninstaller struct {
client k8sInstallerImplementation
params UninstallParameters
flavor k8s.Flavor
client k8sInstallerImplementation
params UninstallParameters
flavor k8s.Flavor
version semver.Version
}

func NewK8sUninstaller(client k8sInstallerImplementation, p UninstallParameters) *K8sUninstaller {
return &K8sUninstaller{
uninstaller := &K8sUninstaller{
client: client,
params: p,
}
ciliumVersion, err := client.GetRunningCiliumVersion(context.Background(), p.Namespace)
if err != nil {
uninstaller.Log("Error getting Cilium Version: %s", err)
}
version, err := semver.Parse(ciliumVersion)
if err != nil {
uninstaller.Log("Error parsing Cilium Version: %s", err)
} else {
uninstaller.version = version
}
return uninstaller
}

func (k *K8sUninstaller) Log(format string, a ...interface{}) {
Expand Down Expand Up @@ -133,7 +146,7 @@ func (k *K8sUninstaller) Uninstall(ctx context.Context) error {
k.client.DeleteResourceQuota(ctx, k.params.Namespace, defaults.OperatorResourceQuota, metav1.DeleteOptions{})
}

if needsNodeInit(k.flavor.Kind) {
if needsNodeInit(k.flavor.Kind, k.version) {
k.Log("🔥 Deleting node init daemonset...")
k.client.DeleteDaemonSet(ctx, k.params.Namespace, defaults.NodeInitDaemonSetName, metav1.DeleteOptions{})
}
Expand Down