Skip to content
This repository was archived by the owner on Feb 20, 2024. It is now read-only.

Commit b3caa2d

Browse files
committed
Working version of schema registry and rest proxy
1 parent 688219d commit b3caa2d

17 files changed

+416
-1
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.idea/*
22
charts/cp-kafka/requirements.lock
3-
charts/*/charts
3+
charts/*/charts
4+
charts/*/requirements.lock

charts/cp-kafka-rest/.helmignore

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*~
18+
# Various IDEs
19+
.project
20+
.idea/
21+
*.tmproj

charts/cp-kafka-rest/Chart.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
apiVersion: v1
2+
appVersion: "1.0"
3+
description: A Helm chart for Kubernetes
4+
name: cp-kafka-rest
5+
version: 0.1.0
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
dependencies:
2+
- name: cp-kafka
3+
version: 0.1.0
4+
repository: file://../cp-kafka
5+
condition: kafka.enabled

charts/cp-kafka-rest/templates/NOTES.txt

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
{{/*
3+
Expand the name of the chart.
4+
*/}}
5+
{{- define "cp-kafka-rest.name" -}}
6+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
7+
{{- end -}}
8+
9+
{{/*
10+
Create a default fully qualified app name.
11+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
12+
If release name contains chart name it will be used as a full name.
13+
*/}}
14+
{{- define "cp-kafka-rest.fullname" -}}
15+
{{- if .Values.fullnameOverride -}}
16+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
17+
{{- else -}}
18+
{{- $name := default .Chart.Name .Values.nameOverride -}}
19+
{{- if contains $name .Release.Name -}}
20+
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
21+
{{- else -}}
22+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
23+
{{- end -}}
24+
{{- end -}}
25+
{{- end -}}
26+
27+
{{/*
28+
Create chart name and version as used by the chart label.
29+
*/}}
30+
{{- define "cp-kafka-rest.chart" -}}
31+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
32+
{{- end -}}
33+
34+
{{/*
35+
Create a default fully qualified zookeeper name.
36+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
37+
*/}}
38+
{{- define "cp-kafka-rest.cp-zookeeper.fullname" -}}
39+
{{- $name := default "cp-zookeeper" .Values.zookeeper.nameOverride -}}
40+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
41+
{{- end -}}
42+
43+
{{/*
44+
Form the Zookeeper URL. If zookeeper is installed as part of this chart, use k8s service discovery,
45+
else use user-provided URL
46+
*/}}
47+
{{- define "cp-kafka-rest.cp-zookeeper.service-name" }}
48+
{{- $port := .Values.zookeeper.clientPort | toString }}
49+
{{- if .Values.kafka.enabled -}}
50+
{{- printf "%s:%s" (include "cp-kafka-rest.cp-zookeeper.fullname" .) $port }}
51+
{{- else -}}
52+
{{- $zookeeperConnect := printf "%s:%s" .Values.kafka.zookeeper.url $port }}
53+
{{- $zookeeperConnectOverride := index .Values "configurationOverrides" "zookeeper.connect" }}
54+
{{- default $zookeeperConnect $zookeeperConnectOverride }}
55+
{{- end -}}
56+
{{- end -}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
apiVersion: apps/v1beta2
2+
kind: Deployment
3+
metadata:
4+
name: {{ template "cp-kafka-rest.fullname" . }}
5+
labels:
6+
app: {{ template "cp-kafka-rest.name" . }}
7+
chart: {{ template "cp-kafka-rest.chart" . }}
8+
release: {{ .Release.Name }}
9+
heritage: {{ .Release.Service }}
10+
spec:
11+
replicas: {{ .Values.replicaCount }}
12+
selector:
13+
matchLabels:
14+
app: {{ template "cp-kafka-rest.name" . }}
15+
release: {{ .Release.Name }}
16+
template:
17+
metadata:
18+
labels:
19+
app: {{ template "cp-kafka-rest.name" . }}
20+
release: {{ .Release.Name }}
21+
spec:
22+
containers:
23+
- name: {{ template "cp-kafka-rest.name" . }}-server
24+
image: "{{ .Values.image }}:{{ .Values.imageTag }}"
25+
imagePullPolicy: "{{ .Values.imagePullPolicy }}"
26+
ports:
27+
- name: rest-proxy
28+
containerPort: {{ .Values.servicePort}}
29+
protocol: TCP
30+
livenessProbe:
31+
httpGet:
32+
path: /
33+
port: rest-proxy
34+
initialDelaySeconds: {{ .Values.initialDelaySeconds }}
35+
timeoutSeconds: {{ .Values.timeoutSeconds }}
36+
readinessProbe:
37+
httpGet:
38+
path: /
39+
port: rest-proxy
40+
initialDelaySeconds: {{ .Values.initialDelaySeconds }}
41+
timeoutSeconds: {{ .Values.timeoutSeconds }}
42+
resources:
43+
{{ toYaml .Values.resources | indent 12 }}
44+
env:
45+
- name: KAFKA_REST_HOST_NAME
46+
valueFrom:
47+
fieldRef:
48+
fieldPath: metadata.name
49+
- name: KAFKA_REST_ZOOKEEPER_CONNECT
50+
value: {{ template "cp-kafka-rest.cp-zookeeper.service-name" . }}
51+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: {{ template "cp-kafka-rest.fullname" . }}
5+
labels:
6+
app: {{ template "cp-kafka-rest.name" . }}
7+
chart: {{ template "cp-kafka-rest.chart" . }}
8+
release: {{ .Release.Name }}
9+
heritage: {{ .Release.Service }}
10+
spec:
11+
ports:
12+
- name: rest-proxy
13+
port: {{ .Values.servicePort }}
14+
selector:
15+
app: {{ template "cp-kafka-rest.name" . }}
16+
release: {{ .Release.Name }}

charts/cp-kafka-rest/values.yaml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Default values for cp-kafka-rest.
2+
# This is a YAML-formatted file.
3+
# Declare variables to be passed into your templates.
4+
5+
replicaCount: 1
6+
7+
## Image Info
8+
## ref: https://hub.docker.com/r/confluentinc/cp-kafka/
9+
image: confluentinc/cp-kafka-rest
10+
imageTag: 4.0.1
11+
12+
## Specify a imagePullPolicy
13+
## ref: http://kubernetes.io/docs/user-guide/images/#pre-pulling-images
14+
imagePullPolicy: IfNotPresent
15+
16+
## Liveness and Readiness Probe Configuration
17+
initialDelaySeconds: 30
18+
timeoutSeconds: 5
19+
20+
servicePort: 8082
21+
22+
resources: {}
23+
# We usually recommend not to specify default resources and to leave this as a conscious
24+
# choice for the user. This also increases chances charts run on environments with little
25+
# resources, such as Minikube. If you do want to specify resources, uncomment the following
26+
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
27+
# limits:
28+
# cpu: 100m
29+
# memory: 128Mi
30+
# requests:
31+
# cpu: 100m
32+
# memory: 128Mi
33+
34+
kafka:
35+
## If true, install the cp-kafka chart alongside cp-kafka-rest
36+
## ref: ../cp-kafka
37+
enabled: true
38+
39+
## If the Kafka Chart is disabled a URL and port are required to connect
40+
zookeeper:
41+
url: ""
42+
clientPort: 2181

charts/cp-schema-registry/.helmignore

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*~
18+
# Various IDEs
19+
.project
20+
.idea/
21+
*.tmproj

charts/cp-schema-registry/Chart.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
apiVersion: v1
2+
appVersion: "1.0"
3+
description: A Helm chart for Kubernetes
4+
name: cp-schema-registry
5+
version: 0.1.0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
dependencies:
2+
- name: cp-kafka
3+
version: 0.1.0
4+
repository: file://../cp-kafka
5+
condition: kafka.enabled

charts/cp-schema-registry/templates/NOTES.txt

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
{{/*
3+
Expand the name of the chart.
4+
*/}}
5+
{{- define "cp-schema-registry.name" -}}
6+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
7+
{{- end -}}
8+
9+
{{/*
10+
Create a default fully qualified app name.
11+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
12+
If release name contains chart name it will be used as a full name.
13+
*/}}
14+
{{- define "cp-schema-registry.fullname" -}}
15+
{{- if .Values.fullnameOverride -}}
16+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
17+
{{- else -}}
18+
{{- $name := default .Chart.Name .Values.nameOverride -}}
19+
{{- if contains $name .Release.Name -}}
20+
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
21+
{{- else -}}
22+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
23+
{{- end -}}
24+
{{- end -}}
25+
{{- end -}}
26+
27+
{{/*
28+
Create chart name and version as used by the chart label.
29+
*/}}
30+
{{- define "cp-schema-registry.chart" -}}
31+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
32+
{{- end -}}
33+
34+
35+
{{/*
36+
Form the Kafka URL. If Kafka is installed as part of this chart, use k8s service discovery,
37+
else use user-provided URL
38+
*/}}
39+
{{- define "cp-schema-registry.kafkaStore.bootstrapServers" }}
40+
{{- if .Values.kafkaStore.overrideBootstrapServers -}}
41+
{{- .Values.kafkaStore.overrideBootstrapServers }}
42+
{{- else -}}
43+
{{- printf "PLAINTEXT://%s-cp-kafka-headless:9092" .Release.Name }}
44+
{{- end -}}
45+
{{- end -}}
46+
47+
{{/*
48+
Default GroupId to Release Name but allow it to be overridden
49+
*/}}
50+
{{- define "cp-schema-registry.groupId" -}}
51+
{{- if .Values.overrideGroupId -}}
52+
{{- .Values.overrideGroupId -}}
53+
{{- else -}}
54+
{{- .Release.Name -}}
55+
{{- end -}}
56+
{{- end -}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
apiVersion: apps/v1beta2
2+
kind: Deployment
3+
metadata:
4+
name: {{ template "cp-schema-registry.fullname" . }}
5+
labels:
6+
app: {{ template "cp-schema-registry.name" . }}
7+
chart: {{ template "cp-schema-registry.chart" . }}
8+
release: {{ .Release.Name }}
9+
heritage: {{ .Release.Service | quote }}
10+
spec:
11+
replicas: {{ .Values.replicaCount }}
12+
selector:
13+
matchLabels:
14+
app: {{ template "cp-schema-registry.name" . }}
15+
release: {{ .Release.Name }}
16+
template:
17+
metadata:
18+
labels:
19+
app: {{ template "cp-schema-registry.name" . }}
20+
release: {{ .Release.Name }}
21+
spec:
22+
containers:
23+
- name: {{ template "cp-schema-registry.name" . }}-server
24+
image: "{{ .Values.image }}:{{ .Values.imageTag }}"
25+
imagePullPolicy: "{{ .Values.imagePullPolicy }}"
26+
ports:
27+
- name: schema-registry
28+
containerPort: {{ .Values.servicePort}}
29+
protocol: TCP
30+
livenessProbe:
31+
httpGet:
32+
path: /
33+
port: schema-registry
34+
initialDelaySeconds: {{ .Values.initialDelaySeconds }}
35+
timeoutSeconds: {{ .Values.timeoutSeconds }}
36+
readinessProbe:
37+
httpGet:
38+
path: /
39+
port: schema-registry
40+
initialDelaySeconds: {{ .Values.initialDelaySeconds }}
41+
timeoutSeconds: {{ .Values.timeoutSeconds }}
42+
resources:
43+
{{ toYaml .Values.resources | indent 12 }}
44+
env:
45+
- name: SCHEMA_REGISTRY_HOST_NAME
46+
valueFrom:
47+
fieldRef:
48+
fieldPath: metadata.name
49+
- name: SCHEMA_REGISTRY_KAFKASTORE_BOOTSTRAP_SERVERS
50+
value: {{ template "cp-schema-registry.kafkaStore.bootstrapServers" . }}
51+
- name: SCHEMA_REGISTRY_KAFKASTORE_GROUP_ID
52+
value: {{ template "cp-schema-registry.groupId" . }}
53+
- name: SCHEMA_REGISTRY_MASTER_ELIGIBILITY
54+
value: "true"
55+
{{ range $configName, $configValue := .Values.configurationOverrides }}
56+
- name: SCHEMA_REGISTRY_{{ $configName | replace "." "_" | upper }}
57+
value: {{ $configValue }}
58+
{{ end }}
59+
{{- if .Values.schemaRegistryOpts }}
60+
# The pre-flight checks use KAFKA_OPTS instead of SCHEMA_REGISTRY_OPTS.
61+
- name: KAFKA_OPTS
62+
value: "{{ .Values.schemaRegistryOpts }}"
63+
- name: SCHEMA_REGISTRY_OPTS
64+
value: "{{ .Values.schemaRegistryOpts }}"
65+
{{- end }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: {{ template "cp-schema-registry.fullname" . }}
5+
labels:
6+
app: {{ template "cp-schema-registry.name" . }}
7+
chart: {{ template "cp-schema-registry.chart" . }}
8+
release: {{ .Release.Name }}
9+
heritage: {{ .Release.Service }}
10+
spec:
11+
ports:
12+
- name: schema-registry
13+
port: {{ .Values.servicePort }}
14+
selector:
15+
app: {{ template "cp-schema-registry.name" . }}
16+
release: {{ .Release.Name }}

0 commit comments

Comments
 (0)