cluster: migrate registry from host container to in-cluster deployment - #3856
cluster: migrate registry from host container to in-cluster deployment#3856lkingland wants to merge 5 commits into
Conversation
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: lkingland The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
f96a48b to
0470fa1
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3856 +/- ##
==========================================
+ Coverage 53.43% 53.48% +0.05%
==========================================
Files 200 200
Lines 23405 23381 -24
==========================================
- Hits 12506 12505 -1
+ Misses 9649 9626 -23
Partials 1250 1250
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
|
||
| if err := ensureRegistry(ctx, cfg, out); err != nil { | ||
| return err | ||
| registryManifest := `apiVersion: apps/v1 |
There was a problem hiding this comment.
possible improvement: make this Go struct instead of string literal.
There was a problem hiding this comment.
🤖 Done in 47c768b — Deployment/Service/Ingress/ConfigMap are typed k8s objects marshaled to YAML; same apply path.
| return fmt.Errorf("applying registry service: %w", err) | ||
| } | ||
|
|
||
| success(out, "Registry", time.Since(start)) |
There was a problem hiding this comment.
potential improvement: we could wait until http://registry.localtest.me/v2/ returns 200.
There was a problem hiding this comment.
🤖 Done in ed43102 — poll until /v2/ returns 200. Uses http://127.0.0.1:5000 (hostPort) rather than registry.localtest.me because Contour installs in parallel with the registry goroutine; hostPort is ready with the Deployment and matches the containerd mirror endpoint.
| // installRegistry deploys the container registry as in-cluster Kubernetes | ||
| // resources (Deployment + ClusterIP Service + Contour Ingress), configures | ||
| // host-side trust, and applies the local-registry-hosting ConfigMap. | ||
| func installRegistry(ctx context.Context, cfg ClusterConfig, out io.Writer) error { |
There was a problem hiding this comment.
Not sure when/how installRegistry() is called but it preferably should be called after Contour installation (or in parallel to it). But it's not necessary.
There was a problem hiding this comment.
But it's not necessary.
Because we use generic k8s ingress not some specific Contour resource.
There was a problem hiding this comment.
🤖 Agreed — leaving order as-is (generic Ingress; Contour still parallel). No change.
|
unrelated to this PR: why we use |
0470fa1 to
05b13f2
Compare
Exactly right! This is simply a stepping-stone. Translating script->Go code with this structure is much less error-prone. Next step is to replace the exec's with code wherever possible! Same way we did with the builders: wrap the cli, get it working, replace with the stdlib 👍🏻 |
|
/retest |
gauron99
left a comment
There was a problem hiding this comment.
note from AI: stale comment incmd/cluster.go -> Deletes a local development cluster and its associated registry container 😁
Replace the shared host-side func-registry container with Kubernetes-native resources deployed inside each Kind cluster: - Deployment (registry:2 with hostPort 5000 + emptyDir volume) - ClusterIP Service (port 5000) - Contour Ingress at registry.localtest.me Key changes: - registryAddr is now "registry.localtest.me" (was "localhost:50000") - containerd mirrors point at http://localhost:5000 via hostPort (was http://func-registry:5000 via Docker network DNS) - Each cluster owns its own registry, destroyed with kind delete cluster - Delete flow simplified: no shared container teardown, just host trust revert on last-cluster removal - Removed: ensureRegistry, registryStatus, teardownRegistry, setupPodmanMacOSForwarding, and all host-container lifecycle code
Help still said "registry container" (host-side lifecycle). Match the in-cluster Deployment model: Kind removes the registry with the cluster; host trust reverts only on last func-managed cluster. Functions#43 / knative#3856
05b13f2 to
f5a260a
Compare
Replace YAML string literals for the in-cluster registry Deployment, Service, Ingress, and local-registry-hosting ConfigMap with typed k8s API objects marshaled via sigs.k8s.io/yaml. Same resources; apply path unchanged (kubectl apply -f -). Addresses matejvasek review on knative#3856. Functions#43
Poll http://127.0.0.1:5000/v2/ until 200 (hostPort path) before create returns, so the first push is less likely to race an unready registry. Uses hostPort rather than registry.localtest.me because Contour installs in parallel with the registry goroutine. Addresses matejvasek review on knative#3856. Functions#43
|
🤖 @matejvasek re your note on exec vs Go APIs: agreed this PR stays on the script→Go stepping-stone. Follow-up for kind/kubectl/docker library calls: #3964 |
Used by pkg/cluster for typed registry manifest marshaling. Satisfies hack/update-codegen / verify-deps which require direct deps in go.mod. Functions#43 / knative#3856
Summary
Migrates
func cluster createfrom running a standalonefunc-registrycontainer on the host to deploying the registry as in-cluster Kubernetes resources, matching the approach already taken inhack/cluster.sh(PR #3718).What changed:
docker runcontainer with ExternalName Service)registryAddrisregistry.localtest.me(waslocalhost:50000)http://localhost:5000via hostPort (washttp://func-registry:5000via Docker network DNS)kind delete clusterensureRegistry,registryStatus,teardownRegistry,setupPodmanMacOSForwarding, and all host-container lifecycle constantsWhat's preserved:
daemon.json/ Podmanregistries.conf) — now usesregistry.localtest.me--skip-registry-configflag behavior unchanged