kubeRestartDeployment: Add function

The `kubeRestartDeployment` function restarts a Kubernetes deployment
using `kubectl rollout restart`.  This command is run in a dedicated
pod, with the `kubectl` binary bind-mounted from the host.
master
Dustin 2025-03-12 20:36:04 -05:00
commit 917db648c7
1 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1,34 @@
@groovy.transform.Field
def POD_YAML = '''\
spec:
containers:
- name: jnlp
volumeMounts:
- name: kubectl
mountPath: /bin/kubectl
readOnly: true
volumes:
- name: kubectl
hostPath:
path: /usr/bin/kubectl
type: File
'''
def call(args) {
def namespace = args?.namespace
def name = args?.name
if (name == null) {
name = env.JOB_NAME.split('/')[1]
}
if (namespace == null) {
namespace = name
}
podTemplate(yaml: POD_YAML) {
node(POD_LABEL) {
sh "kubectl rollout restart deployment -n ${namespace} ${name}"
}
}
}