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

Custom ImagePullPolicy and ImagePullSecrets #1771

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,4 @@ import.log
### Kubernetes ###
kubeconfig
bin
temp
13 changes: 10 additions & 3 deletions apis/v1/jaeger_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,13 @@ type JaegerCommonSpec struct {

// +optional
ServiceAccount string `json:"serviceAccount,omitempty"`

// +optional
ImagePullPolicy v1.PullPolicy `json:"imagePullPolicy,omitempty"`

// +optional
// +listType=atomic
ImagePullSecrets []v1.LocalObjectReference `json:"imagePullSecrets,omitempty"`
}

// JaegerQuerySpec defines the options to be used when deploying the query
Expand Down Expand Up @@ -451,9 +458,9 @@ type JaegerAgentSpec struct {
// +optional
Image string `json:"image,omitempty"`

// +optional
// +listType=atomic
ImagePullSecrets []v1.LocalObjectReference `json:"imagePullSecrets,omitempty"`
// // +optional
// // +listType=atomic
// ImagePullSecrets []v1.LocalObjectReference `json:"imagePullSecrets,omitempty"`

// +optional
// +kubebuilder:pruning:PreserveUnknownFields
Expand Down
11 changes: 5 additions & 6 deletions apis/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

92 changes: 92 additions & 0 deletions config/crd/bases/jaegertracing.io_jaegers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,8 @@ spec:
type: boolean
image:
type: string
imagePullPolicy:
type: string
imagePullSecrets:
items:
properties:
Expand Down Expand Up @@ -2026,6 +2028,16 @@ spec:
x-kubernetes-preserve-unknown-fields: true
image:
type: string
imagePullPolicy:
type: string
imagePullSecrets:
items:
properties:
name:
type: string
type: object
type: array
x-kubernetes-list-type: atomic
labels:
additionalProperties:
type: string
Expand Down Expand Up @@ -3235,6 +3247,16 @@ spec:
x-kubernetes-preserve-unknown-fields: true
image:
type: string
imagePullPolicy:
type: string
imagePullSecrets:
items:
properties:
name:
type: string
type: object
type: array
x-kubernetes-list-type: atomic
labels:
additionalProperties:
type: string
Expand Down Expand Up @@ -4082,6 +4104,16 @@ spec:
type: array
x-kubernetes-list-type: atomic
type: object
imagePullPolicy:
type: string
imagePullSecrets:
items:
properties:
name:
type: string
type: object
type: array
x-kubernetes-list-type: atomic
ingester:
properties:
affinity:
Expand Down Expand Up @@ -4450,6 +4482,16 @@ spec:
x-kubernetes-preserve-unknown-fields: true
image:
type: string
imagePullPolicy:
type: string
imagePullSecrets:
items:
properties:
name:
type: string
type: object
type: array
x-kubernetes-list-type: atomic
labels:
additionalProperties:
type: string
Expand Down Expand Up @@ -5661,6 +5703,16 @@ spec:
type: string
type: array
x-kubernetes-list-type: atomic
imagePullPolicy:
type: string
imagePullSecrets:
items:
properties:
name:
type: string
type: object
type: array
x-kubernetes-list-type: atomic
ingressClassName:
type: string
labels:
Expand Down Expand Up @@ -6877,6 +6929,16 @@ spec:
type: integer
image:
type: string
imagePullPolicy:
type: string
imagePullSecrets:
items:
properties:
name:
type: string
type: object
type: array
x-kubernetes-list-type: atomic
labels:
additionalProperties:
type: string
Expand Down Expand Up @@ -8563,6 +8625,16 @@ spec:
type: boolean
image:
type: string
imagePullPolicy:
type: string
imagePullSecrets:
items:
properties:
name:
type: string
type: object
type: array
x-kubernetes-list-type: atomic
javaOpts:
type: string
labels:
Expand Down Expand Up @@ -9826,6 +9898,16 @@ spec:
type: boolean
image:
type: string
imagePullPolicy:
type: string
imagePullSecrets:
items:
properties:
name:
type: string
type: object
type: array
x-kubernetes-list-type: atomic
labels:
additionalProperties:
type: string
Expand Down Expand Up @@ -11017,6 +11099,16 @@ spec:
type: string
image:
type: string
imagePullPolicy:
type: string
imagePullSecrets:
items:
properties:
name:
type: string
type: object
type: array
x-kubernetes-list-type: atomic
labels:
additionalProperties:
type: string
Expand Down
16 changes: 9 additions & 7 deletions pkg/cronjob/es_index_cleaner.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,14 @@ func CreateEsIndexCleaner(jaeger *v1.Jaeger) *batchv1beta1.CronJob {
Spec: corev1.PodSpec{
Containers: []corev1.Container{
{
Name: util.Truncate(name, 63),
Image: util.ImageName(jaeger.Spec.Storage.EsIndexCleaner.Image, "jaeger-es-index-cleaner-image"),
Args: []string{strconv.Itoa(*jaeger.Spec.Storage.EsIndexCleaner.NumberOfDays), esUrls},
Env: util.RemoveEmptyVars(envs),
EnvFrom: envFromSource,
Resources: commonSpec.Resources,
VolumeMounts: commonSpec.VolumeMounts,
Name: util.Truncate(name, 63),
Image: util.ImageName(jaeger.Spec.Storage.EsIndexCleaner.Image, "jaeger-es-index-cleaner-image"),
Args: []string{strconv.Itoa(*jaeger.Spec.Storage.EsIndexCleaner.NumberOfDays), esUrls},
Env: util.RemoveEmptyVars(envs),
EnvFrom: envFromSource,
Resources: commonSpec.Resources,
VolumeMounts: commonSpec.VolumeMounts,
ImagePullPolicy: commonSpec.ImagePullPolicy,
},
},
RestartPolicy: corev1.RestartPolicyNever,
Expand All @@ -88,6 +89,7 @@ func CreateEsIndexCleaner(jaeger *v1.Jaeger) *batchv1beta1.CronJob {
SecurityContext: commonSpec.SecurityContext,
ServiceAccountName: account.JaegerServiceAccountFor(jaeger, account.EsIndexCleanerComponent),
Volumes: commonSpec.Volumes,
ImagePullSecrets: commonSpec.ImagePullSecrets,
},
ObjectMeta: metav1.ObjectMeta{
Labels: commonSpec.Labels,
Expand Down
16 changes: 9 additions & 7 deletions pkg/cronjob/es_rollover.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,17 @@ func createTemplate(name, action string, jaeger *v1.Jaeger, envs []corev1.EnvVar
Volumes: commonSpec.Volumes,
Containers: []corev1.Container{
{
Name: name,
Image: util.ImageName(jaeger.Spec.Storage.EsRollover.Image, "jaeger-es-rollover-image"),
Args: []string{action, util.GetEsHostname(jaeger.Spec.Storage.Options.Map())},
Env: util.RemoveEmptyVars(envs),
EnvFrom: envFromSource,
Resources: commonSpec.Resources,
VolumeMounts: commonSpec.VolumeMounts,
Name: name,
Image: util.ImageName(jaeger.Spec.Storage.EsRollover.Image, "jaeger-es-rollover-image"),
Args: []string{action, util.GetEsHostname(jaeger.Spec.Storage.Options.Map())},
Env: util.RemoveEmptyVars(envs),
EnvFrom: envFromSource,
Resources: commonSpec.Resources,
VolumeMounts: commonSpec.VolumeMounts,
ImagePullPolicy: commonSpec.ImagePullPolicy,
},
},
ImagePullSecrets: commonSpec.ImagePullSecrets,
},
}
}
Expand Down
10 changes: 6 additions & 4 deletions pkg/cronjob/spark_dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,11 @@ func CreateSparkDependencies(jaeger *v1.Jaeger) *batchv1beta1.CronJob {
Image: image,
Name: name,
// let spark job use its default values
Env: util.RemoveEmptyVars(envVars),
EnvFrom: envFromSource,
Resources: commonSpec.Resources,
VolumeMounts: jaeger.Spec.Storage.Dependencies.JaegerCommonSpec.VolumeMounts,
Env: util.RemoveEmptyVars(envVars),
EnvFrom: envFromSource,
Resources: commonSpec.Resources,
VolumeMounts: jaeger.Spec.Storage.Dependencies.JaegerCommonSpec.VolumeMounts,
ImagePullPolicy: commonSpec.ImagePullPolicy,
},
},
RestartPolicy: corev1.RestartPolicyNever,
Expand All @@ -106,6 +107,7 @@ func CreateSparkDependencies(jaeger *v1.Jaeger) *batchv1beta1.CronJob {
SecurityContext: commonSpec.SecurityContext,
ServiceAccountName: account.JaegerServiceAccountFor(jaeger, account.DependenciesComponent),
Volumes: jaeger.Spec.Storage.Dependencies.JaegerCommonSpec.Volumes,
ImagePullSecrets: commonSpec.ImagePullSecrets,
},
ObjectMeta: metav1.ObjectMeta{
Labels: commonSpec.Labels,
Expand Down
6 changes: 4 additions & 2 deletions pkg/deployment/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,9 @@ func (a *Agent) Get() *appsv1.DaemonSet {
},
InitialDelaySeconds: 1,
},
Resources: commonSpec.Resources,
VolumeMounts: commonSpec.VolumeMounts,
Resources: commonSpec.Resources,
VolumeMounts: commonSpec.VolumeMounts,
ImagePullPolicy: commonSpec.ImagePullPolicy,
}},
DNSPolicy: dnsPolicy,
HostNetwork: hostNetwork,
Expand All @@ -186,6 +187,7 @@ func (a *Agent) Get() *appsv1.DaemonSet {
SecurityContext: commonSpec.SecurityContext,
ServiceAccountName: account.JaegerServiceAccountFor(a.jaeger, account.AgentComponent),
EnableServiceLinks: &falseVar,
ImagePullSecrets: commonSpec.ImagePullSecrets,
},
},
},
Expand Down
4 changes: 3 additions & 1 deletion pkg/deployment/all_in_one.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@ func (a *AllInOne) Get() *appsv1.Deployment {
},
InitialDelaySeconds: 1,
},
Resources: commonSpec.Resources,
Resources: commonSpec.Resources,
ImagePullPolicy: commonSpec.ImagePullPolicy,
}},
Volumes: commonSpec.Volumes,
ServiceAccountName: account.JaegerServiceAccountFor(a.jaeger, account.AllInOneComponent),
Expand All @@ -233,6 +234,7 @@ func (a *AllInOne) Get() *appsv1.Deployment {
SecurityContext: commonSpec.SecurityContext,
EnableServiceLinks: &falseVar,
InitContainers: storage.GetGRPCPluginInitContainers(a.jaeger, commonSpec),
ImagePullSecrets: commonSpec.ImagePullSecrets,
},
},
},
Expand Down
2 changes: 2 additions & 0 deletions pkg/deployment/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ func (c *Collector) Get() *appsv1.Deployment {
InitialDelaySeconds: 1,
},
Resources: commonSpec.Resources,
ImagePullPolicy: commonSpec.ImagePullPolicy,
}},
PriorityClassName: priorityClassName,
Volumes: commonSpec.Volumes,
Expand All @@ -197,6 +198,7 @@ func (c *Collector) Get() *appsv1.Deployment {
SecurityContext: commonSpec.SecurityContext,
EnableServiceLinks: &falseVar,
InitContainers: storage.GetGRPCPluginInitContainers(c.jaeger, commonSpec),
ImagePullSecrets: commonSpec.ImagePullSecrets,
},
},
},
Expand Down
2 changes: 2 additions & 0 deletions pkg/deployment/ingester.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ func (i *Ingester) Get() *appsv1.Deployment {
InitialDelaySeconds: 1,
},
Resources: commonSpec.Resources,
ImagePullPolicy: commonSpec.ImagePullPolicy,
}},
Volumes: commonSpec.Volumes,
ServiceAccountName: account.JaegerServiceAccountFor(i.jaeger, account.IngesterComponent),
Expand All @@ -164,6 +165,7 @@ func (i *Ingester) Get() *appsv1.Deployment {
SecurityContext: commonSpec.SecurityContext,
EnableServiceLinks: &falseVar,
InitContainers: storage.GetGRPCPluginInitContainers(i.jaeger, commonSpec),
ImagePullSecrets: commonSpec.ImagePullSecrets,
},
},
},
Expand Down
4 changes: 3 additions & 1 deletion pkg/deployment/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ func (q *Query) Get() *appsv1.Deployment {
},
InitialDelaySeconds: 1,
},
Resources: commonSpec.Resources,
Resources: commonSpec.Resources,
ImagePullPolicy: commonSpec.ImagePullPolicy,
}},
PriorityClassName: priorityClassName,
Volumes: commonSpec.Volumes,
Expand All @@ -185,6 +186,7 @@ func (q *Query) Get() *appsv1.Deployment {
SecurityContext: commonSpec.SecurityContext,
EnableServiceLinks: &falseVar,
InitContainers: storage.GetGRPCPluginInitContainers(q.jaeger, commonSpec),
ImagePullSecrets: commonSpec.ImagePullSecrets,
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/inject/sidecar.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ func container(jaeger *v1.Jaeger, dep *appsv1.Deployment, agentIdx int) corev1.C
// see https://github.com/jaegertracing/jaeger-operator/issues/334
sort.Strings(args)

dep.Spec.Template.Spec.ImagePullSecrets = util.RemoveDuplicatedImagePullSecrets(append(dep.Spec.Template.Spec.ImagePullSecrets, jaeger.Spec.Agent.ImagePullSecrets...))
dep.Spec.Template.Spec.ImagePullSecrets = util.RemoveDuplicatedImagePullSecrets(append(dep.Spec.Template.Spec.ImagePullSecrets, jaeger.Spec.Agent.JaegerCommonSpec.ImagePullSecrets...))
dep.Spec.Template.Spec.Volumes = util.RemoveDuplicatedVolumes(append(dep.Spec.Template.Spec.Volumes, volumesAndMountsSpec.Volumes...))
return corev1.Container{
Image: util.ImageName(jaeger.Spec.Agent.Image, "jaeger-agent-image"),
Expand Down
Loading