From cb470338382cafcac1c564e975ee8cf8c33704a9 Mon Sep 17 00:00:00 2001 From: Anupam Kumar Date: Tue, 14 Apr 2026 16:44:57 +0530 Subject: [PATCH 1/3] fix(dev): use NC_INSTANCE_URL in all the places Signed-off-by: Anupam Kumar --- development/redeploy_host_k8s.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/development/redeploy_host_k8s.sh b/development/redeploy_host_k8s.sh index f8da05e..0b893bb 100755 --- a/development/redeploy_host_k8s.sh +++ b/development/redeploy_host_k8s.sh @@ -48,10 +48,10 @@ PROXY_IP=$(docker inspect master-proxy-1 \ --format "{{(index .NetworkSettings.Networks \"$NC_DOCKER_NETWORK\").IPAddress}}" 2>/dev/null || true) K8S_HOST_ALIASES="" if [ -n "$PROXY_IP" ]; then - K8S_HOST_ALIASES="nextcloud.local:${PROXY_IP}" - echo " nextcloud.local -> $PROXY_IP" + K8S_HOST_ALIASES="${NC_HOSTNAME}:${PROXY_IP}" + echo " ${NC_HOSTNAME} -> $PROXY_IP" else - echo " WARNING: Could not detect proxy IP. ExApp pods may not resolve nextcloud.local." + echo " WARNING: Could not detect proxy IP. ExApp pods may not resolve ${NC_HOSTNAME}." fi echo "==> Removing old HaRP container..." From a4ad02aae76bca7a497fab421dd186d556ccfa43 Mon Sep 17 00:00:00 2001 From: Anupam Kumar Date: Tue, 14 Apr 2026 16:45:34 +0530 Subject: [PATCH 2/3] fix(dev): use kind container's gateway IP instead of NC's proxy IP This skips the addition of master_default (NC's network) to the kind container and uses the host network for pod -> NC communication. All other communication takes place in host so it would be consistent, and make development easier. Signed-off-by: Anupam Kumar --- development/redeploy_host_k8s.sh | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/development/redeploy_host_k8s.sh b/development/redeploy_host_k8s.sh index 0b893bb..d328416 100755 --- a/development/redeploy_host_k8s.sh +++ b/development/redeploy_host_k8s.sh @@ -32,24 +32,17 @@ echo "==> Generating fresh bearer token for SA '$K8S_SA' (valid 1 year)..." K8S_BEARER_TOKEN=$(kubectl --context "$K8S_CONTEXT" -n "$K8S_NAMESPACE" create token "$K8S_SA" --duration=8760h) echo " Token generated (${#K8S_BEARER_TOKEN} chars)" -# ── Ensure kind node can reach the Nextcloud Docker network ─────────── -echo "==> Connecting kind node '$KIND_NODE' to Docker network '$NC_DOCKER_NETWORK'..." -if docker network connect "$NC_DOCKER_NETWORK" "$KIND_NODE" 2>/dev/null; then - echo " Connected." -else - echo " Already connected (or network not found)." -fi - -# Detect the nginx proxy IP on NC_DOCKER_NETWORK for pod DNS resolution. +# Extract the kind container's gateway IP for pod DNS resolution. # Pods inside the kind cluster cannot resolve hostnames like "nextcloud.local" that only exist in the host's /etc/hosts. -# Try to inject hostAliases so that ExApp pods can reach Nextcloud. +# Try to inject hostAliases so that ExApp pods can reach Nextcloud on the host network. echo "==> Detecting nginx proxy IP for host aliases..." -PROXY_IP=$(docker inspect master-proxy-1 \ - --format "{{(index .NetworkSettings.Networks \"$NC_DOCKER_NETWORK\").IPAddress}}" 2>/dev/null || true) +KIND_HOST_IP=$(docker inspect nc-exapps-control-plane \ + --format "{{(index .NetworkSettings.Networks \"kind\").Gateway}}" 2>/dev/null || true) +NC_HOSTNAME="$(echo $NC_INSTANCE_URL | awk -F[/:] '{print $4}')" K8S_HOST_ALIASES="" -if [ -n "$PROXY_IP" ]; then - K8S_HOST_ALIASES="${NC_HOSTNAME}:${PROXY_IP}" - echo " ${NC_HOSTNAME} -> $PROXY_IP" +if [ -n "$KIND_HOST_IP" ]; then + K8S_HOST_ALIASES="${NC_HOSTNAME}:${KIND_HOST_IP}" + echo " ${NC_HOSTNAME} -> $KIND_HOST_IP" else echo " WARNING: Could not detect proxy IP. ExApp pods may not resolve ${NC_HOSTNAME}." fi From 07098e6163eeed662550eba33023529827068dab Mon Sep 17 00:00:00 2001 From: Oleksandr Piskun Date: Fri, 25 Sep 2026 13:31:55 +0000 Subject: [PATCH 3/3] fix(dev): use KIND_NODE, fix messages, warn when pods cannot reach Nextcloud Signed-off-by: Oleksandr Piskun --- development/redeploy_host_k8s.sh | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/development/redeploy_host_k8s.sh b/development/redeploy_host_k8s.sh index d328416..b3a9666 100755 --- a/development/redeploy_host_k8s.sh +++ b/development/redeploy_host_k8s.sh @@ -5,10 +5,11 @@ # Redeploy HaRP with Kubernetes backend for local development. # # Prerequisites: -# - kind cluster "nc-exapps" running (see docs/kubernetes-local-setup.md) +# - kind cluster "nc-exapps" running # - kubectl context set to kind-nc-exapps -# - Nextcloud Docker-Dev running with nginx proxy -# - nginx vhost configured to proxy /exapps/ to HaRP (see docs) +# - Nextcloud Docker-Dev running with nginx proxy, published on all host interfaces +# (IP_BIND=0.0.0.0 in its .env; with the default 127.0.0.1 ExApp pods cannot reach it) +# - nginx vhost configured to proxy /exapps/ to HaRP (see README) set -e @@ -18,7 +19,6 @@ KIND_NODE="${KIND_CLUSTER}-control-plane" K8S_CONTEXT="kind-${KIND_CLUSTER}" K8S_NAMESPACE="nextcloud-exapps" K8S_SA="harp-exapps" -NC_DOCKER_NETWORK="master_default" HP_SHARED_KEY="some_very_secure_password" NC_INSTANCE_URL="http://nextcloud.local" @@ -32,19 +32,28 @@ echo "==> Generating fresh bearer token for SA '$K8S_SA' (valid 1 year)..." K8S_BEARER_TOKEN=$(kubectl --context "$K8S_CONTEXT" -n "$K8S_NAMESPACE" create token "$K8S_SA" --duration=8760h) echo " Token generated (${#K8S_BEARER_TOKEN} chars)" -# Extract the kind container's gateway IP for pod DNS resolution. +# Detect the gateway IP of the kind Docker network for pod DNS resolution. # Pods inside the kind cluster cannot resolve hostnames like "nextcloud.local" that only exist in the host's /etc/hosts. -# Try to inject hostAliases so that ExApp pods can reach Nextcloud on the host network. -echo "==> Detecting nginx proxy IP for host aliases..." -KIND_HOST_IP=$(docker inspect nc-exapps-control-plane \ +# The gateway is the host itself, so an alias to it lets ExApp pods reach Nextcloud through the ports the nginx proxy +# publishes on all interfaces (a proxy bound to 127.0.0.1 only is not reachable this way). +echo "==> Detecting the kind gateway IP for host aliases..." +KIND_HOST_IP=$(docker inspect "$KIND_NODE" \ --format "{{(index .NetworkSettings.Networks \"kind\").Gateway}}" 2>/dev/null || true) -NC_HOSTNAME="$(echo $NC_INSTANCE_URL | awk -F[/:] '{print $4}')" +NC_HOSTNAME="$(echo "$NC_INSTANCE_URL" | awk -F'[/:]' '{print $4}')" K8S_HOST_ALIASES="" -if [ -n "$KIND_HOST_IP" ]; then +if [ -z "$NC_HOSTNAME" ]; then + echo " WARNING: Could not extract a hostname from NC_INSTANCE_URL='$NC_INSTANCE_URL'." +elif [ "${NC_HOSTNAME#*[!0-9.]}" = "$NC_HOSTNAME" ]; then + echo " ${NC_HOSTNAME} is an IP address, no host alias needed." +elif [ -n "$KIND_HOST_IP" ]; then K8S_HOST_ALIASES="${NC_HOSTNAME}:${KIND_HOST_IP}" echo " ${NC_HOSTNAME} -> $KIND_HOST_IP" + if ! docker exec "$KIND_NODE" curl -fsSk -m 5 -o /dev/null \ + --connect-to "${NC_HOSTNAME}::${KIND_HOST_IP}:" "${NC_INSTANCE_URL%/}/status.php"; then + echo " WARNING: Nextcloud did not answer on $KIND_HOST_IP from the kind node. Is the proxy published on all interfaces (IP_BIND=0.0.0.0)?" + fi else - echo " WARNING: Could not detect proxy IP. ExApp pods may not resolve ${NC_HOSTNAME}." + echo " WARNING: Could not detect the kind gateway IP. ExApp pods may not resolve ${NC_HOSTNAME}." fi echo "==> Removing old HaRP container..."