Skip to content

Commit 7302df0

Browse files
committed
Addressing review comments:
* do not expose all internal tasks, just keep the important targets documents * remove the keycloak-forward * move binaries for dev tools to _output * generate a configuration TOML file into the _output folder Signed-off-by: Matthias Wessendorf <[email protected]>
1 parent 488ccee commit 7302df0

File tree

12 files changed

+69
-47
lines changed

12 files changed

+69
-47
lines changed

.gitignore

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,3 @@ python/build/
2727
python/dist/
2828
python/kubernetes_mcp_server.egg-info/
2929
!python/kubernetes-mcp-server
30-
31-
/bin/
32-
hack/cert-manager-ca/
33-
hack/keycloak-certs/ca.crt

Makefile

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ update-readme-tools: ## Update the README.md file with the latest toolsets
117117
##@ Tools
118118

119119
.PHONY: tools
120-
tools: ## Install all required tools (kind) to ./bin/
121-
@echo "Checking and installing required tools to ./bin/ ..."
122-
@if [ -f bin/kind ]; then echo "[OK] kind already installed"; else echo "Installing kind..."; $(MAKE) -s kind; fi
120+
tools: ## Install all required tools (kind) to ./_output/bin/
121+
@echo "Checking and installing required tools to ./_output/bin/ ..."
122+
@if [ -f _output/bin/kind ]; then echo "[OK] kind already installed"; else echo "Installing kind..."; $(MAKE) -s kind; fi
123123
@echo "All tools ready!"
124124

125125
##@ Local Development
@@ -138,11 +138,14 @@ local-env-setup: ## Setup complete local development environment with Kind clust
138138
@echo "Local environment ready!"
139139
@echo "========================================="
140140
@echo ""
141+
@echo "Configuration file generated:"
142+
@echo " _output/config.toml"
143+
@echo ""
141144
@echo "Run the MCP server with:"
142-
@echo " ./$(BINARY_NAME) --port ..."
145+
@echo " ./$(BINARY_NAME) --port 8080 --config _output/config.toml"
143146
@echo ""
144147
@echo "Or run with MCP inspector:"
145-
@echo " npx @modelcontextprotocol/inspector@latest \$$(pwd)/$(BINARY_NAME)"
148+
@echo " npx @modelcontextprotocol/inspector@latest \$$(pwd)/$(BINARY_NAME) --config _output/config.toml"
146149

147150
.PHONY: local-env-teardown
148151
local-env-teardown: ## Tear down the local Kind cluster

build/keycloak.mk

Lines changed: 49 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ KEYCLOAK_ADMIN_USER = admin
55
KEYCLOAK_ADMIN_PASSWORD = admin
66

77
.PHONY: keycloak-install
8-
keycloak-install: ## Install Keycloak for local development
8+
keycloak-install:
99
@echo "Installing Keycloak (dev mode using official image)..."
10-
@kubectl apply -f config/keycloak/deployment.yaml
10+
@kubectl apply -f dev/config/keycloak/deployment.yaml
1111
@echo "Applying Keycloak ingress (cert-manager will create TLS certificate)..."
12-
@kubectl apply -f config/keycloak/ingress.yaml
12+
@kubectl apply -f dev/config/keycloak/ingress.yaml
1313
@echo "Extracting cert-manager CA certificate..."
14-
@mkdir -p hack/cert-manager-ca
15-
@kubectl get secret selfsigned-ca-secret -n cert-manager -o jsonpath='{.data.ca\.crt}' | base64 -d > hack/cert-manager-ca/ca.crt
16-
@echo "✅ cert-manager CA certificate extracted to hack/cert-manager-ca/ca.crt (bind-mounted to API server)"
14+
@mkdir -p _output/cert-manager-ca
15+
@kubectl get secret selfsigned-ca-secret -n cert-manager -o jsonpath='{.data.ca\.crt}' | base64 -d > _output/cert-manager-ca/ca.crt
16+
@echo "✅ cert-manager CA certificate extracted to _output/cert-manager-ca/ca.crt (bind-mounted to API server)"
1717
@echo "Restarting Kubernetes API server to pick up new CA..."
1818
@docker exec kubernetes-mcp-server-control-plane pkill -f kube-apiserver || \
1919
podman exec kubernetes-mcp-server-control-plane pkill -f kube-apiserver
@@ -29,23 +29,26 @@ keycloak-install: ## Install Keycloak for local development
2929
done
3030
@echo "Waiting for Keycloak to be ready..."
3131
@kubectl wait --for=condition=ready pod -l app=keycloak -n $(KEYCLOAK_NAMESPACE) --timeout=120s || true
32+
@echo "Waiting for Keycloak HTTP endpoint to be available..."
33+
@for i in $$(seq 1 30); do \
34+
STATUS=$$(curl -sk -o /dev/null -w "%{http_code}" https://keycloak.127-0-0-1.sslip.io:8443/realms/master 2>/dev/null || echo "000"); \
35+
if [ "$$STATUS" = "200" ]; then \
36+
echo "✅ Keycloak HTTP endpoint ready"; \
37+
break; \
38+
fi; \
39+
echo " Attempt $$i/30: Waiting for Keycloak (status: $$STATUS)..."; \
40+
sleep 3; \
41+
done
42+
@echo ""
43+
@echo "Setting up OpenShift realm..."
44+
@$(MAKE) -s keycloak-setup-realm
3245
@echo ""
33-
@echo "Keycloak installed!"
34-
@echo "Admin credentials: $(KEYCLOAK_ADMIN_USER) / $(KEYCLOAK_ADMIN_PASSWORD)"
46+
@echo "✅ Keycloak installed and configured!"
3547
@echo "Access at: https://keycloak.127-0-0-1.sslip.io:8443"
3648

3749
.PHONY: keycloak-uninstall
38-
keycloak-uninstall: ## Uninstall Keycloak
39-
@kubectl delete -f config/keycloak/deployment.yaml 2>/dev/null || true
40-
41-
.PHONY: keycloak-forward
42-
keycloak-forward: ## Port forward Keycloak (optional - ingress provides direct access)
43-
@echo "⚠️ Port forwarding not needed - Keycloak accessible via ingress"
44-
@echo "Access at: https://keycloak.127-0-0-1.sslip.io:8443"
45-
@echo "Login: $(KEYCLOAK_ADMIN_USER) / $(KEYCLOAK_ADMIN_PASSWORD)"
46-
@echo ""
47-
@echo "If you still want port forwarding, use:"
48-
@echo " kubectl port-forward -n $(KEYCLOAK_NAMESPACE) svc/keycloak 8090:80"
50+
keycloak-uninstall:
51+
@kubectl delete -f dev/config/keycloak/deployment.yaml 2>/dev/null || true
4952

5053
.PHONY: keycloak-status
5154
keycloak-status: ## Show Keycloak status and connection info
@@ -78,22 +81,25 @@ keycloak-logs: ## Tail Keycloak logs
7881
@kubectl logs -n $(KEYCLOAK_NAMESPACE) -l app=keycloak -f --tail=100
7982

8083
.PHONY: keycloak-setup-realm
81-
keycloak-setup-realm: ## Setup OpenShift realm with token exchange support
84+
keycloak-setup-realm:
8285
@echo "========================================="
8386
@echo "Setting up OpenShift Realm for Token Exchange"
8487
@echo "========================================="
8588
@echo "Using Keycloak at https://keycloak.127-0-0-1.sslip.io:8443"
8689
@echo ""
8790
@echo "Getting admin access token..."
88-
@TOKEN=$$(curl -sk -X POST "https://keycloak.127-0-0-1.sslip.io:8443/realms/master/protocol/openid-connect/token" \
91+
@RESPONSE=$$(curl -sk -X POST "https://keycloak.127-0-0-1.sslip.io:8443/realms/master/protocol/openid-connect/token" \
8992
-H "Content-Type: application/x-www-form-urlencoded" \
9093
-d "username=$(KEYCLOAK_ADMIN_USER)" \
9194
-d "password=$(KEYCLOAK_ADMIN_PASSWORD)" \
9295
-d "grant_type=password" \
93-
-d "client_id=admin-cli" \
94-
2>/dev/null | jq -r '.access_token // empty'); \
96+
-d "client_id=admin-cli"); \
97+
TOKEN=$$(echo "$$RESPONSE" | jq -r '.access_token // empty' 2>/dev/null); \
9598
if [ -z "$$TOKEN" ] || [ "$$TOKEN" = "null" ]; then \
96-
echo "❌ Failed to get access token. Check if:"; \
99+
echo "❌ Failed to get access token"; \
100+
echo "Response was: $$RESPONSE" | head -c 200; \
101+
echo ""; \
102+
echo "Check if:"; \
97103
echo " - Keycloak is running (make keycloak-install)"; \
98104
echo " - Keycloak is accessible at https://keycloak.127-0-0-1.sslip.io:8443"; \
99105
echo " - Admin credentials are correct: $(KEYCLOAK_ADMIN_USER)/$(KEYCLOAK_ADMIN_PASSWORD)"; \
@@ -373,7 +379,7 @@ keycloak-setup-realm: ## Setup OpenShift realm with token exchange support
373379
fi; \
374380
echo ""; \
375381
echo "Setting up RBAC for mcp user..."; \
376-
kubectl apply -f config/keycloak/rbac.yaml; \
382+
kubectl apply -f dev/config/keycloak/rbac.yaml; \
377383
echo "✅ RBAC binding created for mcp user"; \
378384
echo ""; \
379385
echo "🎉 OpenShift realm setup complete!"; \
@@ -416,11 +422,27 @@ keycloak-setup-realm: ## Setup OpenShift realm with token exchange support
416422
echo " sts_client_secret = \"$$CLIENT_SECRET\""; \
417423
echo " sts_audience = \"openshift\""; \
418424
echo " sts_scopes = [\"mcp:openshift\"]"; \
419-
echo " certificate_authority = \"hack/cert-manager-ca/ca.crt\""; \
425+
echo " certificate_authority = \"_output/cert-manager-ca/ca.crt\""; \
420426
echo "========================================"; \
421427
echo ""; \
422428
echo "Note: The Kubernetes API server is configured with:"; \
423429
echo " --oidc-issuer-url=https://keycloak.127-0-0-1.sslip.io:8443/realms/openshift"; \
424430
echo ""; \
425431
echo "Important: The cert-manager CA certificate was extracted to:"; \
426-
echo " hack/cert-manager-ca/ca.crt"
432+
echo " _output/cert-manager-ca/ca.crt"; \
433+
echo ""; \
434+
echo "Writing configuration to _output/config.toml..."; \
435+
mkdir -p _output; \
436+
printf '%s\n' \
437+
'require_oauth = true' \
438+
'oauth_audience = "mcp-server"' \
439+
'oauth_scopes = ["openid", "mcp-server"]' \
440+
'validate_token = false' \
441+
'authorization_url = "https://keycloak.127-0-0-1.sslip.io:8443/realms/openshift"' \
442+
'sts_client_id = "mcp-server"' \
443+
"sts_client_secret = \"$$CLIENT_SECRET\"" \
444+
'sts_audience = "openshift"' \
445+
'sts_scopes = ["mcp:openshift"]' \
446+
'certificate_authority = "_output/cert-manager-ca/ca.crt"' \
447+
> _output/config.toml; \
448+
echo "✅ Configuration written to _output/config.toml"

build/kind.mk

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ KIND_CLUSTER_NAME ?= kubernetes-mcp-server
66
CONTAINER_ENGINE ?= $(shell command -v docker 2>/dev/null || command -v podman 2>/dev/null)
77

88
.PHONY: kind-create-certs
9-
kind-create-certs: ## Generate placeholder CA certificate for KIND bind mount
10-
@if [ ! -f hack/cert-manager-ca/ca.crt ]; then \
9+
kind-create-certs:
10+
@if [ ! -f _output/cert-manager-ca/ca.crt ]; then \
1111
echo "Creating placeholder CA certificate for bind mount..."; \
1212
./hack/generate-placeholder-ca.sh; \
1313
else \
1414
echo "✅ Placeholder CA already exists"; \
1515
fi
1616

1717
.PHONY: kind-create-cluster
18-
kind-create-cluster: kind kind-create-certs ## Create the kind cluster for development
18+
kind-create-cluster: kind kind-create-certs
1919
@# Set KIND provider for podman on Linux
2020
@if [ "$(shell uname -s)" != "Darwin" ] && echo "$(CONTAINER_ENGINE)" | grep -q "podman"; then \
2121
export KIND_EXPERIMENTAL_PROVIDER=podman; \
@@ -24,11 +24,11 @@ kind-create-cluster: kind kind-create-certs ## Create the kind cluster for devel
2424
echo "Kind cluster '$(KIND_CLUSTER_NAME)' already exists, skipping creation"; \
2525
else \
2626
echo "Creating Kind cluster '$(KIND_CLUSTER_NAME)'..."; \
27-
$(KIND) create cluster --name $(KIND_CLUSTER_NAME) --config config/kind/cluster.yaml; \
27+
$(KIND) create cluster --name $(KIND_CLUSTER_NAME) --config dev/config/kind/cluster.yaml; \
2828
echo "Adding ingress-ready label to control-plane node..."; \
2929
kubectl label node $(KIND_CLUSTER_NAME)-control-plane ingress-ready=true --overwrite; \
3030
echo "Installing nginx ingress controller..."; \
31-
kubectl apply -f config/ingress/nginx-ingress.yaml; \
31+
kubectl apply -f dev/config/ingress/nginx-ingress.yaml; \
3232
echo "Waiting for ingress controller to be ready..."; \
3333
kubectl wait --namespace ingress-nginx --for=condition=ready pod --selector=app.kubernetes.io/component=controller --timeout=90s; \
3434
echo "✅ Ingress controller ready"; \
@@ -41,7 +41,7 @@ kind-create-cluster: kind kind-create-certs ## Create the kind cluster for devel
4141
echo "✅ cert-manager ready"; \
4242
echo "Creating cert-manager ClusterIssuer..."; \
4343
sleep 5; \
44-
kubectl apply -f config/cert-manager/selfsigned-issuer.yaml; \
44+
kubectl apply -f dev/config/cert-manager/selfsigned-issuer.yaml; \
4545
echo "✅ ClusterIssuer created"; \
4646
echo "Adding /etc/hosts entry for Keycloak in control plane..."; \
4747
if command -v docker >/dev/null 2>&1 && docker ps --filter "name=$(KIND_CLUSTER_NAME)-control-plane" --format "{{.Names}}" | grep -q "$(KIND_CLUSTER_NAME)-control-plane"; then \
@@ -53,7 +53,7 @@ kind-create-cluster: kind kind-create-certs ## Create the kind cluster for devel
5353
fi
5454

5555
.PHONY: kind-delete-cluster
56-
kind-delete-cluster: kind ## Delete the kind cluster
56+
kind-delete-cluster: kind
5757
@# Set KIND provider for podman on Linux
5858
@if [ "$(shell uname -s)" != "Darwin" ] && echo "$(CONTAINER_ENGINE)" | grep -q "podman"; then \
5959
export KIND_EXPERIMENTAL_PROVIDER=podman; \

build/tools.mk

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ ifeq ($(ARCH),aarch64)
1010
ARCH = arm64
1111
endif
1212

13-
KIND = bin/kind
13+
KIND = _output/bin/kind
1414
KIND_VERSION = v0.30.0
1515
$(KIND):
16-
GOBIN=$(PWD)/bin go install sigs.k8s.io/kind@$(KIND_VERSION)
16+
@mkdir -p _output/bin
17+
GOBIN=$(PWD)/_output/bin go install sigs.k8s.io/kind@$(KIND_VERSION)
1718

1819
.PHONY: kind
1920
kind: $(KIND) ## Download kind locally if necessary
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)