Skip to content

Instantly share code, notes, and snippets.

@miminar
Created September 23, 2020 13:21
Show Gist options
  • Save miminar/1399627ef114f96245f011185fa3747b to your computer and use it in GitHub Desktop.
Save miminar/1399627ef114f96245f011185fa3747b to your computer and use it in GitHub Desktop.
Remove network.openshift.io/mtu-too-small taint from nodes

Remove network.openshift.io/mtu-too-small taint from nodes

The pod monitors nodes and removes network.openshift.io/mtu-too-small taint whenever openshift-sdn pod taints the node with network.openshift.io/mtu-too-small

See https://bugzilla.redhat.com/show_bug.cgi?id=1879077 for more details.

Usage

oc new-project infra
oc create -f sa.yaml
oc create -f clusterrolebinding.yaml
oc create -f dc.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: node-controller-untainter
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: system:controller:node-controller
subjects:
- kind: ServiceAccount
name: untainter
apiVersion: v1
kind: DeploymentConfig
metadata:
name: untaint-mtu-too-small
spec:
replicas: 2
selector:
app: untaint-mtu-too-small
strategy:
type: Recreate
template:
metadata:
labels:
app: untaint-mtu-too-small
name: untaint-mtu-too-small
spec:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchLabels:
app: untaint-mtu-too-small
topologyKey: kubernetes.io/hostname
serviceAccountName: untainter
containers:
- args:
- bash
- -c
- |
set -euo pipefail
IFS=$'\n\t'
oc observe nodes --output=gotemplate \
--argument='{{with .spec.taints}}{{range .}}{{if eq .key "network.openshift.io/mtu-too-small"}}#tainted{{end}}{{end}}{{end}}' | \
while IFS=' ' read -r _ _ _ _ nodename arguments; do
if [[ -z "${nodename:-}" || ! "${arguments:-}" =~ tainted ]]; then
continue
fi
oc adm taint nodes $nodename network.openshift.io/mtu-too-small-
done
command:
- /usr/bin/env
image: " "
imagePullPolicy: IfNotPresent
name: untainter
ports:
resources:
limits:
cpu: "200m"
memory: 250Mi
requests:
cpu: "200m"
memory: 250Mi
triggers:
- type: ConfigChange
- imageChangeParams:
automatic: true
containerNames:
- untainter
from:
kind: ImageStreamTag
name: cli:latest
namespace: openshift
type: ImageChange
strategy:
type: Rolling
apiVersion: v1
kind: ServiceAccount
metadata:
name: untainter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment