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

Deprecate the init container settings for Reaper #1290

Merged
merged 5 commits into from
Apr 18, 2024
Merged
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
3 changes: 2 additions & 1 deletion CHANGELOG/CHANGELOG-1.15.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ When cutting a new release, update the `unreleased` heading to the tag being gen
* [BUGFIX] [#1253](https://github.com/k8ssandra/k8ssandra-operator/issues/1253) Medusa storage secrets are now labelled with a unique label.
* [FEATURE] [#1260](https://github.com/k8ssandra/k8ssandra-operator/issues/1260) Update controller-gen to version 0.14.0.
* [BUGFIX] [1287](https://github.com/k8ssandra/k8ssandra-operator/pull/1287) Use the same image for Reaper init and main containers
* [ENHANCEMENT] [1288](https://github.com/k8ssandra/k8ssandra-operator/issues/1288) Allow disabling the CRD upgrader
* [ENHANCEMENT] [1288](https://github.com/k8ssandra/k8ssandra-operator/issues/1288) Allow disabling the CRD upgrader
* [CHANGE] Upgrade Reaper to v3.6.0
9 changes: 3 additions & 6 deletions apis/reaper/v1alpha1/reaper_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,14 @@ type ReaperTemplate struct {
SecretsProvider string `json:"secretsProvider,omitempty"`

// The image to use for the Reaper pod main container.
// The default is "thelastpickle/cassandra-reaper:3.5.0".
// The default is "thelastpickle/cassandra-reaper:3.6.0".
// +optional
// TODO: update with real release version.
// +kubebuilder:default={repository:"thelastpickle",name:"cassandra-reaper",tag:"3.5.0"}
// +kubebuilder:default={repository:"thelastpickle",name:"cassandra-reaper",tag:"3.6.0"}
ContainerImage *images.Image `json:"containerImage,omitempty"`

// The image to use for the Reaper pod init container (that performs schema migrations).
// The default is "thelastpickle/cassandra-reaper:3.5.0".
// Deprecated: The main container image will be used for the init container as well.
// +optional
// TODO: update with real release version.
// +kubebuilder:default={repository:"thelastpickle",name:"cassandra-reaper",tag:"3.5.0"}
InitContainerImage *images.Image `json:"initContainerImage,omitempty"`

// +kubebuilder:default="default"
Expand Down
28 changes: 8 additions & 20 deletions charts/k8ssandra-operator/crds/k8ssandra-operator-crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26236,10 +26236,10 @@ spec:
default:
name: cassandra-reaper
repository: thelastpickle
tag: 3.5.0
tag: 3.6.0
description: |-
The image to use for the Reaper pod main container.
The default is "thelastpickle/cassandra-reaper:3.5.0".
The default is "thelastpickle/cassandra-reaper:3.6.0".
TODO: update with real release version.
properties:
name:
Expand Down Expand Up @@ -26320,14 +26320,8 @@ spec:
x-kubernetes-map-type: atomic
type: object
initContainerImage:
default:
name: cassandra-reaper
repository: thelastpickle
tag: 3.5.0
description: |-
The image to use for the Reaper pod init container (that performs schema migrations).
The default is "thelastpickle/cassandra-reaper:3.5.0".
TODO: update with real release version.
description: 'Deprecated: The main container image will be used
for the init container as well.'
properties:
name:
description: The image name to use.
Expand Down Expand Up @@ -31837,10 +31831,10 @@ spec:
default:
name: cassandra-reaper
repository: thelastpickle
tag: 3.5.0
tag: 3.6.0
description: |-
The image to use for the Reaper pod main container.
The default is "thelastpickle/cassandra-reaper:3.5.0".
The default is "thelastpickle/cassandra-reaper:3.6.0".
TODO: update with real release version.
properties:
name:
Expand Down Expand Up @@ -31945,14 +31939,8 @@ spec:
x-kubernetes-map-type: atomic
type: object
initContainerImage:
default:
name: cassandra-reaper
repository: thelastpickle
tag: 3.5.0
description: |-
The image to use for the Reaper pod init container (that performs schema migrations).
The default is "thelastpickle/cassandra-reaper:3.5.0".
TODO: update with real release version.
description: 'Deprecated: The main container image will be used for
the init container as well.'
properties:
name:
description: The image name to use.
Expand Down
14 changes: 4 additions & 10 deletions config/crd/bases/k8ssandra.io_k8ssandraclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26174,10 +26174,10 @@ spec:
default:
name: cassandra-reaper
repository: thelastpickle
tag: 3.5.0
tag: 3.6.0
description: |-
The image to use for the Reaper pod main container.
The default is "thelastpickle/cassandra-reaper:3.5.0".
The default is "thelastpickle/cassandra-reaper:3.6.0".
TODO: update with real release version.
properties:
name:
Expand Down Expand Up @@ -26258,14 +26258,8 @@ spec:
x-kubernetes-map-type: atomic
type: object
initContainerImage:
default:
name: cassandra-reaper
repository: thelastpickle
tag: 3.5.0
description: |-
The image to use for the Reaper pod init container (that performs schema migrations).
The default is "thelastpickle/cassandra-reaper:3.5.0".
TODO: update with real release version.
description: 'Deprecated: The main container image will be used
for the init container as well.'
properties:
name:
description: The image name to use.
Expand Down
14 changes: 4 additions & 10 deletions config/crd/bases/reaper.k8ssandra.io_reapers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -986,10 +986,10 @@ spec:
default:
name: cassandra-reaper
repository: thelastpickle
tag: 3.5.0
tag: 3.6.0
description: |-
The image to use for the Reaper pod main container.
The default is "thelastpickle/cassandra-reaper:3.5.0".
The default is "thelastpickle/cassandra-reaper:3.6.0".
TODO: update with real release version.
properties:
name:
Expand Down Expand Up @@ -1094,14 +1094,8 @@ spec:
x-kubernetes-map-type: atomic
type: object
initContainerImage:
default:
name: cassandra-reaper
repository: thelastpickle
tag: 3.5.0
description: |-
The image to use for the Reaper pod init container (that performs schema migrations).
The default is "thelastpickle/cassandra-reaper:3.5.0".
TODO: update with real release version.
description: 'Deprecated: The main container image will be used for
the init container as well.'
properties:
name:
description: The image name to use.
Expand Down
2 changes: 1 addition & 1 deletion pkg/reaper/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
const (
DefaultImageRepository = "thelastpickle"
DefaultImageName = "cassandra-reaper"
DefaultVersion = "3.5.0"
DefaultVersion = "3.6.0"
// When changing the default version above, please also change the kubebuilder markers in
// apis/reaper/v1alpha1/reaper_types.go accordingly.

Expand Down
21 changes: 6 additions & 15 deletions pkg/reaper/deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ import (

func TestNewDeployment(t *testing.T) {
mainImage := &images.Image{Repository: "test", Name: "reaper", Tag: "latest", PullPolicy: corev1.PullAlways}
initImage := &images.Image{Repository: "test", Name: "reaper-init", Tag: "1.2.3", PullPolicy: corev1.PullNever}
reaper := newTestReaper()
reaper.Spec.ContainerImage = mainImage
reaper.Spec.InitContainerImage = initImage
reaper.Spec.AutoScheduling = reaperapi.AutoScheduling{Enabled: false}
reaper.Spec.ServiceAccountName = "reaper"
reaper.Spec.DatacenterAvailability = DatacenterAvailabilityAll
Expand Down Expand Up @@ -126,8 +124,8 @@ func TestNewDeployment(t *testing.T) {
assert.Len(t, podSpec.InitContainers, 1)

initContainer := podSpec.InitContainers[0]
assert.Equal(t, "docker.io/test/reaper-init:1.2.3", initContainer.Image)
assert.Equal(t, corev1.PullNever, initContainer.ImagePullPolicy)
assert.Equal(t, "docker.io/test/reaper:latest", initContainer.Image)
assert.Equal(t, corev1.PullAlways, initContainer.ImagePullPolicy)
assert.ElementsMatch(t, initContainer.Env, []corev1.EnvVar{
{
Name: "REAPER_STORAGE_TYPE",
Expand Down Expand Up @@ -342,28 +340,22 @@ func TestImages(t *testing.T) {
// Note: nil images are normally not possible due to the kubebuilder markers on the CRD spec
t.Run("nil images", func(t *testing.T) {
reaper := newTestReaper()
reaper.Spec.InitContainerImage = nil
reaper.Spec.ContainerImage = nil
logger := testlogr.NewTestLogger(t)
deployment := NewDeployment(reaper, newTestDatacenter(), nil, nil, logger)
assert.Equal(t, "docker.io/thelastpickle/cassandra-reaper:3.5.0", deployment.Spec.Template.Spec.InitContainers[0].Image)
assert.Equal(t, "docker.io/thelastpickle/cassandra-reaper:3.5.0", deployment.Spec.Template.Spec.Containers[0].Image)
assert.Equal(t, "docker.io/thelastpickle/cassandra-reaper:3.6.0", deployment.Spec.Template.Spec.InitContainers[0].Image)
assert.Equal(t, "docker.io/thelastpickle/cassandra-reaper:3.6.0", deployment.Spec.Template.Spec.Containers[0].Image)
assert.Equal(t, corev1.PullIfNotPresent, deployment.Spec.Template.Spec.InitContainers[0].ImagePullPolicy)
assert.Equal(t, corev1.PullIfNotPresent, deployment.Spec.Template.Spec.Containers[0].ImagePullPolicy)
assert.Empty(t, deployment.Spec.Template.Spec.ImagePullSecrets)
})
t.Run("default images", func(t *testing.T) {
reaper := newTestReaper()
reaper.Spec.InitContainerImage = &images.Image{
Repository: "thelastpickle",
Name: "cassandra-reaper",
Tag: DefaultVersion,
}
reaper.Spec.ContainerImage = nil
logger := testlogr.NewTestLogger(t)
deployment := NewDeployment(reaper, newTestDatacenter(), nil, nil, logger)
assert.Equal(t, "docker.io/thelastpickle/cassandra-reaper:3.5.0", deployment.Spec.Template.Spec.InitContainers[0].Image)
assert.Equal(t, "docker.io/thelastpickle/cassandra-reaper:3.5.0", deployment.Spec.Template.Spec.Containers[0].Image)
assert.Equal(t, "docker.io/thelastpickle/cassandra-reaper:3.6.0", deployment.Spec.Template.Spec.InitContainers[0].Image)
assert.Equal(t, "docker.io/thelastpickle/cassandra-reaper:3.6.0", deployment.Spec.Template.Spec.Containers[0].Image)
assert.Equal(t, corev1.PullIfNotPresent, deployment.Spec.Template.Spec.InitContainers[0].ImagePullPolicy)
assert.Equal(t, corev1.PullIfNotPresent, deployment.Spec.Template.Spec.Containers[0].ImagePullPolicy)
assert.Empty(t, deployment.Spec.Template.Spec.ImagePullSecrets)
Expand All @@ -376,7 +368,6 @@ func TestImages(t *testing.T) {
Tag: "latest",
PullSecretRef: &corev1.LocalObjectReference{Name: "my-secret"},
}
reaper.Spec.InitContainerImage = image
reaper.Spec.ContainerImage = image
logger := testlogr.NewTestLogger(t)
deployment := NewDeployment(reaper, newTestDatacenter(), nil, nil, logger)
Expand Down
Loading