Skip to content

Commit

Permalink
Merge pull request #80 from devops-ia/feat/add-cp-schema-registry
Browse files Browse the repository at this point in the history
feat: initial cp-schema-registry version
  • Loading branch information
ialejandro authored Sep 5, 2024
2 parents 1b4ec77 + 73baf09 commit 46a5cab
Show file tree
Hide file tree
Showing 20 changed files with 1,029 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .github/ct.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ chart-dirs: charts
check-version-increment: true
debug: false
remote: origin
target-branch: main
upgrade: true
validate-chart-schema: true
validate-maintainers: false
validate-yaml: true
excluded-charts: ["bigquery-exporter"]
excluded-charts: ["bigquery-exporter", "cp-schema-registry"]
32 changes: 32 additions & 0 deletions .github/updatecli/helm-update.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ sources:
spec:
image: devopsiaci/bitbucket-bot
architecture: linux/amd64
cp-schema-registry-helm:
kind: helmchart
spec:
url: https://devops-ia.github.io/helm-charts
name: cp-schema-registry
cp-schema-registry:
kind: dockerimage
spec:
image: confluentinc/cp-schema-registry
architecture: linux/amd64
versionFilter:
kind: semver
ecr-token-helm:
kind: helmchart
spec:
Expand Down Expand Up @@ -61,6 +73,14 @@ targets:
key: $.appVersion
sourceid: bitbucket-bot

cp-schema-registry:
name: bump chart dependencies
kind: yaml
spec:
file: charts/cp-schema-registry/Chart.yaml
key: $.appVersion
sourceid: cp-schema-registry

ecr-token:
name: bump chart dependencies
kind: yaml
Expand Down Expand Up @@ -101,6 +121,18 @@ targets:
key: $.version
versionincrement: patch

cp-schema-registry-helm:
name: Update cp-schema-registry helm chart
kind: helmchart
disablesourceinput: true
dependsonchange: true
dependson: [cp-schema-registry]
spec:
name: charts/cp-schema-registry
file: Chart.yaml
key: $.version
versionincrement: patch

ecr-token-helm:
name: Update ecr-token helm chart
kind: helmchart
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/lint-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
check-latest: true

- name: Set up chart-testing
uses: helm/chart-testing-action@v2.6.1
uses: helm/chart-testing-action@v2

- name: Run chart-testing (list-changed)
id: list-changed
Expand All @@ -33,12 +33,12 @@ jobs:
- name: Run chart-testing (lint)
if: steps.list-changed.outputs.changed == 'true'
run: ct lint --config .github/ct.yaml --target-branch ${{ github.event.repository.default_branch }}
run: ct lint --config .github/ct.yaml

- name: Create kind cluster
if: steps.list-changed.outputs.changed == 'true'
uses: helm/[email protected]

- name: Run chart-testing (install)
if: steps.list-changed.outputs.changed == 'true'
run: ct install --config .github/ct.yaml --target-branch ${{ github.event.repository.default_branch }}
run: ct install --config .github/ct.yaml
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ You can then run `helm search repo devops-ia` to see the charts.
| [azure-prometheus-config](./charts/azure-prometheus-config) | A Helm chart to configure Azure Managed Prometheus |
| [bigquery-exporter](./charts/bigquery-exporter) | A Helm chart to deploy Bigquery Exporter |
| [bitbucket-bot](./charts/bitbucket-bot) | A Helm chart to deploy Bitbucket Bot for Google Chats (Spaces) |
| [cp-schema-registry](./charts/cp-schema-registry) | A Helm chart with cp-schema-registry for Kubernetes |
| [default-resources](./charts/default-resources) | A Helm chart for Default Resources |
| [ecr-token](./charts/ecr-token) | A Helm chart to deploy cronjob to update Amazon ECR token |
| [helm-release-cleaner](./charts/helm-release-cleaner) | A Helm chart for Helm Charts to clean up the releases installed in the declared namespaces |
| [release-cleaner](./charts/release-cleaner) | A Helm chart for Helm Charts to clean up the releases installed in the declared namespaces |
| [ssl-exporter](./charts/ssl-exporter) | A Helm Chart to SSL Certificate Exporter for Prometheus |
23 changes: 23 additions & 0 deletions charts/cp-schema-registry/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# 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/
19 changes: 19 additions & 0 deletions charts/cp-schema-registry/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: v2
name: cp-schema-registry
description: A Helm chart with cp-schema-registry for Kubernetes
type: application
maintainers:
- name: ialejandro
email: [email protected]
url: https://ialejandro.rocks
sources:
- https://github.com/devops-ia/helm-charts/cp-schema-registry
- https://github.com/m-lab/prometheus-bigquery-exporter
version: 1.0.0
appVersion: 7.4.6
home: https://github.com/devops-ia/helm-charts/cp-schema-registry
keywords:
- cp-schema-registry
- confluent
- kafka
- schema-registry
106 changes: 106 additions & 0 deletions charts/cp-schema-registry/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# cp-schema-registry

## Motivation

The original Helm chart for [Confluent Schema Registry](https://github.com/confluentinc/cp-helm-charts/tree/master/charts/cp-schema-registry) has been deprecated, and over time it became too bulky and outdated. That's why I've created a new, lighter, and more up-to-date Helm chart. This new chart is more streamlined and easier to customize.

Some of the key changes include:

* Configurations that are compatible with the latest Kubernetes features
* Easier setup, with more modular and flexible options

A Helm chart with cp-schema-registry for Kubernetes

## Maintainers

| Name | Email | Url |
| ---- | ------ | --- |
| ialejandro | <[email protected]> | <https://ialejandro.rocks> |

## Prerequisites

* Helm 3+

## Add repository

```console
helm repo add devops-ia https://devops-ia.github.io/helm-charts
helm repo update
```

## Install Helm chart (repository mode)

```console
helm install [RELEASE_NAME] devops-ia/cp-schema-registry
```

This install all the Kubernetes components associated with the chart and creates the release.

_See [helm install](https://helm.sh/docs/helm/helm_install/) for command documentation._

## Uninstall Helm chart

```console
helm uninstall [RELEASE_NAME]
```

This removes all the Kubernetes components associated with the chart and deletes the release.

_See [helm uninstall](https://helm.sh/docs/helm/helm_uninstall/) for command documentation._

## Configuration

See [Customizing the chart before installing](https://helm.sh/docs/intro/using_helm/#customizing-the-chart-before-installing). To see all configurable options with comments:

```console
helm show values devops-ia/cp-schema-registry
```

## Values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| affinity | object | `{}` | Affinity for pod assignment </br> Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity |
| autoscaling | object | `{"enabled":false,"maxReplicas":100,"minReplicas":1,"targetCPUUtilizationPercentage":80}` | Autoscaling with CPU or memory utilization percentage </br> Ref: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/ |
| env | object | `{"SCHEMA_REGISTRY_HEAP_OPTS":"-Xms512M -Xmx512M","SCHEMA_REGISTRY_MASTER_ELIGIBILITY":"true"}` | Environment variables to configure application </br> Ref: https://docs.cp-schema-registry.io/latest/deployment/configuration/#platform |
| envFromSecrets | object | `{}` | Secrets from variables |
| fullnameOverride | string | `""` | String to fully override cp-schema-registry.fullname template |
| image | object | `{"pullPolicy":"IfNotPresent","repository":"confluentinc/cp-schema-registry","tag":""}` | Image registry The image configuration for the base service |
| imagePullSecrets | list | `[]` | Global Docker registry secret names as an array |
| ingress | object | `{"annotations":{},"className":"","enabled":false,"hosts":[{"host":"chart-example.local","paths":[{"path":"/","pathType":"ImplementationSpecific"}]}],"tls":[]}` | Ingress configuration to expose app </br> Ref: https://kubernetes.io/docs/concepts/services-networking/ingress/ |
| initContainers | list | `[]` | Configure additional containers </br> Ref: https://kubernetes.io/docs/concepts/workloads/pods/init-containers/ |
| livenessProbe | object | `{"enabled":true,"failureThreshold":3,"initialDelaySeconds":180,"periodSeconds":10,"successThreshold":1,"timeoutSeconds":5}` | Configure liveness checker </br> Ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#define-startup-probes |
| livenessProbeCustom | object | `{}` | Custom livenessProbe |
| metrics | object | `{"enabled":false,"exporter":{"enabled":false,"image":{"pullPolicy":"IfNotPresent","repository":"solsson/kafka-prometheus-jmx-exporter@sha256","tag":"6f82e2b0464f50da8104acd7363fb9b995001ddff77d248379f8788e78946143"},"port":5556,"resources":{}},"port":5555}` | Enable metrics |
| metrics.enabled | bool | `false` | Enable or disable |
| metrics.exporter | object | `{"enabled":false,"image":{"pullPolicy":"IfNotPresent","repository":"solsson/kafka-prometheus-jmx-exporter@sha256","tag":"6f82e2b0464f50da8104acd7363fb9b995001ddff77d248379f8788e78946143"},"port":5556,"resources":{}}` | prometheus-jmx-exporter configuration |
| metrics.exporter.enabled | bool | `false` | Enable or disable |
| metrics.exporter.image | object | `{"pullPolicy":"IfNotPresent","repository":"solsson/kafka-prometheus-jmx-exporter@sha256","tag":"6f82e2b0464f50da8104acd7363fb9b995001ddff77d248379f8788e78946143"}` | Image registry The image configuration for the base service |
| metrics.exporter.port | int | `5556` | Expose exporter port |
| metrics.exporter.resources | object | `{}` | Resources limits and requested </br> Ref: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ |
| metrics.port | int | `5555` | Expose metrics port |
| nameOverride | string | `""` | String to partially override cp-schema-registry.fullname template (will maintain the release name) |
| nodeSelector | object | `{}` | Node labels for pod assignment </br> Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#nodeselector |
| podAnnotations | object | `{}` | Configure annotations on Pods |
| podDisruptionBudget | object | `{"enabled":false,"maxUnavailable":1,"minAvailable":null}` | Pod Disruption Budget </br> Ref: https://kubernetes.io/docs/reference/kubernetes-api/policy-resources/pod-disruption-budget-v1/ |
| podLabels | object | `{}` | Configure labels on Pods |
| podSecurityContext | object | `{}` | Defines privilege and access control settings for a Pod </br> Ref: https://kubernetes.io/docs/concepts/security/pod-security-standards/ </br> Ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/ |
| readinessProbe | object | `{"enabled":true,"failureThreshold":3,"initialDelaySeconds":10,"periodSeconds":10,"successThreshold":1,"timeoutSeconds":1}` | Configure readinessProbe checker </br> Ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#define-startup-probes |
| readinessProbeCustom | object | `{}` | Custom readinessProbe |
| replicaCount | int | `1` | Number of replicas Specifies the number of replicas for the service |
| resources | object | `{}` | Resources limits and requested </br> Ref: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ |
| secrets | object | `{}` | Secrets values to create credentials and reference by envFromSecrets Generate Secret with following name: <release-name>-credentials |
| securityContext | object | `{}` | Defines privilege and access control settings for a Container </br> Ref: https://kubernetes.io/docs/concepts/security/pod-security-standards/ </br> Ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/ |
| service | object | `{"port":8081,"targetPort":8081,"type":"ClusterIP"}` | Kubernetes service to expose Pod </br> Ref: https://kubernetes.io/docs/concepts/services-networking/service/ |
| service.port | int | `8081` | Kubernetes Service port |
| service.targetPort | int | `8081` | Pod expose port |
| service.type | string | `"ClusterIP"` | Kubernetes Service type. Allowed values: NodePort, LoadBalancer or ClusterIP |
| serviceAccount | object | `{"annotations":{},"automount":true,"create":true,"name":""}` | Enable creation of ServiceAccount |
| serviceMonitor | object | `{"enabled":false,"interval":"30s","metricRelabelings":[],"relabelings":[],"scrapeTimeout":"10s"}` | Enable ServiceMonitor to get metrics </br> Ref: https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/api.md#servicemonitor |
| serviceMonitor.enabled | bool | `false` | Enable or disable |
| startupProbe | object | `{"enabled":true,"failureThreshold":30,"initialDelaySeconds":180,"periodSeconds":10,"successThreshold":1,"timeoutSeconds":5}` | Configure startupProbe checker </br> Ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#define-startup-probes |
| startupProbeCustom | object | `{}` | Custom startupProbe |
| testConnection | bool | `false` | Enable or disable test connection |
| tolerations | list | `[]` | Tolerations for pod assignment </br> Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/ |
| volumeMounts | list | `[]` | Additional volumeMounts on the output Deployment definition |
| volumes | list | `[]` | Additional volumes on the output Deployment definition |
57 changes: 57 additions & 0 deletions charts/cp-schema-registry/README.md.gotmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# {{ template "chart.name" . }}

## Motivation

The original Helm chart for [Confluent Schema Registry](https://github.com/confluentinc/cp-helm-charts/tree/master/charts/cp-schema-registry) has been deprecated, and over time it became too bulky and outdated. That's why I've created a new, lighter, and more up-to-date Helm chart. This new chart is more streamlined and easier to customize.

Some of the key changes include:

* Configurations that are compatible with the latest Kubernetes features
* Easier setup, with more modular and flexible options

{{ template "chart.description" . }}

{{ template "chart.maintainersSection" . }}

## Prerequisites

* Helm 3+

{{ template "chart.requirementsSection" . }}

## Add repository

```console
helm repo add devops-ia https://devops-ia.github.io/helm-charts
helm repo update
```

## Install Helm chart (repository mode)

```console
helm install [RELEASE_NAME] devops-ia/{{ template "chart.name" . }}
```

This install all the Kubernetes components associated with the chart and creates the release.

_See [helm install](https://helm.sh/docs/helm/helm_install/) for command documentation._

## Uninstall Helm chart

```console
helm uninstall [RELEASE_NAME]
```

This removes all the Kubernetes components associated with the chart and deletes the release.

_See [helm uninstall](https://helm.sh/docs/helm/helm_uninstall/) for command documentation._

## Configuration

See [Customizing the chart before installing](https://helm.sh/docs/intro/using_helm/#customizing-the-chart-before-installing). To see all configurable options with comments:

```console
helm show values devops-ia/{{ template "chart.name" . }}
```

{{ template "chart.valuesSection" . }}
22 changes: 22 additions & 0 deletions charts/cp-schema-registry/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
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 }}{{ .path }}
{{- 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 "cp-schema-registry.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 its status by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "cp-schema-registry.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "cp-schema-registry.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 "cp-schema-registry.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
{{- end }}
62 changes: 62 additions & 0 deletions charts/cp-schema-registry/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
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 }}

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "cp-schema-registry.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "cp-schema-registry.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
Loading

0 comments on commit 46a5cab

Please sign in to comment.