Skip to content

Instantly share code, notes, and snippets.

@keyan1603
Last active May 16, 2024 08:22
Show Gist options
  • Save keyan1603/5cad0b8bf5d6ed8f942cab233cde9598 to your computer and use it in GitHub Desktop.
Save keyan1603/5cad0b8bf5d6ed8f942cab233cde9598 to your computer and use it in GitHub Desktop.
Kubectl commands to gracefully rollout nodes in EKS
Cordon all nodes:
kubectl get nodes | ForEach-Object{($_.Split(""))[0]} | where {$_ -ne " NAME"} | ForEach-Object{(kubectl cordon $_)}
Rollout Master node:
kubectl get deployments -n kube-system| ForEach-Object{($_.Split(""))[0]} | where {$_ -ne " NAME"} | ForEach-Object{(kubectl -n kube-system rollout restart deployment $_)}
kubectl get daemonsets -n kube-system| ForEach-Object{($_.Split(""))[0]} | where {$_ -ne " NAME"} | ForEach-Object{(kubectl -n kube-system rollout restart daemonset $_)}
Rollout Worker nodes:
kubectl get deployments | ForEach-Object{($_.Split(""))[0]} | where {$_ -ne " NAME"} | ForEach-Object{(kubectl rollout restart deployment $_)}
kubectl get daemonsets | ForEach-Object{($_.Split(""))[0]} | where {$_ -ne " NAME"} | ForEach-Object{(kubectl rollout restart daemonset $_)}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment