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

added feature to provide imagePullSecrets and imagePullPolicy to runn… #791

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -14,6 +14,14 @@ data:
{{- if .Values.controllerManager.runnerImages }}
runnerImages:
{{ toYaml .Values.controllerManager.runnerImages | indent 6 }}
{{- end }}
{{- if .Values.controllerManager.runnerImagePullSecrets }}
runnerImagePullSecrets:
{{ toYaml .Values.controllerManager.runnerImagePullSecrets | indent 6 }}
{{- end }}
{{- if .Values.controllerManager.runnerImagePullPolicy }}
runnerImagePullPolicy:
{{ toYaml .Values.controllerManager.runnerImagePullPolicy | indent 6 }}
{{- end }}
{{- if .Values.controllerManager.resourceLabels }}
resourceLabels:
24 changes: 24 additions & 0 deletions controllers/spec/common.go
Original file line number Diff line number Diff line change
@@ -1923,6 +1923,14 @@ func generateAnnotations(customAnnotations ...map[string]string) map[string]stri
return annotations
}

func getFunctionRunnerImagePullSecret() []map[string]string {
return Configs.RunnerImagePullSecrets
}

func getFunctionRunnerImagePullPolicy() corev1.PullPolicy {
return Configs.RunnerImagePullPolicy
}

func getFunctionRunnerImage(spec *v1alpha1.FunctionSpec) string {
runtime := &spec.Runtime
img := spec.Image
@@ -1940,6 +1948,14 @@ func getFunctionRunnerImage(spec *v1alpha1.FunctionSpec) string {
return DefaultRunnerImage
}

func getSinkRunnerImagePullSecret() []map[string]string {
return Configs.RunnerImagePullSecrets
}

func getSinkRunnerImagePullPolicy() corev1.PullPolicy {
return Configs.RunnerImagePullPolicy
}

func getSinkRunnerImage(spec *v1alpha1.SinkSpec) string {
img := spec.Image
if img != "" {
@@ -1952,6 +1968,14 @@ func getSinkRunnerImage(spec *v1alpha1.SinkSpec) string {
return DefaultRunnerImage
}

func getSourceRunnerImagePullSecret() []map[string]string {
return Configs.RunnerImagePullSecrets
}

func getSourceRunnerImagePullPolicy() corev1.PullPolicy {
return Configs.RunnerImagePullPolicy
}

func getSourceRunnerImage(spec *v1alpha1.SourceSpec) string {
img := spec.Image
if img != "" {
9 changes: 6 additions & 3 deletions controllers/spec/controller_configs.go
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@ package spec
import (
"os"

corev1 "k8s.io/api/core/v1"
"sigs.k8s.io/yaml"
)

@@ -31,9 +32,11 @@ type RunnerImages struct {
}

type ControllerConfigs struct {
RunnerImages RunnerImages `yaml:"runnerImages,omitempty"`
ResourceLabels map[string]string `yaml:"resourceLabels,omitempty"`
ResourceAnnotations map[string]string `yaml:"resourceAnnotations,omitempty"`
RunnerImages RunnerImages `yaml:"runnerImages,omitempty"`
RunnerImagePullSecrets []map[string]string `yaml:"runnerImagePullSecrets,omitempty"`
RunnerImagePullPolicy corev1.PullPolicy `yaml:"imagePullPolicy,omitempty"`
ResourceLabels map[string]string `yaml:"resourceLabels,omitempty"`
ResourceAnnotations map[string]string `yaml:"resourceAnnotations,omitempty"`
}

var Configs = DefaultConfigs()
10 changes: 10 additions & 0 deletions controllers/spec/function.go
Original file line number Diff line number Diff line change
@@ -54,6 +54,16 @@ func MakeFunctionService(function *v1alpha1.Function) *corev1.Service {

func MakeFunctionStatefulSet(ctx context.Context, cli client.Client, function *v1alpha1.Function) (*appsv1.StatefulSet, error) {
objectMeta := MakeFunctionObjectMeta(function)

runnerImagePullSecrets := getFunctionRunnerImagePullSecret()
for _, mapSecret := range runnerImagePullSecrets {
if value, ok := mapSecret["name"]; ok {
function.Spec.Pod.ImagePullSecrets = append(function.Spec.Pod.ImagePullSecrets, corev1.LocalObjectReference{Name: value})
}
}
runnerImagePullPolicy := getFunctionRunnerImagePullPolicy()
function.Spec.ImagePullPolicy = runnerImagePullPolicy

labels := makeFunctionLabels(function)
statefulSet := MakeStatefulSet(objectMeta, function.Spec.Replicas, function.Spec.DownloaderImage,
makeFunctionContainer(function), makeFunctionVolumes(function, function.Spec.Pulsar.AuthConfig), labels, function.Spec.Pod,
10 changes: 10 additions & 0 deletions controllers/spec/sink.go
Original file line number Diff line number Diff line change
@@ -51,6 +51,16 @@ func MakeSinkService(sink *v1alpha1.Sink) *corev1.Service {

func MakeSinkStatefulSet(ctx context.Context, cli client.Client, sink *v1alpha1.Sink) (*appsv1.StatefulSet, error) {
objectMeta := MakeSinkObjectMeta(sink)

runnerImagePullSecrets := getSinkRunnerImagePullSecret()
for _, mapSecret := range runnerImagePullSecrets {
if value, ok := mapSecret["name"]; ok {
sink.Spec.Pod.ImagePullSecrets = append(sink.Spec.Pod.ImagePullSecrets, corev1.LocalObjectReference{Name: value})
}
}
runnerImagePullPolicy := getSinkRunnerImagePullPolicy()
sink.Spec.ImagePullPolicy = runnerImagePullPolicy

statefulSet := MakeStatefulSet(objectMeta, sink.Spec.Replicas, sink.Spec.DownloaderImage, makeSinkContainer(sink),
makeSinkVolumes(sink, sink.Spec.Pulsar.AuthConfig), makeSinkLabels(sink), sink.Spec.Pod, sink.Spec.Pulsar.AuthConfig,
sink.Spec.Pulsar.TLSConfig, sink.Spec.Pulsar.PulsarConfig, sink.Spec.Pulsar.AuthSecret, sink.Spec.Pulsar.TLSSecret,
10 changes: 10 additions & 0 deletions controllers/spec/source.go
Original file line number Diff line number Diff line change
@@ -52,6 +52,16 @@ func MakeSourceService(source *v1alpha1.Source) *corev1.Service {

func MakeSourceStatefulSet(ctx context.Context, cli client.Client, source *v1alpha1.Source) (*appsv1.StatefulSet, error) {
objectMeta := MakeSourceObjectMeta(source)

runnerImagePullSecrets := getSourceRunnerImagePullSecret()
for _, mapSecret := range runnerImagePullSecrets {
if value, ok := mapSecret["name"]; ok {
source.Spec.Pod.ImagePullSecrets = append(source.Spec.Pod.ImagePullSecrets, corev1.LocalObjectReference{Name: value})
}
}
runnerImagePullPolicy := getSourceRunnerImagePullPolicy()
source.Spec.ImagePullPolicy = runnerImagePullPolicy

statefulSet := MakeStatefulSet(objectMeta, source.Spec.Replicas, source.Spec.DownloaderImage, makeSourceContainer(source),
makeSourceVolumes(source, source.Spec.Pulsar.AuthConfig), makeSourceLabels(source), source.Spec.Pod, source.Spec.Pulsar.AuthConfig,
source.Spec.Pulsar.TLSConfig, source.Spec.Pulsar.PulsarConfig, source.Spec.Pulsar.AuthSecret, source.Spec.Pulsar.TLSSecret,