Skip to content

Commit 2bd7d36

Browse files
committed
* Added Helm chart for deploying KillBill, Kaui, and MariaDB on Kubernetes
* Added configurable images, replicas, services, and environment variables * Configured Kubernetes service discovery between KB, Kaui, and MariaDB * Added startup, readiness, and liveness probes * Updated KB startup script to support configurable DB host * Added Kubernetes service based communication between components
1 parent 17639fa commit 2bd7d36

14 files changed

Lines changed: 568 additions & 2 deletions

‎docker/templates/killbill/latest/killbill.sh‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ echo "Installing plugins..."
77
# Run both the main playbook and the one enabling structured logging
88
$KPM_INSTALL_CMD $KILLBILL_CLOUD_ANSIBLE_ROLES/killbill_json_logging.yml
99

10-
until mysql --protocol=TCP -h127.0.0.1 -P3306 -uroot -pkillbill -e "SELECT 1"; do
10+
DB_HOST="${DB_HOST:-127.0.0.1}"
11+
12+
until mysql --protocol=TCP -h"$DB_HOST" -P3306 -uroot -pkillbill -e "SELECT 1"; do
1113
echo "Waiting for DB..."
1214
sleep 5
1315
done
1416

1517
INSTALL_PLUGINS_CMD="$INSTALL_PLUGINS_CMD \
16-
-e db_config_address=127.0.0.1 \
18+
-e db_config_address=$DB_HOST \
1719
-e db_config_port=3306 \
1820
-e db_config_username=$KILLBILL_DAO_USER \
1921
-e db_config_password=$KILLBILL_DAO_PASSWORD \

‎helm/killbill/.helmignore‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/

‎helm/killbill/Chart.yaml‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: v2
2+
name: killbill
3+
description: A Helm chart for Kubernetes
4+
5+
# A chart can be either an 'application' or a 'library' chart.
6+
#
7+
# Application charts are a collection of templates that can be packaged into versioned archives
8+
# to be deployed.
9+
#
10+
# Library charts provide useful utilities or functions for the chart developer. They're included as
11+
# a dependency of application charts to inject those utilities and functions into the rendering
12+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
13+
type: application
14+
15+
# This is the chart version. This version number should be incremented each time you make changes
16+
# to the chart and its templates, including the app version.
17+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18+
version: 0.1.0
19+
20+
# This is the version number of the application being deployed. This version number should be
21+
# incremented each time you make changes to the application. Versions are not expected to
22+
# follow Semantic Versioning. They should reflect the version the application is using.
23+
# It is recommended to use it with quotes.
24+
appVersion: "1.16.0"

‎helm/killbill/templates/NOTES.txt‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
1. Get the application URL by running these commands:
2+
{{- if .Values.httpRoute.enabled }}
3+
{{- if .Values.httpRoute.hostnames }}
4+
export APP_HOSTNAME={{ .Values.httpRoute.hostnames | first }}
5+
{{- else }}
6+
export APP_HOSTNAME=$(kubectl get --namespace {{(first .Values.httpRoute.parentRefs).namespace | default .Release.Namespace }} gateway/{{ (first .Values.httpRoute.parentRefs).name }} -o jsonpath="{.spec.listeners[0].hostname}")
7+
{{- end }}
8+
{{- if and .Values.httpRoute.rules (first .Values.httpRoute.rules).matches (first (first .Values.httpRoute.rules).matches).path.value }}
9+
echo "Visit http://$APP_HOSTNAME{{ (first (first .Values.httpRoute.rules).matches).path.value }} to use your application"
10+
11+
NOTE: Your HTTPRoute depends on the listener configuration of your gateway and your HTTPRoute rules.
12+
The rules can be set for path, method, header and query parameters.
13+
You can check the gateway configuration with 'kubectl get --namespace {{(first .Values.httpRoute.parentRefs).namespace | default .Release.Namespace }} gateway/{{ (first .Values.httpRoute.parentRefs).name }} -o yaml'
14+
{{- end }}
15+
{{- else if .Values.ingress.enabled }}
16+
{{- range $host := .Values.ingress.hosts }}
17+
{{- range .paths }}
18+
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
19+
{{- end }}
20+
{{- end }}
21+
{{- else if contains "NodePort" .Values.service.type }}
22+
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "killbill.fullname" . }})
23+
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
24+
echo http://$NODE_IP:$NODE_PORT
25+
{{- else if contains "LoadBalancer" .Values.service.type }}
26+
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
27+
You can watch its status by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "killbill.fullname" . }}'
28+
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "killbill.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
29+
echo http://$SERVICE_IP:{{ .Values.service.port }}
30+
{{- else if contains "ClusterIP" .Values.service.type }}
31+
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "killbill.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
32+
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
33+
echo "Visit http://127.0.0.1:8080 to use your application"
34+
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
35+
{{- end }}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "killbill.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "killbill.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "killbill.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "killbill.labels" -}}
37+
helm.sh/chart: {{ include "killbill.chart" . }}
38+
{{ include "killbill.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "killbill.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "killbill.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
52+
53+
{{/*
54+
Create the name of the service account to use
55+
*/}}
56+
{{- define "killbill.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "killbill.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}

‎helm/killbill/templates/hpa.yaml‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{{- if .Values.autoscaling.enabled }}
2+
apiVersion: autoscaling/v2
3+
kind: HorizontalPodAutoscaler
4+
metadata:
5+
name: {{ include "killbill.fullname" . }}
6+
labels:
7+
{{- include "killbill.labels" . | nindent 4 }}
8+
spec:
9+
scaleTargetRef:
10+
apiVersion: apps/v1
11+
kind: Deployment
12+
name: {{ include "killbill.fullname" . }}
13+
minReplicas: {{ .Values.autoscaling.minReplicas }}
14+
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
15+
metrics:
16+
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
17+
- type: Resource
18+
resource:
19+
name: cpu
20+
target:
21+
type: Utilization
22+
averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
23+
{{- end }}
24+
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
25+
- type: Resource
26+
resource:
27+
name: memory
28+
target:
29+
type: Utilization
30+
averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
31+
{{- end }}
32+
{{- end }}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{{- if .Values.httpRoute.enabled -}}
2+
{{- $fullName := include "killbill.fullname" . -}}
3+
{{- $svcPort := .Values.service.port -}}
4+
apiVersion: gateway.networking.k8s.io/v1
5+
kind: HTTPRoute
6+
metadata:
7+
name: {{ $fullName }}
8+
labels:
9+
{{- include "killbill.labels" . | nindent 4 }}
10+
{{- with .Values.httpRoute.annotations }}
11+
annotations:
12+
{{- toYaml . | nindent 4 }}
13+
{{- end }}
14+
spec:
15+
parentRefs:
16+
{{- with .Values.httpRoute.parentRefs }}
17+
{{- toYaml . | nindent 4 }}
18+
{{- end }}
19+
{{- with .Values.httpRoute.hostnames }}
20+
hostnames:
21+
{{- toYaml . | nindent 4 }}
22+
{{- end }}
23+
rules:
24+
{{- range .Values.httpRoute.rules }}
25+
{{- with .matches }}
26+
- matches:
27+
{{- toYaml . | nindent 8 }}
28+
{{- end }}
29+
{{- with .filters }}
30+
filters:
31+
{{- toYaml . | nindent 8 }}
32+
{{- end }}
33+
backendRefs:
34+
- name: {{ $fullName }}
35+
port: {{ $svcPort }}
36+
weight: 1
37+
{{- end }}
38+
{{- end }}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: kaui
5+
spec:
6+
replicas: {{ .Values.kaui.replicaCount }}
7+
8+
selector:
9+
matchLabels:
10+
app: kaui
11+
12+
template:
13+
metadata:
14+
labels:
15+
app: kaui
16+
17+
spec:
18+
containers:
19+
- name: kaui
20+
image: "{{ .Values.kaui.image.repository }}:{{ .Values.kaui.image.tag }}"
21+
imagePullPolicy: IfNotPresent
22+
23+
ports:
24+
- name: http
25+
containerPort: 8080
26+
protocol: TCP
27+
28+
env:
29+
- name: KAUI_CONFIG_DAO_USER
30+
value: root
31+
32+
- name: KAUI_CONFIG_DAO_PASSWORD
33+
value: killbill
34+
35+
- name: KAUI_CONFIG_DAO_URL
36+
value: jdbc:mysql://mariadb:3306/kaui
37+
38+
- name: KAUI_KILLBILL_URL
39+
value: http://killbill:8080
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: kaui
5+
spec:
6+
type: ClusterIP
7+
8+
ports:
9+
- port: {{ .Values.kaui.service.port }}
10+
targetPort: 9090
11+
protocol: TCP
12+
name: http
13+
14+
selector:
15+
app: kaui
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: killbill
5+
spec:
6+
replicas: {{ .Values.killbill.replicaCount }}
7+
8+
selector:
9+
matchLabels:
10+
app: killbill
11+
12+
template:
13+
metadata:
14+
labels:
15+
app: killbill
16+
17+
spec:
18+
containers:
19+
- name: killbill
20+
image: "{{ .Values.killbill.image.repository }}:{{ .Values.killbill.image.tag }}"
21+
imagePullPolicy: IfNotPresent
22+
23+
ports:
24+
- name: http
25+
containerPort: 8080
26+
27+
env:
28+
- name: DB_HOST
29+
value: mariadb
30+
31+
- name: KILLBILL_ADMIN_PASSWORD
32+
value: password
33+
34+
- name: KILLBILL_DAO_USER
35+
value: root
36+
37+
- name: KILLBILL_DAO_PASSWORD
38+
value: killbill
39+
40+
- name: KILLBILL_DAO_URL
41+
value: jdbc:mysql://mariadb:3306/killbill
42+
43+
readinessProbe:
44+
httpGet:
45+
path: /1.0/healthcheck
46+
port: 8080
47+
initialDelaySeconds: 30
48+
periodSeconds: 10
49+
50+
livenessProbe:
51+
httpGet:
52+
path: /1.0/healthcheck
53+
port: 8080
54+
initialDelaySeconds: 60
55+
periodSeconds: 20

0 commit comments

Comments
 (0)