## 在自己的笔记本上搭建k8s集群
> 系统 deepin
> 安装minikube参考文档: https://kubernetes.io/docs/tasks/tools/install-minikube/
1. 安装 kubectl
```shell
sudo curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl \
&& sudo mv kubectl /usr/local/bin/
```
2. 安装 minikube
```shell
sudo curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 \
&& sudo chmod +x minikube \
&& sudo mv minikube /sur/local/bin/
```
3. 启动 minikube
```shell
sudo minikube start --vm-driver=none
```
4. 验证是否成功
```shell
sudo kubectl cluster-info
输出:
Kubernetes master is running at https://192.168.1.191:8443
KubeDNS is running at https://192.168.1.191:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
类似这样就代表成功了
```
5. 部署一个nginx服务
```
sudo kubectl run nginx --image=nginx --port=80
输出: deployment.apps/nginx created 代表创建成功
sudo kubectl get pod
输出:
NAME READY STATUS RESTARTS AGE
nginx-7c45b84548-7rkzp 1/1 Running 0 84s
看到status为 Runing 代表运行成功了
```
6. 将部署公开为服务
```shell
sudo kubectl expose deployment nginx --type=NodePort
```
7. 获取服务地址
```shell
sudo minikube service nginx --url
输出: http://192.168.1.191:32505/
```
8. 删除服务
```
sudo kubectl delete services nginx
```
9. 删除部署
```
sudo kubectl delete deployment nginx
```
有疑问加站长微信联系(非本文作者))