Minikube in container
环境
Ubuntu18.04 VMware虚拟机
步骤
安装curl
root@ubuntu:~# apt install curl
安装docker
root@ubuntu:~# curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
下载minikube
root@ubuntu:~# curl -Lo minikube https://kubernetes.oss-cn-hangzhou.aliyuncs.com/minikube/releases/v1.16.0/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
下载kubectl
root@ubuntu:~# cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
> deb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial main
> EOF
root@ubuntu:~# apt update
root@ubuntu:~# apt install kubectl
添加新user
root@ubuntu:~# adduser k8smini
给新user添加权限
root@ubuntu:~# chmod u+w /etc/sudoers
root@ubuntu:~# vi /etc/sudoers
在root ALL=(ALL:ALL) ALL下面添加新user ALL=(ALL:ALL) ALL
# User privilege specification
root ALL=(ALL:ALL) ALL
k8smini ALL=(ALL:ALL) ALL
将新user添加到docker group以具有使用docker权限
root@ubuntu:~# su - k8smini
k8smini@ubuntu:~$ sudo usermod -aG docker $USER && newgrp docker
以docker driver启动minikube
k8smini@ubuntu:~$ minikube start --driver=docker
* minikube v1.16.0 on Ubuntu 18.04
* Using the docker driver based on user configuration
X The requested memory allocation of 1970MiB does not leave room for system overhead (total system memory: 1970MiB). You may face stability issues.
* Suggestion: Start minikube with less memory allocated: 'minikube start --memory=1970mb'
* Starting control plane node minikube in cluster minikube
* Pulling base image ...
* Creating docker container (CPUs=2, Memory=1970MB) ...
> kubeadm.sha256: 64 B / 64 B [--------------------------] 100.00% ? p/s 0s
> kubectl.sha256: 64 B / 64 B [--------------------------] 100.00% ? p/s 0s
> kubelet.sha256: 64 B / 64 B [--------------------------] 100.00% ? p/s 0s
> kubeadm: 37.40 MiB / 37.40 MiB [---------------] 100.00% 13.76 MiB p/s 3s
> kubectl: 38.37 MiB / 38.37 MiB [---------------] 100.00% 12.48 MiB p/s 3s
> kubelet: 108.69 MiB / 108.69 MiB [-------------] 100.00% 14.51 MiB p/s 8s
- Generating certificates and keys ...
- Booting up control plane ...
- Configuring RBAC rules ...
* Verifying Kubernetes components...
* Enabled addons: default-storageclass, storage-provisioner
* Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default
查看
查看宿主机容器情况
宿主机的docker上运行着minikube的容器
k8smini@ubuntu:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d52d295d9936 registry.cn-hangzhou.aliyuncs.com/google_containers/kicbase:v0.0.15-snapshot4 "/usr/local/bin/entr…" 6 minutes ago Up 5 minutes 127.0.0.1:49156->22/tcp, 127.0.0.1:49155->2376/tcp, 127.0.0.1:49154->5000/tcp, 127.0.0.1:49153->8443/tcp minikube
查看minikube容器
可以看到minikube是一个linux的container,后续查看到是ubuntu20.04的container,并且在minikube容器里面,也有自己的docker 以及kubernetes 相关容器
所以宿主机与minikube容器的关系就是kubernetes集群是部署在minikube容器之中,而这个集群的管理者是宿主机,kubectl工具也在宿主机上
k8smini@ubuntu:~$ minikube ssh
docker@minikube:~$ uname -a
Linux minikube 4.15.0-76-generic #86-Ubuntu SMP Fri Jan 17 17:24:28 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
docker@minikube:~$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
kubernetesui/dashboard v2.1.0 9a07b5b4bfac 2 weeks ago 226MB
registry.cn-hangzhou.aliyuncs.com/google_containers/dashboard v2.1.0 9a07b5b4bfac 2 weeks ago 226MB
registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy v1.20.0 10cc881966cf 2 weeks ago 118MB
registry.cn-hangzhou.aliyuncs.com/google_containers/kube-controller-manager v1.20.0 b9fa1895dcaa 2 weeks ago 116MB
registry.cn-hangzhou.aliyuncs.com/google_containers/kube-apiserver v1.20.0 ca9843d3b545 2 weeks ago 122MB
registry.cn-hangzhou.aliyuncs.com/google_containers/kube-scheduler v1.20.0 3138b6e3d471 2 weeks ago 46.4MB
registry.cn-hangzhou.aliyuncs.com/google_containers/storage-provisioner v4 85069258b98a 3 weeks ago 29.7MB
registry.cn-hangzhou.aliyuncs.com/google_containers/etcd 3.4.13-0 0369cf4303ff 4 months ago 253MB
registry.cn-hangzhou.aliyuncs.com/google_containers/coredns 1.7.0 bfe3a36ebd25 6 months ago 45.2MB
kubernetesui/metrics-scraper v1.0.4 86262685d9ab 9 months ago 36.9MB
registry.cn-hangzhou.aliyuncs.com/google_containers/metrics-scraper v1.0.4 86262685d9ab 9 months ago 36.9MB
registry.cn-hangzhou.aliyuncs.com/google_containers/pause 3.2 80d28bedfe5d 10 months ago 683kB
docker@minikube:~$ kubectl get all -n kube-system
-bash: kubectl: command not found
docker@minikube:~$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
kubernetesui/dashboard v2.1.0 9a07b5b4bfac 2 weeks ago 226MB
registry.cn-hangzhou.aliyuncs.com/google_containers/dashboard v2.1.0 9a07b5b4bfac 2 weeks ago 226MB
registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy v1.20.0 10cc881966cf 2 weeks ago 118MB
registry.cn-hangzhou.aliyuncs.com/google_containers/kube-apiserver v1.20.0 ca9843d3b545 2 weeks ago 122MB
registry.cn-hangzhou.aliyuncs.com/google_containers/kube-scheduler v1.20.0 3138b6e3d471 2 weeks ago 46.4MB
registry.cn-hangzhou.aliyuncs.com/google_containers/kube-controller-manager v1.20.0 b9fa1895dcaa 2 weeks ago 116MB
registry.cn-hangzhou.aliyuncs.com/google_containers/storage-provisioner v4 85069258b98a 3 weeks ago 29.7MB
registry.cn-hangzhou.aliyuncs.com/google_containers/etcd 3.4.13-0 0369cf4303ff 4 months ago 253MB
registry.cn-hangzhou.aliyuncs.com/google_containers/coredns 1.7.0 bfe3a36ebd25 6 months ago 45.2MB
kubernetesui/metrics-scraper v1.0.4 86262685d9ab 9 months ago 36.9MB
registry.cn-hangzhou.aliyuncs.com/google_containers/metrics-scraper v1.0.4 86262685d9ab 9 months ago 36.9MB
registry.cn-hangzhou.aliyuncs.com/google_containers/pause 3.2 80d28bedfe5d 10 months ago 683kB
docker@minikube:~$ e
网友评论