Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add telemetry support #158

Merged
merged 13 commits into from
Apr 16, 2024
9 changes: 6 additions & 3 deletions .github/kubeconform.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ tar -xf /tmp/kubeconform.tar.gz kubeconform
# validate charts
for CHART_DIR in ${CHART_DIRS}; do
echo "Running kubeconform for folder: '$CHART_DIR'"
helm dep up "${CHART_DIR}" \
&& helm template --kube-version "${KUBERNETES_VERSION#v}" --values "${CHART_DIR}"/ci/kubeconform-values.yaml "${CHART_DIR}" \
| ./kubeconform --strict --summary --kubernetes-version "${KUBERNETES_VERSION#v}"
helm dep up "${CHART_DIR}"
for VALUES_FILE in $(find "${CHART_DIR}/ci" -name '*values.yaml'); do
echo "== Checking values file: ${VALUES_FILE}"
helm template --kube-version "${KUBERNETES_VERSION#v}" --values "${VALUES_FILE}" "${CHART_DIR}" \
| ./kubeconform --strict --summary --kubernetes-version "${KUBERNETES_VERSION#v}"
done
done
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
charts/**/*.tgz
.prettierignore

kubeconform
/kubeconform

.DS_Store
5 changes: 5 additions & 0 deletions .helmignore → charts/retool/.helmignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,8 @@
.idea/
*.tmproj
.vscode/

# Don't package testing values files
/ci
# Try not to package past versions into new chart bundles
retool*.tgz
2 changes: 1 addition & 1 deletion charts/retool/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: retool
description: A Helm chart for Kubernetes
type: application
version: 6.1.6
version: 6.2.0
maintainers:
- name: Retool Engineering
email: [email protected]
Expand Down
59 changes: 59 additions & 0 deletions charts/retool/ci/kubeconform/telemetry-enabled-basic-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# ================================================
# === boilerplate to get a bootable deployment ===
# ================================================
config:
encryptionKey: '000000000'
jwtSecret: '000000000'

licenseKey: "EXPIRED-LICENSE-KEY-TRIAL"

image:
tag: 'latest'

resources:
requests:
cpu: 500m
memory: 1024Mi
limits:
cpu: 1000m
memory: 4096Mi

workflows:
resources:
requests:
cpu: 500m
memory: 1024Mi
limits:
cpu: 1000m
memory: 2048Mi

env:
NUM_WORKERS: '1'
# NODE_DEBUG: 'module'

ingress:
kubernetes.io/ingress.class: nginx
hosts:
- host: retool.example.com
paths:
- path: /

livenessProbe:
timeoutSeconds: 60
periodSeconds: 2
failureThreshold: 60
readinessProbe:
timeoutSeconds: 30
periodSeconds: 5

replicaCount: 1

persistentVolumeClaim:
size: '3Gi'
# ================================================

# === New telemetry stuff ===
telemetry:
enabled: true
image:
tag: 3.42.0-edge
84 changes: 84 additions & 0 deletions charts/retool/ci/kubeconform/telemetry-enabled-full-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# ================================================
# === boilerplate to get a bootable deployment ===
# ================================================
config:
encryptionKey: '000000000'
jwtSecret: '000000000'

licenseKey: "EXPIRED-LICENSE-KEY-TRIAL"

image:
tag: 'latest'

resources:
requests:
cpu: 500m
memory: 1024Mi
limits:
cpu: 1000m
memory: 4096Mi

workflows:
resources:
requests:
cpu: 500m
memory: 1024Mi
limits:
cpu: 1000m
memory: 2048Mi

env:
NUM_WORKERS: '1'
# NODE_DEBUG: 'module'

ingress:
kubernetes.io/ingress.class: nginx
hosts:
- host: retool.example.com
paths:
- path: /

livenessProbe:
timeoutSeconds: 60
periodSeconds: 2
failureThreshold: 60
readinessProbe:
timeoutSeconds: 30
periodSeconds: 5

replicaCount: 1

persistentVolumeClaim:
size: '3Gi'
# ================================================

# === New telemetry stuff ===
telemetry:
enabled: true
image:
repository: 'tryretool/telemetry'
tag: 3.42.0-edge
sendToRetool:
enabled: true
customVectorConfig:
foo: bar
customGrafanaAgentConfig: |
// wee woo custom text
extraAnnotations:
foo.com/bar: baz
extraPodSpec:
hostname: bleepbloop
extraVolumes:
- name: varlog
hostPath:
path: "/var/log"
extraVolumeMounts:
- name: varlog
mountPath: "/hostvarlog"
readOnly: true
extraPorts:
- containerPort: 9999
name: yaaaaa
protocol: TCP
extraContainerSpec:
args: ["this should be ignored"]
1 change: 1 addition & 0 deletions charts/retool/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
{{- end }}

{{- if and .Values.postgresql.enabled (and (not .Values.postgresql.auth.postgresPassword) (eq .Values.postgresql.auth.username "postgres")) }}

***************************************************************************
Warning: Using in-cluster postgresql setup. `.Values.postgresql.auth.username username` is set to the default admin username "postgres", but the admin password field `.Values.postgresql.auth.postgresPassword` is not set, so a random password is generated and used. This wouldn't affect your usage, but if you choose to uninstall and reinstall this helm chart, please make sure you remove the existing PersistentVolumeClaim backing the in-cluster postgresql by running:
kubectl --namespace {{ .Release.Namespace }} delete pvc/data-{{ include "retool.fullname" . }}-postgresql-0
Expand Down
74 changes: 69 additions & 5 deletions charts/retool/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,71 @@ Common labels
*/}}
{{- define "retool.labels" -}}
helm.sh/chart: {{ include "retool.chart" . }}
{{ include "retool.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
Selector labels for main backend. Note changes here will require deployment
recreation and incur downtime. The "app.kubernetes.io/instance" label should
also be included in all deployments, so telemetry knows how to find logs.
*/}}
{{- define "retool.selectorLabels" -}}
app.kubernetes.io/name: {{ include "retool.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Selector labels for workflow backend. Note changes here will require manual
deployment recreation and incur downtime, so should be avoided.
*/}}
{{- define "retool.workflowBackend.selectorLabels" -}}
retoolService: {{ include "retool.workflowBackend.name" . }}
{{- end }}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and all the retool.*.selectorLabels partials below don't actually change the selector labels that were already used, they're just refactoring the template code.


{{/*
Extra (non-selector) labels for workflow backend.
*/}}
{{- define "retool.workflowBackend.labels" -}}
app.kubernetes.io/name: {{ include "retool.workflowBackend.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
telemetry.retool.com/service-name: workflow-backend
{{- end }}

{{/*
Selector labels for workflow worker. Note changes here will require manual
deployment recreation and incur downtime, so should be avoided.
*/}}
{{- define "retool.workflowWorker.selectorLabels" -}}
retoolService: {{ include "retool.workflowWorker.name" . }}
{{- end }}

{{/*
Extra (non-selector) labels for workflow worker.
*/}}
{{- define "retool.workflowWorker.labels" -}}
app.kubernetes.io/name: {{ include "retool.workflowWorker.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
telemetry.retool.com/service-name: workflow-worker
{{- end }}

{{/*
Selector labels for code executor. Note changes here will require manual
deployment recreation and incur downtime, so should be avoided.
*/}}
{{- define "retool.codeExecutor.selectorLabels" -}}
retoolService: {{ include "retool.codeExecutor.name" . }}
{{- end }}

{{/*
Extra (non-selector) labels for code executor.
*/}}
{{- define "retool.codeExecutor.labels" -}}
app.kubernetes.io/name: {{ include "retool.codeExecutor.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
telemetry.retool.com/service-name: code-executor
{{- end }}


{{/*
Create the name of the service account to use
*/}}
Expand Down Expand Up @@ -234,6 +284,20 @@ Set Temporal namespace
{{- end -}}
{{- end -}}

{{/*
Set workflow backend service name
*/}}
{{- define "retool.workflowBackend.name" -}}
{{ template "retool.fullname" . }}-workflow-backend
{{- end -}}

{{/*
Set workflow worker service name
*/}}
{{- define "retool.workflowWorker.name" -}}
{{ template "retool.fullname" . }}-workflow-worker
{{- end -}}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These result in the exact same names as before, just a template code refactor for reuse.


{{/*
Set code executor service name
*/}}
Expand Down
72 changes: 72 additions & 0 deletions charts/retool/templates/_telemetry_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{{/*
Reusable name for telemetry-related chart resources.
*/}}
{{- define "retool.telemetry.fullname" -}}
{{- $name := default "telemetry" .Values.telemetry.nameOverride -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Labels to include on telemetry pods.
*/}}
{{- define "retool.telemetry.labels" -}}
helm.sh/chart: {{ include "retool.chart" . }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}

{{/*
Labels to use as selector for telemetry pods and deployment. Note these become
immutable once deployed, so changes here will require recreating the deployment.
*/}}
{{- define "retool.telemetry.selectorLabels" -}}
app.kubernetes.io/name: {{ default "telemetry" .Values.telemetry.nameOverride }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}


{{/*
The name of the service account to use.
*/}}
{{- define "retool.telemetry.serviceAccountName" -}}
{{- if .Values.telemetry.serviceAccount.create }}
{{- default (include "retool.telemetry.fullname" .) .Values.telemetry.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.telemetry.serviceAccount.name }}
{{- end }}
{{- end }}


{{/*
The labels to use for scoping log collection to only the pods in the same
release, as a single comma-separated string. The label(s) below should be
present on all relevant pods, or else logs won't be collected. */}}
{{- define "retool.telemetry.logSourcePodLabels" -}}
app.kubernetes.io/instance={{ .Release.Name }}
{{- end }}


{{/*
Env vars to include on retool pods to collect telemetry via telemetry pod.
*/}}
{{- define "retool.telemetry.includeEnvVars" -}}
{{- if .Values.telemetry.enabled }}
- name: RTEL_ENABLED
value: 'true'
- name: RTEL_SERVICE_NAME
valueFrom:
fieldRef:
fieldPath: metadata.labels['telemetry.retool.com/service-name']
- name: K8S_POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: K8S_NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: STATSD_HOST
value: {{ printf "%s.%s" (include "retool.telemetry.fullname" .) .Release.Namespace | quote }}
- name: STATSD_PORT
value: "9125"
{{- end }}
{{- end }}
Loading
Loading