-
Notifications
You must be signed in to change notification settings - Fork 3
/
microshift-install.sh
executable file
·87 lines (79 loc) · 3.35 KB
/
microshift-install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# Install script for https://github.com/redhat-et/microshift
# Can be installed using:
# curl -sfL https://raw.githubusercontent.com/nerdalert/microshift-installer/main/microshift-install.sh | sh -s -
#!/bin/sh
set -e
set -o noglob
# If the node does not have a FQDN
export IP=$(hostname -I | awk '{print $1}')
echo -e "- Adding the following host entry to /etc/hosts if it doesn't exist: $(hostname) $IP"
if ! grep --quiet "$IP $hostname" /etc/hosts; then
echo $IP $(hostname) | sudo tee -a /etc/hosts
fi
echo -e "\xE2\x9C\x94 Done\n"
# Detect the OS and install cri-o
uname=$(uname -r)
if echo "$uname" | grep -Eq 'fc'; then
echo "Fedora OS detected"
echo '- Installing cri-o container runtime...'
sudo dnf module enable -y cri-o:1.21
sudo dnf install -y cri-o cri-tools
sudo systemctl enable crio --now
echo -e "\xE2\x9C\x94 Done"
sleep 15
elif echo "$uname" | grep -Eq 'el'; then
echo 'CentOS/RHEL OS detected'
echo '- Installing cri-o container runtime...'
sudo curl -L -o /etc/yum.repos.d/devel:kubic:libcontainers:stable.repo https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/CentOS_8_Stream/devel:kubic:libcontainers:stable.repo
sudo curl -L -o /etc/yum.repos.d/devel:kubic:libcontainers:stable:cri-o:1.21.repo https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable:cri-o:1.21/CentOS_8_Stream/devel:kubic:libcontainers:stable:cri-o:1.21.repo
sudo dnf install -y cri-o cri-tools
sudo systemctl enable crio --now
echo -e "\xE2\x9C\x94 Done"
else
echo "No supported OS detected (requires CentOS or Fedora) exiting install.."
exit
fi
echo '- Installing Microshift packages...'
sudo dnf copr enable -y @redhat-et/microshift
sudo dnf install -y microshift
sudo systemctl enable microshift --now
echo -e "\xE2\x9C\x94 Done"
# wait for the kubeconfig file to become available
echo "Wating for cri-o pods to initiate.."
count=1
kubeconf=/var/lib/microshift/resources/kubeadmin/kubeconfig
until sudo test -f $kubeconf; do
if [ $count -gt 180 ]; then
echo -e "\u274c kubeconfig not found in $kubeconf, there may be an issue with the installation"
break
fi
count=$((count + 1))
sleep 1
done
cricount=1
while ! sudo crictl ps | grep -q 'flannel'; do
cricount=$((cricount + 1))
if [ $cricount -gt 180 ]; then
echo "timed out waiting on cri-o pods"
break
fi
sleep 1
done
# check for kubectl
if ! command -v kubectl &> /dev/null
then
echo -e "Warning: the kubectl binary was not found, install it with:\n"
echo "curl -LO https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
echo "chmod +x ./kubectl"
echo -e "sudo mv ./kubectl /usr/local/bin/kubectl\n"
fi
echo "pods are initiating may take a couple of minutes depending on resources.."
echo "- Installation complete, view the pods with the following:"
echo "########################################################################"
echo "mkdir ~/.kube"
echo "sudo cat /var/lib/microshift/resources/kubeadmin/kubeconfig > ~/.kube/config"
echo "export KUBECONFIG=~/.kube/config"
echo "########################################################################"
echo -e "cmd -> kubectl get pods --all-namespaces -o wide\n"
echo "- Once all of the microshift pods are up and running, test the deployment with:"
echo -e "cmd -> kubectl apply -f https://k8s.io/examples/application/shell-demo.yaml \n"