Merge pull request #7324 from dokku/fix-k3s-run

Correctly pull the deployment id from an app's helm values when executing dokku run under the k3s scheduler
This commit is contained in:
Jose Diaz-Gonzalez
2024-11-04 15:56:12 -05:00
committed by GitHub
10 changed files with 35 additions and 18 deletions

View File

@@ -43,7 +43,7 @@ type AppValues struct {
type GlobalValues struct {
Annotations ProcessAnnotations `yaml:"annotations,omitempty"`
AppName string `yaml:"app_name"`
DeploymentID string `yaml:"deploment_id"`
DeploymentID string `yaml:"deployment_id"`
Image GlobalImage `yaml:"image"`
Labels ProcessLabels `yaml:"labels,omitempty"`
Keda GlobalKedaValues `yaml:"keda"`

View File

@@ -5,7 +5,7 @@ apiVersion: batch/v1
kind: CronJob
metadata:
annotations:
app.kubernetes.io/version: {{ $.Values.global.deploment_id | quote }}
app.kubernetes.io/version: {{ $.Values.global.deployment_id | quote }}
dokku.com/builder-type: {{ $.Values.global.image.type }}
dokku.com/cron-id: {{ $config.cron.id }}
dokku.com/job-suffix: {{ $config.cron.suffix }}
@@ -28,7 +28,7 @@ spec:
jobTemplate:
metadata:
annotations:
app.kubernetes.io/version: {{ $.Values.global.deploment_id | quote }}
app.kubernetes.io/version: {{ $.Values.global.deployment_id | quote }}
dokku.com/builder-type: {{ $.Values.global.image.type }}
dokku.com/cron-id: {{ $config.cron.id }}
dokku.com/job-suffix: {{ $config.cron.suffix }}
@@ -50,7 +50,7 @@ spec:
template:
metadata:
annotations:
app.kubernetes.io/version: {{ $.Values.global.deploment_id | quote }}
app.kubernetes.io/version: {{ $.Values.global.deployment_id | quote }}
dokku.com/builder-type: {{ $.Values.global.image.type }}
dokku.com/cron-id: {{ $config.cron.id }}
dokku.com/job-suffix: {{ $config.cron.suffix }}
@@ -73,7 +73,7 @@ spec:
{{- end }}
envFrom:
- secretRef:
name: env-{{ $.Values.global.app_name }}.{{ $.Values.global.deploment_id }}
name: env-{{ $.Values.global.app_name }}.{{ $.Values.global.deployment_id }}
optional: true
image: {{ $.Values.global.image.name }}
imagePullPolicy: Always

View File

@@ -11,7 +11,7 @@ apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
app.kubernetes.io/version: {{ $.Values.global.deploment_id | quote }}
app.kubernetes.io/version: {{ $.Values.global.deployment_id | quote }}
dokku.com/builder-type: {{ $.Values.global.image.type }}
dokku.com/managed: "true"
kubectl.kubernetes.io/default-container: {{ $.Values.global.app_name }}-{{ $processName }}
@@ -39,7 +39,7 @@ spec:
template:
metadata:
annotations:
app.kubernetes.io/version: {{ $.Values.global.deploment_id | quote }}
app.kubernetes.io/version: {{ $.Values.global.deployment_id | quote }}
dokku.com/builder-type: {{ $.Values.global.image.type }}
dokku.com/managed: "true"
kubectl.kubernetes.io/default-container: {{ $.Values.global.app_name }}-{{ $processName }}
@@ -64,7 +64,7 @@ spec:
{{- end }}
envFrom:
- secretRef:
name: env-{{ $.Values.global.app_name }}.{{ $.Values.global.deploment_id }}
name: env-{{ $.Values.global.app_name }}.{{ $.Values.global.deployment_id }}
optional: true
image: {{ $.Values.global.image.name }}
imagePullPolicy: Always

View File

@@ -4,15 +4,15 @@ apiVersion: v1
kind: Secret
metadata:
annotations:
app.kubernetes.io/version: {{ $.Values.global.deploment_id | quote }}
app.kubernetes.io/version: {{ $.Values.global.deployment_id | quote }}
dokku.com/managed: "true"
{{ include "print.annotations" (dict "config" $.Values.global "key" "secret") | indent 4 }}
labels:
app.kubernetes.io/instance: ims-{{ $.Values.global.app_name }}.{{ $.Values.global.deploment_id }}
app.kubernetes.io/instance: ims-{{ $.Values.global.app_name }}.{{ $.Values.global.deployment_id }}
app.kubernetes.io/name: ims-{{ $.Values.global.app_name }}
app.kubernetes.io/part-of: {{ $.Values.global.app_name }}
{{ include "print.labels" (dict "config" $.Values.global "key" "secret") | indent 4 }}
name: ims-{{ $.Values.global.app_name }}.{{ $.Values.global.deploment_id }}
name: ims-{{ $.Values.global.app_name }}.{{ $.Values.global.deployment_id }}
namespace: {{ $.Values.global.namespace }}
data:
.dockerconfigjson: "{{ $.Values.global.image.pull_secret_base64 }}"

View File

@@ -6,7 +6,7 @@ apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
annotations:
app.kubernetes.io/version: {{ $.Values.global.deploment_id | quote }}
app.kubernetes.io/version: {{ $.Values.global.deployment_id | quote }}
dokku.com/managed: "true"
{{ include "print.annotations" (dict "config" $.Values.global "key" "keda_scaled_object") | indent 4 }}
{{ include "print.annotations" (dict "config" $config "key" "keda_scaled_object") | indent 4 }}

View File

@@ -5,7 +5,7 @@ apiVersion: v1
kind: Secret
metadata:
annotations:
app.kubernetes.io/version: {{ $.Values.global.deploment_id | quote }}
app.kubernetes.io/version: {{ $.Values.global.deployment_id | quote }}
dokku.com/managed: "true"
{{ include "print.annotations" (dict "config" $.Values.global "key" "keda_secret") | indent 4 }}
labels:

View File

@@ -5,7 +5,7 @@ apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
annotations:
app.kubernetes.io/version: {{ $.Values.global.deploment_id | quote }}
app.kubernetes.io/version: {{ $.Values.global.deployment_id | quote }}
dokku.com/managed: "true"
{{- if and $.Values.global.annotations $.Values.global.annotations.keda_trigger_authentication }}
{{- range $k, $v := $.Values.global.annotations.keda_trigger_authentication }}

View File

@@ -3,15 +3,15 @@ apiVersion: v1
kind: Secret
metadata:
annotations:
app.kubernetes.io/version: {{ $.Values.global.deploment_id | quote }}
app.kubernetes.io/version: {{ $.Values.global.deployment_id | quote }}
dokku.com/managed: "true"
{{ include "print.annotations" (dict "config" $.Values.global "key" "secret") | indent 4 }}
labels:
app.kubernetes.io/instance: env-{{ $.Values.global.app_name }}.{{ $.Values.global.deploment_id }}
app.kubernetes.io/instance: env-{{ $.Values.global.app_name }}.{{ $.Values.global.deployment_id }}
app.kubernetes.io/name: env-{{ $.Values.global.app_name }}
app.kubernetes.io/part-of: {{ $.Values.global.app_name }}
{{ include "print.labels" (dict "config" $.Values.global "key" "secret") | indent 4 }}
name: env-{{ $.Values.global.app_name }}.{{ $.Values.global.deploment_id }}
name: env-{{ $.Values.global.app_name }}.{{ $.Values.global.deployment_id }}
namespace: {{ $.Values.global.namespace }}
{{- with .Values.global.secrets }}
data:

View File

@@ -1085,7 +1085,12 @@ func TriggerSchedulerRun(scheduler string, appName string, envCount int, args []
return fmt.Errorf("Error getting helm values: %w", err)
}
deploymentIDValue, ok := values["deploment_id"].(string)
globalValues, ok := values["global"].(map[string]interface{})
if !ok {
return errors.New("Global helm values not found")
}
deploymentIDValue, ok := globalValues["deployment_id"].(string)
if !ok {
return fmt.Errorf("Deployment ID is not a string")
}

View File

@@ -148,6 +148,18 @@ teardown_() {
echo "status: $status"
assert_success
assert_output "512Mi"
# include run tests
run /bin/bash -c "dokku run $TEST_APP ls -lah"
echo "output: $output"
echo "status: $status"
assert_success
# include enter tests
run /bin/bash -c "dokku enter $TEST_APP web ls -lah"
echo "output: $output"
echo "status: $status"
assert_success
}
@test "(scheduler-k3s) deploy nginx" {