Skip to content

Commit

Permalink
Some fixes. Added nginx ingress controller support
Browse files Browse the repository at this point in the history
  • Loading branch information
garutilorenzo committed Feb 25, 2022
1 parent a3aac49 commit 59e88e8
Showing 1 changed file with 32 additions and 17 deletions.
49 changes: 32 additions & 17 deletions files/k3s-install-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,47 @@ first_instance=$(oci compute instance list --compartment-id ${compartment_ocid}
instance_id=$(curl -s -H "Authorization: Bearer Oracle" -L http://169.254.169.254/opc/v2/instance | jq -r '.displayName')
first_last="last"

%{ if install_nginx_ingress }
disable_traefik="--disable traefik"
%{ endif }

if [[ "$first_instance" == "$instance_id" ]]; then
echo "I'm the first yeeee: Cluster init!"
until (curl -sfL https://get.k3s.io | K3S_TOKEN=${k3s_token} sh -s - --cluster-init --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
done
echo "I'm the first yeeee: Cluster init!"
first_last="first"
until (curl -sfL https://get.k3s.io | K3S_TOKEN=${k3s_token} sh -s - --cluster-init $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
done
else
echo ":( Cluster join"
until (curl -sfL https://get.k3s.io | K3S_TOKEN=${k3s_token} sh -s - --server https://${k3s_url}:6443 --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
done
echo ":( Cluster join"
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
done
fi

%{ if is_k3s_server }
until kubectl get pods -A | grep 'Running'; do
echo 'Waiting for k3s startup'
sleep 5
echo 'Waiting for k3s startup'
sleep 5
done

%{ if install_longhorn }
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y open-iscsi curl util-linux
systemctl enable iscsid.service
systemctl start iscsid.service
kubectl apply -f https://raw.githubusercontent.com/longhorn/longhorn/${longhorn_release}/deploy/longhorn.yaml
kubectl create -f https://raw.githubusercontent.com/longhorn/longhorn/${longhorn_release}/examples/storageclass.yaml
if [[ "$first_last" == "first" ]]; then
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y open-iscsi curl util-linux
systemctl enable iscsid.service
systemctl start iscsid.service
kubectl apply -f https://raw.githubusercontent.com/longhorn/longhorn/${longhorn_release}/deploy/longhorn.yaml
kubectl create -f https://raw.githubusercontent.com/longhorn/longhorn/${longhorn_release}/examples/storageclass.yaml
fi
%{ endif }

%{ 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/garutilorenzo/k3s-oci-cluster/master/nginx-ingress-config/all-resources.yml
fi

%{ endif }

%{ endif }

0 comments on commit 59e88e8

Please sign in to comment.