Skip to content

Commit

Permalink
Working version of schema registry and rest proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
qshao-pivotal committed Apr 30, 2018
1 parent 688219d commit b3caa2d
Show file tree
Hide file tree
Showing 17 changed files with 416 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea/*
charts/cp-kafka/requirements.lock
charts/*/charts
charts/*/charts
charts/*/requirements.lock
21 changes: 21 additions & 0 deletions charts/cp-kafka-rest/.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-kafka-rest/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 for Kubernetes
name: cp-kafka-rest
version: 0.1.0
5 changes: 5 additions & 0 deletions charts/cp-kafka-rest/requirements.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
dependencies:
- name: cp-kafka
version: 0.1.0
repository: file://../cp-kafka
condition: kafka.enabled
Empty file.
56 changes: 56 additions & 0 deletions charts/cp-kafka-rest/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "cp-kafka-rest.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-kafka-rest.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-kafka-rest.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- 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-kafka-rest.cp-zookeeper.fullname" -}}
{{- $name := default "cp-zookeeper" .Values.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-kafka-rest.cp-zookeeper.service-name" }}
{{- $port := .Values.zookeeper.clientPort | toString }}
{{- if .Values.kafka.enabled -}}
{{- printf "%s:%s" (include "cp-kafka-rest.cp-zookeeper.fullname" .) $port }}
{{- else -}}
{{- $zookeeperConnect := printf "%s:%s" .Values.kafka.zookeeper.url $port }}
{{- $zookeeperConnectOverride := index .Values "configurationOverrides" "zookeeper.connect" }}
{{- default $zookeeperConnect $zookeeperConnectOverride }}
{{- end -}}
{{- end -}}
51 changes: 51 additions & 0 deletions charts/cp-kafka-rest/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: {{ template "cp-kafka-rest.fullname" . }}
labels:
app: {{ template "cp-kafka-rest.name" . }}
chart: {{ template "cp-kafka-rest.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: {{ template "cp-kafka-rest.name" . }}
release: {{ .Release.Name }}
template:
metadata:
labels:
app: {{ template "cp-kafka-rest.name" . }}
release: {{ .Release.Name }}
spec:
containers:
- name: {{ template "cp-kafka-rest.name" . }}-server
image: "{{ .Values.image }}:{{ .Values.imageTag }}"
imagePullPolicy: "{{ .Values.imagePullPolicy }}"
ports:
- name: rest-proxy
containerPort: {{ .Values.servicePort}}
protocol: TCP
livenessProbe:
httpGet:
path: /
port: rest-proxy
initialDelaySeconds: {{ .Values.initialDelaySeconds }}
timeoutSeconds: {{ .Values.timeoutSeconds }}
readinessProbe:
httpGet:
path: /
port: rest-proxy
initialDelaySeconds: {{ .Values.initialDelaySeconds }}
timeoutSeconds: {{ .Values.timeoutSeconds }}
resources:
{{ toYaml .Values.resources | indent 12 }}
env:
- name: KAFKA_REST_HOST_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: KAFKA_REST_ZOOKEEPER_CONNECT
value: {{ template "cp-kafka-rest.cp-zookeeper.service-name" . }}

16 changes: 16 additions & 0 deletions charts/cp-kafka-rest/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-kafka-rest.fullname" . }}
labels:
app: {{ template "cp-kafka-rest.name" . }}
chart: {{ template "cp-kafka-rest.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
ports:
- name: rest-proxy
port: {{ .Values.servicePort }}
selector:
app: {{ template "cp-kafka-rest.name" . }}
release: {{ .Release.Name }}
42 changes: 42 additions & 0 deletions charts/cp-kafka-rest/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Default values for cp-kafka-rest.
# 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-kafka-rest
imageTag: 4.0.1

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

## Liveness and Readiness Probe Configuration
initialDelaySeconds: 30
timeoutSeconds: 5

servicePort: 8082

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

kafka:
## If true, install the cp-kafka chart alongside cp-kafka-rest
## ref: ../cp-kafka
enabled: true

## If the Kafka Chart is disabled a URL and port are required to connect
zookeeper:
url: ""
clientPort: 2181
21 changes: 21 additions & 0 deletions charts/cp-schema-registry/.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-schema-registry/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 for Kubernetes
name: cp-schema-registry
version: 0.1.0
5 changes: 5 additions & 0 deletions charts/cp-schema-registry/requirements.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
dependencies:
- name: cp-kafka
version: 0.1.0
repository: file://../cp-kafka
condition: kafka.enabled
Empty file.
56 changes: 56 additions & 0 deletions charts/cp-schema-registry/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "cp-schema-registry.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-schema-registry.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-schema-registry.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | 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-schema-registry.kafkaStore.bootstrapServers" }}
{{- if .Values.kafkaStore.overrideBootstrapServers -}}
{{- .Values.kafkaStore.overrideBootstrapServers }}
{{- else -}}
{{- printf "PLAINTEXT://%s-cp-kafka-headless:9092" .Release.Name }}
{{- end -}}
{{- end -}}

{{/*
Default GroupId to Release Name but allow it to be overridden
*/}}
{{- define "cp-schema-registry.groupId" -}}
{{- if .Values.overrideGroupId -}}
{{- .Values.overrideGroupId -}}
{{- else -}}
{{- .Release.Name -}}
{{- end -}}
{{- end -}}
65 changes: 65 additions & 0 deletions charts/cp-schema-registry/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: {{ template "cp-schema-registry.fullname" . }}
labels:
app: {{ template "cp-schema-registry.name" . }}
chart: {{ template "cp-schema-registry.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service | quote }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: {{ template "cp-schema-registry.name" . }}
release: {{ .Release.Name }}
template:
metadata:
labels:
app: {{ template "cp-schema-registry.name" . }}
release: {{ .Release.Name }}
spec:
containers:
- name: {{ template "cp-schema-registry.name" . }}-server
image: "{{ .Values.image }}:{{ .Values.imageTag }}"
imagePullPolicy: "{{ .Values.imagePullPolicy }}"
ports:
- name: schema-registry
containerPort: {{ .Values.servicePort}}
protocol: TCP
livenessProbe:
httpGet:
path: /
port: schema-registry
initialDelaySeconds: {{ .Values.initialDelaySeconds }}
timeoutSeconds: {{ .Values.timeoutSeconds }}
readinessProbe:
httpGet:
path: /
port: schema-registry
initialDelaySeconds: {{ .Values.initialDelaySeconds }}
timeoutSeconds: {{ .Values.timeoutSeconds }}
resources:
{{ toYaml .Values.resources | indent 12 }}
env:
- name: SCHEMA_REGISTRY_HOST_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: SCHEMA_REGISTRY_KAFKASTORE_BOOTSTRAP_SERVERS
value: {{ template "cp-schema-registry.kafkaStore.bootstrapServers" . }}
- name: SCHEMA_REGISTRY_KAFKASTORE_GROUP_ID
value: {{ template "cp-schema-registry.groupId" . }}
- name: SCHEMA_REGISTRY_MASTER_ELIGIBILITY
value: "true"
{{ range $configName, $configValue := .Values.configurationOverrides }}
- name: SCHEMA_REGISTRY_{{ $configName | replace "." "_" | upper }}
value: {{ $configValue }}
{{ end }}
{{- if .Values.schemaRegistryOpts }}
# The pre-flight checks use KAFKA_OPTS instead of SCHEMA_REGISTRY_OPTS.
- name: KAFKA_OPTS
value: "{{ .Values.schemaRegistryOpts }}"
- name: SCHEMA_REGISTRY_OPTS
value: "{{ .Values.schemaRegistryOpts }}"
{{- end }}
16 changes: 16 additions & 0 deletions charts/cp-schema-registry/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-schema-registry.fullname" . }}
labels:
app: {{ template "cp-schema-registry.name" . }}
chart: {{ template "cp-schema-registry.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
ports:
- name: schema-registry
port: {{ .Values.servicePort }}
selector:
app: {{ template "cp-schema-registry.name" . }}
release: {{ .Release.Name }}
Loading

0 comments on commit b3caa2d

Please sign in to comment.