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 Image Pull Policy #1798

Merged
Merged
Show file tree
Hide file tree
Changes from 5 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
3 changes: 3 additions & 0 deletions apis/v1/jaeger_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ type JaegerCommonSpec struct {
// +optional
// +listType=atomic
ImagePullSecrets []v1.LocalObjectReference `json:"imagePullSecrets,omitempty"`

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

// JaegerQuerySpec defines the options to be used when deploying the query
Expand Down
20 changes: 20 additions & 0 deletions bundle/manifests/jaegertracing.io_jaegers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,8 @@ spec:
type: boolean
image:
type: string
imagePullPolicy:
type: string
imagePullSecrets:
items:
properties:
Expand Down Expand Up @@ -2027,6 +2029,8 @@ spec:
x-kubernetes-preserve-unknown-fields: true
image:
type: string
imagePullPolicy:
type: string
imagePullSecrets:
items:
properties:
Expand Down Expand Up @@ -3244,6 +3248,8 @@ spec:
x-kubernetes-preserve-unknown-fields: true
image:
type: string
imagePullPolicy:
type: string
imagePullSecrets:
items:
properties:
Expand Down Expand Up @@ -4099,6 +4105,8 @@ spec:
type: array
x-kubernetes-list-type: atomic
type: object
imagePullPolicy:
type: string
imagePullSecrets:
items:
properties:
Expand Down Expand Up @@ -4475,6 +4483,8 @@ spec:
x-kubernetes-preserve-unknown-fields: true
image:
type: string
imagePullPolicy:
type: string
imagePullSecrets:
items:
properties:
Expand Down Expand Up @@ -5694,6 +5704,8 @@ spec:
type: string
type: array
x-kubernetes-list-type: atomic
imagePullPolicy:
type: string
imagePullSecrets:
items:
properties:
Expand Down Expand Up @@ -6918,6 +6930,8 @@ spec:
type: integer
image:
type: string
imagePullPolicy:
type: string
imagePullSecrets:
items:
properties:
Expand Down Expand Up @@ -8612,6 +8626,8 @@ spec:
type: boolean
image:
type: string
imagePullPolicy:
type: string
imagePullSecrets:
items:
properties:
Expand Down Expand Up @@ -9883,6 +9899,8 @@ spec:
type: boolean
image:
type: string
imagePullPolicy:
type: string
imagePullSecrets:
items:
properties:
Expand Down Expand Up @@ -11082,6 +11100,8 @@ spec:
type: string
image:
type: string
imagePullPolicy:
type: string
imagePullSecrets:
items:
properties:
Expand Down
20 changes: 20 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,8 @@ spec:
x-kubernetes-preserve-unknown-fields: true
image:
type: string
imagePullPolicy:
type: string
imagePullSecrets:
items:
properties:
Expand Down Expand Up @@ -3243,6 +3247,8 @@ spec:
x-kubernetes-preserve-unknown-fields: true
image:
type: string
imagePullPolicy:
type: string
imagePullSecrets:
items:
properties:
Expand Down Expand Up @@ -4098,6 +4104,8 @@ spec:
type: array
x-kubernetes-list-type: atomic
type: object
imagePullPolicy:
type: string
imagePullSecrets:
items:
properties:
Expand Down Expand Up @@ -4474,6 +4482,8 @@ spec:
x-kubernetes-preserve-unknown-fields: true
image:
type: string
imagePullPolicy:
type: string
imagePullSecrets:
items:
properties:
Expand Down Expand Up @@ -5693,6 +5703,8 @@ spec:
type: string
type: array
x-kubernetes-list-type: atomic
imagePullPolicy:
type: string
imagePullSecrets:
items:
properties:
Expand Down Expand Up @@ -6917,6 +6929,8 @@ spec:
type: integer
image:
type: string
imagePullPolicy:
type: string
imagePullSecrets:
items:
properties:
Expand Down Expand Up @@ -8611,6 +8625,8 @@ spec:
type: boolean
image:
type: string
imagePullPolicy:
type: string
imagePullSecrets:
items:
properties:
Expand Down Expand Up @@ -9882,6 +9898,8 @@ spec:
type: boolean
image:
type: string
imagePullPolicy:
type: string
imagePullSecrets:
items:
properties:
Expand Down Expand Up @@ -11081,6 +11099,8 @@ spec:
type: string
image:
type: string
imagePullPolicy:
type: string
imagePullSecrets:
items:
properties:
Expand Down
5 changes: 3 additions & 2 deletions pkg/deployment/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,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 Down
12 changes: 12 additions & 0 deletions pkg/deployment/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,18 @@ func TestAgentImagePullSecrets(t *testing.T) {
assert.Equal(t, pullSecret, dep.Spec.Template.Spec.ImagePullSecrets[0].Name)
}

func TestAgentImagePullPolicy(t *testing.T) {
jaeger := v1.NewJaeger(types.NamespacedName{Name: "TestAgentImagePullPolicy"})
const pullPolicy = corev1.PullPolicy("Always")
jaeger.Spec.Agent.Strategy = "daemonset"
jaeger.Spec.ImagePullPolicy = corev1.PullPolicy("Always")

agent := NewAgent(jaeger)
dep := agent.Get()

assert.Equal(t, pullPolicy, dep.Spec.Template.Spec.Containers[0].ImagePullPolicy)
}

func TestAgentServiceLinks(t *testing.T) {
jaeger := v1.NewJaeger(types.NamespacedName{Name: "my-instance"})
jaeger.Spec.Agent.Strategy = "daemonset"
Expand Down
3 changes: 2 additions & 1 deletion pkg/deployment/all_in_one.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,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 Down
11 changes: 11 additions & 0 deletions pkg/deployment/all_in_one_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,17 @@ func TestAllInOneImagePullSecrets(t *testing.T) {
assert.Equal(t, pullSecret, dep.Spec.Template.Spec.ImagePullSecrets[0].Name)
}

func TestAllInOneImagePullPolicy(t *testing.T) {
jaeger := v1.NewJaeger(types.NamespacedName{Name: "TestAllInOneImagePullPolicy"})
const pullPolicy = corev1.PullPolicy("Always")
jaeger.Spec.ImagePullPolicy = corev1.PullPolicy("Always")

allInOne := NewAllInOne(jaeger)
dep := allInOne.Get()

assert.Equal(t, pullPolicy, dep.Spec.Template.Spec.Containers[0].ImagePullPolicy)
}

func TestAllInOneMountGlobalVolumes(t *testing.T) {
name := "TestAllInOneMountGlobalVolumes"

Expand Down
3 changes: 2 additions & 1 deletion pkg/deployment/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ func (c *Collector) Get() *appsv1.Deployment {
},
InitialDelaySeconds: 1,
},
Resources: commonSpec.Resources,
Resources: commonSpec.Resources,
ImagePullPolicy: commonSpec.ImagePullPolicy,
}},
PriorityClassName: priorityClassName,
Volumes: commonSpec.Volumes,
Expand Down
11 changes: 11 additions & 0 deletions pkg/deployment/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,17 @@ func TestCollectorImagePullSecrets(t *testing.T) {
assert.Equal(t, pullSecret, dep.Spec.Template.Spec.ImagePullSecrets[0].Name)
}

func TestCollectorImagePullPolicy(t *testing.T) {
jaeger := v1.NewJaeger(types.NamespacedName{Name: "TestCollectorImagePullPolicy"})
const pullPolicy = corev1.PullPolicy("Always")
jaeger.Spec.ImagePullPolicy = corev1.PullPolicy("Always")

collector := NewCollector(jaeger)
dep := collector.Get()

assert.Equal(t, pullPolicy, dep.Spec.Template.Spec.Containers[0].ImagePullPolicy)
}

func TestCollectorVolumeMountsWithVolumes(t *testing.T) {
name := "my-instance"

Expand Down
3 changes: 2 additions & 1 deletion pkg/deployment/ingester.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ func (i *Ingester) Get() *appsv1.Deployment {
},
InitialDelaySeconds: 1,
},
Resources: commonSpec.Resources,
Resources: commonSpec.Resources,
ImagePullPolicy: commonSpec.ImagePullPolicy,
}},
Volumes: commonSpec.Volumes,
ServiceAccountName: account.JaegerServiceAccountFor(i.jaeger, account.IngesterComponent),
Expand Down
11 changes: 11 additions & 0 deletions pkg/deployment/ingester_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,17 @@ func TestIngeterImagePullSecrets(t *testing.T) {
assert.Equal(t, pullSecret, dep.Spec.Template.Spec.ImagePullSecrets[0].Name)
}

func TestIngesterImagePullPolicy(t *testing.T) {
jaeger := newIngesterJaeger("TestIngesterImagePullPolicy")
const pullPolicy = corev1.PullPolicy("Always")
jaeger.Spec.ImagePullPolicy = corev1.PullPolicy("Always")

ingester := NewIngester(jaeger)
dep := ingester.Get()

assert.Equal(t, pullPolicy, dep.Spec.Template.Spec.Containers[0].ImagePullPolicy)
}

func TestIngesterVolumeMountsWithVolumes(t *testing.T) {
name := "TestIngesterVolumeMountsWithVolumes"

Expand Down
3 changes: 2 additions & 1 deletion pkg/deployment/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ func (q *Query) Get() *appsv1.Deployment {
},
InitialDelaySeconds: 1,
},
Resources: commonSpec.Resources,
Resources: commonSpec.Resources,
ImagePullPolicy: commonSpec.ImagePullPolicy,
}},
PriorityClassName: priorityClassName,
Volumes: commonSpec.Volumes,
Expand Down
11 changes: 11 additions & 0 deletions pkg/deployment/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,17 @@ func TestQueryImagePullSecrets(t *testing.T) {
assert.Equal(t, pullSecret, dep.Spec.Template.Spec.ImagePullSecrets[0].Name)
}

func TestQueryImagePullPolicy(t *testing.T) {
jaeger := v1.NewJaeger(types.NamespacedName{Name: "TestQueryImagePullPolicy"})
const pullPolicy = corev1.PullPolicy("Always")
jaeger.Spec.ImagePullPolicy = corev1.PullPolicy("Always")

query := NewQuery(jaeger)
dep := query.Get()

assert.Equal(t, pullPolicy, dep.Spec.Template.Spec.Containers[0].ImagePullPolicy)
}

func TestQueryPodName(t *testing.T) {
name := "TestQueryPodName"
query := NewQuery(v1.NewJaeger(types.NamespacedName{Name: name}))
Expand Down
6 changes: 6 additions & 0 deletions pkg/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ func Merge(commonSpecs []v1.JaegerCommonSpec) *v1.JaegerCommonSpec {
var securityContext *corev1.PodSecurityContext
var serviceAccount string
var imagePullSecrets []corev1.LocalObjectReference
var imagePullPolicy corev1.PullPolicy

for _, commonSpec := range commonSpecs {
// Merge annotations
Expand Down Expand Up @@ -115,6 +116,10 @@ func Merge(commonSpecs []v1.JaegerCommonSpec) *v1.JaegerCommonSpec {
for _, ips := range commonSpec.ImagePullSecrets {
imagePullSecrets = append(imagePullSecrets, ips)
}

if imagePullPolicy == corev1.PullPolicy("") {
imagePullPolicy = commonSpec.ImagePullPolicy
}
}

return &v1.JaegerCommonSpec{
Expand All @@ -123,6 +128,7 @@ func Merge(commonSpecs []v1.JaegerCommonSpec) *v1.JaegerCommonSpec {
VolumeMounts: RemoveDuplicatedVolumeMounts(volumeMounts),
Volumes: RemoveDuplicatedVolumes(volumes),
ImagePullSecrets: RemoveDuplicatedImagePullSecrets(imagePullSecrets),
ImagePullPolicy: imagePullPolicy,
Resources: *resources,
Affinity: affinity,
Tolerations: tolerations,
Expand Down
17 changes: 17 additions & 0 deletions pkg/util/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,23 @@ func TestMergeImagePullSecrets(t *testing.T) {
assert.Equal(t, "hij", merged.ImagePullSecrets[3].Name)
}

func TestMergeImagePullPolicy(t *testing.T) {
emptySpec := v1.JaegerCommonSpec{}
generalSpec := v1.JaegerCommonSpec{
ImagePullPolicy: corev1.PullPolicy("Never"),
}
specificSpec := v1.JaegerCommonSpec{
ImagePullPolicy: corev1.PullPolicy("Always"),
}
anotherSpec := v1.JaegerCommonSpec{
ImagePullPolicy: corev1.PullPolicy("IfNotPresent"),
}

merged := Merge([]v1.JaegerCommonSpec{specificSpec, generalSpec, emptySpec, anotherSpec})

assert.Equal(t, corev1.PullPolicy("Always"), merged.ImagePullPolicy)
}

func TestMergeAnnotations(t *testing.T) {
generalSpec := v1.JaegerCommonSpec{
Annotations: map[string]string{
Expand Down