Skip to content

Commit 496d8b4

Browse files
authored
Fix dev-gitea svc not ready failure (#345)
Signed-off-by: Fiachra Corcoran <fiachra.corcoran@est.tech>
1 parent b94696b commit 496d8b4

5 files changed

Lines changed: 24 additions & 53 deletions

File tree

deployments/local/replace-gitea-service-ports.yaml

Lines changed: 0 additions & 21 deletions
This file was deleted.

scripts/install-dev-gitea-setup.sh

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -52,23 +52,9 @@ else
5252
kpt fn eval \
5353
--image ghcr.io/kptdev/krm-functions-catalog/set-annotations:v0.1.4 \
5454
--match-kind Service \
55-
--match-name gitea \
55+
--match-name gitea-lb \
5656
--match-namespace gitea \
5757
-- "metallb.universe.tf/loadBalancerIPs=${gitea_ip}"
58-
59-
cp -f "${git_root}/deployments/local/kind_porch_test_cluster.yaml" cluster-config.yaml
60-
61-
# Append KRM metadata to the cluster-config
62-
cat >> cluster-config.yaml <<EOF
63-
metadata:
64-
name: not-used
65-
annotations:
66-
config.kubernetes.io/local-config: "true"
67-
EOF
68-
69-
kpt fn eval \
70-
--image ghcr.io/kptdev/krm-functions-catalog/apply-replacements:v0.1.1 \
71-
--fn-config "${git_root}/deployments/local/replace-gitea-service-ports.yaml"
7258
fi
7359

7460
kpt fn render
@@ -80,10 +66,10 @@ kubectl wait pod --all --for=condition=Ready --namespace=gitea --timeout=90s
8066
###############################################################
8167

8268
h1 Create git repos in gitea
83-
curl -v -k -H "content-type: application/json" "http://nephio:secret@localhost:3000/api/v1/user/repos" --data "{\"name\":\"$git_repo_name\"}"
69+
curl -v -k -H "content-type: application/json" "http://nephio:secret@${gitea_ip}:3000/api/v1/user/repos" --data "{\"name\":\"$git_repo_name\"}"
8470
TMP_DIR=$(mktemp -d)
8571
cd "$TMP_DIR"
86-
git clone "http://nephio:secret@localhost:3000/nephio/$git_repo_name.git"
72+
git clone "http://nephio:secret@${gitea_ip}:3000/nephio/$git_repo_name.git"
8773
cd "$git_repo_name"
8874
if ! git rev-parse -q --verify refs/remotes/origin/main >/dev/null; then
8975
echo "Add main branch to git repo:"
@@ -100,15 +86,15 @@ cd "${git_root}"
10086
rm -fr "$TMP_DIR"
10187

10288
test_git_repo_name="test-blueprints"
103-
curl -v -k -H "content-type: application/json" "http://nephio:secret@localhost:3000/api/v1/user/repos" --data "{\"name\":\"$test_git_repo_name\"}"
89+
curl -v -k -H "content-type: application/json" "http://nephio:secret@${gitea_ip}:3000/api/v1/user/repos" --data "{\"name\":\"$test_git_repo_name\"}"
10490
TMP_DIR=$(mktemp -d)
10591
cd "$TMP_DIR"
10692
git clone "${git_root}/test/pkgs/test-pkgs/test-blueprints.bundle" -b main
10793
cd "$test_git_repo_name"
10894

10995
git gc
11096
git remote rename origin upstream
111-
git remote add origin "http://nephio:secret@localhost:3000/nephio/$test_git_repo_name"
97+
git remote add origin "http://nephio:secret@${gitea_ip}:3000/nephio/$test_git_repo_name"
11298
git push -u origin --all
11399
git push -u origin --tags
114100

scripts/setup-dev-env.sh

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ set -o pipefail # Check errors in piped commands
2020
self_dir="$(dirname "$(readlink -f "$0")")"
2121

2222
porch_cluster_name=${PORCH_TEST_CLUSTER:-porch-test}
23-
git_repo_name="$porch_cluster_name"
24-
gitea_ip=172.18.255.200 # should be from the address range in deployments/local/metallb-conf.yaml
2523

2624
git_root="$(readlink -f "${self_dir}/..")"
2725
cd "${git_root}"
@@ -60,18 +58,24 @@ kind export kubeconfig --name="$porch_cluster_name"
6058

6159
##############################################
6260
h1 Install MetalLB
63-
kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.14.9/config/manifests/metallb-native.yaml
64-
sleep 1
65-
echo "Waiting for controller to become ready..."
66-
kubectl wait --namespace metallb-system deploy controller \
67-
--for=condition=available \
68-
--timeout=90s
69-
kubectl apply -f "${git_root}/deployments/local/metallb-conf.yaml"
61+
if ! kubectl get namespace metallb-system >/dev/null 2>&1; then
62+
kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.14.9/config/manifests/metallb-native.yaml
63+
sleep 1
64+
echo "Waiting for controller to become ready..."
65+
kubectl wait --namespace metallb-system deploy controller \
66+
--for=condition=available \
67+
--timeout=90s
68+
kubectl apply -f "${git_root}/deployments/local/metallb-conf.yaml"
69+
else
70+
echo "MetalLB already installed"
71+
fi
7072

7173
############################################
7274
# Install gitea and setup test repos
7375
cd "${git_root}"
74-
./scripts/install-dev-gitea-setup.sh $git_repo_name $gitea_ip
76+
# Extract first IP from MetalLB address range
77+
gitea_ip=$(grep -A1 "addresses:" "${git_root}/deployments/local/metallb-conf.yaml" | grep -o "[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+" | head -1)
78+
./scripts/install-dev-gitea-setup.sh $porch_cluster_name $gitea_ip
7579

7680
############################################
7781
h1 Generate certs and keys

test/pkgs/gitea-dev/deployment.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,13 @@ spec:
164164
timeoutSeconds: 1
165165
readinessProbe:
166166
failureThreshold: 3
167-
initialDelaySeconds: 5
167+
initialDelaySeconds: 30
168168
periodSeconds: 10
169169
successThreshold: 1
170-
tcpSocket:
170+
httpGet:
171+
path: /api/v1/version
171172
port: http
172-
timeoutSeconds: 1
173+
timeoutSeconds: 5
173174
resources: {}
174175
securityContext: {}
175176
volumeMounts:

test/pkgs/gitea-dev/service-lb.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ spec:
1818
- name: http
1919
port: 3000
2020
targetPort: 3000
21+
nodePort: 30000 # Should match the gitea nodes.extraPortMappings.containerPort on the Kind cluster
2122
selector:
2223
app.kubernetes.io/name: gitea
2324
app.kubernetes.io/instance: gitea

0 commit comments

Comments
 (0)