Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

helm charts for kafka-gitops #72

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions helm_charts/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: kafka-manage
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: "1.16.0"
62 changes: 62 additions & 0 deletions helm_charts/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "kafka-manage.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 "kafka-manage.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 }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "kafka-manage.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "kafka-manage.labels" -}}
helm.sh/chart: {{ include "kafka-manage.chart" . }}
{{ include "kafka-manage.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "kafka-manage.selectorLabels" -}}
app.kubernetes.io/name: {{ include "kafka-manage.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "kafka-manage.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "kafka-manage.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
21 changes: 21 additions & 0 deletions helm_charts/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "kafka-manage.fullname" . }}
labels:
{{- include "kafka-manage.labels" . | nindent 4 }}
data:
{{- if .Values.state }}
{{ $root := . }}
{{- range $key, $value := .Values.state }}
{{ $key }}: |
{{ tpl (toYaml $value | indent 4) $root }}
{{- end -}}
{{- end -}}

{{- if .Values.notifiers }}
{{- range $key, $value := .Values.notifiers }}
{{ $key }}: |
{{ toYaml $value | indent 4 }}
{{- end -}}
{{- end -}}
53 changes: 53 additions & 0 deletions helm_charts/templates/job.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
apiVersion: batch/v1
kind: Job
metadata:
name: {{ template "kafka-manage.fullname" . }}
spec:
template:
spec:
containers:
- image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
name: {{ template "kafka-manage.fullname" . }}
env:
- name: ACTION
value: "{{ .Values.state.action }}"
- name: ARGS
value: "{{ .Values.state.args }}"
- name: KAFKA_BOOTSTRAP_SERVERS
value: "{{ .Values.bootstrap.servers }}"
{{- range .Values.environment | default list}}
- name: {{ .name | quote}}
value: {{ .value | quote }}
{{- end }}
args: ['/usr/local/bin/kafka-gitops', '-f', '/config/state.yaml', '$(ACTION)']
{{- if .Values.state.args }}
args: ['/usr/local/bin/kafka-gitops', '-f', '/config/state.yaml', '$(ARGS)', '$(ACTION)']
{{- end }}
{{- with .Values.resources }}
resources:
{{ toYaml . | indent 10 }}
{{- end }}
volumeMounts:
- name: {{ template "kafka-manage.fullname" . }}
mountPath: "/config/state.yaml"
subPath: state.yaml
{{- with .Values.nodeSelector }}
nodeSelector:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{ toYaml . | indent 8 }}
{{- end }}
volumes:
- name: {{ template "kafka-manage.fullname" . }}
configMap:
name: {{ template "kafka-manage.fullname" . }}
restartPolicy: {{ .Values.restartPolicy }}
backoffLimit: {{ .Values.backoffLimit }}
12 changes: 12 additions & 0 deletions helm_charts/templates/serviceaccount.yaml
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 "kafka-manage.serviceAccountName" . }}
labels:
{{- include "kafka-manage.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
143 changes: 143 additions & 0 deletions helm_charts/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
# Default values for kafka-manage.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

## More info https://github.com/devshawn/kafka-gitops

replicaCount: 1

image:
repository: devshawn/kafka-gitops
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: "0.2.15"

imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""

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: ""

restartPolicy: Never
backoffLimit: 1

### args ###
# --skip-acls Do not take ACLs into account during plans or applies.
# --no-delete Disable the ability to delete resources.
# --verbose Show more detail during execution
# --version Print the current version of this tool
###

### action
# plan Apply changes to Kafka resources.
# apply Generate an execution plan of changes to Kafka resources.
# validate Validates the desired state file.
###

state:
action: plan
args: ""
state.yaml: # state.yaml configuration
users:
gitops-user:
principal: User:gitops-user
roles: []

customUserAcls:
gitops-user:
alter-cluster:
name: kafka-cluster
type: CLUSTER
pattern: LITERAL
host: "*"
operation: ALTER
permission: ALLOW
create-topics:
name: "*"
type: TOPIC
pattern: LITERAL
host: "*"
operation: CREATE
permission: ALLOW
alter-topics:
name: "*"
type: TOPIC
pattern: LITERAL
host: "*"
operation: ALTER
permission: ALLOW
describe-topics:
name: "*"
type: TOPIC
pattern: LITERAL
host: "*"
operation: DESCRIBE
permission: ALLOW
delete-topics:
name: "*"
type: TOPIC
pattern: LITERAL
host: "*"
operation: DELETE
permission: ALLOW
describe-topic-configs:
name: "*"
type: TOPIC
pattern: LITERAL
host: "*"
operation: DESCRIBE_CONFIGS
permission: ALLOW
alter-topic-configs:
name: "*"
type: TOPIC
pattern: LITERAL
host: "*"
operation: ALTER_CONFIGS
permission: ALLOW

## default vars
bootstrap:
servers: "localhost:9200"

## More vars
#environment:
# - name: KAFKA_SASL_JAAS_USERNAME
# value:

podAnnotations: {}

podSecurityContext: {}
# fsGroup: 2000

securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000

resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi

nodeSelector: {}

tolerations: []

affinity: {}