minikube
About 1 min
minikube
references
prepare
- fedora os 38
- use non root user, for example
ben.wangz
# for example useradd ben.wangz
- configure sudoers to add NOPASSWD to
ben.wangz
# for example echo 'ben.wangz ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
- install podman(use none root user from here)
sudo dnf -y install podman
- prepare minikube binary
MIRROR="files." curl -LO "https://${MIRROR}storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64" mv minikube-linux-amd64 minikube chmod u+x minikube mkdir -p ${HOME}/bin mv -f minikube ${HOME}/bin
- (optional) disable aegis service and reboot system for aliyun
- https://bugzilla.openanolis.cn/show_bug.cgi?id=5437
sudo systemctl disable aegis && sudo reboot
install k8s by minikube
- start minikube
- aliyuncs
minikube start --driver=podman --container-runtime=cri-o --kubernetes-version=v1.27.10 --image-mirror-country=cn --image-repository=registry.cn-hangzhou.aliyuncs.com/google_containers
gcr.iominikube start --driver=podman --container-runtime=cri-o --kubernetes-version=v1.27.10 --image-mirror-country=cn --image-repository=gcr.io
- add alias of
kubectl
alias kubectl="minikube kubectl --"
- it's recommended to download
kubectl
binary and use it directlyMIRROR="files." VERSION=$(curl -L -s "https://${MIRROR}dl.k8s.io/release/stable.txt") [ $(uname -m) = x86_64 ] && curl -sSLo kubectl "https://${MIRROR}dl.k8s.io/release/${VERSION}/bin/linux/amd64/kubectl" [ $(uname -m) = aarch64 ] && curl -sSLo kubectl "https://${MIRROR}dl.k8s.io/release/${VERSION}/bin/linux/arm64/kubectl" chmod u+x kubectl mkdir -p ${HOME}/bin mv -f kubectl ${HOME}/bin
- may change memory(requires a restart)
minikube config set memory 6144
- restart minikube
minikube stop && minikube start
port-forward with ssh tunnel
- reason
- minikube is running in a virtual machine, so we need to use ssh tunnel to access the service
- open ssh tunnel, for example
ssh -i ~/.minikube/machines/minikube/id_rsa docker@$(minikube ip) -L '*:30443:0.0.0.0:30443' -N -f ssh -i ~/.minikube/machines/minikube/id_rsa docker@$(minikube ip) -L '*:32443:0.0.0.0:32443' -N -f ssh -i ~/.minikube/machines/minikube/id_rsa docker@$(minikube ip) -L '*:32080:0.0.0.0:32080' -N -f
- use ssh tunnel to transport k8s api service to the machine which host minikube
ssh -i ~/.minikube/machines/minikube/id_rsa docker@$(minikube ip) -L '*:8443:0.0.0.0:8443' -N -f
- use ssh tunnel to transport k8s api service to local
#MACHINE_IP_ADDRESS=ip_address_of_your_machine_which_host_minikube MINIKUBE_IP_ADDRESS=$(ssh -o 'UserKnownHostsFile /dev/null' ben.wangz@$MACHINE_IP_ADDRESS '$HOME/bin/minikube ip') ssh -o 'UserKnownHostsFile /dev/null' ben.wangz@$MACHINE_IP_ADDRESS -L "*:8443:$MINIKUBE_IP_ADDRESS:8443" -N -f
- better solution with kubectl port-forward
kubectl port-forward -n argocd --address 0.0.0.0 service/argocd-server-external 443:30443 kubectl port-forward -n basic-components --address 0.0.0.0 service/ingress-nginx-controller 443:32443 kubectl port-forward -n basic-components --address 0.0.0.0 service/ingress-nginx-controller 80:32080
uninstall
- delete minikube
minikube delete --all
addtional software
- optional download
kubectl
binary, then you can usekubectl
command directlyMIRROR="files." VERSION=$(curl -L -s "https://${MIRROR}dl.k8s.io/release/stable.txt") [ $(uname -m) = x86_64 ] && curl -sSLo kubectl "https://${MIRROR}dl.k8s.io/release/${VERSION}/bin/linux/amd64/kubectl" [ $(uname -m) = aarch64 ] && curl -sSLo kubectl "https://${MIRROR}dl.k8s.io/release/${VERSION}/bin/linux/arm64/kubectl" chmod u+x kubectl mkdir -p ${HOME}/bin mv -f kubectl ${HOME}/bin
- install argocd by helm
ssh -i ~/.minikube/machines/minikube/id_rsa docker@$(minikube ip) -L '*:30443:0.0.0.0:30443' -N -f
- install ingress by argocd
- install cert-manager by argocd