欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

使用minikube搭建k8s单节点集群

程序员文章站 2022-03-07 11:13:00
...

在国内不*,通过minikube快速搭建k8s单节点环境。

  • 下载kubectl:
# curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.16.0/bin/linux/amd64/kubectl

# mv kubectl /usr/local/bin/ && chmod +x /usr/local/bin/kubectl

# kubectl version
  • 下载安装minikube:
# curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-1.5.2.rpm && sudo rpm -ivh minikube-1.5.2.rpm

# minikube config set vm-driver none

# minikube start
  • 报错:
* Unable to pull images, which may be OK: running cmd: "/bin/bash -c \"sudo env PATH=/var/lib/minikube/binaries/v1.16.2:$PATH kubeadm config images pull --config /var/tmp/minikube/kubeadm.yaml\"": command failed: /bin/bash -c "sudo env PATH=/var/lib/minikube/binaries/v1.16.2:$PATH kubeadm config images pull --config /var/tmp/minikube/kubeadm.yaml"
stdout: 
stderr: failed to pull image "k8s.gcr.io/kube-apiserver:v1.16.2": output: Error response from daemon: Get https://k8s.gcr.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

解决报错:

# minikube start --registry-mirror=https://registry.docker-cn.com --image-repository=registry.cn-hangzhou.aliyuncs.com/google_containers# minikube start --image-mirror-country=cn

两条命令都可以成功创建k8s单节点集群。

  • 查看单节点集群信息:
# kubectl cluster-info
Kubernetes master is running at https://192.168.30.128:8443
KubeDNS is running at https://192.168.30.128:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

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