Skip to content

Commit

Permalink
Pass controller variable through GITHUB_ENV
Browse files Browse the repository at this point in the history
  • Loading branch information
cderici committed Sep 29, 2023
1 parent 002d69a commit de8cb2a
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions .github/workflows/k8s_tunnel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,13 @@ jobs:
- name: "Set environment to configure provider"
# language=bash
run: |
CONTROLLER=$(juju whoami --format yaml | yq .controller)
echo "JUJU_CONTROLLER_ADDRESSES=$(juju show-controller | yq .$CONTROLLER.details.api-endpoints | yq -r '. | join(",")')" >> $GITHUB_ENV
echo "CONTROLLER=$(juju whoami --format yaml | yq .controller)" >> $GITHUB_ENV
echo "JUJU_USERNAME=$(juju show-controller | yq .$CONTROLLER.account.user)" >> $GITHUB_ENV
echo "JUJU_PASSWORD=$(cat ~/.local/share/juju/accounts.yaml | yq .controllers.$CONTROLLER.password)" >> $GITHUB_ENV
echo "JUJU_CA_CERT<<EOF" >> $GITHUB_ENV
juju show-controller | yq .$CONTROLLER.details.ca-cert >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
echo "JUJU_CA_CERT=$(juju show-controller | yq .$CONTROLLER.details.ca-cert)" >> $GITHUB_ENV
- run: go mod download
- name: "Bring up loadbalancer & access via terraform plan"
run: |
CONTROLLER=$(juju whoami --format yaml | yq .controller)
# enable ingress and metallb to
sudo microk8s enable ingress
echo "Ingress enabled."
Expand All @@ -97,7 +92,7 @@ jobs:
echo "Juju Username : $JUJU_USERNAME"
echo "Services layout:"
sudo microk8s.kubectl get services -n controller-$CONTROLLER controller-service
sudo microk8s.kubectl get services -n controller-$CONTROLLER
# bring up the load balancer service
sudo microk8s.kubectl apply -f - <<EOF
Expand All @@ -122,15 +117,15 @@ jobs:
EOF
echo "Services layout with the Load Balancer:"
sudo microk8s.kubectl get services -n controller-$CONTROLLER controller-service
sudo microk8s.kubectl get services -n controller-$CONTROLLER
# get the external IP of the load balancer service
LB_IP="$(microk8s.kubectl get services -n controller-$CONTROLLER | grep -o 'controller-service-lb.*' | awk '{print $4}')"; echo "$LB_IP"
# write a plan using this IP
echo "
provider \"juju\" {
controller_addresses = $LB_IP
controller_addresses = [$LB_IP]
username = $JUJU_USERNAME
password = $JUJU_PASSWORD
ca_certificate = $JUJU_CA_CERT
Expand All @@ -150,5 +145,14 @@ jobs:
}
" > ./terraform_config.tf
terraform init && terraform plan && terraform apply --auto-approve
# Initialize and apply Terraform
echo "Initializing Terraform..."
terraform init
echo "Planning Terraform changes..."
terraform plan
echo "Applying Terraform changes..."
terraform apply --auto-approve
# Cleanup: Remove Terraform configuration file
# rm ./terraform_config.tf

0 comments on commit de8cb2a

Please sign in to comment.