From b87c2f6411cb9d3b28c540d9846c09d1b986ab8f Mon Sep 17 00:00:00 2001 From: Rustam Gimadiev Date: Fri, 5 Feb 2021 21:11:18 +0300 Subject: [PATCH] helm chart added (#171) --- .gitignore | 5 ++ chart/kafka-ui/.helmignore | 25 +++++++ chart/kafka-ui/Chart.yaml | 6 ++ chart/kafka-ui/README.md | 21 ++++++ chart/kafka-ui/templates/NOTES.txt | 21 ++++++ chart/kafka-ui/templates/_helpers.tpl | 63 +++++++++++++++++ chart/kafka-ui/templates/configmap.yaml | 8 +++ chart/kafka-ui/templates/deployment.yaml | 74 ++++++++++++++++++++ chart/kafka-ui/templates/hpa.yaml | 28 ++++++++ chart/kafka-ui/templates/ingress.yaml | 41 +++++++++++ chart/kafka-ui/templates/secret.yaml | 9 +++ chart/kafka-ui/templates/service.yaml | 15 ++++ chart/kafka-ui/templates/serviceaccount.yaml | 12 ++++ chart/kafka-ui/values.yaml | 72 +++++++++++++++++++ 14 files changed, 400 insertions(+) create mode 100644 chart/kafka-ui/.helmignore create mode 100644 chart/kafka-ui/Chart.yaml create mode 100644 chart/kafka-ui/README.md create mode 100644 chart/kafka-ui/templates/NOTES.txt create mode 100644 chart/kafka-ui/templates/_helpers.tpl create mode 100644 chart/kafka-ui/templates/configmap.yaml create mode 100644 chart/kafka-ui/templates/deployment.yaml create mode 100644 chart/kafka-ui/templates/hpa.yaml create mode 100644 chart/kafka-ui/templates/ingress.yaml create mode 100644 chart/kafka-ui/templates/secret.yaml create mode 100644 chart/kafka-ui/templates/service.yaml create mode 100644 chart/kafka-ui/templates/serviceaccount.yaml create mode 100644 chart/kafka-ui/values.yaml diff --git a/.gitignore b/.gitignore index f0239e402c..751745cefb 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,8 @@ build/ .DS_Store *.code-workspace + + +*.tar.gz +*.tgz +**/charts/ diff --git a/chart/kafka-ui/.helmignore b/chart/kafka-ui/.helmignore new file mode 100644 index 0000000000..7a93969f5a --- /dev/null +++ b/chart/kafka-ui/.helmignore @@ -0,0 +1,25 @@ +# 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/ +example/ +README.md diff --git a/chart/kafka-ui/Chart.yaml b/chart/kafka-ui/Chart.yaml new file mode 100644 index 0000000000..99838a00a2 --- /dev/null +++ b/chart/kafka-ui/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: kafka-ui +description: A Helm chart for kafka-UI +type: application +version: 0.0.1 +appVersion: 0.0.9 diff --git a/chart/kafka-ui/README.md b/chart/kafka-ui/README.md new file mode 100644 index 0000000000..e6f11c426e --- /dev/null +++ b/chart/kafka-ui/README.md @@ -0,0 +1,21 @@ +# Kafka-UI Helm Chart +## Configuration +Most of the Helm charts parameters are common, follow table describe unique parameters related to application configuration. +### Kafka-UI parameters +| Parameter| Description| Default| +|---|---|---| +| `existingConfigMap`| Name of the existing ConfigMap with Kafka-UI environment variables | `nil`| +| `existingSecret`| Name of the existing Secret with Kafka-UI environment variables| `nil`| +| `envs.secret`| Set of the sensitive environment variables to pass to Kafka-UI | `{}`| +| `envs.config`| Set of the environment variables to pass to Kafka-UI | `{}`| + +## Example +To install Kafka-UI need to execute follow: +``` bash +helm install kafka-ui . --set envs.config.KAFKA_CLUSTERS_0_NAME=local --set envs.config.KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS=kafka:9092 +``` +To connect to Kafka-UI web application need to execute: +``` bash +kubectl port-forward svc/kafka-ui 8080:80 +``` +Open the `http://127.0.0.1:8080` on the browser to access Kafka-UI. \ No newline at end of file diff --git a/chart/kafka-ui/templates/NOTES.txt b/chart/kafka-ui/templates/NOTES.txt new file mode 100644 index 0000000000..65196604d4 --- /dev/null +++ b/chart/kafka-ui/templates/NOTES.txt @@ -0,0 +1,21 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "kafka-ui.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "kafka-ui.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "kafka-ui.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "kafka-ui.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80 +{{- end }} diff --git a/chart/kafka-ui/templates/_helpers.tpl b/chart/kafka-ui/templates/_helpers.tpl new file mode 100644 index 0000000000..076c4886f8 --- /dev/null +++ b/chart/kafka-ui/templates/_helpers.tpl @@ -0,0 +1,63 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "kafka-ui.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-ui.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-ui.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "kafka-ui.labels" -}} +helm.sh/chart: {{ include "kafka-ui.chart" . }} +{{ include "kafka-ui.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "kafka-ui.selectorLabels" -}} +app.kubernetes.io/name: {{ include "kafka-ui.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "kafka-ui.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "kafka-ui.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/chart/kafka-ui/templates/configmap.yaml b/chart/kafka-ui/templates/configmap.yaml new file mode 100644 index 0000000000..c802e57522 --- /dev/null +++ b/chart/kafka-ui/templates/configmap.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "kafka-ui.fullname" . }} + labels: + {{- include "kafka-ui.labels" . | nindent 4 }} +data: + {{- toYaml .Values.envs.config | nindent 2 }} \ No newline at end of file diff --git a/chart/kafka-ui/templates/deployment.yaml b/chart/kafka-ui/templates/deployment.yaml new file mode 100644 index 0000000000..23b1ccf745 --- /dev/null +++ b/chart/kafka-ui/templates/deployment.yaml @@ -0,0 +1,74 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "kafka-ui.fullname" . }} + labels: + {{- include "kafka-ui.labels" . | nindent 4 }} +spec: +{{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} +{{- end }} + selector: + matchLabels: + {{- include "kafka-ui.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "kafka-ui.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "kafka-ui.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + envFrom: + {{- if .Values.existingConfigMap }} + - configMapRef: + name: {{ .Values.existingConfigMap }} + {{- end }} + - configMapRef: + name: {{ include "kafka-ui.fullname" . }} + {{- if .Values.existingSecret }} + - secretRef: + name: {{ .Values.existingSecret }} + {{- end }} + - secretRef: + name: {{ include "kafka-ui.fullname" . }} + ports: + - name: http + containerPort: 8080 + protocol: TCP + livenessProbe: + httpGet: + path: / + port: http + readinessProbe: + httpGet: + path: / + port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/chart/kafka-ui/templates/hpa.yaml b/chart/kafka-ui/templates/hpa.yaml new file mode 100644 index 0000000000..1509ef3f01 --- /dev/null +++ b/chart/kafka-ui/templates/hpa.yaml @@ -0,0 +1,28 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "kafka-ui.fullname" . }} + labels: + {{- include "kafka-ui.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "kafka-ui.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/chart/kafka-ui/templates/ingress.yaml b/chart/kafka-ui/templates/ingress.yaml new file mode 100644 index 0000000000..a966d32785 --- /dev/null +++ b/chart/kafka-ui/templates/ingress.yaml @@ -0,0 +1,41 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "kafka-ui.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "kafka-ui.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ . }} + backend: + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} diff --git a/chart/kafka-ui/templates/secret.yaml b/chart/kafka-ui/templates/secret.yaml new file mode 100644 index 0000000000..a2ebf0fdba --- /dev/null +++ b/chart/kafka-ui/templates/secret.yaml @@ -0,0 +1,9 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "kafka-ui.fullname" . }} + labels: + {{- include "kafka-ui.labels" . | nindent 4 }} +type: Opaque +data: + {{- toYaml .Values.envs.secret | nindent 2 }} \ No newline at end of file diff --git a/chart/kafka-ui/templates/service.yaml b/chart/kafka-ui/templates/service.yaml new file mode 100644 index 0000000000..339bb35a5a --- /dev/null +++ b/chart/kafka-ui/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "kafka-ui.fullname" . }} + labels: + {{- include "kafka-ui.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "kafka-ui.selectorLabels" . | nindent 4 }} diff --git a/chart/kafka-ui/templates/serviceaccount.yaml b/chart/kafka-ui/templates/serviceaccount.yaml new file mode 100644 index 0000000000..b89551c833 --- /dev/null +++ b/chart/kafka-ui/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "kafka-ui.serviceAccountName" . }} + labels: + {{- include "kafka-ui.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/chart/kafka-ui/values.yaml b/chart/kafka-ui/values.yaml new file mode 100644 index 0000000000..19db608288 --- /dev/null +++ b/chart/kafka-ui/values.yaml @@ -0,0 +1,72 @@ +replicaCount: 1 + +image: + repository: provectuslabs/kafka-ui + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "latest" + +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: "" + +existingConfigMap: "" +existingSecret: "" +envs: + secret: {} + config: {} + +podAnnotations: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: false + annotations: {} + hosts: + - host: chart-example.local + paths: [] + tls: [] + +resources: {} + # limits: + # cpu: 200m + # memory: 512Mi + # requests: + # cpu: 200m + # memory: 256Mi + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +nodeSelector: {} + +tolerations: [] + +affinity: {}