Skip to content

Commit

Permalink
feat: validate license file for platform >= 2.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
joshiste committed Dec 5, 2024
1 parent 616f995 commit 482c5df
Show file tree
Hide file tree
Showing 7 changed files with 169 additions and 7 deletions.
2 changes: 1 addition & 1 deletion charts/steadybit-platform/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
name: steadybit-platform
description: steadybit Platform Helm chart for Kubernetes.
version: 1.0.106
version: 1.1.0
appVersion: 2.1.26
home: https://www.steadybit.com/
icon: https://steadybit-website-assets.s3.amazonaws.com/logo-symbol-transparent.png
Expand Down
6 changes: 3 additions & 3 deletions charts/steadybit-platform/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{{- if not .Values.platform.tenant.agentKey -}}

##################################################################################
#### ERROR: You did not specify your secret agent key (platform.tenant.agentKey). ####
##################################################################################
##############################################################################
#### ERROR: You did not specify your secret agent key. ####
##############################################################################

{{- else -}}

Expand Down
11 changes: 11 additions & 0 deletions charts/steadybit-platform/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,15 @@ returns either the url or the data-url for an image
{{- else if .data -}}
{{- printf "data:%s;base64,%s" .mediaType (.data | b64enc) -}}
{{- end -}}
{{- end -}}

{{/*
returns the image tag for the platform container and validates wether a license is provided
*/}}
{{- define "validContainerImageTag" -}}
{{- $version := default .Values.image.tag | default .Chart.AppVersion -}}
{{- if and (semverCompare ">=2.2.0-0" $version) (not .Values.platform.tenant.license) -}}
{{- fail ".Values.platform.license missing. A license is required to run steadybit platform >= 2.2.0" -}}
{{- end -}}
{{- $version -}}
{{- end -}}
4 changes: 2 additions & 2 deletions charts/steadybit-platform/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ spec:
{{- if .Values.platform.database.migration.useInitContainer }}
initContainers:
- name: {{ include "steadybit-platform.name" . }}-db-migration
image: "{{ .Values.image.name }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
image: "{{ .Values.image.name }}:{{ template "validContainerImageTag" . }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
resources:
requests:
Expand Down Expand Up @@ -99,7 +99,7 @@ spec:
{{- end }}
containers:
- name: {{ include "steadybit-platform.name" . }}
image: "{{ .Values.image.name }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
image: "{{ .Values.image.name }}:{{ template "validContainerImageTag" . }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
lifecycle: {{ .Values.platform.lifecycle | toYaml | nindent 12 }}
resources:
Expand Down
134 changes: 134 additions & 0 deletions charts/steadybit-platform/tests/__snapshot__/deployment_test.yaml.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1366,3 +1366,137 @@ manifest should support various variables:
imagePullSecrets:
- name: RELEASE-NAME-steadybit-platform-pull-secrets
serviceAccountName: RELEASE-NAME-steadybit-platform
should not fail with missing license for version >= 2.2.0:
1: |
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: steadybit-platform
app.kubernetes.io/version: 0.0.0
helm.sh/chart: steadybit-platform-0.0.0
name: RELEASE-NAME-steadybit-platform
namespace: NAMESPACE
spec:
minReadySeconds: 60
replicas: 1
selector:
matchLabels:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/name: steadybit-platform
strategy:
type: Recreate
template:
metadata:
annotations:
prometheus.io/path: /actuator/prometheus
prometheus.io/port: "9090"
prometheus.io/scrape: "true"
labels:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: steadybit-platform
app.kubernetes.io/version: 0.0.0
helm.sh/chart: steadybit-platform-0.0.0
spec:
containers:
- env:
- name: STEADYBIT_EXPERIMENT_EXECUTION_SHUTDOWN_CHECK_INTERVAL
value: 10s
- name: LOGGING_FORMAT
value: text
- name: INSTANCE_GROUP
valueFrom:
fieldRef:
fieldPath: metadata.labels['pod-template-hash']
- name: STEADYBIT_TENANT_MODE
value: ONPREM
- name: STEADYBIT_TENANT_AGENTKEY
valueFrom:
secretKeyRef:
key: key
name: RELEASE-NAME-steadybit-platform
- name: STEADYBIT_TENANT_KEY
value: onprem
- name: STEADYBIT_TENANT_NAME
value: onprem
- name: STEADYBIT_TENANT_LICENSE
valueFrom:
secretKeyRef:
key: license
name: RELEASE-NAME-steadybit-platform-license
- name: STEADYBIT_WEB_PUBLIC_EXPERIMENT_PORT
value: "80"
- name: SPRING_DATASOURCE_USERNAME
value: steadybit
- name: SPRING_DATASOURCE_URL
value: jdbc:postgresql://RELEASE-NAME-postgresql:5432/steadybit
- name: SPRING_DATASOURCE_PASSWORD
valueFrom:
secretKeyRef:
key: password
name: RELEASE-NAME-postgresql
- name: STEADYBIT_AUTH_PROVIDER
value: static
- name: STEADYBIT_AUTH_STATIC_0_USERNAME
value: admin
- name: STEADYBIT_AUTH_STATIC_0_PASSWORD
value: '{noop}admin'
envFrom: []
image: docker.steadybit.io/steadybit/platform:2.2.0
imagePullPolicy: Always
lifecycle:
preStop:
exec:
command:
- /bin/sh
- -c
- sleep 20
livenessProbe:
failureThreshold: 5
httpGet:
path: /api/health/liveness
port: ui-port
initialDelaySeconds: 10
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 5
name: steadybit-platform
ports:
- containerPort: 8080
name: ui-port
protocol: TCP
- containerPort: 7878
name: websocket-port
protocol: TCP
readinessProbe:
failureThreshold: 3
httpGet:
path: /api/health/readiness
port: ui-port
initialDelaySeconds: 10
periodSeconds: 5
successThreshold: 1
timeoutSeconds: 5
resources:
limits:
cpu: 4000m
memory: 4Gi
requests:
cpu: 2000m
memory: 2Gi
startupProbe:
failureThreshold: 200
httpGet:
path: /api/health/liveness
port: ui-port
initialDelaySeconds: 60
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 5
volumeMounts: null
imagePullSecrets:
- name: RELEASE-NAME-steadybit-platform-pull-secrets
serviceAccountName: RELEASE-NAME-steadybit-platform
16 changes: 16 additions & 0 deletions charts/steadybit-platform/tests/deployment_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,21 @@ tests:
loadingScreen:
data: <svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path d="M11.2691 4.41115C11.5006 3.89177 11.6164 3.63208 11.7776 3.55211C11.9176 3.48263 12.082 3.48263 12.222 3.55211C12.3832 3.63208 12.499 3.89177 12.7305 4.41115L14.5745 8.54808C14.643 8.70162 14.6772 8.77839 14.7302 8.83718C14.777 8.8892 14.8343 8.93081 14.8982 8.95929C14.9705 8.99149 15.0541 9.00031 15.2213 9.01795L19.7256 9.49336C20.2911 9.55304 20.5738 9.58288 20.6997 9.71147C20.809 9.82316 20.8598 9.97956 20.837 10.1342C20.8108 10.3122 20.5996 10.5025 20.1772 10.8832L16.8125 13.9154C16.6877 14.0279 16.6252 14.0842 16.5857 14.1527C16.5507 14.2134 16.5288 14.2807 16.5215 14.3503C16.5132 14.429 16.5306 14.5112 16.5655 14.6757L17.5053 19.1064C17.6233 19.6627 17.6823 19.9408 17.5989 20.1002C17.5264 20.2388 17.3934 20.3354 17.2393 20.3615C17.0619 20.3915 16.8156 20.2495 16.323 19.9654L12.3995 17.7024C12.2539 17.6184 12.1811 17.5765 12.1037 17.56C12.0352 17.5455 11.9644 17.5455 11.8959 17.56C11.8185 17.5765 11.7457 17.6184 11.6001 17.7024L7.67662 19.9654C7.18404 20.2495 6.93775 20.3915 6.76034 20.3615C6.60623 20.3354 6.47319 20.2388 6.40075 20.1002C6.31736 19.9408 6.37635 19.6627 6.49434 19.1064L7.4341 14.6757C7.46898 14.5112 7.48642 14.429 7.47814 14.3503C7.47081 14.2807 7.44894 14.2134 7.41394 14.1527C7.37439 14.0842 7.31195 14.0279 7.18708 13.9154L3.82246 10.8832C3.40005 10.5025 3.18884 10.3122 3.16258 10.1342C3.13978 9.97956 3.19059 9.82316 3.29993 9.71147C3.42581 9.58288 3.70856 9.55304 4.27406 9.49336L8.77835 9.01795C8.94553 9.00031 9.02911 8.99149 9.10139 8.95929C9.16534 8.93081 9.2226 8.8892 9.26946 8.83718C9.32241 8.77839 9.35663 8.70162 9.42508 8.54808L11.2691 4.41115Z" stroke="#96d35f" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></g></svg>
mediaType: image/svg+xml
asserts:
- matchSnapshot: {}
- it: should fail with missing license for version >= 2.2.0
set:
image:
tag: 2.2.0
asserts:
- failedTemplate:
errorMessage: .Values.platform.license missing. A license is required to run steadybit platform >= 2.2.0
- it: should not fail with missing license for version >= 2.2.0
set:
image:
tag: 2.2.0
platform:
tenant:
license: "test"
asserts:
- matchSnapshot: {}
3 changes: 2 additions & 1 deletion charts/steadybit-platform/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ platform:
key: onprem
# platform.tenant.name -- Key for the tenant assigned to you.
name: onprem
# -- The secret token which your agent uses to authenticate to steadybit's servers. Get it from https://platform.steadybit.io/settings/agents/setup.
# platform.tenant.agentKey -- The secret token which your agent uses to authenticate to steadybit's servers. Get it from https://platform.steadybit.io/settings/agents/setup.
agentKey: null
# platform.tenant.license -- The license to run the platform. This is mandatory for platform >= 2.2.0
license: null
agent:
auth:
Expand Down

0 comments on commit 482c5df

Please sign in to comment.