Skip to content

Instantly share code, notes, and snippets.

@allanlei allanlei/daemonset.yaml
Last active Sep 2, 2019

Embed
What would you like to do?
Kubernetes sysctl daemonset for tuning Transparent Huge Pages
apiVersion: apps/v1
kind: DaemonSet
metadata:
namespace: kube-system
name: sysctl
spec:
selector:
matchLabels:
app: sysctl
template:
metadata:
labels:
app: sysctl
spec:
volumes:
- name: sys
hostPath:
path: /sys
initContainers:
- name: disable-thp
image: busybox
command: ["sh", "-c"]
args:
- |-
set -e
set -o pipefail
echo never > /rootfs/sys/kernel/mm/transparent_hugepage/enabled
echo never > /rootfs/sys/kernel/mm/transparent_hugepage/defrag
grep -q -F [never] /sys/kernel/mm/transparent_hugepage/enabled
grep -q -F [never] /sys/kernel/mm/transparent_hugepage/defrag
volumeMounts:
- name: sys
mountPath: /rootfs/sys
- name: label-node
image: wardsco/kubectl:1.11
command: ["kubectl"]
args: ["label", "node", "--overwrite", "$(NODE_NAME)", "sysctl/mm.transparent_hugepage.enabled=never", "sysctl/mm.transparent_hugepage.defrag=never"]
env:
- name: NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
containers:
- name: sleep
image: wardsco/sleep
imagePullPolicy: IfNotPresent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.