Kubectl Force recreate plugin
The snippet can be accessed without any authentication.
Authored by
Adphi
Description
This kubectl plugin recreates the pods managed by the specified deployment or daemonset.
Installation:
curl -s https://gitlab.bertha.cloud/snippets/17/raw > kubectl-force && chmod +x kubectl-force && sudo mv kubectl-force /usr/local/bin/
Usage:
kubectl force deploy kube-dns
#!/usr/bin/env bash
# Copyright 2020, The Bertha Cloud Team.
# Copyright 2017, Z Lab Corporation. All rights reserved.
# Copyright 2017, Kubernetes scripts contributors
set -e
if [[ $# -lt 2 ]]; then
echo "Usage: $0 deploy/ds NAME [kubectl options]" >&2
echo "" >&2
echo "This script recreates the pods managed by the specified deployment or daemonset." >&2
exit 1
fi
function _kubectl() {
kubectl $@ $kubectl_options
}
resource="$1"
deployment="$2"
updated_at=$(date +%s)
kubectl_options="${@:3}"
_kubectl patch "$resource" "$deployment" \
-p "{\"spec\":{\"template\":{\"metadata\":{\"annotations\":{\"force-update.bertha.cloud/updated-at\":\"$updated_at\"}}}}}"
Please register or sign in to comment