Skip to content

Commit

Permalink
Wait for internal LB
Browse files Browse the repository at this point in the history
  • Loading branch information
garutilorenzo committed Feb 25, 2022
1 parent cc079d6 commit 2389a41
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
14 changes: 14 additions & 0 deletions files/k3s-install-agent.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
#!/bin/bash

wait_lb() {
while [ true ]
do
curl --output /dev/null --silent -k https://${k3s_url}:6443
if [[ "$?" -eq 0 ]]; then
break
fi
sleep 5
echo "wait for LB"
done
}

# Disable firewall
/usr/sbin/netfilter-persistent stop
/usr/sbin/netfilter-persistent flush
Expand All @@ -18,6 +30,8 @@ pip install oci-cli
local_ip=$(curl -s -H "Authorization: Bearer Oracle" -L http://169.254.169.254/opc/v2/vnics/ | jq -r '.[0].privateIp')
flannel_iface=$(ip -4 route ls | grep default | grep -Po '(?<=dev )(\S+)')

wait_lb

until (curl -sfL https://get.k3s.io | K3S_TOKEN=${k3s_token} K3S_URL=https://${k3s_url}:6443 sh -s - --node-ip $local_ip --flannel-iface $flannel_iface); do
echo 'k3s did not install correctly'
sleep 2
Expand Down
15 changes: 14 additions & 1 deletion files/k3s-install-server.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
#!/bin/bash

wait_lb() {
while [ true ]
do
curl --output /dev/null --silent -k https://${k3s_url}:6443
if [[ "$?" -eq 0 ]]; then
break
fi
sleep 5
echo "wait for LB"
done
}

# Disable firewall
/usr/sbin/netfilter-persistent stop
/usr/sbin/netfilter-persistent flush
Expand Down Expand Up @@ -36,6 +48,7 @@ if [[ "$first_instance" == "$instance_id" ]]; then
done
else
echo ":( Cluster join"
wait_lb
until (curl -sfL https://get.k3s.io | K3S_TOKEN=${k3s_token} sh -s - --server https://${k3s_url}:6443 $disable_traefik --node-ip $local_ip --advertise-address $local_ip --flannel-iface $flannel_iface --tls-san ${k3s_tls_san}); do
echo 'k3s did not install correctly'
sleep 2
Expand All @@ -60,7 +73,7 @@ fi

%{ if install_nginx_ingress }
if [[ "$first_last" == "first" ]]; then
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/baremetal/deploy.yaml
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.1.1/deploy/static/provider/baremetal/deploy.yaml
kubectl apply -f https://raw.githubusercontent.com/garutilorenzo/k3s-oci-cluster/master/nginx-ingress-config/all-resources.yml
fi

Expand Down
4 changes: 4 additions & 0 deletions k3s-workers.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
resource "oci_core_instance_pool" "k3s_workers" {

depends_on = [
oci_network_load_balancer_network_load_balancer.k3s_load_balancer,
]

lifecycle {
create_before_destroy = true
ignore_changes = [load_balancers, freeform_tags]
Expand Down

0 comments on commit 2389a41

Please sign in to comment.