Skip to content

Instantly share code, notes, and snippets.

@danpawlik
Last active September 27, 2023 11:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danpawlik/c42bac76efef1baa99af7870946a7f87 to your computer and use it in GitHub Desktop.
Save danpawlik/c42bac76efef1baa99af7870946a7f87 to your computer and use it in GitHub Desktop.
Install pure minikube with cri-o runtime
#!/bin/bash
echo "$USER ALL=(ALL) ALL" | sudo tee -a /etc/sudoers
echo "%$USER ALL=(ALL) NOPASSWD: ALL" | sudo tee -a /etc/sudoers
# install crio
CRIO_VERSION=1.26
OS="xUbuntu_$(lsb_release -r -s)"
echo "deb [trusted=true] https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/$OS/ /"|sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
echo "deb [trusted=true] http://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/$CRIO_VERSION/$OS/ /"|sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable:cri-o:$CRIO_VERSION.list
sudo apt update
sudo apt install -y cri-o cri-o-runc conntrack containernetworking-plugins cri-tools docker.io
# https://minikube.sigs.k8s.io/docs/faq/#how-do-i-install-containernetworking-plugins-for-none-driver
CNI_PLUGIN_VERSION="v1.3.0"
CNI_PLUGIN_TAR="cni-plugins-linux-amd64-$CNI_PLUGIN_VERSION.tgz" # change arch if not on amd64
CNI_PLUGIN_INSTALL_DIR="/opt/cni/bin"
curl -LO "https://github.com/containernetworking/plugins/releases/download/$CNI_PLUGIN_VERSION/$CNI_PLUGIN_TAR"
sudo mkdir -p "$CNI_PLUGIN_INSTALL_DIR"
sudo tar -xf "$CNI_PLUGIN_TAR" -C "$CNI_PLUGIN_INSTALL_DIR"
rm "$CNI_PLUGIN_TAR"
sudo mkdir -p /etc/crio/crio.conf.d
sudo touch /etc/crio/crio.conf.d/02-crio.conf
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube
ln -s /usr/local/bin/minikube /tmp/minikube
sudo snap install kubectl --classic
## cri-docker
VER=$(curl -s https://api.github.com/repos/Mirantis/cri-dockerd/releases/latest|grep tag_name | cut -d '"' -f 4|sed 's/v//g')
DL=$(mktemp -d)
pushd ${DL}
curl -LO https://github.com/Mirantis/cri-dockerd/releases/download/v${VER}/cri-dockerd-${VER}.amd64.tgz
tar xvf cri-dockerd-${VER}.amd64.tgz
sudo mv cri-dockerd/cri-dockerd /usr/local/bin
curl -LO https://raw.githubusercontent.com/Mirantis/cri-dockerd/v${VER}/packaging/systemd/cri-docker.service
curl -LO https://raw.githubusercontent.com/Mirantis/cri-dockerd/v${VER}/packaging/systemd/cri-docker.socket
sudo mv cri-docker.socket cri-docker.service /etc/systemd/system/
sudo sed -i -e 's,/usr/bin/cri-dockerd,/usr/local/bin/cri-dockerd,' /etc/systemd/system/cri-docker.service
popd
rm -rf ${DL}
sudo systemctl daemon-reload
export MINIKUBE_WANTUPDATENOTIFICATION=false;
export MINIKUBE_WANTREPORTERRORPROMPT=false;
export MINIKUBE_WANTNONEDRIVERWARNING=false;
export MINIKUBE_WANTKUBECTLDOWNLOADMSG=false;
export CHANGE_MINIKUBE_NONE_USER=true;
export MINIKUBE_HOME="/home/ubuntu";
export KUBECONFIG="/home/ubuntu/.kube/config";
/tmp/minikube start \
--v=7 \
--driver=none \
--container-runtime=cri-o \
--network-plugin=cni
sleep 10
kubectl apply -f https://k8s.io/examples/admin/dns/dnsutils.yaml
while true; do
if [ "$(kubectl get pods dnsutils -o 'jsonpath={..status.conditions[?(@.type=="Ready")].status}')" = "True" ]; then
break;
else
echo "Waiting for pod to be ready"
sleep 1;
fi;
done
kubectl exec -i -t dnsutils -- nslookup opendev.org
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment