Skip to content

Commit 897b8a6

Browse files
committed
Enhance Kind cluster setup and testing workflow for OP Stack Operator
This commit introduces several improvements to the Makefile and scripts for managing the Kind cluster used in OP Stack Operator development. Key changes include: - Added new Make targets for creating, deleting, and checking the status of the Kind cluster. - Enhanced error messages for missing Kind installations and cluster status checks. - Introduced a new `simple-cluster.yaml` configuration file for optimized resource allocation. - Added a comprehensive development workflow script to streamline setup, deployment, testing, and cleanup processes. - Updated documentation to guide users through the Kind cluster setup and usage. These changes aim to simplify the development experience and ensure a more robust testing environment.
1 parent e088fee commit 897b8a6

9 files changed

Lines changed: 1455 additions & 20 deletions

File tree

Makefile

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,19 @@ test-integration: manifests generate fmt vet setup-envtest ## Run integration te
8888
.PHONY: test-e2e
8989
test-e2e: manifests generate fmt vet ## Run the e2e tests. Expected an isolated environment using Kind.
9090
@command -v kind >/dev/null 2>&1 || { \
91-
echo "Kind is not installed. Please install Kind manually."; \
91+
echo "❌ Kind is not installed. Please install Kind manually:"; \
92+
echo " brew install kind # macOS"; \
93+
echo " # or visit https://kind.sigs.k8s.io/docs/user/quick-start/#installation"; \
9294
exit 1; \
9395
}
94-
@kind get clusters | grep -q 'kind' || { \
95-
echo "No Kind cluster is running. Please start a Kind cluster before running the e2e tests."; \
96+
@kind get clusters | grep -q 'op-stack-operator' || { \
97+
echo "❌ OP Stack Operator Kind cluster is not running."; \
98+
echo " Run: make kind-create"; \
99+
exit 1; \
100+
}
101+
@kubectl config current-context | grep -q 'kind-op-stack-operator' || { \
102+
echo "❌ kubectl context is not set to the OP Stack Operator cluster."; \
103+
echo " Run: kubectl config use-context kind-op-stack-operator"; \
96104
exit 1; \
97105
}
98106
go test ./test/e2e/ -v -ginkgo.v
@@ -170,9 +178,36 @@ test-integration-with-env: manifests generate fmt vet setup-envtest ## Run integ
170178
exit 1; \
171179
fi
172180

181+
##@ Kind Cluster Management
182+
183+
.PHONY: kind-create
184+
kind-create: ## Create Kind cluster for OP Stack Operator development
185+
@./scripts/setup-kind-cluster.sh
186+
187+
.PHONY: kind-delete
188+
kind-delete: ## Delete Kind cluster and cleanup
189+
@echo "🗑️ Deleting Kind cluster..."
190+
kind delete cluster --name op-stack-operator || true
191+
@echo "🗑️ Stopping local registry..."
192+
docker stop kind-registry || true
193+
docker rm kind-registry || true
194+
@echo "✅ Cleanup complete"
195+
196+
.PHONY: kind-status
197+
kind-status: ## Show Kind cluster status
198+
@echo "📋 Kind Cluster Status:"
199+
@echo "Clusters:"
200+
@kind get clusters || echo "No clusters found"
201+
@echo ""
202+
@echo "Registry:"
203+
@docker ps --filter name=kind-registry --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" || echo "No registry found"
204+
@echo ""
205+
@echo "Kubeconfig context:"
206+
@kubectl config current-context 2>/dev/null || echo "No kubectl context set"
207+
173208
.PHONY: kind-load
174209
kind-load: docker-build ## Load image into kind cluster for testing
175-
kind load docker-image ${IMG}
210+
kind load docker-image ${IMG} --name op-stack-operator
176211

177212
.PHONY: deploy-samples
178213
deploy-samples: ## Deploy sample configurations

config/kind/simple-cluster.yaml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Simplified Kind cluster configuration for OP Stack Operator with increased memory
2+
# This configuration allocates more resources for OP Stack workloads
3+
apiVersion: kind.x-k8s.io/v1alpha4
4+
kind: Cluster
5+
name: op-stack-operator
6+
nodes:
7+
# Control plane node with increased resources
8+
- role: control-plane
9+
image: kindest/node:v1.31.0
10+
kubeadmConfigPatches:
11+
- |
12+
kind: InitConfiguration
13+
nodeRegistration:
14+
kubeletExtraArgs:
15+
node-labels: "ingress-ready=true"
16+
# Increase memory limits for control plane
17+
system-reserved: "memory=200Mi"
18+
kube-reserved: "memory=200Mi"
19+
- |
20+
kind: ClusterConfiguration
21+
controllerManager:
22+
extraArgs:
23+
# Allow more pods per node
24+
node-cidr-mask-size: "24"
25+
scheduler:
26+
extraArgs:
27+
# Enable more efficient scheduling
28+
v: "2"
29+
extraPortMappings:
30+
# Expose ingress controller ports
31+
- containerPort: 80
32+
hostPort: 80
33+
protocol: TCP
34+
- containerPort: 443
35+
hostPort: 443
36+
protocol: TCP
37+
# Expose OP Stack ports (using high port numbers to avoid conflicts)
38+
- containerPort: 30545
39+
hostPort: 18545
40+
protocol: TCP
41+
- containerPort: 30546
42+
hostPort: 18546
43+
protocol: TCP
44+
45+
# Worker nodes with optimized settings for OP Stack
46+
- role: worker
47+
image: kindest/node:v1.31.0
48+
kubeadmConfigPatches:
49+
- |
50+
kind: JoinConfiguration
51+
nodeRegistration:
52+
kubeletExtraArgs:
53+
# Optimize for OP Stack workloads
54+
max-pods: "200"
55+
# Reserve less memory for system, more for workloads
56+
system-reserved: "cpu=100m,memory=100Mi"
57+
kube-reserved: "cpu=50m,memory=100Mi"
58+
# Enable swap for better memory management
59+
fail-swap-on: "false"
60+
# Increase image garbage collection thresholds
61+
image-gc-high-threshold: "90"
62+
image-gc-low-threshold: "80"
63+
64+
# Second worker node for better resource distribution
65+
- role: worker
66+
image: kindest/node:v1.31.0
67+
kubeadmConfigPatches:
68+
- |
69+
kind: JoinConfiguration
70+
nodeRegistration:
71+
kubeletExtraArgs:
72+
max-pods: "200"
73+
system-reserved: "cpu=100m,memory=100Mi"
74+
kube-reserved: "cpu=50m,memory=100Mi"
75+
fail-swap-on: "false"
76+
image-gc-high-threshold: "90"
77+
image-gc-low-threshold: "80"
78+
79+
# Networking configuration
80+
networking:
81+
disableDefaultCNI: false
82+
podSubnet: "10.244.0.0/16"
83+
serviceSubnet: "10.96.0.0/16"

config/manager/kustomization.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
resources:
22
- manager.yaml
3+
apiVersion: kustomize.config.k8s.io/v1beta1
4+
kind: Kustomization
5+
images:
6+
- name: controller
7+
newName: controller
8+
newTag: latest

0 commit comments

Comments
 (0)