#!/bin/bash : ' @vendor Chorke Academia, Inc. @web https://cdn.chorke.org/docs/academia @version 1.0.00 @since 1.0.00 ' :</dev/null;then sudo addgroup --quiet --system minikube;fi if ! sudo id -u minikube &>/dev/null;then sudo adduser --quiet --system --home ${MINIKUBE_USER_HOME} --shell '/bin/bash' --ingroup minikube --disabled-password minikube fi sudo chown -R minikube:minikube ${MINIKUBE_HOME_DIR} sudo usermod -aG minikube ${USER} sudo usermod -aG docker minikube sudo usermod -aG minikube root } function setting(){ sudo -i -u minikube bash << EXE # format minikube config path mkdir -p ${MINIKUBE_USER_HOME}/.minikube EXE } function install(){ cat << ENV | sudo tee /etc/default/minikube >/dev/null MINIKUBE_OPTS="${MINIKUBE_OPTS}" MINIKUBE_CONF_ENV=/etc/default/minikube MINIKUBE_CONF_DIR="${MINIKUBE_USER_HOME}/.minikube" ENV sudo chown -R minikube:minikube ${MINIKUBE_HOME_DIR} cat << SYS | sudo tee /etc/systemd/system/minikube.service >/dev/null [Unit] Description=Minikube Cluster Documentation=https://minikube.sigs.k8s.io/docs/ After=network-online.target containerd.service docker.service Requires=network-online.target containerd.service docker.service Wants=network-online.target docker.service AssertFileIsExecutable=${MINIKUBE_HOME_DIR}/bin/minikube [Service] Type=forking User=minikube Group=minikube RemainAfterExit=yes ProtectProc=invisible StandardOutput=journal WorkingDirectory=${MINIKUBE_HOME_DIR} EnvironmentFile=-/etc/default/minikube ExecStartPre=/bin/bash -c "if [ -z \"\${MINIKUBE_OPTS}\" ]; then echo \"Variable MINIKUBE_OPTS not set in /etc/default/minikube\"; errors_exit; fi" ExecStartPost=/bin/bash -c "echo \${MAINPID} > ${MINIKUBE_HOME_DIR}/etc/minikube.pid" ExecStart=${MINIKUBE_HOME_DIR}/bin/minikube start ${MINIKUBE_OPTS} ExecStop=${MINIKUBE_HOME_DIR}/bin/minikube stop Restart=always SendSIGKILL=no TasksMax=infinity TimeoutStopSec=infinity [Install] WantedBy=multi-user.target SYS } function systemd(){ sudo systemctl daemon-reload sudo systemctl enable minikube.service sudo systemctl start minikube.service sudo systemctl status minikube.service } function ingress(){ sudo -i -u minikube bash << EXE # minikube daemon delay FOR_FIVE_SECONDS_ONLY=5 sleep \$((FOR_FIVE_SECONDS_ONLY*2)) # minikube enable addons for ingress for p in ingress ingress-dns dashboard metrics-server;\ do minikube addons enable \${p};done minikube addons list EXE sudo systemctl restart minikube.service sudo systemctl status minikube.service sudo -i -u minikube bash << EXE # minikube addons delay FOR_FIVE_SECONDS_ONLY=5 sleep \$((FOR_FIVE_SECONDS_ONLY*2)) # minikube find coredns last entry CONFIGMAP_COREDNS_FIND=\$(cat </dev/null sudo chmod 600 ~/.kube/config # minikube sudo or root user kubecofig sudo mkdir -p /root/.kube && sudo chmod 755 /root/.kube sudo -i -u minikube kubectl config --kubeconfig=/home/minikube/.kube/config view --flatten | sudo tee /root/.kube/config >/dev/null sudo chmod 600 /root/.kube/config } function init(){ validate download approve setting install systemd ingress k8sconf } init