diff --git a/pkg/common/kubernetes_version.go b/pkg/common/kubernetes_version.go index e1df5104d7..f979e17ea0 100644 --- a/pkg/common/kubernetes_version.go +++ b/pkg/common/kubernetes_version.go @@ -25,9 +25,8 @@ import ( // VersionInfo contains information about the version of Kubernetes API the cluster is using // Major and Minor fields map to the v.+ part of the version string type VersionInfo struct { - Major int - Minor int - GitVersion string + Major int + Minor int } func GetKubernetesVersion(clientset kubernetes.Interface) (*VersionInfo, error) { @@ -48,9 +47,8 @@ func GetKubernetesVersion(clientset kubernetes.Interface) (*VersionInfo, error) } return &VersionInfo{ - Major: major, - Minor: minor, - GitVersion: v.GitVersion, + Major: major, + Minor: minor, }, nil } diff --git a/pkg/controller/installation/core_controller.go b/pkg/controller/installation/core_controller.go index a123014c9c..6b36490ddf 100644 --- a/pkg/controller/installation/core_controller.go +++ b/pkg/controller/installation/core_controller.go @@ -1349,13 +1349,6 @@ func (r *ReconcileInstallation) Reconcile(ctx context.Context, request reconcile r.status.SetDegraded(operator.ResourceReadError, fmt.Sprintf("Services endpoint configmap '%s' does not have all required information for Windows configuration", render.K8sSvcEndpointConfigMapName), err, reqLogger) } - kubernetesVersionInfo, err := common.GetKubernetesVersion(r.clientset) - if err != nil { - r.status.SetDegraded(operator.InternalServerError, "Unable to determine Kubernetes version, defaulting to v1.18.0", err, reqLogger) - kubernetesVersionInfo = &common.VersionInfo{Major: 1, Minor: 18, GitVersion: "v1.18.0-qwerty"} - } - kubernetesVersion := strings.Split(kubernetesVersionInfo.GitVersion, "-")[0] - windowsCfg := render.WindowsConfiguration{ K8sServiceEp: k8sapi.Endpoint, Installation: &instance.Spec, @@ -1366,7 +1359,6 @@ func (r *ReconcileInstallation) Reconcile(ctx context.Context, request reconcile NodeReporterMetricsPort: nodeReporterMetricsPort, VXLANVNI: *felixConfiguration.Spec.VXLANVNI, Terminating: nodeTerminating, - KubernetesVersion: kubernetesVersion, } components = append(components, render.Windows(&windowsCfg)) } diff --git a/pkg/controller/installation/core_controller_test.go b/pkg/controller/installation/core_controller_test.go index aa072e7d8e..d6703ea0b5 100644 --- a/pkg/controller/installation/core_controller_test.go +++ b/pkg/controller/installation/core_controller_test.go @@ -414,7 +414,6 @@ var _ = Describe("Testing core-controller installation", func() { enterpriseCRDsExist: true, migrationChecked: true, tierWatchReady: ready, - clientset: cs, // Needed for GetKubernetesVersion() } r.typhaAutoscaler.start(ctx) @@ -567,22 +566,6 @@ var _ = Describe("Testing core-controller installation", func() { fmt.Sprintf("some.registry.org/%s:%s", components.ComponentTigeraCNIWindows.Image, components.ComponentTigeraCNIWindows.Version))) - dsKubeProxyWin := appsv1.DaemonSet{ - TypeMeta: metav1.TypeMeta{Kind: "DaemonSet", APIVersion: "apps/v1"}, - ObjectMeta: metav1.ObjectMeta{ - Name: common.WindowsKubeProxyDaemonSetName, - Namespace: "kube-system", - }, - } - Expect(test.GetResource(c, &dsKubeProxyWin)).To(BeNil()) - Expect(dsKubeProxyWin.Spec.Template.Spec.Containers).To(HaveLen(1)) - kubeProxyWin := test.GetContainer(dsKubeProxyWin.Spec.Template.Spec.Containers, "kube-proxy") - Expect(kubeProxyWin).ToNot(BeNil()) - - // When getting kubernetes version fails, it defaults to v1.18.0 - kubernetesVersion := "v1.18.0" - Expect(kubeProxyWin.Image).To(Equal( - fmt.Sprintf("sigwindowstools/kube-proxy:%s-calico-hostprocess", kubernetesVersion))) } }) It("should use images from imageset", func() { diff --git a/pkg/controller/installation/typha_autoscaler_test.go b/pkg/controller/installation/typha_autoscaler_test.go index f514710866..b054b40650 100644 --- a/pkg/controller/installation/typha_autoscaler_test.go +++ b/pkg/controller/installation/typha_autoscaler_test.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2022 Tigera, Inc. All rights reserved. +// Copyright (c) 2020-2023 Tigera, Inc. All rights reserved. // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/pkg/render/render_test.go b/pkg/render/render_test.go index af789d2042..677333e7b9 100644 --- a/pkg/render/render_test.go +++ b/pkg/render/render_test.go @@ -121,7 +121,6 @@ func allCalicoComponents( AmazonCloudIntegration: aci, NodeReporterMetricsPort: nodeReporterMetricsPort, VXLANVNI: 4096, - KubernetesVersion: "v1.18.0", } nodeCertComponent := rcertificatemanagement.CertificateManagement(&rcertificatemanagement.Config{ @@ -211,11 +210,11 @@ var _ = Describe("Rendering tests", func() { // - 7 typha resources (Service, SA, Role, Binding, Deployment, PodDisruptionBudget, PodSecurityPolicy) // - 6 kube-controllers resources (ServiceAccount, ClusterRole, Binding, Deployment, PodSecurityPolicy, Service, Secret) // - 1 namespace - // - 6 Windows node resources (ServiceAccount, ClusterRole, Binding, ConfigMap, DaemonSet, kube-proxy DaemonSet) + // - 5 Windows node resources (ServiceAccount, ClusterRole, Binding, ConfigMap, DaemonSet) // - 3 Windows calico-cni-plugin resources (ServiceAccount, ClusterRole, ClusterRoleBinding) c, err := allCalicoComponents(k8sServiceEp, instance, nil, nil, nil, typhaNodeTLS, nil, nil, nil, false, "", dns.DefaultClusterDomain, 9094, 0, nil, nil) Expect(err).To(BeNil(), "Expected Calico to create successfully %s", err) - Expect(componentCount(c)).To(Equal(6 + 3 + 4 + 1 + 7 + 6 + 1 + 6 + 3)) + Expect(componentCount(c)).To(Equal(6 + 3 + 4 + 1 + 7 + 6 + 1 + 5 + 3)) }) It("should render all resources when variant is Tigera Secure", func() { @@ -229,7 +228,7 @@ var _ = Describe("Rendering tests", func() { instance.NodeMetricsPort = &nodeMetricsPort c, err := allCalicoComponents(k8sServiceEp, instance, nil, nil, nil, typhaNodeTLS, nil, nil, nil, false, "", dns.DefaultClusterDomain, 9094, 0, nil, nil) Expect(err).To(BeNil(), "Expected Calico to create successfully %s", err) - Expect(componentCount(c)).To(Equal((6 + 3 + 4 + 1 + 7 + 6 + 1 + 6 + 3) + 1 + 1 + 1)) + Expect(componentCount(c)).To(Equal((6 + 3 + 4 + 1 + 7 + 6 + 1 + 5 + 3) + 1 + 1 + 1)) }) It("should render all resources when variant is Tigera Secure and Management Cluster", func() { @@ -293,7 +292,6 @@ var _ = Describe("Rendering tests", func() { {render.WindowsNodeMetricsService, common.CalicoNamespace, "", "v1", "Service"}, {"cni-config-windows", common.CalicoNamespace, "", "v1", "ConfigMap"}, {common.WindowsDaemonSetName, common.CalicoNamespace, "apps", "v1", "DaemonSet"}, - {common.WindowsKubeProxyDaemonSetName, "kube-system", "apps", "v1", "DaemonSet"}, // Certificate Management objects {"tigera-ca-bundle", common.CalicoNamespace, "", "v1", "ConfigMap"}, diff --git a/pkg/render/windows.go b/pkg/render/windows.go index 4b9d2717f8..981230de26 100644 --- a/pkg/render/windows.go +++ b/pkg/render/windows.go @@ -58,14 +58,12 @@ type WindowsConfiguration struct { AmazonCloudIntegration *operatorv1.AmazonCloudIntegration VXLANVNI int Terminating bool - KubernetesVersion string } type windowsComponent struct { - cfg *WindowsConfiguration - cniImage string - nodeImage string - kubeProxyImage string + cfg *WindowsConfiguration + cniImage string + nodeImage string } func (c *windowsComponent) ResolveImages(is *operatorv1.ImageSet) error { @@ -88,8 +86,6 @@ func (c *windowsComponent) ResolveImages(is *operatorv1.ImageSet) error { c.nodeImage = appendIfErr(components.GetReference(components.ComponentCalicoNodeWindows, reg, path, prefix, is)) } - c.kubeProxyImage = fmt.Sprintf("sigwindowstools/kube-proxy:%s-calico-hostprocess", c.cfg.KubernetesVersion) - if len(errMsgs) != 0 { return fmt.Errorf(strings.Join(errMsgs, ",")) } @@ -136,8 +132,6 @@ func (c *windowsComponent) Objects() ([]client.Object, []client.Object) { objs = append(objs, c.windowsDaemonset(cniConfig)) - objs = append(objs, c.kubeProxyWindowsDaemonset()) - if c.cfg.Terminating { return objsToKeep, append(objs, objsToDelete...) } @@ -1235,74 +1229,3 @@ func (c *windowsComponent) windowsDaemonset(cniCfgMap *corev1.ConfigMap) *appsv1 } return &ds } - -// kubeProxyWindowsDaemonset creates the windows kube-proxy daemonset. -// It uses the sigwindowstools/kube-proxy image and is based on -// https://github.com/kubernetes-sigs/sig-windows-tools/blob/master/hostprocess/calico/kube-proxy/kube-proxy.yml -func (c *windowsComponent) kubeProxyWindowsDaemonset() *appsv1.DaemonSet { - ds := appsv1.DaemonSet{ - TypeMeta: metav1.TypeMeta{Kind: "DaemonSet", APIVersion: "apps/v1"}, - ObjectMeta: metav1.ObjectMeta{ - Name: common.WindowsKubeProxyDaemonSetName, - Namespace: "kube-system", - Labels: map[string]string{"k8s-app": "kube-proxy"}, - }, - Spec: appsv1.DaemonSetSpec{ - Selector: &metav1.LabelSelector{ - MatchLabels: map[string]string{ - "k8s-app": common.WindowsKubeProxyDaemonSetName, - }, - }, - Template: corev1.PodTemplateSpec{ - ObjectMeta: metav1.ObjectMeta{ - Labels: map[string]string{"k8s-app": common.WindowsKubeProxyDaemonSetName}, - }, - Spec: corev1.PodSpec{ - NodeSelector: map[string]string{"kubernetes.io/os": "windows"}, - Tolerations: rmeta.TolerateAll, - ServiceAccountName: "kube-proxy", - HostNetwork: true, - Containers: []corev1.Container{ - c.kubeProxyContainer(), - }, - Volumes: []corev1.Volume{ - { - Name: "kube-proxy", - VolumeSource: corev1.VolumeSource{ConfigMap: &corev1.ConfigMapVolumeSource{ - LocalObjectReference: corev1.LocalObjectReference{Name: "kube-proxy"}}}}}, - }, - }, - UpdateStrategy: c.cfg.Installation.NodeUpdateStrategy, - }, - } - - return &ds -} - -// kubeProxyContainer creates the windows kube-proxy container. -func (c *windowsComponent) kubeProxyContainer() corev1.Container { - return corev1.Container{ - Name: "kube-proxy", - Image: c.kubeProxyImage, - Args: []string{"$env:CONTAINER_SANDBOX_MOUNT_POINT/kube-proxy/start.ps1"}, - WorkingDir: "$env:CONTAINER_SANDBOX_MOUNT_POINT/kube-proxy/", - SecurityContext: securitycontext.NewWindowsHostProcessContext(), - Env: []corev1.EnvVar{ - { - Name: "NODE_NAME", - ValueFrom: &corev1.EnvVarSource{ - FieldRef: &corev1.ObjectFieldSelector{FieldPath: "spec.nodeName"}, - }, - }, - { - Name: "POD_IP", - ValueFrom: &corev1.EnvVarSource{ - FieldRef: &corev1.ObjectFieldSelector{FieldPath: "status.podIP"}, - }, - }, - }, - VolumeMounts: []corev1.VolumeMount{ - {MountPath: "/var/lib/kube-proxy", Name: "kube-proxy"}, - }, - } -}