Last active
May 8, 2019 23:02
-
-
Save limed/2486e84dcbb1098981af076011cfb8db to your computer and use it in GitHub Desktop.
lifecycled handler
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Autoscale Lifecycle Daemon | |
Requires=network-online.target | |
After=network-online.target | |
[Service] | |
Type=simple | |
Restart=on-failure | |
RestartForceExitStatus=SIGPIPE | |
RestartSec=30s | |
TimeoutStopSec=5m | |
EnvironmentFile=/etc/lifecycled | |
ExecStart=/usr/bin/lifecycled --cloudwatch-group=/aws/lifecycled --json | |
[Install] | |
WantedBy=multi-user.target |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -u | |
set -x | |
HOSTNAME=$(curl -fsq http://169.254.169.254/latest/meta-data/hostname) | |
REGION=$(curl -fqs http://169.254.169.254/latest/dynamic/instance-identity/document | jq -r .region) | |
CLUSTER_NAME=$(cat /etc/eks/cluster_name) | |
# Setup kubeconfig | |
aws eks update-kubeconfig --region "${REGION}" --name "${CLUSTER_NAME}" | |
export KUBECONFIG="/root/.kube/config" | |
kubectl cordon "${HOSTNAME}" | |
kubectl drain "${HOSTNAME}" --ignore-daemonsets --grace-period=30 --force | |
sleep 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment