minikube快速搭建 k8s单节点环境
kubectl,类似 docker 中的 docker-cli。
·
1 前提依赖
2 CPUs or more
2GB of free memory
20GB of free disk space
Internet connection
Container or virtual machine manager, such as: Docker, QEMU, Hyperkit, Hyper-V, KVM, Parallels, Podman, VirtualBox, or VMware Fusion/Workstation
kubectl,类似 docker 中的 docker-cli
2 安装
Linux
x86-64 Binary download
[root@icv-monitor-platform-dev ~]# curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 80.0M 100 80.0M 0 0 1671k 0 0:00:49 0:00:49 --:--:-- 1807k
[root@icv-monitor-platform-dev ~]# sudo install minikube-linux-amd64 /usr/local/bin/minikube
[root@icv-monitor-platform-dev ~]#
macOS
javaedge@JavaEdgedeMac-mini ~ % brew install minikube
Running `brew update --auto-update`...
^C==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/api/formula.jws.json
######################################################################## 100.0%
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/api/cask.jws.json
######################################################################## 100.0%
==> Fetching dependencies for minikube: kubernetes-cli
==> Fetching kubernetes-cli
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/bottles/kubernetes-cli-1.27.1.big_sur.bottle.tar.gz
######################################################################## 100.0%
==> Fetching minikube
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/bottles/minikube-1.30.1.big_sur.bottle.tar.gz
######################################################################## 100.0%
==> Installing dependencies for minikube: kubernetes-cli
==> Installing minikube dependency: kubernetes-cli
==> Pouring kubernetes-cli-1.27.1.big_sur.bottle.tar.gz
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink bin/kubectl
Target /usr/local/bin/kubectl
already exists. You may want to remove it:
rm '/usr/local/bin/kubectl'
To force the link and overwrite all conflicting files:
brew link --overwrite kubernetes-cli
To list all files that would be deleted:
brew link --overwrite --dry-run kubernetes-cli
Possible conflicting files are:
/usr/local/bin/kubectl -> /Applications/Docker.app/Contents/Resources/bin/kubectl
==> Summary
🍺 /usr/local/Cellar/kubernetes-cli/1.27.1: 230 files, 59.2MB
==> Installing minikube
==> Pouring minikube-1.30.1.big_sur.bottle.tar.gz
==> Caveats
zsh completions have been installed to:
/usr/local/share/zsh/site-functions
==> Summary
🍺 /usr/local/Cellar/minikube/1.30.1: 9 files, 82MB
==> Running `brew cleanup minikube`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
==> `brew cleanup` has not been run in the last 30 days, running now...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
Removing: /Users/javaedge/Library/Caches/Homebrew/gdk-pixbuf--2.42.10.big_sur.bottle.1.tar.gz... (762.5KB)
Removing: /Users/javaedge/Library/Caches/Homebrew/graphviz--8.0.3.big_sur.bottle.tar.gz... (8.2MB)
Removing: /Users/javaedge/Library/Caches/Homebrew/mysql-client--8.0.32.big_sur.bottle.tar.gz... (40.0MB)
Removing: /Users/javaedge/Library/Caches/Homebrew/netpbm--10.86.38.big_sur.bottle.tar.gz... (1.7MB)
Removing: /Users/javaedge/Library/Caches/Homebrew/openjdk--20.big_sur.bottle.tar.gz... (188.3MB)
Removing: /Users/javaedge/Library/Caches/Homebrew/rabbitmq--3.11.13.all.bottle.tar.gz... (35.2MB)
Removing: /Users/javaedge/Library/Caches/Homebrew/webp--1.3.0.big_sur.bottle.2.tar.gz... (930.5KB)
Removing: /usr/local/Cellar/zstd/1.5.4... (31 files, 2.5MB)
Removing: /Users/javaedge/Library/Logs/Homebrew/pkg-config... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/libtiff... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/libtool... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/xorgproto... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/wxwidgets... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/libxau... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/little-cms2... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/mysql-client... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/libpng... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/ncurses... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/pixman... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/libxdmcp... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/cmake... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/libuv... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/freetype... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/redis... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/openjdk@11... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/brotli... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/maven... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/icu4c... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/harfbuzz... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/glib... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/libxcb... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/erlang... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/lz4... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/graphite2... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/rabbitmq... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/cairo... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/c-ares... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/zlib... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/cabextract... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/xz... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/unixodbc... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/libnghttp2... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/zookeeper... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/fontconfig... (96B)
Removing: /Users/javaedge/Library/Logs/Homebrew/openjdk... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/giflib... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/libfido2... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/krb5... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/libxrender... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/openssl@3... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/kafka... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/ca-certificates... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/gettext... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/hadoop... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/libcbor... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/zstd... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/mysql... (96B)
Removing: /Users/javaedge/Library/Logs/Homebrew/autoconf... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/libxext... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/hbase... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/hive... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/m4... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/pcre2... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/libevent... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/openssl@1.1... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/pcre... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/node... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/zsh... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/pstree... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/percona-toolkit... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/openjdk@8... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/libx11... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/protobuf... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/automake... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/git... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/lzo... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/spark... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/telnet... (64B)
Removing: /Users/javaedge/Library/Logs/Homebrew/jpeg-turbo... (64B)
Pruned 15 symbolic links and 7 directories from /usr/local
==> Caveats
==> minikube
zsh completions have been installed to:
/usr/local/share/zsh/site-functions
javaedge@JavaEdgedeMac-mini ~ %
3 启动
Linux
# 创建单节点的 k8s 集群
[root@icv-monitor-platform-dev ~]# minikube start
😄 minikube v1.30.1 on Centos 7.4.1708 (amd64)
✨ Automatically selected the docker driver. Other choices: none, ssh
🛑 The "docker" driver should not be used with root privileges. If you wish to continue as root, use --force.
💡 If you are running minikube within a VM, consider using --driver=none:
📘 https://minikube.sigs.k8s.io/docs/reference/drivers/none/
❌ Exiting due to DRV_AS_ROOT: The "docker" driver should not be used with root privileges.
[root@icv-monitor-platform-dev ~]# minikube start --force
😄 minikube v1.30.1 on Centos 7.4.1708 (amd64)
❗ minikube skips various validations when --force is supplied; this may lead to unexpected behavior
✨ Automatically selected the docker driver. Other choices: none, ssh
🛑 The "docker" driver should not be used with root privileges. If you wish to continue as root, use --force.
💡 If you are running minikube within a VM, consider using --driver=none:
📘 https://minikube.sigs.k8s.io/docs/reference/drivers/none/
📌 Using Docker driver with root privileges
👍 Starting control plane node minikube in cluster minikube
🚜 Pulling base image ...
💾 Downloading Kubernetes v1.26.3 preload ...
> index.docker.io/kicbase/sta...: 373.53 MiB / 373.53 MiB 100.00% 1.41 Mi
> preloaded-images-k8s-v18-v1...: 397.02 MiB / 397.02 MiB 100.00% 1.17 Mi
❗ minikube was unable to download gcr.io/k8s-minikube/kicbase:v0.0.39, but successfully downloaded docker.io/kicbase/stable:v0.0.39 as a fallback image
🔥 Creating docker container (CPUs=2, Memory=4000MB) ...
🐳 Preparing Kubernetes v1.26.3 on Docker 23.0.2 ...
▪ Generating certificates and keys ...
▪ Booting up control plane ...
▪ Configuring RBAC rules ...
🔗 Configuring bridge CNI (Container Networking Interface) ...
▪ Using image gcr.io/k8s-minikube/storage-provisioner:v5
🔎 Verifying Kubernetes components...
🌟 Enabled addons: default-storageclass, storage-provisioner
💡 kubectl not found. If you need it, try: 'minikube kubectl -- get pods -A'
🏄 Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default
[root@icv-monitor-platform-dev ~]#
[root@icv-monitor-platform-dev ~]# minikube kubectl config view
apiVersion: v1
clusters:
- cluster:
certificate-authority: /root/.minikube/ca.crt
extensions:
- extension:
last-update: Wed, 10 May 2023 23:05:41 CST
provider: minikube.sigs.k8s.io
version: v1.30.1
name: cluster_info
server: https://192.168.49.2:8443
name: minikube
contexts:
- context:
cluster: minikube
extensions:
- extension:
last-update: Wed, 10 May 2023 23:05:41 CST
provider: minikube.sigs.k8s.io
version: v1.30.1
name: context_info
namespace: default
user: minikube
name: minikube
current-context: minikube
kind: Config
preferences: {}
users:
- name: minikube
user:
client-certificate: /root/.minikube/profiles/minikube/client.crt
client-key: /root/.minikube/profiles/minikube/client.key
[root@icv-monitor-platform-dev ~]#
4 ssh
[root@icv-monitor-platform-dev ~]# minikube ssh
docker@minikube:~$ docker version
Client: Docker Engine - Community
Version: 23.0.2
API version: 1.42
Go version: go1.19.7
Git commit: 569dd73
Built: Mon Mar 27 16:16:18 2023
OS/Arch: linux/amd64
Context: default
Server: Docker Engine - Community
Engine:
Version: 23.0.2
API version: 1.42 (minimum version 1.12)
Go version: go1.19.7
Git commit: 219f21b
Built: Mon Mar 27 16:16:18 2023
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.20
GitCommit: 2806fc1057397dbaeefbea0e4e17bddfbd388f38
runc:
Version: 1.1.5
GitCommit: v1.1.5-0-gf19387a
docker-init:
Version: 0.19.0
GitCommit: de40ad0
docker@minikube:~$
参考
- https://minikube.sigs.k8s.io/docs/start/
更多推荐
已为社区贡献7条内容
所有评论(0)