Minikube Systemd: Difference between revisions
Jump to navigation
Jump to search
Line 211: | Line 211: | ||
lxc exec minikube -- curl www.k8s.local | lxc exec minikube -- curl www.k8s.local | ||
lxc exec minikube -- ping www.k8s.local | lxc exec minikube -- ping www.k8s.local | ||
|} | |||
==Kubectl Config== | |||
{| | |||
| valign="top"| | |||
<syntaxhighlight lang="bash"> | |||
cat << EXE | lxc exec minikube -- sudo -i -u ${USER} bash | |||
mkdir -p ~/.kube && sudo chmod 755 ~/.kube | |||
sudo -i -u minikube kubectl config --kubeconfig=/home/minikube/.kube/config view --flatten | tee ~/.kube/config >/dev/null | |||
sudo chmod 600 ~/.kube/config | |||
EXE | |||
</syntaxhighlight> | |||
|- | |||
| valign="top"| | |||
---- | |||
|- | |||
| valign="top"| | |||
<syntaxhighlight lang="bash"> | |||
cat << EXE | lxc exec minikube -- sudo -i -u ${USER} bash | |||
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 | |||
EXE | |||
</syntaxhighlight> | |||
|} | |} |
Revision as of 11:57, 27 June 2024
if [ -x "$(command -v curl)" ];then \
sudo apt -qq update;\
export MINIKUBE_CPU_USE=8;\
export MINIKUBE_RAM_USE=16384;\
bash <(curl -s 'https://cdn.chorke.org/exec/cli/bash/install/minikube/1.0.0-ubuntu-22.04.sh.txt');\
else printf 'curl \033[0;31mnot found! \033[0m:(\n';fi
Prepare Debug
lxc launch ubuntu:22.04 minikube --vm
lxc snapshot minikube ubuntu:22.04
lxc restore minikube ubuntu:22.04
cat << EXE | lxc exec minikube -- bash
LXC_USER_NAME="${USER}"
if ! sudo id -u \${LXC_USER_NAME} &>/dev/null;then
useradd --create-home --shell /bin/bash \${LXC_USER_NAME}
passwd --quiet --delete "\${LXC_USER_NAME}"
usermod -aG sudo "\${LXC_USER_NAME}"
fi
EXE
lxc exec minikube -- sudo --login --user ${USER} bash
lxc exec minikube -- sudo -i -u ${USER} bash
|
cat << EXE | lxc exec minikube -- sudo -i -u ${USER} bash
sudo apt-get update -qq
sudo mkdir -p /etc/apt/keyrings
sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg\
| sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
cat << SRC | sudo tee /etc/apt/sources.list.d/docker.list >/dev/null
deb [arch=\$(dpkg --print-architecture)\
signed-by=/etc/apt/keyrings/docker.gpg]\
https://download.docker.com/linux/ubuntu \$(lsb_release -cs) stable
SRC
EXE
| |
| ||
cat << EXE | lxc exec minikube -- sudo -i -u ${USER} bash
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.30/deb/Release.key\
| sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
EXE
lxc exec minikube -- apt-get update -qq
lxc exec minikube -- apt-get install -y kubectl
lxc exec minikube -- which kubectl
|
cat << EXE | lxc exec minikube -- sudo -i -u ${USER} bash
cat << SRC | sudo tee /etc/apt/sources.list.d/kubernetes.list >/dev/null
deb [arch=$(dpkg --print-architecture)\
signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg]\
https://pkgs.k8s.io/core:/stable:/v1.30/deb/ /
SRC
EXE
| |
| ||
cat << EXE | lxc exec minikube -- sudo -i -u ${USER} bash
sudo apt-get update -qq
sudo apt-get install -y docker-ce jq
sudo usermod -aG docker \${USER}
su - \${USER}
id -nG
EXE
|
cat << EXE | lxc exec minikube -- sudo -i -u ${USER} bash
sudo systemctl status network-online.target
sudo systemctl status containerd.service
sudo systemctl status docker.service
docker version
docker ps -a
EXE
| |
| ||
lxc stop minikube lxc info minikube lxc list |
lxc config set minikube limits.cpu 4 lxc config get minikube limits.cpu lxc config unset minikube limits.cpu |
lxc config set minikube limits.memory 8GB lxc config get minikube limits.memory lxc config unset minikube limits.memory |
| ||
lxc start minikube lxc info minikube lxc config show minikube |
lxc exec minikube -- awk '/^MemTotal:/ { print int($2/1024); }' /proc/meminfo lxc exec minikube -- getconf _NPROCESSORS_ONLN lxc exec minikube -- free -th | |
| ||
lxc delete minikube/ubuntu:docker:22.04 lxc snapshot minikube ubuntu:docker:22.04 |
lxc restore minikube ubuntu:docker:22.04 lxc info minikube |
lxc exec minikube -- sudo -i -u ${USER} docker ps lxc exec minikube -- sudo -i -u ${USER} jq --help |
Execute Debug
cat << EXE | lxc exec minikube -- sudo -i -u ${USER} bash
if [ -x "$(command -v curl)" ];then \
sudo apt-get -qq update;\
export MINIKUBE_CPU_USE=2;\
export MINIKUBE_RAM_USE=5900;\
bash <(curl -s 'https://cdn.chorke.org/exec/cli/bash/install/minikube/1.0.0-ubuntu-22.04.sh.txt');\
else printf 'curl \033[0;31mnot found! \033[0m:(\n';fi
EXE
|
lxc exec minikube -- sudo -i -u minikube minikube status lxc exec minikube -- journalctl -xeu minikube.service lxc exec minikube -- systemctl daemon-reload lxc exec minikube -- systemctl stop minikube.service lxc exec minikube -- systemctl status minikube.service lxc exec minikube -- systemctl restart minikube.service | |
| ||
lxc exec minikube -- sudo -i -u minikube kubectl get ingress kubernetes-dashboard -n kubernetes-dashboard -o yaml lxc exec minikube -- sudo -i -u minikube kubectl get configmap coredns -n kube-system -o yaml lxc exec minikube -- sudo -i -u minikube minikube addons list | ||
| ||
cat << EXE | lxc exec minikube -- sudo -i -u ${USER} bash
printf -v MINIKUBE_NSLOOKUP '%s' \$(sudo -u minikube minikube ip)
if [ -f '/etc/resolv.conf' ]&&[ "\$(grep -c \${MINIKUBE_NSLOOKUP} '/etc/resolv.conf')" == 0 ];then
cat << CFG | sudo tee -a /etc/resolv.conf >/dev/null
# minikube name server
nameserver \${MINIKUBE_NSLOOKUP}
CFG
fi
EXE
|
lxc exec minikube -- nslookup www.k8s.local lxc exec minikube -- dig www.k8s.local lxc exec minikube -- cat /etc/resolv.conf lxc exec minikube -- cat /etc/hosts lxc exec minikube -- curl www.k8s.local lxc exec minikube -- ping www.k8s.local |
Kubectl Config
cat << EXE | lxc exec minikube -- sudo -i -u ${USER} bash
mkdir -p ~/.kube && sudo chmod 755 ~/.kube
sudo -i -u minikube kubectl config --kubeconfig=/home/minikube/.kube/config view --flatten | tee ~/.kube/config >/dev/null
sudo chmod 600 ~/.kube/config
EXE
|
|
cat << EXE | lxc exec minikube -- sudo -i -u ${USER} bash
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
EXE
|
Systemd File
Line number: 20-22 meaningless, kept backed those lines for identical purpose
cat /etc/systemd/system/minikube.service
:'
[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=/var/minikube/bin/minikube
[Service]
Type=forking
User=minikube
Group=minikube
RemainAfterExit=yes
ProtectProc=invisible
StandardOutput=journal
WorkingDirectory=/home/minikube
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} > /var/minikube/etc/minikube.pid"
ExecStart=/var/minikube/bin/minikube start --cpus 2 --memory 5900
ExecStop=/var/minikube/bin/minikube stop
Restart=always
SendSIGKILL=no
TasksMax=infinity
TimeoutStopSec=infinity
[Install]
WantedBy=multi-user.target
'
Playground
lxc launch ubuntu:22.04 minikube --vm lxc exec minikube -- bash |
lxc snapshot minikube ubuntu:docker:22.04 lxc restore minikube ubuntu:docker:22.04 |
lxc delete minikube/ubuntu:docker:22.04 lxc info minikube |
| ||
References
| ||