From 8e739f4077807b879aefcb5f38c1fd43a92d2dd8 Mon Sep 17 00:00:00 2001 From: Falkan Date: Thu, 19 Mar 2026 01:27:16 -0400 Subject: [PATCH] =?UTF-8?q?fix:=20use=20NodePort=20for=20registry=20?= =?UTF-8?q?=E2=80=94=20resolvable=20from=20node=20host=20network?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build-push.sh | 19 ++++--------------- k8s/deployment.yaml | 2 +- k8s/registry.yaml | 5 ++--- 3 files changed, 7 insertions(+), 19 deletions(-) diff --git a/build-push.sh b/build-push.sh index c85c2cf..21a7e4c 100755 --- a/build-push.sh +++ b/build-push.sh @@ -5,29 +5,18 @@ set -euo pipefail TAG="${1:-latest}" -# In-cluster address — how the deployment manifest references the image -REGISTRY="registry.registry.svc.cluster.local:5000" +# Use a node IP:NodePort — resolvable from both dev machine and cluster nodes +REGISTRY="${REGISTRY:-:30500}" IMAGE="$REGISTRY/humor-units:$TAG" -echo "==> Port-forwarding registry (localhost:5000 -> in-cluster registry)..." -kubectl port-forward -n registry svc/registry 5000:5000 & -PF_PID=$! -trap "kill $PF_PID 2>/dev/null" EXIT -sleep 2 - echo "==> Building $IMAGE..." buildah build \ --format docker \ --tag "$IMAGE" \ "$(dirname "$0")" -echo "==> Pushing via port-forward (localhost:5000)..." -# Push to localhost:5000 (the port-forward tunnel) but with the in-cluster tag. -# buildah push accepts a separate destination so we don't retag. -buildah push \ - --tls-verify=false \ - "$IMAGE" \ - "docker://localhost:5000/humor-units:$TAG" +echo "==> Pushing $IMAGE..." +buildah push --tls-verify=false "$IMAGE" echo "==> Restarting humor-units deployment..." kubectl rollout restart deployment/humor-units -n default diff --git a/k8s/deployment.yaml b/k8s/deployment.yaml index ac287f4..ac3487a 100644 --- a/k8s/deployment.yaml +++ b/k8s/deployment.yaml @@ -16,7 +16,7 @@ spec: spec: containers: - name: humor-units - image: registry.registry.svc.cluster.local:5000/humor-units:latest + image: :30500/humor-units:latest imagePullPolicy: Always ports: - containerPort: 3000 diff --git a/k8s/registry.yaml b/k8s/registry.yaml index f78fef0..587e7ac 100644 --- a/k8s/registry.yaml +++ b/k8s/registry.yaml @@ -67,9 +67,8 @@ spec: ports: - port: 5000 targetPort: 5000 - # ClusterIP is fine if you port-forward from dev machine to push. - # Change to NodePort or add an Ingress if you want external push access. - type: ClusterIP + nodePort: 30500 + type: NodePort --- apiVersion: v1 kind: Namespace