Commit Graph
23 Commits
Author SHA1 Message Date
Admin Bot 1dd71de97f refactor: use in-cluster authentication instead of kubeconfig secret
CI / CI (pull_request) Failing after 2m56s
RATIONALE:
Gitea CI runner is running IN-CLUSTER, so we should use Kubernetes' built-in
in-cluster authentication mechanism instead of storing kubeconfig secrets.

IN-CLUSTER AUTHENTICATION:
- Kubernetes automatically mounts service account token
- Location: /var/run/secrets/kubernetes.io/serviceaccount/token
- Location: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
- kubectl automatically detects and uses these
- No need to pass credentials via secrets

CHANGES:
1. Remove KUBECONFIG_B64 secret requirement
2. Add in-cluster auth detection step
3. Update Job to use actual built image (not golang base)
4. Job uses imagePullSecrets for registry auth (can be encrypted with SOPS)
5. Add regcred image pull secret reference

CI FLOW:
  1. Detect in-cluster authentication is available
  2. kubectl commands automatically use mounted service account
  3. No secrets needed in CI env vars
  4. Job applies with RBAC service account
  5. Registry credentials via imagePullSecrets (encrypted with SOPS)

SECURITY:
✓ In-cluster auth is more secure (bound to service account)
✓ No kubeconfig stored in secrets
✓ Sensitive data encrypted with SOPS
✓ Principle of least privilege (service account RBAC)
2026-09-13 13:51:46 +09:00
Admin Bot fa9938df8e refactor: use Kubernetes Job for integration testing instead of manual pod management
CI / CI (pull_request) Failing after 2m56s
RATIONALE:
The Kubernetes way to run integration tests is via Jobs, not manual pod management.
Jobs are simpler, more idiomatic, and handle all the complexity for us.

CHANGES:
- Remove manual: kubectl run, kubectl wait, kubectl exec
- Use Kubernetes Job (already defined in k8s/integration-test-job.yaml)
- Job handles: pod creation, retry, cleanup, status reporting
- CI only does: apply job, set image, wait, check status

SIMPLIFIED CI FLOW:
  1. go vet + go test (unit tests)
  2. Build image: api-gateway:<sha>
  3. Push: <sha> tag only
  4. Apply Job from k8s/integration-test-job.yaml
  5. Set job image to new build
  6. Wait for job completion
  7. Get logs
  8. Check job status
  9. Promote to latest (if job succeeded)
  10. Cleanup job

BENEFITS:
 More idiomatic (Kubernetes Job is the standard way)
 Simpler CI workflow (fewer manual steps)
 Job handles retries, backoff, cleanup automatically
 Better status reporting
 Declarative (job spec in git, not imperative in CI)
 Easier to test locally (just kubectl apply -f k8s/integration-test-job.yaml)

WHAT KUBERNETES JOB HANDLES:
✓ Pod creation and lifecycle
✓ Restart policy and retries
✓ Cleanup on completion
✓ Status tracking
✓ Log aggregation
✓ Resource limits
2026-09-13 13:47:02 +09:00
Admin Bot a700ac065b fix: remove kubectl installation, assume available in runner
CI / CI (pull_request) Failing after 3m6s
OPTIMIZATIONS:
- Remove curl-based kubectl installation (inefficient)
- Assume kubectl is available in Gitea runner environment
- Replace port-forward with kubectl exec for test execution
- Tests now run directly inside test pod (not from runner)
- Simpler, faster, more reliable

CI Flow:
  1. go vet + go test (unit tests)
  2. Build image: api-gateway:<sha>
  3. Push: <sha> tag only
  4. Deploy test pod with proper labels
  5. kubectl exec into pod to run tests
  6. Tests run inside pod, can reach services via network policy
  7. Promote to latest only if tests pass
  8. Cleanup test pod
2026-09-13 13:44:15 +09:00
Admin Bot e0622449cc fix: ensure test pod can reach all downstream services
CI / CI (pull_request) Failing after 2m58s
Add labels to test pod to match network policy selectors:
- app=api-gateway (matches network policy pod selector)
- managed-by=argocd (matches network policy pod selector)
- role=test (identify as test pod)
- test-run=<sha> (track which test run spawned it)

Network policy 'api-gateway' in api namespace already allows egress to:
 kube-system (DNS resolution)
 poimen (port 8080 - Memory service)
 temporal (port 7233 - Workflow service)
 storage (ports 80, 9000 - S3/MinIO)
 sqs (port 9090 - SQS service)
 iam (ports 9000, 9443 - Authentik/IAM)

Test pod inherits same network access as production pods via labels.
No additional network policies needed.
2026-09-13 11:48:04 +09:00
Admin Bot 52c36e587b feat: proper CI/CD workflow with integration testing
BREAKING CHANGE: CI now requires kubeconfig to run integration tests

Changes:
- Build image with commit SHA tag (NOT latest yet)
- Deploy dedicated test pod from new image
- Run full integration test suite against test pod
- Only promote to latest tag AFTER tests pass
- Cleanup test pod after run

CI/CD Flow:
  1. go vet + go test (unit tests)
  2. Build image: api-gateway:<sha>
  3. Push to registry
  4. Deploy test pod with <sha> image
  5. Run integration tests (memory, S3, SQS, workflow, IAM, health)
  6. If tests pass: tag as latest and push
  7. If tests fail: keep <sha> tag, don't promote to latest
  8. Cleanup test pod

This ensures:
- New code is tested in cluster before production deployment
- ArgoCD only pulls latest after tests pass
- Failed builds don't get promoted to production
- Full test coverage of all adapters

Requires: KUBECONFIG_B64 secret in Gitea for cluster access
2026-09-13 11:46:46 +09:00
Admin Bot 0943df8a42 feat: add comprehensive integration tests and CI pipeline
CI / CI (push) Failing after 5m44s
Add integration test suite that tests against production cluster:
- Memory service (ingest, query)
- S3 adapter (list, put objects)
- SQS adapter (list queues with auth enforcement)
- Workflow adapter (gRPC ListWorkflowExecutions)
- IAM adapter (list users)
- Health endpoints (liveness, readiness)

Update CI/CD pipeline:
- Build new docker image from commit
- Push to registry with commit SHA and latest tags
- Deploy test job to cluster to run integration tests
- Tests run against actual production services
- Cleanup test resources after completion

Add Kubernetes Job manifest:
- Runs integration tests in dedicated pod
- Waits for gateway to be ready before testing
- Tests all adapters and downstream services
- Can be run manually: kubectl apply -f k8s/integration-test-job.yaml
2026-09-13 11:42:55 +09:00
rockandAdmin Bot 0605754445 ci: unified workflow - single job, DOCKER_HOST, build+push on all events (#4)
- Single job (no split test/build-push)
- DOCKER_HOST=tcp://localhost:2375 for dind
- Build + push on PRs too (verify before merge)
- workflow_dispatch for manual trigger

---------

Co-authored-by: Admin Bot <[email protected]>
Reviewed-on: rock/homelab-frontend#4
2026-09-07 21:01:02 +00:00
rockandAdmin Bot fbcb8989cd fix: use env vars for docker registry credentials (#2)
Fix registry login by passing FORGEJO_REGISTRY_USER and FORGEJO_REGISTRY_TOKEN via environment variables instead of direct secret interpolation.

Uses the proven pattern from riotpiao.com reference commit.

This prevents credentials from being exposed in logs or shell history while keeping the standard docker login approach.

After merge + org-level secrets configured:
- All repos inherit FORGEJO_REGISTRY_USER and FORGEJO_REGISTRY_TOKEN
- CI validates credentials exist before docker login
- Image pushed to registry on main push

---------

Co-authored-by: Admin Bot <[email protected]>
Reviewed-on: rock/homelab-frontend#2
2026-09-07 06:50:48 +00:00
Admin Bot a23f5b3f31 fix: remove container override, install deps in workflow steps
Container override breaks docker socket access to dind sidecar.

Changes:
- Remove 'container: image: golang:1.26-bookworm'
- Install Node.js before checkout (required by actions runtime)
- Install docker.io in build step (required for docker build/push)

Now works with shared docker socket via dind sidecar.
2026-09-06 22:49:59 -07:00
Admin Bot 4effbf47bc ci: fix docker dind access, remove container override
Problem: Push job used docker:27-cli override with explicit dind cert
mounting, but runner base changed to code.forgejo.org/forgejo/runner:6.
Alpine container couldn't access Debian runner's dind socket paths.

Fix:
- Remove container override, run on golang runner natively
- Install docker.io directly in push step (apt-get)
- Add docker image prune post-action to cleanup

This pattern matches riotpiao.com CI and works with current runner setup.
2026-09-06 05:55:54 -07:00
Admin Bot 9c5fb0ce84 feat: load service adapters from ConfigMap, remove k8s API dependency
CI / Vet, test, build (push) Canceled after 2m10s
CI / Build and push image (push) Canceled after 0s
Adapters defined in config.yaml alongside routes and models.
Parsed by existing config loader, populated into registry at startup.
Removed: client-go deps, REST loader, informer, nginx proxy,
CiliumNetworkPolicy, apis/gateway/v1/ (duplicate types).
Kept: merged CI pipeline, imagePullPolicy Always, CA certs in Dockerfile.
2026-08-26 16:39:30 -07:00
Story Crater Bot abcc6dd4a9 ci(main): tag both SHA and latest during build, push both in one step
Build and push / Build and push image (push) Successful in 28s
Build / Build and push image (push) Successful in 27s
CI / Test, vet, build (push) Successful in 2m18s
2026-08-21 21:00:36 -07:00
Story Crater Bot 9740334d24 ci(main): push latest tag on main commits, auto-deploy via kustomization
Build and push / Build and push image (push) Successful in 29s
Build / Build and push image (push) Successful in 27s
CI / Test, vet, build (push) Successful in 2m17s
2026-08-21 20:56:47 -07:00
Story Crater Bot 0f2cd7565a ci(main): trigger image builds on main branch commits
Build and push / Build and push image (push) Successful in 28s
Build / Build and push image (push) Successful in 26s
CI / Test, vet, build (push) Successful in 2m17s
2026-08-21 20:55:27 -07:00
Story Crater Bot 0fe9de6fbd fix(ci): use universal REGISTRY_PAT secret for Forgejo registry auth
Build (prod) / Build and push image (push) Successful in 34s
2026-08-21 20:52:32 -07:00
Story Crater Bot afcc28fca0 ci(prod): add prod build workflow for image push to Forgejo registry
Build (prod) / Build and push image (push) Failing after 11s
2026-08-21 20:47:02 -07:00
Story Crater Bot b6767e247c fix(deps,ci): update module path to forgejo.riotpiao.com/rock/homelab-frontend, switch to GITHUB_TOKEN
Build / Build and push image (push) Failing after 12s
CI / Test, vet, build (push) Successful in 2m18s
2026-08-21 20:46:45 -07:00
Story Crater Bot 0aaf4116f1 fix(ci): target the golang runner, generic docker runner retired
Build / Build and push image (push) Successful in 1m20s
CI / Test, vet, build (push) Successful in 2m17s
2026-08-21 16:53:05 -07:00
Story Crater Bot 3d63df9ba8 fix(ci): drop ineffective --network host option, runner sets it globally now
Build / Build and push image (push) Failing after 14s
CI / Test, vet, build (push) Failing after 12m47s
2026-08-21 16:14:16 -07:00
Story Crater Bot 7b265b8338 fix(ci): mount /docker-certs/client into the build job container
Build / Build and push image (push) Failing after 13s
CI / Test, vet, build (push) Successful in 1m49s
2026-08-21 15:55:23 -07:00
Story Crater Bot 7ebbf2bd03 fix: install node in job containers so actions/checkout can exec
Build / Build and push image (push) Failing after 15s
CI / Test, vet, build (push) Successful in 1m45s
actions/checkout@v4 is a JS action; Forgejo Actions runs it via node, which
neither golang:1.25-bookworm nor docker:27-cli ship. Every run since the
.gitea/workflows move has failed identically: 'exec: node: executable file
not found in $PATH' during the checkout step, before any real job step ran.

Verified locally against both exact images before pushing:
- golang:1.25-bookworm: apt-get install nodejs ca-certificates git -> node
  v18.20.4, git 2.39.5.
- docker:27-cli: apk add nodejs git -> node v22.23.2, git 2.47.2, and
  actions/checkout's dist/index.js actually executes afterward (confirmed
  by invoking it directly) instead of failing on a missing binary.
- The Dockerfile itself builds clean end to end and the resulting image
  serves /healthz, so checkout was the only remaining blocker in the path.
2026-08-21 13:49:24 -07:00
Story Crater Bot dac1a5da4b fix: move workflows from .forgejo/workflows to .gitea/workflows
Build / Build and push image (push) Failing after 30s
CI / Test, vet, build (push) Failing after 29s
.forgejo/workflows/*.yaml never creates an action_run on push on this
Forgejo instance (1.27.0) -- confirmed directly in the action_run table
across multiple probe pushes. .gitea/workflows fires immediately with an
identical spec. This is why build.yaml never once executed.
2026-08-21 11:36:34 -07:00
Story Crater Bot e71034c3ef test: probe .gitea/workflows path
ProbeGitea / noop (push) Successful in 59s
2026-08-21 11:34:17 -07:00