Skip to content

Commit b9fd25c

Browse files
committed
feat(v0.2.0): added helm chart
Added simple helm chart for ctf-rs; not tested yet
1 parent 6163e40 commit b9fd25c

15 files changed

+838
-0
lines changed

helm/.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/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: ctf-rs
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/templates/NOTES.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
1. Get the application URL by running these commands:
2+
{{- if .Values.ingress.enabled }}
3+
{{- range $host := .Values.ingress.hosts }}
4+
{{- range .paths }}
5+
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
6+
{{- end }}
7+
{{- end }}
8+
{{- else if contains "NodePort" .Values.service.type }}
9+
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "ctf-rs.fullname" . }})
10+
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
11+
echo http://$NODE_IP:$NODE_PORT
12+
{{- else if contains "LoadBalancer" .Values.service.type }}
13+
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
14+
You can watch its status by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "ctf-rs.fullname" . }}'
15+
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "ctf-rs.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
16+
echo http://$SERVICE_IP:{{ .Values.service.port }}
17+
{{- else if contains "ClusterIP" .Values.service.type }}
18+
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "ctf-rs.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
19+
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
20+
echo "Visit http://127.0.0.1:8080 to use your application"
21+
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
22+
{{- end }}

helm/templates/_helpers.tpl

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 "ctf-rs.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 "ctf-rs.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 "ctf-rs.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "ctf-rs.labels" -}}
37+
helm.sh/chart: {{ include "ctf-rs.chart" . }}
38+
{{ include "ctf-rs.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 "ctf-rs.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "ctf-rs.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 "ctf-rs.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "ctf-rs.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
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2JBWk9IWEFhaGJ5RFFLL2RuTHN3CjJkZ0J3bmlJR3kxNElwQlNxaDBJUE03eHk5WjI4VW9oR3piN0FVakRJWHlNdmkvYTJyTVhjWjI1d1NVQmxGc28Kd005dE1QU2JwcEVvRERsa3NsOUIwT1BPdkFyQ0NKNnZGaU1UbS9wMUJIUWJSOExNQW53U0lUYVVNSFByRzJVMgpjTjEvRGNMWjZ2enEyeENjYVoxemh2bzBpY1VIUm9UWmV1ZEp6MkxmR0VHM1VOb2ppbXpBNUZHd0RhS3BySWp3ClVkd1JmZWZ1T29MT1dNVnFNbGRBcTlyT24wNHJaT3Jnak1HSE9tTWxleVdPS1AySllhaDNrVDdKU01zTHhYcFYKV0ExQjRsLzFFQkhWeGlKQi9Zby9JQWVsCi0tLS0tRU5EIENFUlRJRklDQVRFIFJFUVVFU1QtLS0tLQo=
7+
isCA: false
8+
usages:
9+
- signing
10+
- digital signature
11+
- server auth
12+
# 90 days
13+
duration: 2160h
14+
issuerRef:
15+
name: ca-issuer
16+
# We can reference ClusterIssuers by changing the kind here.
17+
# The default value is Issuer (i.e. a locally namespaced Issuer)
18+
kind: Issuer
19+
group: cert-manager.io

helm/templates/deployment.yaml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: api-server
5+
labels:
6+
app: ctf-rs
7+
component: api
8+
scope: user
9+
spec:
10+
replicas: { { .Values.api.replicaCount } }
11+
selector:
12+
matchLabels:
13+
app: ctf-rs
14+
component: api
15+
scope: user
16+
template:
17+
metadata:
18+
annotations: { { toYaml . | nindent 8 } }
19+
labels:
20+
app: ctf-rs
21+
component: api
22+
scope: user
23+
spec:
24+
imagePullSecrets: { { toYaml . | nindent 8 } }
25+
serviceAccountName: { { include "ctf-rs.serviceAccountName" . } }
26+
securityContext: { { toYaml . | nindent 8 } }
27+
containers:
28+
- name: { { .Chart.Name } }
29+
securityContext:
30+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
31+
imagePullPolicy: { { .Values.image.pullPolicy } }
32+
ports:
33+
- name: http
34+
containerPort: { { .Values.service.port } }
35+
protocol: TCP
36+
livenessProbe:
37+
readinessProbe:
38+
resources:
39+
volumeMounts:
40+
volumes:
41+
nodeSelector:
42+
affinity:
43+
tolerations:
44+
---
45+
apiVersion: apps/v1
46+
kind: Deployment
47+
metadata:
48+
name: ctfdb
49+
labels:
50+
app: ctf-rs
51+
component: db
52+
scope: user
53+
spec:
54+
replicas: { { .Values.api.replicaCount } }
55+
selector:
56+
matchLabels:
57+
app: ctf-rs
58+
component: api
59+
scope: backend
60+
template:
61+
metadata:
62+
annotations: { { toYaml . | nindent 8 } }
63+
labels:
64+
app: ctf-rs
65+
component: api
66+
scope: user
67+
spec:
68+
imagePullSecrets: { { toYaml . | nindent 8 } }
69+
serviceAccountName: { { include "ctf-rs.serviceAccountName" . } }
70+
securityContext: { { toYaml . | nindent 8 } }
71+
containers:
72+
- name: { { .Chart.Name } }
73+
securityContext:
74+
image: kuzudb/explorer:latest
75+
imagePullPolicy: { { .Values.image.pullPolicy } }
76+
ports:
77+
- name: http
78+
containerPort: { { .Values.service.port } }
79+
protocol: TCP
80+
livenessProbe:
81+
readinessProbe:
82+
resources:
83+
volumeMounts:
84+
volumes:
85+
nodeSelector:
86+
affinity:
87+
tolerations:

helm/templates/externalsecret.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
apiVersion: external-secrets.io/v1
2+
kind: SecretStore
3+
metadata:
4+
name: vault-backend
5+
labels:
6+
app: ctf-rs
7+
component: operator
8+
scope: backend
9+
spec:
10+
provider:
11+
vault:
12+
server: "http://my.vault.server:8200"
13+
path: "secret"
14+
# Version is the Vault KV secret engine version.
15+
# This can be either "v1" or "v2", defaults to "v2"
16+
version: "v2"
17+
auth:
18+
# points to a secret that contains a vault token
19+
# https://www.vaultproject.io/docs/auth/token
20+
tokenSecretRef:
21+
name: "vault-token"
22+
key: "token"
23+
---
24+
apiVersion: v1
25+
kind: Secret
26+
metadata:
27+
name: vault-token
28+
data:
29+
token: cm9vdA== # "root"

helm/templates/hpa.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
apiVersion: autoscaling/v2
2+
kind: HorizontalPodAutoscaler
3+
metadata:
4+
name: { { include "ctf-rs.fullname" . } }
5+
labels:
6+
app: ctf-rs
7+
component: api
8+
scope: user
9+
spec:
10+
scaleTargetRef:
11+
apiVersion: apps/v1
12+
kind: Deployment
13+
name: { { include "ctf-rs.fullname" . } }
14+
minReplicas: { { .Values.autoscaling.minReplicas } }
15+
maxReplicas: { { .Values.autoscaling.maxReplicas } }
16+
metrics:
17+
- type: Resource
18+
resource:
19+
name: cpu
20+
target:
21+
type: Utilization
22+
averageUtilization:
23+
{ { .Values.autoscaling.targetCPUUtilizationPercentage } }
24+
- type: Resource
25+
resource:
26+
name: memory
27+
target:
28+
type: Utilization
29+
averageUtilization:
30+
{ { .Values.autoscaling.targetMemoryUtilizationPercentage } }

helm/templates/ingress.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
apiVersion: networking.k8s.io/v1
2+
kind: Ingress
3+
metadata:
4+
name: { { include "ctf-rs.fullname" . } }
5+
labels: { { include "ctf-rs.labels" . | nindent 4 } }
6+
annotations: { { toYaml . | nindent 4 } }
7+
spec:
8+
ingressClassName: { { . } }
9+
tls:
10+
- hosts:
11+
- { { . | quote } }
12+
secretName: { { .secretName } }
13+
rules:
14+
- host: { { .host | quote } }
15+
http:
16+
paths:
17+
- path: { { .path } }
18+
pathType: { { . } }
19+
backend:
20+
service:
21+
name: { { include "ctf-rs.fullname" $ } }
22+
port:
23+
number: { { $.Values.service.port } }

helm/templates/networkpolicy.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
apiVersion: networking.k8s.io/v1
2+
kind: NetworkPolicy
3+
metadata:
4+
name: backend
5+
namespace: ctf-backend
6+
labels:
7+
app: ctf-rs
8+
component: operator
9+
scope: backend
10+
spec:
11+
podSelector:
12+
matchLabels:
13+
app: ctf-rs
14+
component: operator
15+
scope: backend
16+
policyTypes:
17+
- Ingress
18+
- Egress
19+
ingress:
20+
- from:
21+
- ipBlock:
22+
cidr: 172.17.0.0/16
23+
except:
24+
- 172.17.1.0/24
25+
- namespaceSelector:
26+
matchLabels:
27+
project: myproject
28+
- podSelector:
29+
matchLabels:
30+
role: frontend
31+
ports:
32+
- protocol: TCP
33+
port: 6379
34+
egress:
35+
- to:
36+
- ipBlock:
37+
cidr: 10.0.0.0/24
38+
ports:
39+
- protocol: TCP
40+
port: 5978

0 commit comments

Comments
 (0)