Skip to content

Commit

Permalink
add control-center charts (confluentinc#271)
Browse files Browse the repository at this point in the history
* add control-center charts

* rename cp-enterprise-control-center to cp-control-center
  • Loading branch information
davidsung authored and gAmUssA committed Apr 4, 2019
1 parent b681f4c commit 81ff624
Show file tree
Hide file tree
Showing 12 changed files with 407 additions and 4 deletions.
21 changes: 21 additions & 0 deletions charts/cp-control-center/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 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
*~
# Various IDEs
.project
.idea/
*.tmproj
5 changes: 5 additions & 0 deletions charts/cp-control-center/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: v1
appVersion: "1.0"
description: A Helm chart Confluent Control Center for Kubernetes
name: cp-control-center
version: 0.1.0
9 changes: 9 additions & 0 deletions charts/cp-control-center/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
This chart installs a Confluent Control Center

To connect to Confluent Control Center directly from outside the k8s cluster:

1. Execute the following command to setup port forward from k8s to localhost
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "cp-control-center.name" . }}" -o jsonpath="{.items[0].metadata.name}")
kubectl port-forward $POD_NAME {{ .Values.serviceHttpPort }}

2. Open a browser and visit http://localhost:{{ .Values.serviceHttpPort }}
128 changes: 128 additions & 0 deletions charts/cp-control-center/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "cp-control-center.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 "cp-control-center.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 "cp-control-center.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create a default fully qualified kafka headless name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "cp-control-center.cp-kafka-headless.fullname" -}}
{{- $name := "cp-kafka-headless" -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Form the Kafka URL. If Kafka is installed as part of this chart, use k8s service discovery,
else use user-provided URL
*/}}
{{- define "cp-control-center.kafka.bootstrapServers" -}}
{{- if .Values.kafka.bootstrapServers -}}
{{- .Values.kafka.bootstrapServers -}}
{{- else -}}
{{- printf "PLAINTEXT://%s:9092" (include "cp-control-center.cp-kafka-headless.fullname" .) -}}
{{- end -}}
{{- end -}}

{{/*
Create a default fully qualified schema registry name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "cp-control-center.cp-schema-registry.fullname" -}}
{{- $name := default "cp-schema-registry" (index .Values "cp-schema-registry" "nameOverride") -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{- define "cp-control-center.cp-schema-registry.service-name" -}}
{{- if (index .Values "cp-schema-registry" "url") -}}
{{- printf "%s" (index .Values "cp-schema-registry" "url") -}}
{{- else -}}
{{- printf "http://%s:8081" (include "cp-control-center.cp-schema-registry.fullname" .) -}}
{{- end -}}
{{- end -}}

{{/*
Create a default fully qualified connect name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "cp-control-center.cp-kafka-connect.fullname" -}}
{{- $name := default "cp-kafka-connect" (index .Values "cp-kafka-connect" "nameOverride") -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{- define "cp-control-center.cp-kafka-connect.service-name" -}}
{{- if (index .Values "cp-kafka-connect" "url") -}}
{{- printf "%s" (index .Values "cp-kafka-connect" "url") -}}
{{- else -}}
{{- printf "http://%s:8083" (include "cp-control-center.cp-kafka-connect.fullname" .) -}}
{{- end -}}
{{- end -}}

{{/*
Create a default fully qualified ksql name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "cp-control-center.cp-ksql-server.fullname" -}}
{{- $name := default "cp-ksql-server" (index .Values "cp-ksql-server" "nameOverride") -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{- define "cp-control-center.cp-ksql-server.service-name" -}}
{{- if (index .Values "cp-ksql-server" "url") -}}
{{- printf "%s" (index .Values "cp-ksql-server" "url") -}}
{{- else -}}
{{- printf "http://%s:8088" (include "cp-control-center.cp-ksql-server.fullname" .) -}}
{{- end -}}
{{- end -}}

{{/*
Create a default fully qualified zookeeper name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "cp-control-center.cp-zookeeper.fullname" -}}
{{- $name := default "cp-zookeeper" (index .Values "cp-zookeeper" "nameOverride") -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Form the Zookeeper URL. If zookeeper is installed as part of this chart, use k8s service discovery,
else use user-provided URL
*/}}
{{- define "cp-control-center.cp-zookeeper.service-name" }}
{{- if (index .Values "cp-zookeeper" "enabled") -}}
{{- $clientPort := default 2181 (index .Values "cp-zookeeper" "clientPort") | int -}}
{{- printf "%s:%d" (include "cp-control-center.cp-zookeeper.fullname" .) $clientPort }}
{{- else -}}
{{- $zookeeperConnect := printf "%s" (index .Values "cp-zookeeper" "url") }}
{{- $zookeeperConnectOverride := (index .Values "configurationOverrides" "zookeeper.connect") }}
{{- default $zookeeperConnect $zookeeperConnectOverride }}
{{- end -}}
{{- end -}}
80 changes: 80 additions & 0 deletions charts/cp-control-center/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: {{ include "cp-control-center.fullname" . }}
labels:
app: {{ include "cp-control-center.name" . }}
chart: {{ include "cp-control-center.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: {{ include "cp-control-center.name" . }}
release: {{ .Release.Name }}
template:
metadata:
labels:
app: {{ include "cp-control-center.name" . }}
release: {{ .Release.Name }}
{{- if or .Values.podAnnotations .Values.prometheus.jmx.enabled }}
annotations:
{{- range $key, $value := .Values.podAnnotations }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- if .Values.prometheus.jmx.enabled }}
prometheus.io/scrape: "true"
prometheus.io/port: {{ .Values.prometheus.jmx.port | quote }}
{{- end }}
{{- end }}
spec:
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image }}:{{ .Values.imageTag }}"
imagePullPolicy: {{ .Values.imagePullPolicy }}
ports:
- name: cc-http
containerPort: {{ .Values.serviceHttpPort}}
protocol: TCP
resources:
{{- toYaml .Values.resources | indent 12 }}
env:
- name: CONTROL_CENTER_BOOTSTRAP_SERVERS
value: {{ template "cp-control-center.kafka.bootstrapServers" . }}
- name: CONTROL_CENTER_ZOOKEEPER_CONNECT
value: {{ template "cp-control-center.cp-zookeeper.service-name" . }}
- name: CONTROL_CENTER_CONNECT_CLUSTER
value: {{ template "cp-control-center.cp-kafka-connect.service-name" . }}
- name: CONTROL_CENTER_KSQL_URL
value: {{ template "cp-control-center.cp-ksql-server.service-name" . }}
- name: CONTROL_CENTER_KSQL_ADVERTISED_URL
value: {{ template "cp-control-center.cp-ksql-server.service-name" . }}
- name: CONTROL_CENTER_SCHEMA_REGISTRY_URL
value: {{ template "cp-control-center.cp-schema-registry.service-name" . }}
- name: KAFKA_HEAP_OPTS
value: "{{ .Values.heapOptions }}"
{{- range $key, $value := .Values.configurationOverrides }}
- name: {{ printf "CONTROL_CENTER_%s" $key | replace "." "_" | upper | quote }}
value: {{ $value | quote }}
{{- end }}
{{- range $key, $value := .Values.customEnv }}
- name: {{ $key | quote }}
value: {{ $value | quote }}
{{- end }}
{{- if .Values.imagePullSecrets }}
imagePullSecrets:
{{ toYaml .Values.imagePullSecrets | indent 8 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
16 changes: 16 additions & 0 deletions charts/cp-control-center/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: Service
metadata:
name: {{ template "cp-control-center.fullname" . }}
labels:
app: {{ template "cp-control-center.name" . }}
chart: {{ template "cp-control-center.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
ports:
- name: cc-http
port: {{ .Values.serviceHttpPort }}
selector:
app: {{ template "cp-control-center.name" . }}
release: {{ .Release.Name }}
103 changes: 103 additions & 0 deletions charts/cp-control-center/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Default values for cp-control-center.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

replicaCount: 1

## Image Info
## ref: https://hub.docker.com/r/confluentinc/cp-kafka/
image: confluentinc/cp-enterprise-control-center
imageTag: 5.2.0

## Specify a imagePullPolicy
## ref: http://kubernetes.io/docs/user-guide/images/#pre-pulling-images
imagePullPolicy: IfNotPresent

## Specify an array of imagePullSecrets.
## Secrets must be manually created in the namespace.
## ref: https://kubernetes.io/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod
imagePullSecrets:

serviceHttpPort: 9021

## Control Center properties
## ref:
configurationOverrides:
"replication.factor": "3"
# "internal.topics.replication": "1"
# "monitoring.interceptor.topic.replication": "1"
# "metrics.topic.replication": "1"
# "command.topic.replication": "1"
# "streams.num.stream.threads": "2"
# "streams.consumer.request.timeout.ms": "960032"
# "rest.listeners": "http://0.0.0.0:9021"

## Kafka Connect JVM Heap Option
heapOptions: "-Xms512M -Xmx512M"

## Additional env variables
customEnv: {}

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

## Custom pod annotations
podAnnotations: {}

## Node labels for pod assignment
## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/
nodeSelector: {}

## Taints to tolerate on node assignment:
## Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/
tolerations: {}

## Monitoring
## Kafka JMX Settings
## ref: https://docs.confluent.io/current/kafka/monitoring.html
jmx:
port: 5555

## Prometheus Exporter Configuration
## ref: https://prometheus.io/docs/instrumenting/exporters/
prometheus:
## JMX Exporter Configuration
## ref: https://github.com/prometheus/jmx_exporter
jmx:
enabled: true
image: solsson/kafka-prometheus-jmx-exporter@sha256
imageTag: 6f82e2b0464f50da8104acd7363fb9b995001ddff77d248379f8788e78946143
port: 5556

## Resources configuration for the JMX exporter container.
## See the `resources` documentation above for details.
resources: {}

## You can list load balanced service endpoint, or list of all brokers (which is hard in K8s). e.g.:
## bootstrapServers: "PLAINTEXT://dozing-prawn-kafka-headless:9092"
kafka:
bootstrapServers: ""

## If the Kafka Chart is disabled a URL and port are required to connect
## e.g. gnoble-panther-cp-schema-registry:8081
cp-schema-registry:
url: ""

cp-kafka-connect:
url: ""

cp-ksql-server:
url: ""

cp-zookeeper:
## If the Zookeeper Chart is disabled a URL and port are required to connect
url: ""
9 changes: 9 additions & 0 deletions charts/cp-kafka/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ external advertised listeners if configurationOverrides.advertised.listeners is
{{- end -}}
{{- end -}}

{{/*
Create a default fully qualified kafka headless name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "cp-kafka.cp-kafka-headless.fullname" -}}
{{- $name := "cp-kafka-headless" -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create a variable containing all the datadirs created.
*/}}
Expand Down
4 changes: 4 additions & 0 deletions charts/cp-kafka/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ spec:
value: {{ include "cp-kafka.cp-zookeeper.service-name" . | quote }}
- name: KAFKA_LOG_DIRS
value: {{ include "cp-kafka.log.dirs" . | quote }}
- name: KAFKA_METRIC_REPORTERS
value: "io.confluent.metrics.reporter.ConfluentMetricsReporter"
- name: CONFLUENT_METRICS_REPORTER_BOOTSTRAP_SERVERS
value: {{ printf "PLAINTEXT://%s:9092" (include "cp-kafka.cp-kafka-headless.fullname" .) | quote }}
{{- range $key, $value := .Values.configurationOverrides }}
- name: {{ printf "KAFKA_%s" $key | replace "." "_" | upper | quote }}
value: {{ $value | quote }}
Expand Down
Loading

0 comments on commit 81ff624

Please sign in to comment.