fix: use NodePort for registry — resolvable from node host network
This commit is contained in:
@@ -5,29 +5,18 @@
|
|||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
TAG="${1:-latest}"
|
TAG="${1:-latest}"
|
||||||
# In-cluster address — how the deployment manifest references the image
|
# Use a node IP:NodePort — resolvable from both dev machine and cluster nodes
|
||||||
REGISTRY="registry.registry.svc.cluster.local:5000"
|
REGISTRY="${REGISTRY:-<NODE_IP>:30500}"
|
||||||
IMAGE="$REGISTRY/humor-units:$TAG"
|
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..."
|
echo "==> Building $IMAGE..."
|
||||||
buildah build \
|
buildah build \
|
||||||
--format docker \
|
--format docker \
|
||||||
--tag "$IMAGE" \
|
--tag "$IMAGE" \
|
||||||
"$(dirname "$0")"
|
"$(dirname "$0")"
|
||||||
|
|
||||||
echo "==> Pushing via port-forward (localhost:5000)..."
|
echo "==> Pushing $IMAGE..."
|
||||||
# Push to localhost:5000 (the port-forward tunnel) but with the in-cluster tag.
|
buildah push --tls-verify=false "$IMAGE"
|
||||||
# buildah push accepts a separate destination so we don't retag.
|
|
||||||
buildah push \
|
|
||||||
--tls-verify=false \
|
|
||||||
"$IMAGE" \
|
|
||||||
"docker://localhost:5000/humor-units:$TAG"
|
|
||||||
|
|
||||||
echo "==> Restarting humor-units deployment..."
|
echo "==> Restarting humor-units deployment..."
|
||||||
kubectl rollout restart deployment/humor-units -n default
|
kubectl rollout restart deployment/humor-units -n default
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: humor-units
|
- name: humor-units
|
||||||
image: registry.registry.svc.cluster.local:5000/humor-units:latest
|
image: <NODE_IP>:30500/humor-units:latest
|
||||||
imagePullPolicy: Always
|
imagePullPolicy: Always
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 3000
|
- containerPort: 3000
|
||||||
|
|||||||
@@ -67,9 +67,8 @@ spec:
|
|||||||
ports:
|
ports:
|
||||||
- port: 5000
|
- port: 5000
|
||||||
targetPort: 5000
|
targetPort: 5000
|
||||||
# ClusterIP is fine if you port-forward from dev machine to push.
|
nodePort: 30500
|
||||||
# Change to NodePort or add an Ingress if you want external push access.
|
type: NodePort
|
||||||
type: ClusterIP
|
|
||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Namespace
|
kind: Namespace
|
||||||
|
|||||||
Reference in New Issue
Block a user