我将带你完成在Ubuntu 18.04操作系统上安装minikube的步骤。Minikube支持VirtualBox和KVM管理程序,本文将涵盖两个虚拟机管理程序。
简介 Minikube是一个开源工具,旨在使开发人员和系统管理员能够在其本地计算机上运行单个Kubernetes集群,Minikube在本地启动单节点kubernetes集群,资源利用率很低。这是开发测试和POC目的的理想选择。 简而言之,Minikube打包并配置Linux VM,然后将Docker和所有Kubernetes组件安装到其中,Minikube支持Kubernetes功能,例如:DNS、NodePorts、ConfigMaps和Secrets、Dashboards。
第1步:更新系统 运行以下命令将所有系统软件包更新到最新版本: sudo apt-get update sudo apt-get install apt-transport-https sudo apt-get upgrade
第2步:安装KVM或VirtualBox Hypervisor 对于VirtualBox用户,使用以下命令安装VirtualBox: sudo apt install virtualbox virtualbox-ext-pack 对于那些有兴趣使用KVM管理程序的人,请参考如何在Ubuntu 18.04服务器上安装和配置KVM。
第3步:下载minikube 你需要下载minikube二进制文件,我将二进制文件放在/usr/local/bin目录下,因为它位于$PATH中: wget https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 chmod +x minikube-linux-amd64 sudo mv minikube-linux-amd64 /usr/local/bin/minikube 确认已安装版本: $ minikube version minikube version: v0.28.0
第4步:在Ubuntu 18.04上安装kubectl 我们需要kubectl,这是一个用于在Kubernetes上部署和管理应用程序的命令行工具: curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - 添加Kubernetes apt存储库: echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list 更新apt索引并安装kubectl: sudo apt update sudo apt -y install kubectl 检查版本: # kubectl version -o json { "clientVersion": { "major": "1", "minor": "10", "gitVersion": "v1.10.4", "gitCommit": "5ca598b4ba5abb89bb773071ce452e33fb66339d", "gitTreeState": "clean", "buildDate": "2019-02-23T08:13:03Z", "goVersion": "go1.9.3", "compiler": "gc", "platform": "linux/amd64" } }
第5步:启动minikube 现在已经安装了组件,你可以启动minikube,将为Kubernetes单节点群集下载和配置VM映像: $ minikube start Starting local Kubernetes v1.10.0 cluster... Starting VM... Downloading Minikube ISO 150.53 MB / 150.53 MB [=====================] 100.00% 0s Getting VM IP address... Moving files into cluster... Downloading kubeadm v1.10.0 Downloading kubelet v1.10.0 Finished Downloading kubeadm v1.10.0 Finished Downloading kubelet v1.10.0 Setting up certs... Connecting to cluster... Setting up kubeconfig... Starting cluster components... Kubectl is now configured to use the cluster. Loading cached images from config file. 等待下载和设置完成,然后确认一切正常。
第6步:Minikube Basic操作 要检查群集状态,请运行: $ kubectl cluster-info Kubernetes master is running at https://192.168.39.117:8443 KubeDNS is running at https://192.168.39.117:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'. 请注意,Minikube配置文件位于: ~/.minikube/machines/minikube/config.json 要查看配置,请使用: $ kubectl config view apiVersion: v1 clusters: - cluster: certificate-authority: /home/jmutai/.minikube/ca.crt server: https://192.168.39.117:8443 name: minikube contexts: - context: cluster: minikube user: minikube name: minikube current-context: minikube kind: Config preferences: {} users: - name: minikube user: client-certificate: /home/jmutai/.minikube/client.crt client-key: /home/jmutai/.minikube/client.key 要检查运行节点: $ kubectl get nodes
使用ssh访问minikube VM: $ minikube ssh
$ sudo su - 要停止正在运行的本地kubernetes集群,请运行: $ minikube stop 要删除本地kubernetes集群,请使用: $ minikube delete
第7步:启用Kubernetes仪表板 Kubernete附带一个Web仪表板,允许你管理群集而无需与命令行交互,默认情况下,在minikube上安装并启用仪表板插件: $ minikube addons list - addon-manager: enabled - coredns: disabled - dashboard: enabled - default-storageclass: enabled - efk: disabled - freshpod: disabled - heapster: disabled - ingress: disabled - kube-dns: enabled - metrics-server: disabled - registry: disabled - registry-creds: disabled - storage-provisioner: enabled 要直接在默认浏览器上打开,请使用: $ minikube dashboard 获取仪表板的URL: $ minikube dashboard --url http://192.168.39.117:30000 然后在浏览器上打开URL访问Kubernetes仪表板。
相关主题 |