Skip to content

Commit 579117b

Browse files
committed
feat: [v2] add new chart
Signed-off-by: Chris Randles <randles.chris@gmail.com>
1 parent c8b2c29 commit 579117b

18 files changed

+832
-0
lines changed

Makefile

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
TRICKSTER_ORG ?= trickstercache
2+
IMAGE_REPO ?= ghcr.io/$(TRICKSTER_ORG)/trickster
3+
IMAGE_TAG ?= main
4+
5+
.PHONY: uninstall
6+
uninstall:
7+
helm uninstall trickster || true
8+
9+
.PHONY: install
10+
install: uninstall
11+
helm upgrade trickster charts/trickster-v2 --install --set image.repository=$(IMAGE_REPO) --set image.tag=$(IMAGE_TAG) --set service.serviceNodePort=31209 --set service.type=NodePort
12+
13+
install-with-pvc: uninstall
14+
helm upgrade trickster charts/trickster-v2 --install --set image.repository=$(IMAGE_REPO) --set image.tag=$(IMAGE_TAG) --set service.serviceNodePort=31209 --set service.type=NodePort --set persistentVolume.enabled=true --set persistentVolume.storageClass=openebs-hostpath
15+
16+
install-with-ingress: uninstall
17+
helm upgrade trickster charts/trickster-v2 --install --set image.repository=$(IMAGE_REPO) --set image.tag=$(IMAGE_TAG) --set ingress.enabled=true
18+
19+
.PHONY: query
20+
query:
21+
open http://localhost:31209/query
22+
23+
query-ingress:
24+
open http://trickster.local/query
25+
# open http://trickster.local/query
26+
27+
.PHONY: logs
28+
logs:
29+
kubectl logs -f deploy/trickster-trickster-v2
30+
31+
.PHONY: install-prom
32+
install-prom:
33+
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
34+
helm repo update
35+
helm install prometheus prometheus-community/prometheus
36+
37+
.PHONY: install-nginx
38+
install-nginx:
39+
kubectl apply -f https://kind.sigs.k8s.io/examples/ingress/deploy-ingress-nginx.yaml
40+
41+
.PHONY: install-openebs
42+
install-openebs:
43+
helm repo add openebs https://openebs.github.io/charts
44+
helm repo update
45+
helm install openebs --namespace openebs openebs/openebs --create-namespace
46+
47+
.PHONY: setup-kind
48+
setup-kind:
49+
kind delete cluster --name trickster || true
50+
kind create cluster --config kind-config.yaml
51+
$(MAKE) install-nginx install-prom install-openebs

charts/trickster-v2/.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/

charts/trickster-v2/Chart.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apiVersion: v2
2+
name: trickster-v2
3+
description: A Helm chart for managing a Trickster Deployment
4+
type: application
5+
version: 0.0.0
6+
appVersion: "2.0.0-beta-tbd"

charts/trickster-v2/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# trickster helm chart
2+
3+
## Chart goals / guidelines
4+
- Should support latest Kubernetes version (Starting with 1.30+)
5+
- Should support the latest major version of Trickster
6+
- Should support the latest minor version of Trickster
7+
- Should not overly abstract Trickster configuration file
8+
9+
## Chart capabilities
10+
- Simple integration with Prometheus Operator or Prometheus Annotation-based Service Discovery
11+
- Arbitrary YAML may be included via the `extraYaml` key within a `values.yaml`
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 "trickster.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 "trickster.fullname" . }}'
15+
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "trickster.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
16+
echo http://$SERVICE_IP:{{ .Values.service.servicePort }}
17+
{{- else if contains "ClusterIP" .Values.service.type }}
18+
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "trickster.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 }}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "trickster.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 "trickster.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 "trickster.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "trickster.labels" -}}
37+
helm.sh/chart: {{ include "trickster.chart" . }}
38+
{{ include "trickster.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 "trickster.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "trickster.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 "trickster.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "trickster.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}
63+
64+
{{/*
65+
Inject default values into the config.yaml that correspond with other chart values.
66+
*/}}
67+
{{- define "trickster.config" -}}
68+
{{- $fsCache := dict "filesystem" (dict "cache_path" (.Values.persistentVolume.mountPath | default "/data")) -}}
69+
{{- $bbCache := dict "bbolt" (dict "filename" (printf "%s/trickster.db" (.Values.persistentVolume.mountPath | default "/data"))) -}}
70+
{{- $bdCache := dict "badger" (dict "directory" (.Values.persistentVolume.mountPath | default "/data") "value_directory" (.Values.persistentVolume.mountPath | default "/data")) -}}
71+
{{- $default := merge (merge $fsCache $bbCache) $bdCache -}}
72+
{{- $config := merge (dict "caches" (dict "default" $default)) .Values.config -}}
73+
{{- $config | toYaml -}}
74+
{{- end }}
75+
76+
{{- define "trickster.proxyPort" -}}
77+
{{- $.Values.config.frontend.listen_port }}
78+
{{- end }}
79+
80+
{{- define "trickster.metricsPort" -}}
81+
{{- $.Values.config.metrics.listen_port }}
82+
{{- end}}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: {{ include "trickster.fullname" . }}
5+
{{- if .Values.configmapAnnotations }}
6+
annotations:
7+
{{- toYaml .Values.configmapAnnotations | nindent 4 }}
8+
{{- end }}
9+
labels:
10+
{{- include "trickster.labels" . | nindent 4 }}
11+
{{- if .Values.configmapLabels }}
12+
{{- toYaml .Values.configmapLabels | nindent 4 }}
13+
{{- end }}
14+
data:
15+
config.yaml: |
16+
{{- include "trickster.config" . | nindent 4 }}
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "trickster.fullname" . }}
5+
{{- if .Values.deploymentAnnotations }}
6+
annotations:
7+
{{- toYaml .Values.deploymentAnnotations | nindent 4 }}
8+
{{- end }}
9+
labels:
10+
{{- include "trickster.labels" . | nindent 4 }}
11+
{{- if .Values.deploymentLabels }}
12+
{{- toYaml .Values.deploymentLabels | nindent 4 }}
13+
{{- end }}
14+
spec:
15+
{{- if not .Values.autoscaling.enabled }}
16+
replicas: {{ .Values.replicaCount }}
17+
{{- end }}
18+
selector:
19+
matchLabels:
20+
{{- include "trickster.selectorLabels" . | nindent 6 }}
21+
template:
22+
metadata:
23+
annotations:
24+
checksum/trickster-cfg: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
25+
{{- with .Values.podAnnotations }}
26+
{{- toYaml . | nindent 8 }}
27+
{{- end }}
28+
labels:
29+
{{- include "trickster.labels" . | nindent 8 }}
30+
{{- with .Values.podLabels }}
31+
{{- toYaml . | nindent 8 }}
32+
{{- end }}
33+
spec:
34+
{{- with .Values.imagePullSecrets }}
35+
imagePullSecrets:
36+
{{- toYaml . | nindent 8 }}
37+
{{- end }}
38+
serviceAccountName: {{ include "trickster.serviceAccountName" . }}
39+
{{- with .Values.podSecurityContext }}
40+
securityContext:
41+
{{- toYaml . | nindent 8 }}
42+
{{- end }}
43+
containers:
44+
- name: {{ .Chart.Name }}
45+
{{- if .Values.extraEnv }}
46+
env:
47+
{{- range $key, $value := .Values.extraEnv }}
48+
- name: {{ $key }}
49+
value: {{ $value }}
50+
{{- end }}
51+
{{- end }}
52+
args:
53+
- --config=/etc/trickster/config.yaml
54+
{{- if .Values.extraArgs }}
55+
{{- range $key, $value := .Values.extraArgs }}
56+
- --{{ $key }}={{ $value }}
57+
{{- end }}
58+
{{- end }}
59+
{{- with .Values.securityContext }}
60+
securityContext:
61+
{{- toYaml . | nindent 12 }}
62+
{{- end }}
63+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
64+
imagePullPolicy: {{ .Values.image.pullPolicy }}
65+
ports:
66+
- name: http
67+
containerPort: {{ include "trickster.proxyPort" . }}
68+
protocol: TCP
69+
- name: metrics
70+
containerPort: {{ include "trickster.metricsPort" . }}
71+
protocol: TCP
72+
livenessProbe:
73+
httpGet:
74+
path: /trickster/ping
75+
port: http
76+
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
77+
periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
78+
readinessProbe:
79+
httpGet:
80+
path: /trickster/ping
81+
port: http
82+
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
83+
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
84+
{{- with .Values.resources }}
85+
resources:
86+
{{- toYaml . | nindent 12 }}
87+
{{- end }}
88+
volumeMounts:
89+
- name: cfg-volume
90+
mountPath: /etc/trickster
91+
- name: storage
92+
mountPath: {{ .Values.persistentVolume.mountPath | default "/data" }}
93+
subPath: {{ .Values.persistentVolume.subPath | default ""}}
94+
{{- with .Values.volumeMounts }}
95+
{{- toYaml . | nindent 12 }}
96+
{{- end }}
97+
volumes:
98+
- name: cfg-volume
99+
configMap:
100+
name: {{ template "trickster.fullname" . }}
101+
items:
102+
- key: config.yaml
103+
path: config.yaml
104+
- name: storage
105+
{{- if .Values.persistentVolume.enabled }}
106+
persistentVolumeClaim:
107+
claimName: {{ if .Values.persistentVolume.existingClaim }}{{ .Values.persistentVolume.existingClaim }}{{- else }}{{ template "trickster.fullname" . }}{{- end }}
108+
{{- else }}
109+
emptyDir: {}
110+
{{- end }}
111+
{{- with .Values.volumes }}
112+
{{- toYaml . | nindent 8 }}
113+
{{- end }}
114+
{{- with .Values.nodeSelector }}
115+
nodeSelector:
116+
{{- toYaml . | nindent 8 }}
117+
{{- end }}
118+
{{- with .Values.affinity }}
119+
affinity:
120+
{{- toYaml . | nindent 8 }}
121+
{{- end }}
122+
{{- with .Values.tolerations }}
123+
tolerations:
124+
{{- toYaml . | nindent 8 }}
125+
{{- end }}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{{ range .Values.extra }}
2+
---
3+
{{ tpl . $ }}
4+
{{ end }}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{{- if .Values.autoscaling.enabled }}
2+
apiVersion: autoscaling/v2
3+
kind: HorizontalPodAutoscaler
4+
metadata:
5+
name: {{ include "trickster.fullname" . }}
6+
{{- if .Values.autoscaling.hpaAnnotations }}
7+
annotations:
8+
{{- toYaml .Values.autoscaling.hpaAnnotations | nindent 4 }}
9+
{{- end }}
10+
labels:
11+
{{- include "trickster.labels" . | nindent 4 }}
12+
{{- if .Values.autoscaling.hpaLabels }}
13+
{{- toYaml .Values.autoscaling.hpaLabels | nindent 4 }}
14+
{{- end }}
15+
spec:
16+
scaleTargetRef:
17+
apiVersion: apps/v1
18+
kind: Deployment
19+
name: {{ include "trickster.fullname" . }}
20+
minReplicas: {{ .Values.autoscaling.minReplicas }}
21+
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
22+
metrics:
23+
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
24+
- type: Resource
25+
resource:
26+
name: cpu
27+
target:
28+
type: Utilization
29+
averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
30+
{{- end }}
31+
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
32+
- type: Resource
33+
resource:
34+
name: memory
35+
target:
36+
type: Utilization
37+
averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
38+
{{- end }}
39+
{{- end }}

0 commit comments

Comments
 (0)