Skip to content

Instantly share code, notes, and snippets.

@jessegoodier
Created August 27, 2023 16:48
Show Gist options
  • Save jessegoodier/7f803c5c4d0d0a6edb6cef6e4f67ddb7 to your computer and use it in GitHub Desktop.
Save jessegoodier/7f803c5c4d0d0a6edb6cef6e4f67ddb7 to your computer and use it in GitHub Desktop.
Kubernetes cronjob to run helm upgrade
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: update-nightly-helm-sa
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: cluster-admin-binding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: update-nightly-helm-sa
namespace: cronjobs
---
apiVersion: batch/v1
kind: CronJob
metadata:
name: update-nightly-helm
namespace: cronjobs
spec:
schedule: "11 * * * *"
jobTemplate:
spec:
template:
spec:
serviceAccountName: update-nightly-helm-sa
restartPolicy: Never
containers:
- name: update-nightly-helm
image: alpine/k8s:1.28.0
command: ["/bin/sh", "-c","helm upgrade -n kubecost-nightly kubecost-nightly --repo https://kubecost.github.io/nightly-helm-chart cost-analyzer --history-max 256"]
imagePullPolicy: IfNotPresent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment