Skip to content

Commit c71a97e

Browse files
committed
Integrate mirrord & fake-deps development flow
Add mirrord-based local dev flow and helm-managed fake near-dependencies. Changes include: - Add .mirrord/mirrord.json with targetless mirrord config (network/env/fs features). - Update .devcontainer to install mirrord and add mirrord VS Code / JetBrains extensions. - Update post-create script to install mirrord, update Helm deps path, and update next-step hints. - Makefile: introduce HELM_FAKE, new dev-deps / dev-deps-delete targets to deploy/remove fake services, and switch dev / dev-run to run the API locally via mirrord (dotnet watch/run). - Skaffold: reduce to managing the fake chart (deploy/fake), remove local image artifacts and port-forwarding so skaffold is only used for fake-deps lifecycle. Motivation: allow running the API locally with cluster network access (DNS/services) without deploying the app into Kubernetes; use Helm to manage fake dependencies in the local kind cluster. Recommended flow: make cluster-create && make dev-deps, then make dev.
1 parent cacf761 commit c71a97e

File tree

5 files changed

+68
-49
lines changed

5 files changed

+68
-49
lines changed

.devcontainer/devcontainer.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"plugins": [
1414
"com.intellij.kubernetes",
1515
"org.jetbrains.plugins.yaml",
16-
"Docker"
16+
"Docker",
17+
"com.metalbear.mirrord"
1718
],
1819
"settings": {
1920
"editor.reformat.on.save": true
@@ -32,7 +33,8 @@
3233
"mhutchie.git-graph",
3334
"ms-kubernetes-tools.vscode-kubernetes-tools",
3435
"redhat.vscode-yaml",
35-
"humao.rest-client"
36+
"humao.rest-client",
37+
"metalbear-co.mirrord"
3638
],
3739
"settings": {
3840
"editor.formatOnSave": true,

.devcontainer/post-create.sh

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/bin/sh
22
# Runs once after the dev container is created.
3-
# Installs tools not available as devcontainer features (kind, skaffold)
4-
# and restores .NET packages.
3+
# Installs tools (kind, mirrord) and restores .NET packages.
54
set -eu
65

76
echo ""
@@ -20,14 +19,14 @@ else
2019
echo "→ kind already installed: $(kind version)"
2120
fi
2221

23-
# ── skaffold ─────────────────────────────────────────────────────────────────
24-
if ! command -v skaffold &>/dev/null; then
25-
echo "→ Installing skaffold (latest stable)..."
26-
curl -sSLo /tmp/skaffold "https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-amd64"
27-
chmod +x /tmp/skaffold
28-
sudo mv /tmp/skaffold /usr/local/bin/skaffold
22+
# ── mirrord ───────────────────────────────────────────────────────────────────
23+
# mirrord gives the local process cluster network access (DNS, services)
24+
# without deploying the app into k8s — run `make dev` to start with it.
25+
if ! command -v mirrord &>/dev/null; then
26+
echo "→ Installing mirrord..."
27+
curl -fsSL https://raw.githubusercontent.com/metalbear-co/mirrord/main/scripts/install.sh | bash
2928
else
30-
echo "skaffold already installed: $(skaffold version)"
29+
echo "mirrord already installed: $(mirrord --version)"
3130
fi
3231

3332
# ── .NET restore ──────────────────────────────────────────────────────────────
@@ -53,12 +52,13 @@ helm repo add open-telemetry https://open-telemetry.github.io/opentelemetry-helm
5352
helm repo update
5453

5554
echo "→ Updating Helm chart dependencies..."
56-
helm dependency update charts
55+
helm dependency update deploy/helm
5756

5857
echo ""
5958
echo "✅ Dev container ready!"
6059
echo ""
6160
echo " Next steps:"
6261
echo " make cluster-create — create local kind cluster + registry"
63-
echo " make dev — build, deploy & watch (skaffold dev)"
62+
echo " make dev-deps — deploy fake near-dependencies into the cluster"
63+
echo " make dev — run the API locally with cluster network access (mirrord)"
6464
echo ""

.mirrord/mirrord.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/metalbear-co/mirrord/main/mirrord-schema.json",
3+
4+
// Targetless mode: no pod is mirrored. The local process gets cluster
5+
// network access (DNS, services) without stealing traffic from any pod.
6+
// This is the right mode when developing against fake near-dependencies
7+
// deployed into the local kind cluster.
8+
"target": "targetless",
9+
10+
"feature": {
11+
"network": {
12+
// Route outgoing traffic through the cluster so service DNS names
13+
// resolve — e.g. http://team-a-service-fake resolves to the pod in k8s.
14+
"outgoing": true
15+
},
16+
// Inject cluster environment variables into the local process.
17+
// Keeps parity with how the app sees its environment when deployed.
18+
"env": true,
19+
// Use local filesystem — do not mirror cluster pod's filesystem.
20+
"fs": "local"
21+
}
22+
}

Makefile

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ CLUSTER_NAME := service-template
1111
REGISTRY := localhost:5001
1212
IMAGE := $(REGISTRY)/service-template
1313
HELM_CHART := deploy/helm
14+
HELM_FAKE := deploy/fake
1415
HELM_RELEASE := service-template
1516
NAMESPACE := default
1617

@@ -66,17 +67,27 @@ cluster-status: ## Show cluster nodes, registry, and Helm release status
6667
@helm list -n $(NAMESPACE) 2>/dev/null || true
6768

6869
# ── Dev loop ───────────────────────────────────────────────────────────────────
70+
.PHONY: dev-deps
71+
dev-deps: ## Deploy fake near-dependencies into local kind cluster
72+
helm dependency update $(HELM_FAKE)
73+
helm upgrade --install dev-deps $(HELM_FAKE) \
74+
-f $(HELM_FAKE)/values.yaml \
75+
--namespace $(NAMESPACE) \
76+
--wait --timeout 5m
77+
78+
.PHONY: dev-deps-delete
79+
dev-deps-delete: ## Remove fake near-dependencies from local cluster
80+
helm uninstall dev-deps --namespace $(NAMESPACE) 2>/dev/null || true
81+
6982
.PHONY: dev
70-
dev: ## Build, deploy and watch for changes (skaffold dev + port-forward :8080)
71-
skaffold dev --port-forward
83+
dev: ## Run the API locally with cluster network access via mirrord (requires: make cluster-create && make dev-deps)
84+
mirrord exec --config .mirrord/mirrord.json -- \
85+
dotnet watch run --project $(SRC_API) --launch-profile Development
7286

7387
.PHONY: dev-run
74-
dev-run: ## One-shot build and deploy (no file watching)
75-
skaffold run --port-forward
76-
77-
.PHONY: dev-delete
78-
dev-delete: ## Remove the skaffold-managed release from the cluster
79-
skaffold delete
88+
dev-run: ## One-shot run without file watching
89+
mirrord exec --config .mirrord/mirrord.json -- \
90+
dotnet run --project $(SRC_API) --launch-profile Development
8091

8192
# ── Build ──────────────────────────────────────────────────────────────────────
8293
.PHONY: build

skaffold.yaml

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,26 @@ kind: Config
33
metadata:
44
name: service-template
55

6+
# The app runs locally via `make dev` (mirrord + dotnet watch).
7+
# Skaffold is used only to manage the fake near-dependency lifecycle in the
8+
# local kind cluster. Run `make dev-deps` instead for simpler helm-only usage.
9+
610
build:
7-
artifacts:
8-
- image: localhost:5001/service-template
9-
docker:
10-
dockerfile: Dockerfile
11-
buildArgs:
12-
VERSION: dev
13-
local:
14-
push: true
15-
useDockerCLI: true
11+
artifacts: []
1612

1713
deploy:
1814
helm:
1915
releases:
20-
- name: service-template
21-
chartPath: deploy/helm
16+
- name: dev-deps
17+
chartPath: deploy/fake
2218
valuesFiles:
23-
- deploy/helm/values.yaml
24-
- values.local.yaml
25-
# Skaffold injects the built image tag by matching image.repository in values.local.yaml
26-
# against the artifact image name above. The tag is set automatically on each build.
27-
setValueTemplates:
28-
image.repository: "{{.IMAGE_REPO_localhost_5001_service_template}}"
29-
image.tag: "{{.IMAGE_TAG_localhost_5001_service_template}}"
19+
- deploy/fake/values.yaml
3020
wait: true
31-
skipBuildDependencies: true # dependencies already updated via 'make helm-deps'
21+
skipBuildDependencies: false
3222
flags:
3323
install: ["--timeout=5m", "--atomic"]
3424
upgrade: ["--timeout=5m", "--atomic", "--cleanup-on-fail"]
3525

36-
# Port-forward the app to localhost:8080 while 'skaffold dev' is running.
37-
# Skaffold cleans this up automatically on exit (Ctrl+C).
38-
portForward:
39-
- resourceType: service
40-
resourceName: service-template
41-
namespace: default
42-
port: 80
43-
localPort: 8080
44-
address: 0.0.0.0
26+
# Port-forward fake services for tools that need localhost access (e.g. tests
27+
# running outside mirrord). Adjust ports to match deploy/fake/values.yaml.
28+
portForward: []

0 commit comments

Comments
 (0)