1 安装minikube

curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-darwin-amd64

sudo install minikube-darwin-amd64 /usr/local/bin/minikube

2 Install kubectl binary with curl on macOS 

1 Download the latest release:

curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/darwin/amd64/kubectl"

2Validate the binary (optional)

curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/darwin/amd64/kubectl.sha256"

Validate the kubectl binary against the checksum file:

echo "$(cat kubectl.sha256)  kubectl" | shasum -a 256 --check

3 Make the kubectl binary executable.

chmod +x ./kubectl

4Move the kubectl binary to a file location on your system PATH.

sudo mv ./kubectl /usr/local/bin/kubectl

sudo chown root: /usr/local/bin/kubectl

5 Test to ensure the version you installed is up-to-date:

kubectl version --client

3 启动minikube

前提是需要装driver,默认选择的是doker,

所以需要提前安装docker destop,可以到官网下载安装Docker: Accelerated, Containerized Application Development

启动minikube,官方给的命令是minikube start

但国内安装的话,很多registry下载不下来,下面是我用minikube start安装时的情况

如果未安装或未启动docker desktop的输出

直接执行minikube start的情况

里面有这么一句, minikube was unable to download gcr.io/k8s-minikube/kicbase:v0.0.39, but successfully downloaded docker.io/kicbase/stable:v0.0.39 as a fallback image

意思是没有从谷歌下载到minicube,但从docker.io下载到了。

后来百度了一下,加上了两个参数container-runtime,和image-mirror-country,启动成功。

minikube start --driver=docker --container-runtime=containerd --image-mirror-country='cn'

打开看板

minikube dashboard

4 发布应用-service

Create a sample deployment and expose it on port 8080:

kubectl create deployment hello-minikube --image=kicbase/echo-server:1.0

kubectl expose deployment hello-minikube --type=NodePort --port=8080

It may take a moment, but your deployment will soon show up when you run:

kubectl get services hello-minikube

The easiest way to access this service is to let minikube launch a web browser for you:

minikube service hello-minikube

Alternatively, use kubectl to forward the port:

kubectl port-forward service/hello-minikube 7080:8080

Tada! Your application is now available at http://localhost:7080/.

You should be able to see the request metadata in the application output. Try changing the path of the request and observe the changes. Similarly, you can do a POST request and observe the body show up in the output.

  

此时浏览器会自动打开页面

也可通过curl命令访问页面

curl http://127.0.0.1:55958

参考

hello minikube

Hello Minikube | Kubernetes

minikube download

—用curl方法安装

minikube start | minikube

kubectl download

—用curl方法安装

Install and Set Up kubectl on macOS | Kubernetes

minicube start

minikube start_一个松的博客-CSDN博客

minikube无法启动:“minikube service hello-minikube”无法访问问题解决

minikube无法启动:“minikube service hello-minikube”无法访问问题解决_minikube 启动失败_程序员不鸣的博客-CSDN博客

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐