Focus On Oracle

Installing, Backup & Recovery, Performance Tuning,
Troubleshooting, Upgrading, Patching, Zero-Downtime Upgrade, GoldenGate

Oracle Exadata ,Oracle ODA, Oracle ZDLRA


当前位置: 首页 » 技术文章 » Cloud

Install minikube on windows by Chocolatey

在Windows上安装Minikube的最简单方法是使用Chocolatey(需要以管理员身份运行)。Chocolatey类似于Node.js的npm,MacOS的brew(Linux上也可以用brew,http://linuxbrew.sh,brew主要为MacOS上用比较方便,在Linux上用yum更方便),Linux上的yum,简称为choco,官方地址是https://chocolatey.org/

本文是在个人笔记本中安装的,很简单,也很快,对初学者来说,可以很快的提供一个学习环境。从开始安装到最后运行主要包含以下几个步骤:

  安装Chocolatey

  通过Chocolatey安装kubernetes-cli和minikube

  minikube生成kubeconfig文件
  minikube创建minikube虚拟机
  minikube在minikube虚拟机中部署k8s
  最后通过在windows上安装的命令行工具kubectl与虚拟机中的k8s协同工作

在安装minikube以前,还需要准备一下:

  1.在计算机的BIOS中启用VT-x或AMD-v虚拟化
  2.安装virtualBox
安装chocolatey
C:\>@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
安装minikube和kubernetes-cli
C:\>choco install minikube kubernetes-cli
启动minikube
C:\>minikube start
o   minikube v0.34.1 on windows (amd64)
>   Creating virtualbox VM (CPUs=2, Memory=2048MB, Disk=20000MB) ...
@   Downloading Minikube ISO ...
 184.30 MB / 184.30 MB [============================================] 100.00% 0s
-   "minikube" IP address is 192.168.99.100
-   Configuring Docker as the container runtime ...
-   Preparing Kubernetes environment ...
@   Downloading kubelet v1.13.3
@   Downloading kubeadm v1.13.3
-   Pulling images required by Kubernetes v1.13.3 ...
-   Launching Kubernetes v1.13.3 using kubeadm ...
-   Configuring cluster permissions ...
-   Verifying component health .....
+   kubectl is now configured to use "minikube"
=   Done! Thank you for using minikube!
C:\>kubectl run hello-minikube --image=k8s.gcr.io/echoserver:1.4 --port=8080
kubectl run --generator=deployment/apps.v1 is DEPRECATED and will be removed in a future version. Use kubectl run --generator=run-pod/v1 or kubectl create instead.
deployment.apps/hello-minikube created
C:\>kubectl expose deployment hello-minikube --type=NodePort
service/hello-minikube exposed
C:\>minikube service hello-minikube --url
http://192.168.99.100:30369
C:\>
C:\>minikube service hello-minikube
-   Opening kubernetes service default/hello-minikube in default browser...

C:\>minikube dashboard
-   Enabling dashboard ...
-   Verifying dashboard health ...
-   Launching proxy ...
-   Verifying proxy health ...
-   Opening http://127.0.0.1:62123/api/v1/namespaces/kube-system/services/http:kubernetes-dashboard:/proxy/ in your default browser...

C:\>kubectl get pods --all-namespaces
NAMESPACE     NAME                               READY   STATUS    RESTARTS   AGE
kube-system   coredns-86c58d9df4-d6xmb           1/1     Running   0          21m
kube-system   coredns-86c58d9df4-d962n           1/1     Running   0          21m
kube-system   etcd-minikube                      1/1     Running   0          21m
kube-system   kube-addon-manager-minikube        1/1     Running   0          21m
kube-system   kube-apiserver-minikube            1/1     Running   0          21m
kube-system   kube-controller-manager-minikube   1/1     Running   0          20m
kube-system   kube-proxy-j9pc2                   1/1     Running   0          21m
kube-system   kube-scheduler-minikube            1/1     Running   0          20m
kube-system   storage-provisioner                1/1     Running   0          21m
C:\>
C:\>minikube stop
:   Stopping "minikube" in virtualbox ...
-   "minikube" stopped.
C:\>minikube start
o   minikube v0.34.1 on windows (amd64)
i   Tip: Use 'minikube start -p <name>' to create a new cluster, or 'minikube delete' to delete this one.
:   Restarting existing virtualbox VM for "minikube" ...
:   Waiting for SSH access ...
-   "minikube" IP address is 192.168.99.100
-   Configuring Docker as the container runtime ...
-   Preparing Kubernetes environment ...
-   Pulling images required by Kubernetes v1.13.3 ...
:   Relaunching Kubernetes v1.13.3 using kubeadm ...
:   Waiting for kube-proxy to come back up ...
-   Verifying component health ......
+   kubectl is now configured to use "minikube"
=   Done! Thank you for using minikube!
C:\> kubectl cluster-info
Kubernetes master is running at https://192.168.99.100:8443
KubeDNS is running at https://192.168.99.100:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
C:\>
C:\>kubectl get pods
NAME                              READY   STATUS    RESTARTS   AGE
hello-minikube-5c856cbf98-vv8jn   1/1     Running   1          42m
C:\>
C:\>kubectl scale --replicas=5 deployment/hello-minikube
deployment.extensions/hello-minikube scaled

C:\>kubectl get deployments
NAME             READY   UP-TO-DATE   AVAILABLE   AGE
hello-minikube   5/5     5            5           53m

C:\>kubectl get pods
NAME                              READY   STATUS    RESTARTS   AGE
hello-minikube-5c856cbf98-dh8vw   1/1     Running   0          57s
hello-minikube-5c856cbf98-ggld8   1/1     Running   0          57s
hello-minikube-5c856cbf98-vv8jn   1/1     Running   1          44m
hello-minikube-5c856cbf98-xgwsd   1/1     Running   0          57s
hello-minikube-5c856cbf98-zb6nv   1/1     Running   0          57s
C:\>kubectl get service
NAME             TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
hello-minikube   NodePort    10.111.17.186   <none>        8080:30369/TCP   46m
kubernetes       ClusterIP   10.96.0.1       <none>        443/TCP          47m
C:\>kubectl get pods --all-namespaces
NAMESPACE     NAME                                   READY   STATUS    RESTARTS   AGE
default       hello-minikube-5c856cbf98-dh8vw        1/1     Running   0          4m28s
default       hello-minikube-5c856cbf98-ggld8        1/1     Running   0          4m28s
default       hello-minikube-5c856cbf98-vv8jn        1/1     Running   1          47m
default       hello-minikube-5c856cbf98-xgwsd        1/1     Running   0          4m28s
default       hello-minikube-5c856cbf98-zb6nv        1/1     Running   0          4m28s
kube-system   coredns-86c58d9df4-mwmnw               1/1     Running   1          49m
kube-system   coredns-86c58d9df4-rjj9t               1/1     Running   1          49m
kube-system   etcd-minikube                          1/1     Running   1          48m
kube-system   kube-addon-manager-minikube            1/1     Running   1          49m
kube-system   kube-apiserver-minikube                1/1     Running   1          48m
kube-system   kube-controller-manager-minikube       1/1     Running   1          48m
kube-system   kube-proxy-876xn                       1/1     Running   0          6m16s
kube-system   kube-scheduler-minikube                1/1     Running   1          48m
kube-system   kubernetes-dashboard-ccc79bfc9-xhjmz   1/1     Running   3          33m
kube-system   storage-provisioner                    1/1     Running   3          49m
C:\>
部署minikube hello

https://kubernetes.io/docs/tutorials/hello-minikube/

C:\>kubectl create deployment hello-node --image=gcr.io/hello-minikube-zero-install/hello-node

deployment.apps/hello-node created
C:\>kubectl get deployments
NAME             READY   UP-TO-DATE   AVAILABLE   AGE
hello-minikube   5/5     5            5           78m
hello-node       0/1     1            0           10s
C:\>kubectl expose deployment hello-node --type=LoadBalancer --port=8080
service/hello-node exposed
C:\>kubectl get services
NAME             TYPE           CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
hello-minikube   NodePort       10.111.17.186   <none>        8080:30369/TCP   79m
hello-node       LoadBalancer   10.100.185.34   <pending>     8080:31229/TCP   8s
kubernetes       ClusterIP      10.96.0.1       <none>        443/TCP          80m
C:\>minikube service hello-node

-   Opening kubernetes service default/hello-node in default browser...


C:\>
C:\>kubectl delete service hello-node
service "hello-node" deleted
C:\>kubectl delete deployment hello-node
deployment.extensions "hello-node" deleted
C:\>

minikube其他平台的安装方式

  • macOS 10.12 (Sierra)

    Requires installing a hypervisor, such as hyperkit (recommended) or VirtualBox
    using brew:brew cask install minikube
    manually:curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-darwin-amd64 && sudo install minikube-darwin-amd64 /usr/local/bin/minikube
  • Linux

    Requires either the kvm2 driver (recommended), or VirtualBox
    VT-x/AMD-v virtualization must be enabled in BIOS
    manually:curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 && sudo install minikube-linux-amd64 /usr/local/bin/minikube
k8s的在线和其他玩法

https://labs.play-with-k8s.com/

https://microk8s.io/


Reference
https://chocolatey.org/install

https://kubernetes.io/docs/tasks/tools/install-minikube/

https://kubernetes.io/docs/setup/minikube/

https://kubernetes.io/docs/tutorials/hello-minikube/

https://kubernetes.io/zh/docs/concepts/overview/components/

https://k8smeetup.github.io/docs/admin/high-availability/

https://jimmysong.io/


关键词:minikube choco k8s 

相关文章

open source technology and cloud
Oracle Cloud Native Solutions
Oracle Kubernetes Engine
Install minikube on windows by Chocolatey
Terraform,docker,wercker,k8s
Top