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:
@@ -43,7 +43,7 @@ type AppValues struct {
|
|||||||
type GlobalValues struct {
|
type GlobalValues struct {
|
||||||
Annotations ProcessAnnotations `yaml:"annotations,omitempty"`
|
Annotations ProcessAnnotations `yaml:"annotations,omitempty"`
|
||||||
AppName string `yaml:"app_name"`
|
AppName string `yaml:"app_name"`
|
||||||
DeploymentID string `yaml:"deploment_id"`
|
DeploymentID string `yaml:"deployment_id"`
|
||||||
Image GlobalImage `yaml:"image"`
|
Image GlobalImage `yaml:"image"`
|
||||||
Labels ProcessLabels `yaml:"labels,omitempty"`
|
Labels ProcessLabels `yaml:"labels,omitempty"`
|
||||||
Keda GlobalKedaValues `yaml:"keda"`
|
Keda GlobalKedaValues `yaml:"keda"`
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ apiVersion: batch/v1
|
|||||||
kind: CronJob
|
kind: CronJob
|
||||||
metadata:
|
metadata:
|
||||||
annotations:
|
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/builder-type: {{ $.Values.global.image.type }}
|
||||||
dokku.com/cron-id: {{ $config.cron.id }}
|
dokku.com/cron-id: {{ $config.cron.id }}
|
||||||
dokku.com/job-suffix: {{ $config.cron.suffix }}
|
dokku.com/job-suffix: {{ $config.cron.suffix }}
|
||||||
@@ -28,7 +28,7 @@ spec:
|
|||||||
jobTemplate:
|
jobTemplate:
|
||||||
metadata:
|
metadata:
|
||||||
annotations:
|
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/builder-type: {{ $.Values.global.image.type }}
|
||||||
dokku.com/cron-id: {{ $config.cron.id }}
|
dokku.com/cron-id: {{ $config.cron.id }}
|
||||||
dokku.com/job-suffix: {{ $config.cron.suffix }}
|
dokku.com/job-suffix: {{ $config.cron.suffix }}
|
||||||
@@ -50,7 +50,7 @@ spec:
|
|||||||
template:
|
template:
|
||||||
metadata:
|
metadata:
|
||||||
annotations:
|
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/builder-type: {{ $.Values.global.image.type }}
|
||||||
dokku.com/cron-id: {{ $config.cron.id }}
|
dokku.com/cron-id: {{ $config.cron.id }}
|
||||||
dokku.com/job-suffix: {{ $config.cron.suffix }}
|
dokku.com/job-suffix: {{ $config.cron.suffix }}
|
||||||
@@ -73,7 +73,7 @@ spec:
|
|||||||
{{- end }}
|
{{- end }}
|
||||||
envFrom:
|
envFrom:
|
||||||
- secretRef:
|
- secretRef:
|
||||||
name: env-{{ $.Values.global.app_name }}.{{ $.Values.global.deploment_id }}
|
name: env-{{ $.Values.global.app_name }}.{{ $.Values.global.deployment_id }}
|
||||||
optional: true
|
optional: true
|
||||||
image: {{ $.Values.global.image.name }}
|
image: {{ $.Values.global.image.name }}
|
||||||
imagePullPolicy: Always
|
imagePullPolicy: Always
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ apiVersion: apps/v1
|
|||||||
kind: Deployment
|
kind: Deployment
|
||||||
metadata:
|
metadata:
|
||||||
annotations:
|
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/builder-type: {{ $.Values.global.image.type }}
|
||||||
dokku.com/managed: "true"
|
dokku.com/managed: "true"
|
||||||
kubectl.kubernetes.io/default-container: {{ $.Values.global.app_name }}-{{ $processName }}
|
kubectl.kubernetes.io/default-container: {{ $.Values.global.app_name }}-{{ $processName }}
|
||||||
@@ -39,7 +39,7 @@ spec:
|
|||||||
template:
|
template:
|
||||||
metadata:
|
metadata:
|
||||||
annotations:
|
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/builder-type: {{ $.Values.global.image.type }}
|
||||||
dokku.com/managed: "true"
|
dokku.com/managed: "true"
|
||||||
kubectl.kubernetes.io/default-container: {{ $.Values.global.app_name }}-{{ $processName }}
|
kubectl.kubernetes.io/default-container: {{ $.Values.global.app_name }}-{{ $processName }}
|
||||||
@@ -64,7 +64,7 @@ spec:
|
|||||||
{{- end }}
|
{{- end }}
|
||||||
envFrom:
|
envFrom:
|
||||||
- secretRef:
|
- secretRef:
|
||||||
name: env-{{ $.Values.global.app_name }}.{{ $.Values.global.deploment_id }}
|
name: env-{{ $.Values.global.app_name }}.{{ $.Values.global.deployment_id }}
|
||||||
optional: true
|
optional: true
|
||||||
image: {{ $.Values.global.image.name }}
|
image: {{ $.Values.global.image.name }}
|
||||||
imagePullPolicy: Always
|
imagePullPolicy: Always
|
||||||
|
|||||||
@@ -4,15 +4,15 @@ apiVersion: v1
|
|||||||
kind: Secret
|
kind: Secret
|
||||||
metadata:
|
metadata:
|
||||||
annotations:
|
annotations:
|
||||||
app.kubernetes.io/version: {{ $.Values.global.deploment_id | quote }}
|
app.kubernetes.io/version: {{ $.Values.global.deployment_id | quote }}
|
||||||
dokku.com/managed: "true"
|
dokku.com/managed: "true"
|
||||||
{{ include "print.annotations" (dict "config" $.Values.global "key" "secret") | indent 4 }}
|
{{ include "print.annotations" (dict "config" $.Values.global "key" "secret") | indent 4 }}
|
||||||
labels:
|
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/name: ims-{{ $.Values.global.app_name }}
|
||||||
app.kubernetes.io/part-of: {{ $.Values.global.app_name }}
|
app.kubernetes.io/part-of: {{ $.Values.global.app_name }}
|
||||||
{{ include "print.labels" (dict "config" $.Values.global "key" "secret") | indent 4 }}
|
{{ 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 }}
|
namespace: {{ $.Values.global.namespace }}
|
||||||
data:
|
data:
|
||||||
.dockerconfigjson: "{{ $.Values.global.image.pull_secret_base64 }}"
|
.dockerconfigjson: "{{ $.Values.global.image.pull_secret_base64 }}"
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ apiVersion: keda.sh/v1alpha1
|
|||||||
kind: ScaledObject
|
kind: ScaledObject
|
||||||
metadata:
|
metadata:
|
||||||
annotations:
|
annotations:
|
||||||
app.kubernetes.io/version: {{ $.Values.global.deploment_id | quote }}
|
app.kubernetes.io/version: {{ $.Values.global.deployment_id | quote }}
|
||||||
dokku.com/managed: "true"
|
dokku.com/managed: "true"
|
||||||
{{ include "print.annotations" (dict "config" $.Values.global "key" "keda_scaled_object") | indent 4 }}
|
{{ 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 }}
|
{{ include "print.annotations" (dict "config" $config "key" "keda_scaled_object") | indent 4 }}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ apiVersion: v1
|
|||||||
kind: Secret
|
kind: Secret
|
||||||
metadata:
|
metadata:
|
||||||
annotations:
|
annotations:
|
||||||
app.kubernetes.io/version: {{ $.Values.global.deploment_id | quote }}
|
app.kubernetes.io/version: {{ $.Values.global.deployment_id | quote }}
|
||||||
dokku.com/managed: "true"
|
dokku.com/managed: "true"
|
||||||
{{ include "print.annotations" (dict "config" $.Values.global "key" "keda_secret") | indent 4 }}
|
{{ include "print.annotations" (dict "config" $.Values.global "key" "keda_secret") | indent 4 }}
|
||||||
labels:
|
labels:
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ apiVersion: keda.sh/v1alpha1
|
|||||||
kind: TriggerAuthentication
|
kind: TriggerAuthentication
|
||||||
metadata:
|
metadata:
|
||||||
annotations:
|
annotations:
|
||||||
app.kubernetes.io/version: {{ $.Values.global.deploment_id | quote }}
|
app.kubernetes.io/version: {{ $.Values.global.deployment_id | quote }}
|
||||||
dokku.com/managed: "true"
|
dokku.com/managed: "true"
|
||||||
{{- if and $.Values.global.annotations $.Values.global.annotations.keda_trigger_authentication }}
|
{{- if and $.Values.global.annotations $.Values.global.annotations.keda_trigger_authentication }}
|
||||||
{{- range $k, $v := $.Values.global.annotations.keda_trigger_authentication }}
|
{{- range $k, $v := $.Values.global.annotations.keda_trigger_authentication }}
|
||||||
|
|||||||
@@ -3,15 +3,15 @@ apiVersion: v1
|
|||||||
kind: Secret
|
kind: Secret
|
||||||
metadata:
|
metadata:
|
||||||
annotations:
|
annotations:
|
||||||
app.kubernetes.io/version: {{ $.Values.global.deploment_id | quote }}
|
app.kubernetes.io/version: {{ $.Values.global.deployment_id | quote }}
|
||||||
dokku.com/managed: "true"
|
dokku.com/managed: "true"
|
||||||
{{ include "print.annotations" (dict "config" $.Values.global "key" "secret") | indent 4 }}
|
{{ include "print.annotations" (dict "config" $.Values.global "key" "secret") | indent 4 }}
|
||||||
labels:
|
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/name: env-{{ $.Values.global.app_name }}
|
||||||
app.kubernetes.io/part-of: {{ $.Values.global.app_name }}
|
app.kubernetes.io/part-of: {{ $.Values.global.app_name }}
|
||||||
{{ include "print.labels" (dict "config" $.Values.global "key" "secret") | indent 4 }}
|
{{ 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 }}
|
namespace: {{ $.Values.global.namespace }}
|
||||||
{{- with .Values.global.secrets }}
|
{{- with .Values.global.secrets }}
|
||||||
data:
|
data:
|
||||||
|
|||||||
@@ -1085,7 +1085,12 @@ func TriggerSchedulerRun(scheduler string, appName string, envCount int, args []
|
|||||||
return fmt.Errorf("Error getting helm values: %w", err)
|
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 {
|
if !ok {
|
||||||
return fmt.Errorf("Deployment ID is not a string")
|
return fmt.Errorf("Deployment ID is not a string")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -148,6 +148,18 @@ teardown_() {
|
|||||||
echo "status: $status"
|
echo "status: $status"
|
||||||
assert_success
|
assert_success
|
||||||
assert_output "512Mi"
|
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" {
|
@test "(scheduler-k3s) deploy nginx" {
|
||||||
|
|||||||
Reference in New Issue
Block a user