Skip to content
Closed
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
33 changes: 33 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ test: manifests generate fmt vet setup-envtest ## Run tests.
# CertManager is installed by default; skip with:
# - CERT_MANAGER_INSTALL_SKIP=true
KIND_CLUSTER ?= multigres-operator-test-e2e
KIND_CLUSTER_DEV ?= multigres-operator-dev

.PHONY: setup-test-e2e
setup-test-e2e: ## Set up a Kind cluster for e2e tests if it does not exist
Expand All @@ -91,6 +92,38 @@ test-e2e: setup-test-e2e manifests generate fmt vet ## Run the e2e tests. Expect
cleanup-test-e2e: ## Tear down the Kind cluster used for e2e tests
@$(KIND) delete cluster --name $(KIND_CLUSTER)

## TODO: This is only temporary, we should have more streamlined setup.
.PHONY: deploy-kind
deploy-kind: docker-build kustomize ## Build, load image to kind, install CRDs, and deploy operator to kind cluster
@echo "Setting up kind cluster '$(KIND_CLUSTER_DEV)'..."
@command -v $(KIND) >/dev/null 2>&1 || { \
echo "Kind is not installed. Please install Kind manually."; \
exit 1; \
}
@case "$$($(KIND) get clusters)" in \
*"$(KIND_CLUSTER_DEV)"*) \
echo "Kind cluster '$(KIND_CLUSTER_DEV)' already exists." ;; \
*) \
echo "Creating Kind cluster '$(KIND_CLUSTER_DEV)'..."; \
$(KIND) create cluster --name $(KIND_CLUSTER_DEV) ;; \
esac
@echo "Loading image $(IMG) into kind cluster..."
$(KIND) load docker-image $(IMG) --name $(KIND_CLUSTER_DEV)
@echo "Installing CRDs..."
$(KUBECTL) --context kind-$(KIND_CLUSTER_DEV) apply -k config/crd
@echo "Deploying operator..."
cd config/deploy && $(KUSTOMIZE) edit set image controller=$(IMG)
$(KUBECTL) --context kind-$(KIND_CLUSTER_DEV) apply -k config/deploy
@echo "Deployment complete! Use 'kubectl --context kind-$(KIND_CLUSTER_DEV) get pods -n multigres-operator' to check status"

.PHONY: undeploy-kind
undeploy-kind: ## Undeploy operator from kind cluster
$(KUBECTL) --context kind-$(KIND_CLUSTER_DEV) delete --ignore-not-found=true -k config/deploy

.PHONY: cleanup-kind
cleanup-kind: ## Delete the kind cluster used for development
@$(KIND) delete cluster --name $(KIND_CLUSTER_DEV)

.PHONY: lint
lint: golangci-lint ## Run golangci-lint linter
$(GOLANGCI_LINT) run
Expand Down
24 changes: 24 additions & 0 deletions config/deploy/clusterrole.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: multigres-operator
rules:
# MultiGres CRDs
- apiGroups: ["multigres.com"]
resources: ["*"]
verbs: ["*"]
# Core resources
- apiGroups: [""]
resources: ["pods", "services", "configmaps", "secrets", "persistentvolumeclaims"]
verbs: ["*"]
- apiGroups: ["apps"]
resources: ["deployments", "statefulsets"]
verbs: ["*"]
# Events for status updates
- apiGroups: [""]
resources: ["events"]
verbs: ["create", "patch"]
# Leases for leader election
- apiGroups: ["coordination.k8s.io"]
resources: ["leases"]
verbs: ["*"]
12 changes: 12 additions & 0 deletions config/deploy/clusterrolebinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: multigres-operator
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: multigres-operator
subjects:
- kind: ServiceAccount
name: multigres-operator
namespace: multigres-operator
61 changes: 61 additions & 0 deletions config/deploy/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: multigres-operator
namespace: multigres-operator
labels:
app: multigres-operator
spec:
replicas: 1
selector:
matchLabels:
app: multigres-operator
template:
metadata:
labels:
app: multigres-operator
spec:
serviceAccountName: multigres-operator
containers:
- name: manager
image: controller:latest
imagePullPolicy: IfNotPresent
command:
- /manager
args:
- --leader-elect
- --health-probe-bind-address=:8081
ports:
- name: health
containerPort: 8081
protocol: TCP
livenessProbe:
httpGet:
path: /healthz
port: 8081
initialDelaySeconds: 15
periodSeconds: 20
readinessProbe:
httpGet:
path: /readyz
port: 8081
initialDelaySeconds: 5
periodSeconds: 10
resources:
limits:
cpu: 500m
memory: 256Mi
requests:
cpu: 100m
memory: 128Mi
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
runAsNonRoot: true
securityContext:
runAsNonRoot: true
seccompProfile:
type: RuntimeDefault
14 changes: 14 additions & 0 deletions config/deploy/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- namespace.yaml
- serviceaccount.yaml
- clusterrole.yaml
- clusterrolebinding.yaml
- deployment.yaml

images:
- name: controller
newName: controller
newTag: latest
4 changes: 4 additions & 0 deletions config/deploy/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: multigres-operator
5 changes: 5 additions & 0 deletions config/deploy/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: multigres-operator
namespace: multigres-operator
6 changes: 3 additions & 3 deletions config/rbac/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ resources:
# default, aiding admins in cluster management. Those roles are
# not used by the kubebuilder itself. You can comment the following lines
# if you do not want those helpers be installed with your Project.
- guestbook_admin_role.yaml
- guestbook_editor_role.yaml
- guestbook_viewer_role.yaml
# - guestbook_admin_role.yaml
# - guestbook_editor_role.yaml
# - guestbook_viewer_role.yaml

7 changes: 7 additions & 0 deletions config/samples/etcd-minimal.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: multigres.com/v1alpha1
kind: Etcd
metadata:
name: etcd-sample
namespace: default
spec:
cellName: cell-1
1 change: 1 addition & 0 deletions devshell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pkgs.mkShell {
docker-buildx
kubectl
kind
kustomize
golangci-lint

# For some script use cases
Expand Down
Loading