feat: add initial support for keda authentication
This commit is contained in:
@@ -404,6 +404,18 @@ func getAnnotations(appName string, processType string) (ProcessAnnotations, err
|
||||
}
|
||||
annotations.KedaScalingObjectAnnotations = kedaScalingObjectAnnotations
|
||||
|
||||
kedaSecretAnnotations, err := getAnnotation(appName, processType, "keda_secret")
|
||||
if err != nil {
|
||||
return annotations, err
|
||||
}
|
||||
annotations.KedaSecretAnnotations = kedaSecretAnnotations
|
||||
|
||||
kedaTriggerAuthenticationAnnotations, err := getAnnotation(appName, processType, "keda_trigger_authentication")
|
||||
if err != nil {
|
||||
return annotations, err
|
||||
}
|
||||
annotations.KedaTriggerAuthenticationAnnotations = kedaTriggerAuthenticationAnnotations
|
||||
|
||||
podAnnotations, err := getAnnotation(appName, processType, "pod")
|
||||
if err != nil {
|
||||
return annotations, err
|
||||
|
||||
@@ -70,18 +70,20 @@ type ProcessValues struct {
|
||||
}
|
||||
|
||||
type ProcessAnnotations struct {
|
||||
CertificateAnnotations map[string]string `yaml:"certificate,omitempty"`
|
||||
CronJobAnnotations map[string]string `yaml:"cronjob,omitempty"`
|
||||
DeploymentAnnotations map[string]string `yaml:"deployment,omitempty"`
|
||||
IngressAnnotations map[string]string `yaml:"ingress,omitempty"`
|
||||
JobAnnotations map[string]string `yaml:"job,omitempty"`
|
||||
KedaScalingObjectAnnotations map[string]string `yaml:"keda_scaled_object,omitempty"`
|
||||
PodAnnotations map[string]string `yaml:"pod,omitempty"`
|
||||
SecretAnnotations map[string]string `yaml:"secret,omitempty"`
|
||||
ServiceAccountAnnotations map[string]string `yaml:"serviceaccount,omitempty"`
|
||||
ServiceAnnotations map[string]string `yaml:"service,omitempty"`
|
||||
TraefikIngressRouteAnnotations map[string]string `yaml:"traefik_ingressroute,omitempty"`
|
||||
TraefikMiddlewareAnnotations map[string]string `yaml:"traefik_middleware,omitempty"`
|
||||
CertificateAnnotations map[string]string `yaml:"certificate,omitempty"`
|
||||
CronJobAnnotations map[string]string `yaml:"cronjob,omitempty"`
|
||||
DeploymentAnnotations map[string]string `yaml:"deployment,omitempty"`
|
||||
IngressAnnotations map[string]string `yaml:"ingress,omitempty"`
|
||||
JobAnnotations map[string]string `yaml:"job,omitempty"`
|
||||
KedaScalingObjectAnnotations map[string]string `yaml:"keda_scaled_object,omitempty"`
|
||||
KedaSecretAnnotations map[string]string `yaml:"keda_secret,omitempty"`
|
||||
KedaTriggerAuthenticationAnnotations map[string]string `yaml:"keda_trigger_authentication,omitempty"`
|
||||
PodAnnotations map[string]string `yaml:"pod,omitempty"`
|
||||
SecretAnnotations map[string]string `yaml:"secret,omitempty"`
|
||||
ServiceAccountAnnotations map[string]string `yaml:"serviceaccount,omitempty"`
|
||||
ServiceAnnotations map[string]string `yaml:"service,omitempty"`
|
||||
TraefikIngressRouteAnnotations map[string]string `yaml:"traefik_ingressroute,omitempty"`
|
||||
TraefikMiddlewareAnnotations map[string]string `yaml:"traefik_middleware,omitempty"`
|
||||
}
|
||||
|
||||
// ProcessAutoscaling contains the autoscaling configuration for a process
|
||||
|
||||
@@ -7,9 +7,7 @@ kind: ScaledObject
|
||||
metadata:
|
||||
annotations:
|
||||
app.kubernetes.io/version: {{ $.Values.global.deploment_id | quote }}
|
||||
dokku.com/builder-type: {{ $.Values.global.image.type }}
|
||||
dokku.com/managed: "true"
|
||||
kubectl.kubernetes.io/default-container: {{ $.Values.global.app_name }}-{{ $processName }}
|
||||
{{- if and $.Values.global.annotations $.Values.global.annotations.keda_scaled_object }}
|
||||
{{- range $k, $v := $.Values.global.annotations.keda_scaled_object }}
|
||||
{{ $k }}: {{ $v | quote }}
|
||||
@@ -21,7 +19,7 @@ metadata:
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
labels:
|
||||
app.kubernetes.io/instance: {{ $.Values.global.app_name }}-{{ $processName }}-scaled-object
|
||||
app.kubernetes.io/instance: {{ $.Values.global.app_name }}-{{ $processName }}
|
||||
app.kubernetes.io/name: {{ $processName }}
|
||||
app.kubernetes.io/part-of: {{ $.Values.global.app_name }}
|
||||
name: {{ $.Values.global.app_name}}-{{ $processName }}
|
||||
@@ -40,6 +38,8 @@ spec:
|
||||
failureThreshold: 3
|
||||
replicas: {{ $config.replicas }}
|
||||
triggers:
|
||||
{{- toYaml $config.autoscaling.triggers | nindent 4 }}
|
||||
{{- with $config.autoscaling.triggers }}
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
32
plugins/scheduler-k3s/templates/chart/keda-secret.yaml
Normal file
32
plugins/scheduler-k3s/templates/chart/keda-secret.yaml
Normal file
@@ -0,0 +1,32 @@
|
||||
{{- if .Capabilities.APIVersions.Has "keda.sh/v1alpha1" -}}
|
||||
{{- range $type, $config := .Values.global.keda.auth }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
annotations:
|
||||
app.kubernetes.io/version: {{ $.Values.global.deploment_id | quote }}
|
||||
dokku.com/managed: "true"
|
||||
{{- if and $.Values.global.annotations $.Values.global.annotations.keda_secret }}
|
||||
{{- range $k, $v := $.Values.global.annotations.keda_secret }}
|
||||
{{ $k }}: {{ $v | quote }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if and $config.annotations $config.annotations.keda_secret }}
|
||||
{{- range $k, $v := $config.annotations.keda_secret }}
|
||||
{{ $k }}: {{ $v | quote }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
labels:
|
||||
app.kubernetes.io/instance: {{ $.Values.global.app_name }}-trigger-auth-secret
|
||||
app.kubernetes.io/name: {{ $type }}
|
||||
app.kubernetes.io/part-of: {{ $.Values.global.app_name }}
|
||||
name: app-auth-{{ $type }}
|
||||
namespace: {{ $.Values.global.namespace }}
|
||||
data:
|
||||
{{- with $config.secrets }}
|
||||
data:
|
||||
{{- toYaml . | nindent 2 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,34 @@
|
||||
{{- if .Capabilities.APIVersions.Has "keda.sh/v1alpha1" -}}
|
||||
{{- range $type, $config := .Values.global.keda.auth }}
|
||||
---
|
||||
apiVersion: keda.sh/v1alpha1
|
||||
kind: TriggerAuthentication
|
||||
metadata:
|
||||
annotations:
|
||||
app.kubernetes.io/version: {{ $.Values.global.deploment_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 }}
|
||||
{{ $k }}: {{ $v | quote }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if and $config.annotations $config.annotations.keda_trigger_authentication }}
|
||||
{{- range $k, $v := $config.annotations.keda_trigger_authentication }}
|
||||
{{ $k }}: {{ $v | quote }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
labels:
|
||||
app.kubernetes.io/instance: {{ $.Values.global.app_name }}-{{ $type }}
|
||||
app.kubernetes.io/name: {{ $type }}
|
||||
app.kubernetes.io/part-of: {{ $.Values.global.app_name }}
|
||||
name: {{ $.Values.global.app_name }}-{{ $type }}
|
||||
namespace: {{ $.Values.global.namespace }}
|
||||
spec:
|
||||
secretTargetRef:
|
||||
{{- range $key := $config.secrets }}
|
||||
- parameter: {{ $key }}
|
||||
name: app-auth-{{ $type }}
|
||||
key: {{ $key }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
@@ -399,7 +399,7 @@ func TriggerSchedulerDeploy(scheduler string, appName string, imageTag string) e
|
||||
|
||||
values.Processes[processType] = processValues
|
||||
|
||||
templateFiles := []string{"deployment", "scaled-object"}
|
||||
templateFiles := []string{"deployment", "keda-scaled-object"}
|
||||
if processType == "web" {
|
||||
templateFiles = append(templateFiles, "service", "certificate", "ingress", "ingress-route", "https-redirect-middleware")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user