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 imagePullPolicy option to CRD #413

Merged
Merged
Show file tree
Hide file tree
Changes from 3 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
5 changes: 5 additions & 0 deletions api/v1alpha1/opentelemetrycollector_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ type OpenTelemetryCollectorSpec struct {
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true
Replicas *int32 `json:"replicas,omitempty"`

// ImagePullPolicy indicates the pull policy to be used for retrieving the container image (Always, Never, IfNotPresent)
// +optional
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true
ImagePullPolicy v1.PullPolicy `json:"imagePullPolicy,omitempty"`

// Image indicates the container image to use for the OpenTelemetry Collector.
// +optional
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ metadata:
operators.operatorframework.io/project_layout: go.kubebuilder.io/v2
repository: github.com/open-telemetry/opentelemetry-operator
support: OpenTelemetry Community
name: opentelemetry-operator.v0.33.0
name: opentelemetry-operator.v0.33.0-5-g3efd850
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes to this file should be reverted.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've reverted the changes, but they were made by the make bundle command. I hope this does not affect CI.

namespace: placeholder
spec:
apiservicedefinitions: {}
Expand Down Expand Up @@ -206,7 +206,7 @@ spec:
- --enable-leader-election
command:
- /manager
image: quay.io/opentelemetry/opentelemetry-operator:v0.33.0
image: controller
name: manager
ports:
- containerPort: 9443
Expand Down Expand Up @@ -298,7 +298,7 @@ spec:
maturity: alpha
provider:
name: OpenTelemetry Community
version: 0.33.0
version: 0.33.0-5-g3efd850
webhookdefinitions:
- admissionReviewVersions:
- v1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@ spec:
description: Image indicates the container image to use for the OpenTelemetry
Collector.
type: string
imagePullPolicy:
description: ImagePullPolicy indicates the pull policy to be used
for retrieving the container image (Always, Never, IfNotPresent)
type: string
mode:
description: Mode represents how the collector should be deployed
(deployment, daemonset, statefulset or sidecar)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ spec:
description: Image indicates the container image to use for the OpenTelemetry
Collector.
type: string
imagePullPolicy:
description: ImagePullPolicy indicates the pull policy to be used
for retrieving the container image (Always, Never, IfNotPresent)
type: string
mode:
description: Mode represents how the collector should be deployed
(deployment, daemonset, statefulset or sidecar)
Expand Down
3 changes: 3 additions & 0 deletions docs/otelcol_cr_spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ spec:

// +optional Image indicates the container image to use for the OpenTelemetry Collector.
image: ""

// +optional ImagePullPolicy indicates what image pull policy to be used to retrieve the container image to use for the OpenTelemetry Collector.
imagePullPolicy: ""

// +optional ServiceAccount indicates the name of an existing service account to use with this instance.
serviceAccount: ""
Expand Down
1 change: 1 addition & 0 deletions pkg/collector/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func Container(cfg config.Config, logger logr.Logger, otelcol v1alpha1.OpenTelem
return corev1.Container{
Name: naming.Container(),
Image: image,
ImagePullPolicy: otelcol.Spec.ImagePullPolicy,
VolumeMounts: volumeMounts,
Args: args,
Env: envVars,
Expand Down
16 changes: 16 additions & 0 deletions pkg/collector/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,3 +222,19 @@ func TestContainerArgs(t *testing.T) {
assert.Contains(t, c.Args, "--metrics-level=detailed")
assert.Contains(t, c.Args, "--log-level=debug")
}

func TestContainerImagePullPolicy(t *testing.T) {
// prepare
otelcol := v1alpha1.OpenTelemetryCollector{
Spec: v1alpha1.OpenTelemetryCollectorSpec{
ImagePullPolicy: corev1.PullIfNotPresent,
},
}
cfg := config.New()

// test
c := Container(cfg, logger, otelcol)

// verify
assert.Equal(t, c.ImagePullPolicy, corev1.PullIfNotPresent)
}