Skip to content

Instantly share code, notes, and snippets.

@dims
Last active July 22, 2024 14:15
Show Gist options
  • Save dims/62a2eb5c1cf6e3473d2d7f54d3e33415 to your computer and use it in GitHub Desktop.
Save dims/62a2eb5c1cf6e3473d2d7f54d3e33415 to your computer and use it in GitHub Desktop.
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: tune-kindnet
namespace: kube-system
labels:
app: tune-kindnet
spec:
selector:
matchLabels:
name: tune-kindnet
template:
metadata:
labels:
name: tune-kindnet
spec:
tolerations:
- key: node-role.kubernetes.io/control-plane
operator: Exists
effect: NoSchedule
containers:
- name: patch-kindnet
image: gcr.io/k8s-prow/alpine:latest
command:
- "sh"
- "-c"
- |
set -x
while true; do
/sbin/apk add jq && jq '
# Define a function to increment IP
def increment_ip:
split(".") | map(tonumber) | .[3] += 2 | map(tostring) | join(".");
# Extract the subnet
.plugins[0].ipam.ranges[0][0].subnet as $subnet |
# Split the subnet into IP and mask
($subnet | split("/") | .[0]) as $ip |
($subnet | split("/") | .[1]) as $mask |
# Increment the IP
($ip | increment_ip) as $new_ip |
# Add the new rangeStart field
.plugins[0].ipam.ranges[0][0].rangeStart = $new_ip
' /etc/cni/net.d/10-kindnet.conflist > /tmp/10-kindnet.conflist && cp /tmp/10-kindnet.conflist /etc/cni/net.d/10-kindnet.conflist
sleep 5
done
volumeMounts:
- name: host-root
mountPath: /etc/cni/net.d
volumes:
- name: host-root
hostPath:
path: /etc/cni/net.d
type: Directory
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment