Skip to content

Commit e646213

Browse files
committed
Initial KinD setup
Signed-off-by: Matthias Wessendorf <[email protected]>
1 parent c447bf8 commit e646213

File tree

5 files changed

+102
-0
lines changed

5 files changed

+102
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,5 @@ python/build/
2727
python/dist/
2828
python/kubernetes_mcp_server.egg-info/
2929
!python/kubernetes-mcp-server
30+
31+
/bin/

Makefile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,40 @@ lint: golangci-lint ## Lint the code
115115
.PHONY: update-readme-tools
116116
update-readme-tools: ## Update the README.md file with the latest toolsets
117117
go run ./internal/tools/update-readme/main.go README.md
118+
119+
##@ Tools
120+
121+
.PHONY: tools
122+
tools: ## Install all required tools (kind) to ./bin/
123+
@echo "Checking and installing required tools to ./bin/ ..."
124+
@if [ -f bin/kind ]; then echo "[OK] kind already installed"; else echo "Installing kind..."; $(MAKE) -s kind; fi
125+
@echo "All tools ready!"
126+
127+
##@ Local Development
128+
129+
.PHONY: local-env-setup
130+
local-env-setup: ## Setup complete local development environment with Kind cluster
131+
@echo "========================================="
132+
@echo "Kubernetes MCP Server - Local Setup"
133+
@echo "========================================="
134+
$(MAKE) tools
135+
$(MAKE) kind-create-cluster
136+
$(MAKE) build
137+
@echo ""
138+
@echo "========================================="
139+
@echo "Local environment ready!"
140+
@echo "========================================="
141+
@echo ""
142+
@echo "Run the MCP server with:"
143+
@echo " ./$(BINARY_NAME)"
144+
@echo ""
145+
@echo "Or run with MCP inspector:"
146+
@echo " npx @modelcontextprotocol/inspector@latest \$$(pwd)/$(BINARY_NAME)"
147+
@echo ""
148+
149+
.PHONY: local-env-teardown
150+
local-env-teardown: ## Tear down the local Kind cluster
151+
$(MAKE) kind-delete-cluster
152+
153+
# Include build configuration files
154+
-include build/*.mk

build/kind.mk

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Kind cluster management
2+
3+
KIND_CLUSTER_NAME ?= kubernetes-mcp-server
4+
5+
# Detect container engine (docker or podman)
6+
CONTAINER_ENGINE ?= $(shell command -v docker 2>/dev/null || command -v podman 2>/dev/null)
7+
8+
.PHONY: kind-create-cluster
9+
kind-create-cluster: kind ## Create the kind cluster for development
10+
@# Set KIND provider for podman on Linux
11+
@if [ "$(shell uname -s)" != "Darwin" ] && echo "$(CONTAINER_ENGINE)" | grep -q "podman"; then \
12+
export KIND_EXPERIMENTAL_PROVIDER=podman; \
13+
fi; \
14+
if $(KIND) get clusters 2>/dev/null | grep -q "^$(KIND_CLUSTER_NAME)$$"; then \
15+
echo "Kind cluster '$(KIND_CLUSTER_NAME)' already exists, skipping creation"; \
16+
else \
17+
echo "Creating Kind cluster '$(KIND_CLUSTER_NAME)'..."; \
18+
$(KIND) create cluster --name $(KIND_CLUSTER_NAME) --config config/kind/cluster.yaml; \
19+
fi
20+
21+
.PHONY: kind-delete-cluster
22+
kind-delete-cluster: kind ## Delete the kind cluster
23+
@# Set KIND provider for podman on Linux
24+
@if [ "$(shell uname -s)" != "Darwin" ] && echo "$(CONTAINER_ENGINE)" | grep -q "podman"; then \
25+
export KIND_EXPERIMENTAL_PROVIDER=podman; \
26+
fi; \
27+
$(KIND) delete cluster --name $(KIND_CLUSTER_NAME)

build/tools.mk

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Tools
2+
3+
# Platform detection
4+
OS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
5+
ARCH := $(shell uname -m | tr '[:upper:]' '[:lower:]')
6+
ifeq ($(ARCH),x86_64)
7+
ARCH = amd64
8+
endif
9+
ifeq ($(ARCH),aarch64)
10+
ARCH = arm64
11+
endif
12+
13+
KIND = bin/kind
14+
KIND_VERSION = v0.30.0
15+
$(KIND):
16+
GOBIN=$(PWD)/bin go install sigs.k8s.io/kind@$(KIND_VERSION)
17+
18+
.PHONY: kind
19+
kind: $(KIND) ## Download kind locally if necessary

config/kind/cluster.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
kind: Cluster
2+
apiVersion: kind.x-k8s.io/v1alpha4
3+
nodes:
4+
- role: control-plane
5+
kubeadmConfigPatches:
6+
- |
7+
kind: InitConfiguration
8+
nodeRegistration:
9+
kubeletExtraArgs:
10+
node-labels: "ingress-ready=true"
11+
extraPortMappings:
12+
- containerPort: 80
13+
hostPort: 8080
14+
protocol: TCP
15+
- containerPort: 443
16+
hostPort: 8443
17+
protocol: TCP

0 commit comments

Comments
 (0)