placement, infra: fallback to master node
At some environment control-plane is still not present, and nodes are
labeled with master only. This change replace toleratin + node selector
with a affinity rules that implement a fallback to master if
control-plane is not there.
@@ -9,16 +9,45 @@ import (
func GetDefaultPlacementConfiguration() cnao.PlacementConfiguration {
return cnao.PlacementConfiguration{
Infra: &cnao.Placement{
- NodeSelector: map[string]string{
- "beta.kubernetes.io/arch": "amd64",
- "node-role.kubernetes.io/control-plane": "",
- },
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,
+ },
+ },
+ Affinity: corev1.Affinity{
+ NodeAffinity: &corev1.NodeAffinity{
+ PreferredDuringSchedulingIgnoredDuringExecution: []corev1.PreferredSchedulingTerm{
+ {
+ Weight: 10,
+ Preference: corev1.NodeSelectorTerm{
+ MatchExpressions: []corev1.NodeSelectorRequirement{
+ {
+ Key: "node-role.kubernetes.io/control-plane",
+ Operator: corev1.NodeSelectorOpExists,
+ },
+ },
+ },
+ },
+ {
+ Weight: 1,
+ Preference: corev1.NodeSelectorTerm{
+ MatchExpressions: []corev1.NodeSelectorRequirement{
+ {
+ Key: "node-role.kubernetes.io/master",
+ Operator: corev1.NodeSelectorOpExists,
+ },
+ },
+ },
+ },
+ },
+ },
},
},
Workloads: &cnao.Placement{
