Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…rator into otel-allocator
  • Loading branch information
alexperez52 committed Aug 27, 2021
2 parents 902a212 + 036d678 commit f450e17
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 0 deletions.
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 @@ -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)
}

0 comments on commit f450e17

Please sign in to comment.