Skip to content

Instantly share code, notes, and snippets.

@willthames
Created October 30, 2018 23:41
Show Gist options
  • Save willthames/897513e685586d9d24940bcfce26a7d4 to your computer and use it in GitHub Desktop.
Save willthames/897513e685586d9d24940bcfce26a7d4 to your computer and use it in GitHub Desktop.
hooks definition for kubectl drain service in kops
hooks:
- execContainer:
command:
- sh
- -c
- chroot /rootfs curl -LsO https://storage.googleapis.com/kubernetes-release/release/v1.12.0/bin/linux/amd64/kubectl && chroot /rootfs install -m 755 kubectl /usr/local/bin/kubectl
image: busybox
roles:
- Node
- name: kubectl-drain.service
roles:
- Node
useRawManifest: true
manifest: |
[Unit]
Description=drain this k8s node to make running pods time to gracefully shut down before stopping kubelet
After=kubelet.service
[Service]
Type=oneshot
RemainAfterExit=true
ExecStart=/bin/true
TimeoutStopSec=120s
ExecStop=/bin/sh -c "/usr/local/bin/kubectl drain --ignore-daemonsets=true --delete-local-data=true $$(hostname -f) --kubeconfig /var/lib/kubelet/kubeconfig"
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment