Skip to content

feat: add support for local PVC cleanup during upgrade and rolling restart [KO-427] #374

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

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} GO111MODULE=on go
FROM registry.access.redhat.com/ubi9/ubi-minimal:latest

# Version of Operator (build arg)
ARG VERSION="4.0.2"
ARG VERSION="4.1.0-preview"

# User to run container as
ARG USER="root"
Expand Down
4 changes: 2 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -240,13 +240,13 @@ boolean isNightly() {
}

String getVersion() {
def prefix = "4.0.2"
def prefix = "4.1.0-preview"
def candidateName = ""
if(isNightly()) {
def timestamp = new Date().format("yyyy-MM-dd")
candidateName = "nightly-${timestamp}"
} else {
candidateName = "candidate-${env.BRANCH_NAME}"
candidateName = "${env.BRANCH_NAME}"
}

def candidateNameMax = 30 - prefix.length()
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ OPENSHIFT_VERSION="v4.10"
# - use the VERSION as arg of the bundle target (e.g make bundle VERSION=0.0.2)
# - use environment variables to overwrite this value (e.g export VERSION=0.0.2)
# TODO: Version must be pulled from git tags
VERSION ?= 4.0.2
VERSION ?= 4.1.0-preview

# Platforms supported
PLATFORMS ?= linux/amd64,linux/arm64
Expand Down Expand Up @@ -313,7 +313,7 @@ submodules: ## Pull and update git submodules recursively

# Generate bundle manifests and metadata, then validate generated files.
# For OpenShift bundles run
# CHANNELS=stable DEFAULT_CHANNEL=stable OPENSHIFT_VERSION=v4.10 IMG=docker.io/aerospike/aerospike-kubernetes-operator-nightly:4.0.2 make bundle
# CHANNELS=stable DEFAULT_CHANNEL=stable OPENSHIFT_VERSION=v4.10 IMG=docker.io/aerospike/aerospike-kubernetes-operator-nightly:4.1.0-preview make bundle
.PHONY: bundle
bundle: manifests kustomize operator-sdk
rm -rf $(ROOT_DIR)/bundle.Dockerfile $(BUNDLE_DIR)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Run the following command with the appropriate name and version for the operator

```sh
IMAGE_TAG_BASE=aerospike/aerospike-kubernetes-operator-nightly
VERSION=4.0.2
VERSION=4.1.0-preview
make docker-buildx IMG=${IMAGE_TAG_BASE}:${VERSION} PLATFORMS=linux/amd64
```
**Note**: Change `PLATFORMS` var as per host machine or remove it to build multi-arch image
Expand Down Expand Up @@ -96,7 +96,7 @@ Set up the environment with image names.
```shell
export ACCOUNT=aerospike
export IMAGE_TAG_BASE=${ACCOUNT}/aerospike-kubernetes-operator
export VERSION=4.0.2
export VERSION=4.1.0-preview
export IMG=docker.io/${IMAGE_TAG_BASE}-nightly:${VERSION}
export BUNDLE_IMG=docker.io/${IMAGE_TAG_BASE}-bundle-nightly:${VERSION}
export CATALOG_IMG=docker.io/${IMAGE_TAG_BASE}-catalog-nightly:${VERSION}
Expand Down
11 changes: 8 additions & 3 deletions api/v1/aerospikecluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -739,8 +739,8 @@ type PersistentVolumeSpec struct { //nolint:govet // for readability
// Size of volume.
Size resource.Quantity `json:"size"`

// Name for creating PVC for this volume, Name or path should be given
// Name string `json:"name"`
// AccessModes contains the desired access modes the volume should have.
// More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes
// +optional
AccessModes []corev1.PersistentVolumeAccessMode `json:"accessModes,omitempty" protobuf:"bytes,1,rep,name=accessModes,casttype=PersistentVolumeAccessMode"` //nolint:lll // for readability

Expand Down Expand Up @@ -812,6 +812,11 @@ type AerospikeStorageSpec struct { //nolint:govet // for readability
// +optional
LocalStorageClasses []string `json:"localStorageClasses,omitempty"`

// DeleteLocalStorageOnRestart enables the deletion of local storage PVCs when a pod is restarted or rescheduled
// by AKO. It only considers local storage classes given in the localStorageClasses field.
// +optional
DeleteLocalStorageOnRestart *bool `json:"deleteLocalStorageOnRestart,omitempty"`

// Volumes list to attach to created pods.
// +patchMergeKey=name
// +patchStrategy=merge
Expand Down Expand Up @@ -1206,7 +1211,7 @@ type AerospikePodStatus struct { //nolint:govet // for readability

// AerospikeCluster is the schema for the AerospikeCluster API
// +operator-sdk:csv:customresourcedefinitions:displayName="Aerospike Cluster",resources={{Service, v1},{Pod,v1},{StatefulSet,v1}}
// +kubebuilder:metadata:annotations="aerospike-kubernetes-operator/version=4.0.2"
// +kubebuilder:metadata:annotations="aerospike-kubernetes-operator/version=4.1.0-preview"
//
//nolint:lll // for readability
type AerospikeCluster struct { //nolint:govet // for readability
Expand Down
5 changes: 5 additions & 0 deletions api/v1/zz_generated.deepcopy.go

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

2 changes: 1 addition & 1 deletion api/v1beta1/aerospikebackup_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ type AerospikeBackupStatus struct {

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:metadata:annotations="aerospike-kubernetes-operator/version=4.0.2"
// +kubebuilder:metadata:annotations="aerospike-kubernetes-operator/version=4.1.0-preview"
// +kubebuilder:printcolumn:name="Backup Service Name",type=string,JSONPath=`.spec.backupService.name`
// +kubebuilder:printcolumn:name="Backup Service Namespace",type=string,JSONPath=`.spec.backupService.namespace`
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
Expand Down
2 changes: 1 addition & 1 deletion api/v1beta1/aerospikebackupservice_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ type ServiceContainerSpec struct {

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:metadata:annotations="aerospike-kubernetes-operator/version=4.0.2"
// +kubebuilder:metadata:annotations="aerospike-kubernetes-operator/version=4.1.0-preview"
// +kubebuilder:printcolumn:name="Image",type=string,JSONPath=`.spec.image`
// +kubebuilder:printcolumn:name="Service Type",type=string,JSONPath=`.spec.service.type`
// +kubebuilder:printcolumn:name="Phase",type=string,JSONPath=`.status.phase`
Expand Down
2 changes: 1 addition & 1 deletion api/v1beta1/aerospikerestore_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ type AerospikeRestoreStatus struct {

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:metadata:annotations="aerospike-kubernetes-operator/version=4.0.2"
// +kubebuilder:metadata:annotations="aerospike-kubernetes-operator/version=4.1.0-preview"
// +kubebuilder:printcolumn:name="Backup Service Name",type=string,JSONPath=`.spec.backupService.name`
// +kubebuilder:printcolumn:name="Backup Service Namespace",type=string,JSONPath=`.spec.backupService.namespace`
// +kubebuilder:printcolumn:name="Phase",type=string,JSONPath=`.status.phase`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
aerospike-kubernetes-operator/version: 4.0.2
aerospike-kubernetes-operator/version: 4.1.0-preview
controller-gen.kubebuilder.io/version: v0.16.1
name: aerospikebackups.asdb.aerospike.com
spec:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
aerospike-kubernetes-operator/version: 4.0.2
aerospike-kubernetes-operator/version: 4.1.0-preview
controller-gen.kubebuilder.io/version: v0.16.1
name: aerospikebackupservices.asdb.aerospike.com
spec:
Expand Down
56 changes: 43 additions & 13 deletions config/crd/bases/asdb.aerospike.com_aerospikeclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
aerospike-kubernetes-operator/version: 4.0.2
aerospike-kubernetes-operator/version: 4.1.0-preview
controller-gen.kubebuilder.io/version: v0.16.1
name: aerospikeclusters.asdb.aerospike.com
spec:
Expand Down Expand Up @@ -6221,6 +6221,11 @@ spec:
description: CleanupThreads contains the maximum number
of cleanup threads(dd or blkdiscard) per init container.
type: integer
deleteLocalStorageOnRestart:
description: |-
DeleteLocalStorageOnRestart enables the deletion of local storage PVCs when a pod is restarted or rescheduled
by AKO. It only considers local storage classes given in the localStorageClasses field.
type: boolean
filesystemVolumePolicy:
description: FileSystemVolumePolicy contains default
policies for filesystem volumes.
Expand Down Expand Up @@ -6571,8 +6576,8 @@ spec:
properties:
accessModes:
description: |-
Name for creating PVC for this volume, Name or path should be given
Name string `json:"name"`
AccessModes contains the desired access modes the volume should have.
More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes
items:
type: string
type: array
Expand Down Expand Up @@ -7822,6 +7827,11 @@ spec:
description: CleanupThreads contains the maximum number
of cleanup threads(dd or blkdiscard) per init container.
type: integer
deleteLocalStorageOnRestart:
description: |-
DeleteLocalStorageOnRestart enables the deletion of local storage PVCs when a pod is restarted or rescheduled
by AKO. It only considers local storage classes given in the localStorageClasses field.
type: boolean
filesystemVolumePolicy:
description: FileSystemVolumePolicy contains default
policies for filesystem volumes.
Expand Down Expand Up @@ -8172,8 +8182,8 @@ spec:
properties:
accessModes:
description: |-
Name for creating PVC for this volume, Name or path should be given
Name string `json:"name"`
AccessModes contains the desired access modes the volume should have.
More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes
items:
type: string
type: array
Expand Down Expand Up @@ -8497,6 +8507,11 @@ spec:
description: CleanupThreads contains the maximum number of cleanup
threads(dd or blkdiscard) per init container.
type: integer
deleteLocalStorageOnRestart:
description: |-
DeleteLocalStorageOnRestart enables the deletion of local storage PVCs when a pod is restarted or rescheduled
by AKO. It only considers local storage classes given in the localStorageClasses field.
type: boolean
filesystemVolumePolicy:
description: FileSystemVolumePolicy contains default policies
for filesystem volumes.
Expand Down Expand Up @@ -8844,8 +8859,8 @@ spec:
properties:
accessModes:
description: |-
Name for creating PVC for this volume, Name or path should be given
Name string `json:"name"`
AccessModes contains the desired access modes the volume should have.
More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes
items:
type: string
type: array
Expand Down Expand Up @@ -15362,6 +15377,11 @@ spec:
description: CleanupThreads contains the maximum number
of cleanup threads(dd or blkdiscard) per init container.
type: integer
deleteLocalStorageOnRestart:
description: |-
DeleteLocalStorageOnRestart enables the deletion of local storage PVCs when a pod is restarted or rescheduled
by AKO. It only considers local storage classes given in the localStorageClasses field.
type: boolean
filesystemVolumePolicy:
description: FileSystemVolumePolicy contains default
policies for filesystem volumes.
Expand Down Expand Up @@ -15712,8 +15732,8 @@ spec:
properties:
accessModes:
description: |-
Name for creating PVC for this volume, Name or path should be given
Name string `json:"name"`
AccessModes contains the desired access modes the volume should have.
More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes
items:
type: string
type: array
Expand Down Expand Up @@ -16963,6 +16983,11 @@ spec:
description: CleanupThreads contains the maximum number
of cleanup threads(dd or blkdiscard) per init container.
type: integer
deleteLocalStorageOnRestart:
description: |-
DeleteLocalStorageOnRestart enables the deletion of local storage PVCs when a pod is restarted or rescheduled
by AKO. It only considers local storage classes given in the localStorageClasses field.
type: boolean
filesystemVolumePolicy:
description: FileSystemVolumePolicy contains default
policies for filesystem volumes.
Expand Down Expand Up @@ -17313,8 +17338,8 @@ spec:
properties:
accessModes:
description: |-
Name for creating PVC for this volume, Name or path should be given
Name string `json:"name"`
AccessModes contains the desired access modes the volume should have.
More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes
items:
type: string
type: array
Expand Down Expand Up @@ -17704,6 +17729,11 @@ spec:
description: CleanupThreads contains the maximum number of cleanup
threads(dd or blkdiscard) per init container.
type: integer
deleteLocalStorageOnRestart:
description: |-
DeleteLocalStorageOnRestart enables the deletion of local storage PVCs when a pod is restarted or rescheduled
by AKO. It only considers local storage classes given in the localStorageClasses field.
type: boolean
filesystemVolumePolicy:
description: FileSystemVolumePolicy contains default policies
for filesystem volumes.
Expand Down Expand Up @@ -18051,8 +18081,8 @@ spec:
properties:
accessModes:
description: |-
Name for creating PVC for this volume, Name or path should be given
Name string `json:"name"`
AccessModes contains the desired access modes the volume should have.
More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes
items:
type: string
type: array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
aerospike-kubernetes-operator/version: 4.0.2
aerospike-kubernetes-operator/version: 4.1.0-preview
controller-gen.kubebuilder.io/version: v0.16.1
name: aerospikerestores.asdb.aerospike.com
spec:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ require (
github.com/go-logr/logr v1.4.2
github.com/onsi/ginkgo/v2 v2.22.2
github.com/onsi/gomega v1.36.2
github.com/prometheus/client_golang v1.21.1
github.com/sirupsen/logrus v1.9.3
github.com/stretchr/testify v1.10.0
golang.org/x/crypto v0.38.0
Expand Down Expand Up @@ -73,7 +74,6 @@ require (
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.21.1 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.63.0 // indirect
github.com/prometheus/procfs v0.16.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions helm-charts/aerospike-backup-service/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ type: application
name: aerospike-backup-service

# version tracks chart changes
version: 4.0.2
version: 4.1.0-preview
# appVersion tracks operator version
appVersion: 4.0.2
appVersion: 4.1.0-preview

description: A Helm chart for Aerospike Backup Service Custom Resource
icon: https://avatars0.githubusercontent.com/u/2214313?s=200&v=4
Expand Down
4 changes: 2 additions & 2 deletions helm-charts/aerospike-backup/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ type: application
name: aerospike-backup

# version tracks chart changes
version: 4.0.2
version: 4.1.0-preview
# appVersion tracks operator version
appVersion: 4.0.2
appVersion: 4.1.0-preview

description: A Helm chart for Aerospike Backup Custom Resource
icon: https://avatars0.githubusercontent.com/u/2214313?s=200&v=4
Expand Down
4 changes: 2 additions & 2 deletions helm-charts/aerospike-cluster/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ type: application
name: aerospike-cluster

# version tracks chart changes
version: 4.0.2
version: 4.1.0-preview
# appVersion tracks operator version
appVersion: 4.0.2
appVersion: 4.1.0-preview

description: A Helm chart for Aerospike Cluster Custom Resource
icon: https://avatars0.githubusercontent.com/u/2214313?s=200&v=4
Expand Down
4 changes: 2 additions & 2 deletions helm-charts/aerospike-kubernetes-operator/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ type: application
name: aerospike-kubernetes-operator

# version tracks chart changes
version: 4.0.2
version: 4.1.0-preview
# appVersion tracks operator version
appVersion: 4.0.2
appVersion: 4.1.0-preview

description: A Helm chart for Aerospike Kubernetes Operator
icon: https://avatars0.githubusercontent.com/u/2214313?s=200&v=4
Expand Down
Loading
Loading