知乎专栏 |
目录
执行下面命令检查服务器是否开启虚拟化技术
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
检查硬件是否支持虚拟化
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