Skip to content

Commit

Permalink
Merge branch 'master' into KO-338
Browse files Browse the repository at this point in the history
  • Loading branch information
tanmayja committed Sep 9, 2024
2 parents 35cf80d + fbd9d18 commit 870ecfc
Show file tree
Hide file tree
Showing 156 changed files with 12,623 additions and 1,742 deletions.
28 changes: 24 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# # /bin/sh does not support source command needed in make test
# # /bin/sh does not support source command needed in make all-test
#SHELL := /bin/bash

ROOT_DIR=$(shell git rev-parse --show-toplevel)
Expand Down Expand Up @@ -113,6 +113,9 @@ help: ## Display this help.
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
cp $(ROOT_DIR)/config/crd/bases/asdb.aerospike.com_aerospikeclusters.yaml $(ROOT_DIR)/helm-charts/aerospike-kubernetes-operator/crds/customresourcedefinition_aerospikeclusters.asdb.aerospike.com.yaml
cp $(ROOT_DIR)/config/crd/bases/asdb.aerospike.com_aerospikebackupservices.yaml $(ROOT_DIR)/helm-charts/aerospike-kubernetes-operator/crds/customresourcedefinition_aerospikebackupservices.asdb.aerospike.com.yaml
cp $(ROOT_DIR)/config/crd/bases/asdb.aerospike.com_aerospikebackups.yaml $(ROOT_DIR)/helm-charts/aerospike-kubernetes-operator/crds/customresourcedefinition_aerospikebackups.asdb.aerospike.com.yaml
cp $(ROOT_DIR)/config/crd/bases/asdb.aerospike.com_aerospikerestores.yaml $(ROOT_DIR)/helm-charts/aerospike-kubernetes-operator/crds/customresourcedefinition_aerospikerestores.asdb.aerospike.com.yaml

.PHONY: generate
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
Expand All @@ -137,10 +140,27 @@ $(GOLANGCI_LINT): $(LOCALBIN)
go-lint: golanci-lint ## Run golangci-lint against code.
$(GOLANGCI_LINT) run

.PHONY: test
test: manifests generate fmt vet envtest ## Run tests.
.PHONY: all-test
all-test: manifests generate fmt vet envtest ## Run tests.
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" cd $(shell pwd)/test; go run github.com/onsi/ginkgo/v2/ginkgo -coverprofile cover.out -r --keep-going -show-node-events -v -timeout=12h0m0s --junit-report="junit.xml" -- ${ARGS}

.PHONY: cluster-test
cluster-test: manifests generate fmt vet envtest ## Run tests.
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" cd $(shell pwd)/test; go run github.com/onsi/ginkgo/v2/ginkgo -coverprofile cover.out --keep-separate-coverprofiles -v . ./cluster -show-node-events -timeout=12h0m0s --junit-report="junit.xml" -- ${ARGS}


.PHONY: backup-service-test
backup-service-test: manifests generate fmt vet envtest ## Run tests.
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" cd $(shell pwd)/test; go run github.com/onsi/ginkgo/v2/ginkgo -coverprofile cover.out --keep-separate-coverprofiles -v . ./backup_service -show-node-events -timeout=1h0m0s --junit-report="junit.xml" -- ${ARGS}

.PHONY: backup-test
backup-test: manifests generate fmt vet envtest ## Run tests.
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" cd $(shell pwd)/test; go run github.com/onsi/ginkgo/v2/ginkgo -coverprofile cover.out --keep-separate-coverprofiles -v . ./backup -show-node-events -timeout=1h0m0s --junit-report="junit.xml" -- ${ARGS}

.PHONY: restore-test
restore-test: manifests generate fmt vet envtest ## Run tests.
# KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test ./... -coverprofile cover.out
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" cd $(shell pwd)/test; go run github.com/onsi/ginkgo/v2/ginkgo -coverprofile cover.out -show-node-events -v -timeout=12h0m0s -focus=${FOCUS} --junit-report="junit.xml" -- ${ARGS}
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" cd $(shell pwd)/test; go run github.com/onsi/ginkgo/v2/ginkgo -coverprofile cover.out --keep-separate-coverprofiles -v . ./restore -show-node-events -timeout=1h0m0s --junit-report="junit.xml" -- ${ARGS}

##@ Build

Expand Down
39 changes: 39 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,43 @@ resources:
defaulting: true
validation: true
webhookVersion: v1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: aerospike.com
group: asdb
kind: AerospikeBackup
path: github.com/aerospike/aerospike-kubernetes-operator/api/v1beta1
version: v1beta1
webhooks:
defaulting: false
validation: true
webhookVersion: v1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: aerospike.com
group: asdb
kind: AerospikeRestore
path: github.com/aerospike/aerospike-kubernetes-operator/api/v1beta1
version: v1beta1
webhooks:
defaulting: true
validation: true
webhookVersion: v1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: aerospike.com
group: asdb
kind: AerospikeBackupService
path: github.com/aerospike/aerospike-kubernetes-operator/api/v1beta1
version: v1beta1
webhooks:
defaulting: false
validation: true
webhookVersion: v1
version: "3"
3 changes: 3 additions & 0 deletions api/v1/aerospikecluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ type AerospikeClusterSpec struct { //nolint:govet // for readability
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Kubernetes Node BlockList"
// +kubebuilder:validation:MinItems:=1
K8sNodeBlockList []string `json:"k8sNodeBlockList,omitempty"`
// Paused flag is used to pause the reconciliation for the AerospikeCluster.
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Pause Reconcile"
Paused *bool `json:"paused,omitempty"`
// Operations is a list of on-demand operations to be performed on the Aerospike cluster.
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Operations"
// +kubebuilder:validation:MaxItems:=1
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.

110 changes: 110 additions & 0 deletions api/v1beta1/aerospikebackup_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
/*
Copyright 2021.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1beta1

import (
"fmt"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
)

// AerospikeBackupSpec defines the desired state of AerospikeBackup for a given AerospikeCluster
// +k8s:openapi-gen=true
type AerospikeBackupSpec struct {
// BackupService is the backup service reference i.e. name and namespace.
// It is used to communicate to the backup service to trigger backups. This field is immutable
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Backup Service"
BackupService BackupService `json:"backupService"`

// Config is the free form configuration for the backup in YAML format.
// This config is used to trigger backups. It includes: aerospike-cluster, backup-routines.
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Backup Config"
Config runtime.RawExtension `json:"config"`

// OnDemandBackups is the configuration for on-demand backups.
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="On Demand Backups"
// +kubebuilder:validation:MaxItems:=1
OnDemandBackups []OnDemandBackupSpec `json:"onDemandBackups,omitempty"`
}

type BackupService struct {
// Backup service name
Name string `json:"name"`

// Backup service namespace
Namespace string `json:"namespace"`
}

func (b *BackupService) String() string {
return fmt.Sprintf("%s/%s", b.Namespace, b.Name)
}

type OnDemandBackupSpec struct {
// ID is the unique identifier for the on-demand backup.
// +kubebuilder:validation:MinLength=1
ID string `json:"id"`

// RoutineName is the routine name used to trigger on-demand backup.
RoutineName string `json:"routineName"`

// Delay is the interval before starting the on-demand backup.
Delay metav1.Duration `json:"delay,omitempty"`
}

// AerospikeBackupStatus defines the observed state of AerospikeBackup
type AerospikeBackupStatus struct {
// BackupService is the backup service reference i.e. name and namespace.
BackupService BackupService `json:"backupService"`

// Config is the configuration for the backup in YAML format.
// This config is used to trigger backups. It includes: aerospike-cluster, backup-routines.
Config runtime.RawExtension `json:"config"`

// OnDemandBackups is the configuration for on-demand backups.
OnDemandBackups []OnDemandBackupSpec `json:"onDemandBackups,omitempty"`

// TODO: finalize the status and phase
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +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"

// AerospikeBackup is the Schema for the aerospikebackup API
type AerospikeBackup struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec AerospikeBackupSpec `json:"spec,omitempty"`
Status AerospikeBackupStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

// AerospikeBackupList contains a list of AerospikeBackup
type AerospikeBackupList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []AerospikeBackup `json:"items"`
}

func init() {
SchemeBuilder.Register(&AerospikeBackup{}, &AerospikeBackupList{})
}
Loading

0 comments on commit 870ecfc

Please sign in to comment.