使用minikube构建本地单节点的kubernetes集群

minikube可以快速构建一个单节点k8s集群用于学习测试使用。

  • 用户赋权,不要使用root用户
[root@localhost ~]# usermod -aG docker minik && newgrp docker
[root@localhost ~]# id minik
uid=1001(minik) gid=1001(minik) groups=1001(minik),996(docker)
  • 下载安装最新版minikube
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube
  • 启动集群。 安装完成后使用minikube start启动一个集群
[minik@localhost ~]$ minikube start
* minikube v1.24.0 on Centos 7.8.2003
* Using the docker driver based on existing profile

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

* Starting control plane node minikube in cluster minikube
* Pulling base image ...

  • 安装kubectl后使用kubectl get po -A或直接使用minikube kubectl -- get po -A直接与集群交互,为方便操作,可以顺便同时使用别名
alias kubectl="minikube kubectl --"
[minik@localhost ~]$ minikube kubectl -- get pods -A
NAMESPACE              NAME                                         READY   STATUS    RESTARTS      AGE
kube-system            coredns-78fcd69978-wv74w                     1/1     Running   1 (48m ago)   7d7h
kube-system            etcd-minikube                                1/1     Running   1 (48m ago)   7d7h
kube-system            kube-apiserver-minikube                      1/1     Running   1 (48m ago)   7d7h
kube-system            kube-controller-manager-minikube             1/1     Running   1 (48m ago)   7d7h
kube-system            kube-proxy-bgzxq                             1/1     Running   1 (48m ago)   7d7h
kube-system            kube-scheduler-minikube                      1/1     Running   1 (48m ago)   7d7h
kube-system            storage-provisioner                          1/1     Running   2 (47m ago)   7d7h
kubernetes-dashboard   dashboard-metrics-scraper-5594458c94-n4sn5   1/1     Running   1 (48m ago)   7d6h
kubernetes-dashboard   kubernetes-dashboard-654cf69797-t7blw        1/1     Running   2 (47m ago)   7d6h

  • 查看集群信息
[minik@localhost ~]$ minikube kubectl cluster-info
Kubernetes control plane is running at https://192.168.49.2:8443
CoreDNS is running at https://192.168.49.2:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.

上一篇:K8s学习笔记-001-Kubeadm安装k8s集群(5台机器CentOS7-3台master,2台node)


下一篇:linux环境nginx每天自动重启:crontab