Skip to content

Commit

Permalink
[release-0.97] Align placement with HCO components (#2011)
Browse files Browse the repository at this point in the history
* placement: Remove default Infra tolerations

To follow the rest of HCO components this change remove the default
Infra tolerations configuration, openshift configure already default
ones that are used by kubevirt and CDI.

Signed-off-by: Enrique Llorente <ellorent@redhat.com>

* placement: Add unschedulable key to Workload

After cordon a node we get:

 taints:
  - effect: NoSchedule
    key: node.kubernetes.io/unschedulable
    timeAdded: "2025-02-26T08:18:29Z"

This change add the missing "key" value at the toleration to be more
specific.

Signed-off-by: Enrique Llorente <ellorent@redhat.com>

* placement: Use infra config for control plane pods

CNAO is using Workload placement config for deployments that are part of
the control plane, this end up them running at worker nodes and also
propertly preventing drain the node.

This change move those to Infra placement so they will run at control
plane nodes.

Signed-off-by: Enrique Llorente <ellorent@redhat.com>

---------

Signed-off-by: Enrique Llorente <ellorent@redhat.com>
Co-authored-by: Enrique Llorente <ellorent@redhat.com>
  • Loading branch information
kubevirt-bot and qinqon authored Feb 27, 2025
1 parent 5fdf0b3 commit 3f7ca03
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 35 deletions.
6 changes: 3 additions & 3 deletions data/kubevirt-ipam-controller/003-passtbindingcni.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ spec:
- name: cnibin
hostPath:
path: {{ .CNIBinDir }}
nodeSelector: {{ toYaml .Placement.NodeSelector | nindent 8 }}
affinity: {{ toYaml .Placement.Affinity | nindent 8 }}
tolerations: {{ toYaml .Placement.Tolerations | nindent 8 }}
nodeSelector: {{ toYaml .PlacementPasst.NodeSelector | nindent 8 }}
affinity: {{ toYaml .PlacementPasst.Affinity | nindent 8 }}
tolerations: {{ toYaml .PlacementPasst.Tolerations | nindent 8 }}
6 changes: 3 additions & 3 deletions hack/components/bump-kubevirt-ipam-controller.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ function __parametize_passt_binding_cni() {
f=003-passtbindingcni.yaml

yaml-utils::update_param ${f} metadata.namespace '{{ .Namespace }}'
yaml-utils::set_param ${f} spec.template.spec.nodeSelector '{{ toYaml .Placement.NodeSelector | nindent 8 }}'
yaml-utils::set_param ${f} spec.template.spec.affinity '{{ toYaml .Placement.Affinity | nindent 8 }}'
yaml-utils::set_param ${f} spec.template.spec.tolerations '{{ toYaml .Placement.Tolerations | nindent 8 }}'
yaml-utils::set_param ${f} spec.template.spec.nodeSelector '{{ toYaml .PlacementPasst.NodeSelector | nindent 8 }}'
yaml-utils::set_param ${f} spec.template.spec.affinity '{{ toYaml .PlacementPasst.Affinity | nindent 8 }}'
yaml-utils::set_param ${f} spec.template.spec.tolerations '{{ toYaml .PlacementPasst.Tolerations | nindent 8 }}'
yaml-utils::update_param ${f} spec.template.spec.containers[0].image '{{ .PasstBindingCNIImage }}'
yaml-utils::set_param ${f} spec.template.spec.containers[0].imagePullPolicy '{{ .ImagePullPolicy }}'
yaml-utils::update_param ${f} spec.template.spec.volumes[0].hostPath.path '{{ .CNIBinDir }}'
Expand Down
2 changes: 1 addition & 1 deletion pkg/network/kube_secondary_dns_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func renderKubeSecondaryDNS(conf *cnao.NetworkAddonsConfigSpec, manifestDir stri
data := render.MakeRenderData()
data.Data["Namespace"] = os.Getenv("OPERAND_NAMESPACE")
data.Data["ImagePullPolicy"] = conf.ImagePullPolicy
data.Data["Placement"] = conf.PlacementConfiguration.Workloads
data.Data["Placement"] = conf.PlacementConfiguration.Infra
data.Data["Domain"] = conf.KubeSecondaryDNS.Domain
data.Data["NameServerIp"] = conf.KubeSecondaryDNS.NameServerIP
data.Data["KubeSecondaryDNSImage"] = os.Getenv("KUBE_SECONDARY_DNS_IMAGE")
Expand Down
3 changes: 2 additions & 1 deletion pkg/network/kubevirt_ipam_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ func renderKubevirtIPAMController(conf *cnao.NetworkAddonsConfigSpec, manifestDi
data := render.MakeRenderData()
data.Data["Namespace"] = os.Getenv("OPERAND_NAMESPACE")
data.Data["ImagePullPolicy"] = conf.ImagePullPolicy
data.Data["Placement"] = conf.PlacementConfiguration.Workloads
data.Data["Placement"] = conf.PlacementConfiguration.Infra
data.Data["PlacementPasst"] = conf.PlacementConfiguration.Workloads
data.Data["KubevirtIpamControllerImage"] = os.Getenv("KUBEVIRT_IPAM_CONTROLLER_IMAGE")
data.Data["PasstBindingCNIImage"] = os.Getenv("PASST_BINDING_CNI_IMAGE")

Expand Down
5 changes: 4 additions & 1 deletion pkg/network/kubevirt_ipam_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ import (

var _ = Describe("Testing kubevirt ipam controller", func() {
Context("Render KubevirtIpamController", func() {
conf := &cnao.NetworkAddonsConfigSpec{ImagePullPolicy: v1.PullAlways, Multus: &cnao.Multus{}, KubevirtIpamController: &cnao.KubevirtIpamController{}, PlacementConfiguration: &cnao.PlacementConfiguration{Workloads: &cnao.Placement{}}}
conf := &cnao.NetworkAddonsConfigSpec{ImagePullPolicy: v1.PullAlways, Multus: &cnao.Multus{}, KubevirtIpamController: &cnao.KubevirtIpamController{}, PlacementConfiguration: &cnao.PlacementConfiguration{
Infra: &cnao.Placement{},
Workloads: &cnao.Placement{},
}}
manifestDir := "../../data"
openshiftNetworkConf := &osv1.Network{}
clusterInfo := &ClusterInfo{}
Expand Down
28 changes: 2 additions & 26 deletions pkg/network/placement_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,8 @@ import (
)

func GetDefaultPlacementConfiguration() cnao.PlacementConfiguration {
var nodeNotNReadyTolerationInSeconds int64 = 60
return cnao.PlacementConfiguration{
Infra: &cnao.Placement{
Tolerations: []corev1.Toleration{
corev1.Toleration{
Key: "node-role.kubernetes.io/control-plane",
Operator: corev1.TolerationOpExists,
Effect: corev1.TaintEffectNoSchedule,
},
corev1.Toleration{
Key: "node-role.kubernetes.io/master",
Operator: corev1.TolerationOpExists,
Effect: corev1.TaintEffectNoSchedule,
},
corev1.Toleration{
Key: "node.kubernetes.io/unreachable",
Operator: corev1.TolerationOpExists,
Effect: corev1.TaintEffectNoExecute,
TolerationSeconds: &nodeNotNReadyTolerationInSeconds,
},
corev1.Toleration{
Key: "node.kubernetes.io/not-ready",
Operator: corev1.TolerationOpExists,
Effect: corev1.TaintEffectNoExecute,
TolerationSeconds: &nodeNotNReadyTolerationInSeconds,
},
},
Affinity: corev1.Affinity{
NodeAffinity: &corev1.NodeAffinity{
PreferredDuringSchedulingIgnoredDuringExecution: []corev1.PreferredSchedulingTerm{
Expand Down Expand Up @@ -65,10 +40,11 @@ func GetDefaultPlacementConfiguration() cnao.PlacementConfiguration {
},
Workloads: &cnao.Placement{
NodeSelector: map[string]string{
"kubernetes.io/os": "linux",
corev1.LabelOSStable: "linux",
},
Tolerations: []corev1.Toleration{
corev1.Toleration{
Key: corev1.TaintNodeUnschedulable,
Operator: corev1.TolerationOpExists,
Effect: corev1.TaintEffectNoSchedule,
},
Expand Down

0 comments on commit 3f7ca03

Please sign in to comment.