Refactor Terraform Apply script to use IP address instead of hostname in kube config

This commit is contained in:
2024-09-26 20:27:37 +02:00
parent 6c9f2326be
commit 26b7eb6ac9
@@ -95,8 +95,8 @@ jobs:
run: | run: |
for HOST in $TRUSTED_HOSTS; do for HOST in $TRUSTED_HOSTS; do
ssh -f -N -L 16443:localhost:16443 $ANSIBLE_USER@$HOST ssh -f -N -L 16443:localhost:16443 $ANSIBLE_USER@$HOST
# override hosts address in kube config IP_ADDR=$(ssh $ANSIBLE_USER@$HOST "hostname -I | cut -d' ' -f1")
sed -i "s/server: https:\/\/$HOST:16443/server: https:\/\/localhost:16443/g" ~/.kube/config sed -i "s/server: https:\/\/$IP_ADDR:16443/server: https:\/\/localhost:16443/g" ~/.kube/config
cd terraform/k8sapps cd terraform/k8sapps
sectool exec terraform apply --auto-approve sectool exec terraform apply --auto-approve
pkill -f "ssh -f -N -L 16443:localhost:16443 $ANSIBLE_USER@$HOST" pkill -f "ssh -f -N -L 16443:localhost:16443 $ANSIBLE_USER@$HOST"