Skip to content
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
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,15 @@ kind-provision: kind kind-create docker-build download-test-crds
echo "Waiting for cert-manager to be ready..."
sleep 45

KIND_IMG ?= $(IMG)
ifeq ($(DOCKER),podman)
KIND_IMG=localhost/$(IMG)
endif

.PHONY: kind-deploy
kind-deploy: kind kind-provision deploy
kubectl set image deployment/questdb-operator-controller-manager -n questdb-operator-system \
manager=$(KIND_IMG)

.PHONY: kind-clean
kind-clean: kind
Expand Down
25 changes: 13 additions & 12 deletions api/v1beta1/questdb_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ const (
AnnotationQuestDBSecretType = "questdb.crd.questdb.io/secret-type"
)

type QuestDBResourcesSpec struct {
Limits v1.ResourceList `json:"limits,omitempty"`
Requests v1.ResourceList `json:"requests,omitempty"`
}

type QuestDBVolumeSpec struct {
Selector *metav1.LabelSelector `json:"selector,omitempty"`
Size resource.Quantity `json:"size,omitempty"`
Expand All @@ -52,13 +47,19 @@ type QuestDBSpec struct {

Image string `json:"image"`

Affinity *v1.Affinity `json:"affinity,omitempty"`
ExtraEnv []v1.EnvVar `json:"extraEnv,omitempty"`
ImagePullPolicy v1.PullPolicy `json:"imagePullPolicy,omitempty"`
ImagePullSecrets []v1.LocalObjectReference `json:"imagePullSecrets,omitempty"`
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
Resources QuestDBResourcesSpec `json:"resources,omitempty"`
Tolerations []v1.Toleration `json:"tolerations,omitempty"`
Affinity *v1.Affinity `json:"affinity,omitempty"`
ExtraEnv []v1.EnvVar `json:"extraEnv,omitempty"`
ExtraVolumeMounts []v1.VolumeMount `json:"extraVolumeMounts,omitempty"`
ExtraVolumes []v1.Volume `json:"extraVolumes,omitempty"`
// ImagePullPolicy defaults to IfNotPresent
ImagePullPolicy v1.PullPolicy `json:"imagePullPolicy,omitempty"`
ImagePullSecrets []v1.LocalObjectReference `json:"imagePullSecrets,omitempty"`
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
PodAnnotations map[string]string `json:"podAnnotations,omitempty"`
PodSecurityContext v1.PodSecurityContext `json:"podSecurityContext,omitempty"`
Resources v1.ResourceRequirements `json:"resources,omitempty"`
StatefulSetAnnotations map[string]string `json:"statefulSetAnnotations,omitempty"`
Tolerations []v1.Toleration `json:"tolerations,omitempty"`
}

type QuestDBEndpointStatus struct {
Expand Down
14 changes: 13 additions & 1 deletion api/v1beta1/questdb_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ import (
"reflect"
"strings"

v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/utils/pointer"
ctrl "sigs.k8s.io/controller-runtime"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/webhook"
Expand All @@ -46,7 +48,13 @@ var _ webhook.Defaulter = &QuestDB{}
func (r *QuestDB) Default() {
questdblog.Info("default", "name", r.Name)

// TODO(user): fill in your defaulting logic.
if r.Spec.ImagePullPolicy == v1.PullPolicy("") {
r.Spec.ImagePullPolicy = v1.PullIfNotPresent
}

if r.Spec.PodSecurityContext.FSGroup == nil {
r.Spec.PodSecurityContext.FSGroup = pointer.Int64(10001)
}
}

// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
Expand Down Expand Up @@ -152,6 +160,10 @@ func (r *QuestDB) ValidateUpdate(old runtime.Object) error {
return errors.New("cannot change storage class name")
}

if r.Spec.ImagePullPolicy == "" {
return errors.New("image pull policy cannot be empty")
}

return nil
}

Expand Down
8 changes: 8 additions & 0 deletions api/v1beta1/questdb_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/pointer"
Expand Down Expand Up @@ -73,6 +74,12 @@ var _ = Describe("QuestDB Webhook", func() {
}
Expect(k8sClient.Create(ctx, q)).ToNot(Succeed())
})

It("should handle an empty image pull policy", func() {
q.Spec.ImagePullPolicy = ""
Expect(k8sClient.Create(ctx, q)).To(Succeed())
Expect(q.Spec.ImagePullPolicy).To(Equal(v1.PullIfNotPresent))
})
})

Context("When validating QuestDB Updates", func() {
Expand Down Expand Up @@ -136,6 +143,7 @@ var _ = Describe("QuestDB Webhook", func() {
q.Spec.Volume.SnapshotName = "foo"
Expect(k8sClient.Update(ctx, q)).ToNot(Succeed())
})

})

})
72 changes: 36 additions & 36 deletions api/v1beta1/zz_generated.deepcopy.go

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

Loading