-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add helm charts with cronjob support (#78)
* feat: add helm charts with cronjob support * chore: add permissions * fix: add correct app version to Chart * feat: add Chart documentation * fix: change command variable name * fix: pull request comments
- Loading branch information
1 parent
8ad17e7
commit f3235b0
Showing
10 changed files
with
342 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Patterns to ignore when building packages. | ||
# This supports shell glob matching, relative path matching, and | ||
# negation (prefixed with !). Only one pattern per line. | ||
.DS_Store | ||
# Common VCS dirs | ||
.git/ | ||
.gitignore | ||
.bzr/ | ||
.bzrignore | ||
.hg/ | ||
.hgignore | ||
.svn/ | ||
# Common backup files | ||
*.swp | ||
*.bak | ||
*.tmp | ||
*.orig | ||
*~ | ||
# Various IDEs | ||
.project | ||
.idea/ | ||
*.tmproj | ||
.vscode/ |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
apiVersion: v2 | ||
name: kor | ||
description: A Helm chart for Kubernetes | ||
|
||
# A chart can be either an 'application' or a 'library' chart. | ||
# | ||
# Application charts are a collection of templates that can be packaged into versioned archives | ||
# to be deployed. | ||
# | ||
# Library charts provide useful utilities or functions for the chart developer. They're included as | ||
# a dependency of application charts to inject those utilities and functions into the rendering | ||
# pipeline. Library charts do not define any templates and therefore cannot be deployed. | ||
type: application | ||
|
||
# This is the chart version. This version number should be incremented each time you make changes | ||
# to the chart and its templates, including the app version. | ||
# Versions are expected to follow Semantic Versioning (https://semver.org/) | ||
version: 0.1.0 | ||
|
||
# This is the version number of the application being deployed. This version number should be | ||
# incremented each time you make changes to the application. Versions are not expected to | ||
# follow Semantic Versioning. They should reflect the version the application is using. | ||
# It is recommended to use it with quotes. | ||
appVersion: "0.2.2" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# kor | ||
|
||
![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.2.2](https://img.shields.io/badge/AppVersion-0.2.2-informational?style=flat-square) | ||
|
||
A Helm chart to deploy Kor as into a Kubernetes cluster. | ||
|
||
## Values | ||
|
||
| Key | Type | Default | Description | | ||
| ---------------------------------- | ------ | ------------------- | ----------- | | ||
| cronJob.enabled | bool | `true` | | | ||
| cronJob.failedJobsHistoryLimit | int | `2` | | | ||
| cronJob.image.repository | string | `"yonahdissen/kor"` | | | ||
| cronJob.image.tag | string | `"latest"` | | | ||
| cronJob.command | string | `"kor all"` | | | ||
| cronJob.name | string | `"kor"` | | | ||
| cronJob.restartPolicy | string | `"OnFailure"` | | | ||
| cronJob.schedule | string | `"0 1 * * 1"` | | | ||
| cronJob.slackAuthToken | string | `""` | | | ||
| cronJob.slackChannel | string | `""` | | | ||
| cronJob.slackWebhookUrl | string | `""` | | | ||
| cronJob.successfulJobsHistoryLimit | int | `3` | | | ||
| namespace | string | `"kor"` | | | ||
| serviceAccount.annotations | object | `{}` | | | ||
| serviceAccount.create | bool | `true` | | | ||
| serviceAccount.name | string | `""` | | | ||
|
||
--- | ||
|
||
Autogenerated from chart metadata using [helm-docs v1.8.1](https://github.com/norwoodj/helm-docs/releases/v1.8.1) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
{{/* | ||
Expand the name of the chart. | ||
*/}} | ||
{{- define "kor.name" -}} | ||
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create a default fully qualified app name. | ||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). | ||
If release name contains chart name it will be used as a full name. | ||
*/}} | ||
{{- define "kor.fullname" -}} | ||
{{- if .Values.fullnameOverride }} | ||
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} | ||
{{- else }} | ||
{{- $name := default .Chart.Name .Values.nameOverride }} | ||
{{- if contains $name .Release.Name }} | ||
{{- .Release.Name | trunc 63 | trimSuffix "-" }} | ||
{{- else }} | ||
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} | ||
|
||
{{/* | ||
Allow the release namespace to be overridden for multi-namespace deployments in combined charts | ||
*/}} | ||
{{- define "kor.namespace" -}} | ||
{{- if .Values.namespaceOverride }} | ||
{{- .Values.namespaceOverride }} | ||
{{- else }} | ||
{{- .Release.Namespace }} | ||
{{- end }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create chart name and version as used by the chart label. | ||
*/}} | ||
{{- define "kor.chart" -}} | ||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
|
||
{{/* | ||
Common labels | ||
*/}} | ||
{{- define "kor.labels" -}} | ||
helm.sh/chart: {{ include "kor.chart" . }} | ||
{{ include "kor.selectorLabels" . }} | ||
{{- if .Chart.AppVersion }} | ||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} | ||
{{- end }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
{{- end }} | ||
|
||
{{/* | ||
Selector labels | ||
*/}} | ||
{{- define "kor.selectorLabels" -}} | ||
app.kubernetes.io/name: {{ include "kor.name" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create the name of the service account to use | ||
*/}} | ||
{{- define "kor.serviceAccountName" -}} | ||
{{- if .Values.serviceAccount.create }} | ||
{{- default (include "kor.fullname" .) .Values.serviceAccount.name }} | ||
{{- else }} | ||
{{- default "default" .Values.serviceAccount.name }} | ||
{{- end }} | ||
{{- end }} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{{- if .Values.cronJob.enabled -}} | ||
apiVersion: batch/v1 | ||
kind: CronJob | ||
metadata: | ||
name: {{ .Release.Name }} | ||
labels: | ||
app: {{ .Release.Name }} | ||
spec: | ||
schedule: {{ .Values.cronJob.schedule }} | ||
jobTemplate: | ||
spec: | ||
template: | ||
metadata: | ||
name: {{ .Release.Name }} | ||
spec: | ||
serviceAccountName: {{ include "kor.serviceAccountName" . }} | ||
containers: | ||
- name: {{ .Release.Name }}-container | ||
image: {{ .Values.cronJob.image.repository }}:{{ .Values.cronJob.image.tag }} | ||
command: ["/bin/sh", "-c"] | ||
{{- if .Values.cronJob.slackWebhookUrl }} | ||
args: ["{{ .Values.cronJob.command }} --slack-webhook-url {{ .Values.cronJob.slackWebhookUrl }}"] | ||
{{- else if and .Values.cronJob.slackChannel .Values.cronJob.slackAuthToken }} | ||
args: ["{{ .Values.cronJob.command }} --slack-channel {{ .Values.cronJob.slackChannel }} --slack-auth-token {{ .Values.cronJob.slackAuthToken }}"] | ||
{{- else }} | ||
args: ["{{ .Values.cronJob.command }}"] | ||
{{- end }} | ||
{{- if .Values.cronJob.env }} | ||
env: | ||
{{- toYaml .Values.cronJob.env | nindent 12 }} | ||
{{- end }} | ||
restartPolicy: {{ .Values.cronJob.restartPolicy }} | ||
{{- if .Values.cronJob.successfulJobsHistoryLimit }} | ||
successfulJobsHistoryLimit: {{ .Values.cronJob.successfulJobsHistoryLimit }} | ||
{{- end }} | ||
{{- if .Values.cronJob.failedJobsHistoryLimit }} | ||
failedJobsHistoryLimit: {{ .Values.cronJob.failedJobsHistoryLimit }} | ||
{{- end }} | ||
{{- end }} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: Role | ||
metadata: | ||
name: {{ include "kor.serviceAccountName" . }}-read-resources-role | ||
rules: | ||
- apiGroups: ["*"] | ||
resources: | ||
- pods | ||
- configmaps | ||
- namespaces | ||
- secrets | ||
- services | ||
- serviceaccounts | ||
- deployments | ||
- statefulsets | ||
- roles | ||
- rolebindings | ||
- clusterroles | ||
- clusterrolebindings | ||
- horizontalpodautoscalers | ||
- persistentvolumeclaims | ||
- ingresses | ||
- poddisruptionbudgets | ||
- endpoints | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: {{ include "kor.serviceAccountName" . }}-read-resources-clusterrole | ||
rules: | ||
- apiGroups: ["*"] | ||
resources: | ||
- pods | ||
- configmaps | ||
- namespaces | ||
- secrets | ||
- services | ||
- serviceaccounts | ||
- deployments | ||
- statefulsets | ||
- roles | ||
- rolebindings | ||
- clusterroles | ||
- clusterrolebindings | ||
- horizontalpodautoscalers | ||
- persistentvolumeclaims | ||
- ingresses | ||
- poddisruptionbudgets | ||
- endpoints | ||
verbs: | ||
- get | ||
- list | ||
- watch |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: RoleBinding | ||
metadata: | ||
name: {{ include "kor.serviceAccountName" . }}-read-resources-role-binding | ||
subjects: | ||
- kind: ServiceAccount | ||
name: {{ include "kor.serviceAccountName" . }} | ||
roleRef: | ||
kind: Role | ||
name: {{ include "kor.serviceAccountName" . }}-read-resources-role | ||
apiGroup: rbac.authorization.k8s.io | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: {{ include "kor.serviceAccountName" . }}-read-resources-clusterrolebinding | ||
subjects: | ||
- kind: ServiceAccount | ||
name: {{ include "kor.serviceAccountName" . }} | ||
namespace: {{ include "kor.namespace" . }} | ||
roleRef: | ||
kind: ClusterRole | ||
name: {{ include "kor.serviceAccountName" . }}-read-resources-clusterrole | ||
apiGroup: rbac.authorization.k8s.io |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{{- if .Values.serviceAccount.create -}} | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: {{ include "kor.serviceAccountName" . }} | ||
labels: | ||
{{- include "kor.labels" . | nindent 4 }} | ||
{{- with .Values.serviceAccount.annotations }} | ||
annotations: | ||
{{- toYaml . | nindent 4 }} | ||
{{- end }} | ||
{{- end }} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
cronJob: | ||
enabled: true | ||
name: kor | ||
schedule: "0 1 * * 1" | ||
image: | ||
repository: yonahdissen/kor | ||
tag: latest | ||
# e.g. kor configmap --include-namespace default,other-ns | ||
command: kor all | ||
slackWebhookUrl: "" | ||
slackChannel: "" | ||
slackAuthToken: "" | ||
restartPolicy: OnFailure | ||
successfulJobsHistoryLimit: 3 | ||
failedJobsHistoryLimit: 2 | ||
|
||
serviceAccount: | ||
# Specifies whether a service account should be created | ||
create: true | ||
# Annotations to add to the service account | ||
annotations: {} | ||
# The name of the service account to use. | ||
# If not set and create is true, a name is generated using the fullname template | ||
name: "" |