Skip to content

Conversation

@p-se
Copy link
Contributor

@p-se p-se commented Oct 29, 2025

Fixes dev/setup-rancher-clusters where public_hostname may end up
being without IP address.

E.g.

+ upstream_ctx=k3d-upstream
+ downstream_ctx=k3d-downstream1
+ rancherpassword=rancherpassword
+ public_hostname=
+ '[' -z '' ']'
+ kubectl get service -n kube-system traefik -o 'jsonpath={.status.loadBalancer.ingress[0].ip}'
Error from server (NotFound): services "traefik" not found
+ sleep 3
+ kubectl get service -n kube-system traefik -o 'jsonpath={.status.loadBalancer.ingress[0].ip}'
Error from server (NotFound): services "traefik" not found
+ sleep 3
+ kubectl get service -n kube-system traefik -o 'jsonpath={.status.loadBalancer.ingress[0].ip}'
Error from server (NotFound): services "traefik" not found
+ sleep 3
+ kubectl get service -n kube-system traefik -o 'jsonpath={.status.loadBalancer.ingress[0].ip}'
++ kubectl get service -n kube-system traefik -o 'jsonpath={.status.loadBalancer.ingress[0].ip}'
+ ip=
+ public_hostname=.sslip.io

Also try again if getting a login token failed for registering a downstream cluster as shown below:

+ public_hostname=172.18.0.2.sslip.io
+ ./.github/scripts/register-downstream-clusters.sh
+ public_hostname=172.18.0.2.sslip.io
+ cluster_downstream=k3d-downstream1
++ kubectl config current-context
+ ctx=k3d-upstream
+ command -v rancher-cli
+ command -v rancher
+ rancher_cli=rancher
++ kubectl get secret --namespace cattle-system bootstrap-secret -o 'go-template={{.data.bootstrapPassword|base64decode}}'
+ rancherpassword=rancherpassword
++ curl -k -s -X POST 'https://172.18.0.2.sslip.io/v3-public/localProviders/local?action=login' -H 'Content-Type: application/json' -d '{"username":"admin","password":"ranc
herpassword"}'
+ login_response='{"baseType":"error","code":"ServerError","message":"Server error while authenticating","status":500,"type":"error"}'
++ echo '{"baseType":"error","code":"ServerError","message":"Server error while authenticating","status":500,"type":"error"}'
++ jq -r .token
+ token=null
+ '[' null = null ']'
+ echo 'Failed to get authentication token'
Failed to get authentication token
+ exit 1

@p-se p-se requested a review from a team as a code owner October 29, 2025 15:50
@p-se p-se changed the title Fix public_hostname without IP address dev-scripts(setup-rancher-clusters): Fix public_hostname without IP address Oct 29, 2025
@p-se p-se marked this pull request as draft October 29, 2025 15:54
@p-se p-se removed the request for review from a team October 29, 2025 15:55
p-se added 2 commits October 29, 2025 17:23
…hostname

Fixes dev/setup-rancher-clusters where `public_hostname` may end up
being without IP address.

E.g.

```
+ upstream_ctx=k3d-upstream
+ downstream_ctx=k3d-downstream1
+ rancherpassword=rancherpassword
+ public_hostname=
+ '[' -z '' ']'
+ kubectl get service -n kube-system traefik -o 'jsonpath={.status.loadBalancer.ingress[0].ip}'
Error from server (NotFound): services "traefik" not found
+ sleep 3
+ kubectl get service -n kube-system traefik -o 'jsonpath={.status.loadBalancer.ingress[0].ip}'
Error from server (NotFound): services "traefik" not found
+ sleep 3
+ kubectl get service -n kube-system traefik -o 'jsonpath={.status.loadBalancer.ingress[0].ip}'
Error from server (NotFound): services "traefik" not found
+ sleep 3
+ kubectl get service -n kube-system traefik -o 'jsonpath={.status.loadBalancer.ingress[0].ip}'
++ kubectl get service -n kube-system traefik -o 'jsonpath={.status.loadBalancer.ingress[0].ip}'
+ ip=
+ public_hostname=.sslip.io
```
@p-se p-se force-pushed the improve-dev-setup-rancher-clusters-script branch from 9f7847d to 864ea3e Compare October 29, 2025 16:24
@p-se p-se marked this pull request as ready for review October 30, 2025 08:07
success=-1
until [ "$success" -eq 0 ]; do
echo "Waiting for Traefik LoadBalancer IP..."
sleep 5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: is there a specific reason for a sleep 5 where the previous until...do construct used a sleep 3?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants