Home | 简体中文 | 繁体中文 | 杂文 | Github | 知乎专栏 | 51CTO学院 | CSDN程序员研修院 | OSChina 博客 | 腾讯云社区 | 阿里云栖社区 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏多维度架构

第 4 章 Minikube

目录

4.1. CentOS 8 安装 minikube
4.1.1. CentOS
4.1.2. Mac OS
4.2. Quickstart
4.3. minikube 命令
4.3.1. minikube ip 地址
4.3.2. 启动 minikube
4.3.3. 停止 minikube
4.3.4. Docker 环境变量
4.3.5. SSH
4.3.6. 缓存镜像
4.3.7. 清理 minikube
4.3.8. Kubernetes 控制面板
4.3.9. service
4.3.10. 查看日志
4.3.11. 查看 Docker 环境变量
4.3.12. profile
4.3.13. addons
4.3.14. SSH
4.3.15. 查看IP地址
4.3.16. 镜像管理
4.3.17. kubectl
4.4. Minikube 案例演示
4.5. FAQ
4.5.1. This computer doesn't have VT-X/AMD-v enabled. Enabling it in the BIOS is mandatory
4.5.2. ERROR FileContent--proc-sys-net-bridge-bridge-nf-call-iptables
4.5.3. ERROR ImagePull
4.5.4. 证书已存在错误
4.5.5. http: server gave HTTP response to HTTPS client
4.5.6. provided port is not in the valid range. The range of valid ports is 30000-32767
4.5.7. Exiting due to MK_ENABLE: run callbacks: running callbacks: [verifying registry addon pods : timed out waiting for the condition: timed out waiting for the condition]
4.5.8. Exiting due to SVC_URL_TIMEOUT: http://127.0.0.1:11068/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/ is not accessible: Temporary Error: unexpected response code: 503
4.5.9. Mac minikube ip 不通,ingress 不工作

4.1. CentOS 8 安装 minikube

4.1.1. CentOS

执行下面命令检查服务器是否开启虚拟化技术

			
egrep --color 'vmx|svm' /proc/cpuinfo
			
			

如果没有任何输出,请重启服务器进入 BIOS 启用 VT-X 或 AMD-v

			
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 \
  && install minikube-linux-amd64 /usr/local/bin/minikube		 	
			
			

尝试运行 minikube 如果输出帮助信息表示安装成功

			
[root@localhost ~]# minikube version
minikube version: v1.13.0
commit: 0c5e9de4ca6f9c55147ae7f90af97eff5befef5f-dirty			
			
			

			
echo "1" > /proc/sys/net/bridge/bridge-nf-call-iptables			
			
			

dnf 安装 kubectl

			
cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
EOF
			
			
			
[root@localhost ~]# dnf install kubectl
			
			

二进制安装 kubectl

						
curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl" \
	&& install kubectl /usr/local/bin/kubectl
			
			
无虚拟机

如果你不想安装虚拟机

			
adduser docker
su - docker
sudo usermod -aG docker $USER && newgrp docker			
			
				

				
[docker@localhost ~]$ minikube start --driver=docker
* minikube v1.13.0 on Centos 8.2.2004
* Using the docker driver based on user configuration

X Requested memory allocation (1694MB) is less than the recommended minimum 2000MB. Deployments may fail.


X The requested memory allocation of 1694MiB does not leave room for system overhead (total system memory: 1694MiB). You may face stability issues.
* Suggestion: Start minikube with less memory allocated: 'minikube start --memory=1694mb'

* Starting control plane node minikube in cluster minikube
* Pulling base image ...
* Downloading Kubernetes v1.19.0 preload ...
    > preloaded-images-k8s-v6-v1.19.0-docker-overlay2-amd64.tar.lz4: 486.28 MiB				
				
				

4.1.2. Mac OS

检查硬件是否支持虚拟化

			
iMac:Linux neo$ sysctl -a | grep -E --color 'machdep.cpu.features|VMX'
machdep.cpu.features: FPU VME DE PSE TSC MSR PAE MCE CX8 APIC SEP MTRR PGE MCA CMOV PAT PSE36 CLFSH DS ACPI MMX FXSR SSE SSE2 SS HTT TM PBE SSE3 PCLMULQDQ DTES64 MON DSCPL VMX SMX EST TM2 SSSE3 CX16 TPR PDCM SSE4.1 SSE4.2 x2APIC POPCNT AES PCID XSAVE OSXSAVE TSCTMR AVX1.0			
			
			
			
$ brew install hyperkit			
$ brew install minikube
$ brew install kubectl
$ brew install kubernetes-helm
			
			
			
neo@MacBook-Pro-Neo ~ % minikube start                 
😄  minikube v1.13.1 on Darwin 11.0
🆕  Kubernetes 1.19.2 is now available. If you would like to upgrade, specify: --kubernetes-version=v1.19.2
✨  Using the hyperkit driver based on existing profile
👍  Starting control plane node minikube in cluster minikube
🔄  Restarting existing hyperkit VM for "minikube" ...
❗  This VM is having trouble accessing https://k8s.gcr.io
💡  To pull new external images, you may need to configure a proxy: https://minikube.sigs.k8s.io/docs/reference/networking/proxy/
🐳  Preparing Kubernetes v1.19.0 on Docker 19.03.12 ...
🔎  Verifying Kubernetes components...
🌟  Enabled addons: dashboard, default-storageclass, storage-provisioner
🏄  Done! kubectl is now configured to use "minikube" by default			
			
			

有些老系统可能不支持 hyperkit,需要virtualbox。

			
$ brew cask install virtualbox
$ minikube start —vm-driver=virtualbox
$ minikube dashboard			
			
			

检查 minikube 启动状态

			
Neo-iMac:~ neo$ docker container inspect minikube --format={{.State.Status}}
running