Minikube:搭建部署单机 Kubernetes
课程分享:
- 课程分享:Docker+Kubernetes(k8s)微服务容器化实践
课程分享:Kubernetes(k8s)生产级实践指南 从部署到核心应用
课程分享:(极客时间)深入剖析Kubernetes
安装kubectl
Kubectl 是 Kubernetes 自带的命令行工具,可以用它直接操作 Kubernetes。
在线方式
macOS,执行:
# using brew https://brew.sh/
brew install kubernetes-cli
Linux,执行:
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl&& chmod +x kubectl && sudo mv kubectl /usr/local/bin/
Windows,执行:
curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.15.0/bin/windows/amd64/kubectl.exe
离线方式
可以从kubernetes库上直接下载,方法如下:
-
step 1: 访问官方github网址:https://github.com/kubernetes/kubernetes/releases
-
step 2: 找到想使用的发布版本,在每个发布版本的最后一行有类似“CHANGELOG-1.10.md”这样的内容,点击超链进入;
-
step 3: 然后进入“Client Binaries”区域;
-
step 4: 选择和目标机器系统匹配的二进制包下载;
-
step 5: 解压缩,放入/usr/local/bin目录;
安装minikube
阿里云(推荐)
首先记住阿里云发布的minikube地址:https://github.com/AliyunContainerService/minikube
阿里云提供了最新的Minikube修改版的文件,可以直接下载使用
Mac OSX
$ minikube version
minikube version: v1.2.0
缺省Minikube使用VirtualBox驱动来创建Kubernetes本地环境
[root@localhost ~]# minikube start -p K8sTest
* [K8sTest] minikube v1.3.1 on Centos 7.2.1511
! Please don't run minikube as root or with 'sudo' privileges. It isn't necessary with virtualbox driver.
* Using image repository registry.cn-hangzhou.aliyuncs.com/google_containers
* Creating virtualbox VM (CPUs=2, Memory=2000MB, Disk=20000MB) ...
* Preparing Kubernetes v1.15.2 on Docker 18.09.8 ...
* Pulling images ...
* Launching Kubernetes ...
* Waiting for: apiserver proxy etcd scheduler controller dns
* Done! kubectl is now configured to use "K8sTest"
通过cat ~/.kube/config 验证多了一个cluster集群
[root@localhost ~]# cat ~/.kube/config
apiVersion: v1
clusters:
- cluster:certificate-authority: /root/.minikube/ca.crtserver: https://192.168.99.101:8443name: K8sTest
- cluster:certificate-authority: /root/.minikube/ca.crtserver: https://192.168.99.100:8443name: minikube
contexts:
- context:cluster: K8sTestuser: K8sTestname: K8sTest
- context:cluster: minikubeuser: minikubename: minikube
current-context: K8sTest
kind: Config
preferences: {}
users:
- name: K8sTestuser:client-certificate: /root/.minikube/client.crtclient-key: /root/.minikube/client.key
- name: minikubeuser:client-certificate: /root/.minikube/client.crtclient-key: /root/.minikube/client.key
验证
执行下面的命令:
$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
minikube Ready master 4m5s v1.15.0
若输出正常,则表示创建成功。
minikube ssh 验证k8s里的服务
但是,但是,minikube start并不代表,整个k8s集群搭建好了,因为k8s里的服务还需要起,比如API server,scheduler,kubelet等等,他们都是以容器的方式在后台启动。
那怎么判断成功了呢?
我们可以通过minikube ssh进到虚机里,然后看看是否有一些container运行起来了

minikube dashboard
在本地运行
minikube dashboard会在本地弹出浏览器,就是Kubernetes的dashboard,那基本上恭喜您,安装成功了

问题3:error: failed to discover supported resources: Get https://192.168.99.100:8443/api: Service Unavailable
[root@localhost ~]# minikube help
Minikube is a CLI tool that provisions and manages single-node Kubernetes clusters optimized for
development workflows.Basic Commands:start Starts a local kubernetes clusterstatus Gets the status of a local kubernetes clusterstop Stops a running local kubernetes clusterdelete Deletes a local kubernetes clusterdashboard Access the kubernetes dashboard running within the minikube clusterImages Commands:docker-env Sets up docker env variables; similar to '$(docker-machine env)'cache Add or delete an image from the local cache.Configuration and Management Commands:addons Modify minikube's kubernetes addonsconfig Modify minikube configprofile Profile gets or sets the current minikube profileupdate-context Verify the IP address of the running cluster in kubeconfig.Networking and Connectivity Commands:service Gets the kubernetes URL(s) for the specified service in your local clustertunnel tunnel makes services of type LoadBalancer accessible on localhostAdvanced Commands:mount Mounts the specified directory into minikubessh Log into or run a command on a machine with SSH; similar to 'docker-machine ssh'kubectl Run kubectlTroubleshooting Commands:ssh-key Retrieve the ssh identity key path of the specified clusterip Retrieves the IP address of the running clusterlogs Gets the logs of the running instance, used for debugging minikube, not user code.update-check Print current and latest version numberversion Print the version of minikubeOther Commands:completion Outputs minikube shell completion for the given shell (bash or zsh)Use "minikube --help" for more information about a given command.
minikube在线使用体验
https://kubernetes.io/docs/tutorials/kubernetes-basics/create-cluster/cluster-interactive/
参考链接:
https://yq.aliyun.com/articles/221687
https://github.com/caicloud/kube-ladder/edit/master/tutorials/lab1-installation.md
https://blog.csdn.net/java_zyq/article/details/88971407
https://stackoverrun.com/cn/q/12359425
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
