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

Automated cherry pick of #3731: Fix tolerations for Kubernetes >= 1.24 #3746

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions build/yamls/antrea-aks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3194,6 +3194,8 @@ spec:
operator: Exists
- effect: NoSchedule
key: node-role.kubernetes.io/master
- effect: NoSchedule
key: node-role.kubernetes.io/control-plane
volumes:
- configMap:
name: antrea-config-82h2mk24gg
Expand Down
2 changes: 2 additions & 0 deletions build/yamls/antrea-eks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3194,6 +3194,8 @@ spec:
operator: Exists
- effect: NoSchedule
key: node-role.kubernetes.io/master
- effect: NoSchedule
key: node-role.kubernetes.io/control-plane
volumes:
- configMap:
name: antrea-config-82h2mk24gg
Expand Down
2 changes: 2 additions & 0 deletions build/yamls/antrea-gke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3194,6 +3194,8 @@ spec:
operator: Exists
- effect: NoSchedule
key: node-role.kubernetes.io/master
- effect: NoSchedule
key: node-role.kubernetes.io/control-plane
volumes:
- configMap:
name: antrea-config-c9ck44454h
Expand Down
2 changes: 2 additions & 0 deletions build/yamls/antrea-ipsec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3208,6 +3208,8 @@ spec:
operator: Exists
- effect: NoSchedule
key: node-role.kubernetes.io/master
- effect: NoSchedule
key: node-role.kubernetes.io/control-plane
volumes:
- configMap:
name: antrea-config-tmhkc66d6c
Expand Down
2 changes: 2 additions & 0 deletions build/yamls/antrea.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3199,6 +3199,8 @@ spec:
operator: Exists
- effect: NoSchedule
key: node-role.kubernetes.io/master
- effect: NoSchedule
key: node-role.kubernetes.io/control-plane
volumes:
- configMap:
name: antrea-config-hkhbh5gf99
Expand Down
3 changes: 3 additions & 0 deletions build/yamls/base/controller.yml
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,9 @@ spec:
# Allow it to schedule onto master nodes.
- key: node-role.kubernetes.io/master
effect: NoSchedule
# Control-plane taint for Kubernetes >= 1.24.
- key: node-role.kubernetes.io/control-plane
effect: NoSchedule
serviceAccountName: antrea-controller
containers:
- name: antrea-controller
Expand Down
28 changes: 15 additions & 13 deletions test/e2e/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,12 +371,19 @@ func labelNodeRoleControlPlane() string {
return labelNodeRoleControlPlane
}

func controlPlaneNoScheduleToleration() corev1.Toleration {
func controlPlaneNoScheduleTolerations() []corev1.Toleration {
// the Node taint still uses "master" in K8s v1.20
return corev1.Toleration{
Key: "node-role.kubernetes.io/master",
Operator: corev1.TolerationOpExists,
Effect: corev1.TaintEffectNoSchedule,
return []corev1.Toleration{
{
Key: "node-role.kubernetes.io/master",
Operator: corev1.TolerationOpExists,
Effect: corev1.TaintEffectNoSchedule,
},
{
Key: "node-role.kubernetes.io/control-plane",
Operator: corev1.TolerationOpExists,
Effect: corev1.TaintEffectNoSchedule,
},
}
}

Expand Down Expand Up @@ -1042,8 +1049,7 @@ func (data *TestData) CreatePodOnNodeInNamespace(name, ns string, nodeName, ctrN
}
if nodeName == controlPlaneNodeName() {
// tolerate NoSchedule taint if we want Pod to run on control-plane Node
noScheduleToleration := controlPlaneNoScheduleToleration()
podSpec.Tolerations = []corev1.Toleration{noScheduleToleration}
podSpec.Tolerations = controlPlaneNoScheduleTolerations()
}
pod := &corev1.Pod{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -2312,9 +2318,7 @@ func (data *TestData) createAgnhostPodOnNodeWithAnnotations(name string, ns stri

func (data *TestData) createDaemonSet(name string, ns string, ctrName string, image string, cmd []string, args []string) (*appsv1.DaemonSet, func() error, error) {
podSpec := corev1.PodSpec{
Tolerations: []corev1.Toleration{
controlPlaneNoScheduleToleration(),
},
Tolerations: controlPlaneNoScheduleTolerations(),
Containers: []corev1.Container{
{
Name: ctrName,
Expand Down Expand Up @@ -2386,9 +2390,7 @@ func (data *TestData) waitForDaemonSetPods(timeout time.Duration, dsName string,

func (data *TestData) createStatefulSet(name string, ns string, size int32, ctrName string, image string, cmd []string, args []string, mutateFunc func(*appsv1.StatefulSet)) (*appsv1.StatefulSet, func() error, error) {
podSpec := corev1.PodSpec{
Tolerations: []corev1.Toleration{
controlPlaneNoScheduleToleration(),
},
Tolerations: controlPlaneNoScheduleTolerations(),
Containers: []corev1.Container{
{
Name: ctrName,
Expand Down
3 changes: 1 addition & 2 deletions test/e2e/networkpolicy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -816,8 +816,7 @@ func testIngressPolicyWithEndPort(t *testing.T, data *TestData) {
}
if nodeName == controlPlaneNodeName() {
// tolerate NoSchedule taint if we want Pod to run on control-plane Node
noScheduleToleration := controlPlaneNoScheduleToleration()
podSpec.Tolerations = []corev1.Toleration{noScheduleToleration}
podSpec.Tolerations = controlPlaneNoScheduleTolerations()
}
pod := &corev1.Pod{
ObjectMeta: metav1.ObjectMeta{
Expand Down
4 changes: 1 addition & 3 deletions test/e2e/performance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ var (
customizePolicyRules = flag.Int("perf.http.policy_rules", 0, "Number of CIDRs in the network policy")
httpConcurrency = flag.Int("perf.http.concurrency", 1, "Number of multiple requests to make at a time")
realizeTimeout = flag.Duration("perf.realize.timeout", 5*time.Minute, "Timeout of the realization of network policies")
// tolerate NoSchedule taint to let the Pod run on control-plane Node
noScheduleToleration = controlPlaneNoScheduleToleration()
labelSelector = &metav1.LabelSelector{
MatchLabels: map[string]string{"app": perfTestAppLabel},
}
Expand Down Expand Up @@ -118,7 +116,7 @@ func createPerfTestPodDefinition(name, containerName, image string) *corev1.Pod
"kubernetes.io/hostname": controlPlaneNodeName(),
}

podSpec.Tolerations = []corev1.Toleration{noScheduleToleration}
podSpec.Tolerations = controlPlaneNoScheduleTolerations()
pod := &corev1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Expand Down