(二十六)、Kuboard 部署网络问题 k8s 使用本地镜像 k8s使用 register本地镜像站 综合应用
Kuboard 部署网络问题&k8s 使用本地镜像&k8s使用 register本地镜像站
文章目录
- 1、k8s 命令
- 2、拉取指定tag:版本镜像
- 2.1、查看本地镜像
- 3、删除本地镜像
- 4、本地对镜像进行重命名(docker tag)
- 5、本地拉取局域网镜像站
- 6、k8s(minikube场景) 直接可以引用本地镜像
- 7、执行 kubectl apply -f kuboard-k8s.yaml
- 8、如果使用官方镜像站,只要保证本地有对应名字和版本号即可
- 9、查看部署情况
- 10、查看 kuboard 运行情况
- 11、设计端口映射访问
- 12、访问 http://127.0.0.1:63366/dashboard
register 如果只是 ip 的话,k8s 中是由于必须使用 https 导致没有办法,因此可以采取先手动把镜像下载到k8s 所在的机器的 docker 本地镜像中,通过 eval $(minikube docker-env) 命令之后,执行
1、k8s 命令
删除 namespace
kubectl delete namespace kuboard
新建 namespace
kubectl create namespace kuboard
2、拉取指定tag:版本镜像
国内
docker pull swr.cn-east-2.myhuaweicloud.com/kuboard/kuboard:v3
VPN不稳定
docker pull kuboard/kuboard:v3
2.1、查看本地镜像
docker images
3、删除本地镜像
docker rmi <镜像ID或镜像名称:标签>
4、本地对镜像进行重命名(docker tag)
docker tag mynginx:latest DiyTag:DiyVersion
5、本地拉取局域网镜像站
192.168.0.116:5001 为局域网镜像站 ip:端口,mynginx:latest 是对应tag 和版本
docker pull 192.168.0.116:5001/mynginx:latest
6、k8s(minikube场景) 直接可以引用本地镜像
从查询顺序来说,k8s 会优先从本地找,下面的命令可以让 minukube 中的 k8s 直接识别docker本地的镜像
eval $(minikube docker-env)
7、执行 kubectl apply -f kuboard-k8s.yaml
此时执行,yaml 就会优先从本地寻找对应 tag和版本的镜像了
注意俩参数
namespace: kuboard
image: eipwork/kuboard:latest
apiVersion: apps/v1
kind: Deployment
metadata:name: kuboardnamespace: kuboardlabels:k8s.kuboard.cn/name: kuboardk8s.kuboard.cn/layer: monitor
spec:replicas: 1selector:matchLabels:k8s.kuboard.cn/name: kuboardk8s.kuboard.cn/layer: monitortemplate:metadata:labels:k8s.kuboard.cn/name: kuboardk8s.kuboard.cn/layer: monitorspec:containers:- name: kuboardimage: eipwork/kuboard:latestimagePullPolicy: IfNotPresentports:- containerPort: 80resources:limits:cpu: 500mmemory: 512Mirequests:cpu: 100mmemory: 128Mitolerations:- key: node-role.kubernetes.io/masteroperator: Existseffect: NoSchedule
---
apiVersion: v1
kind: Service
metadata:name: kuboardnamespace: kuboard
spec:type: NodePortports:- name: httpport: 80targetPort: 80#nodePort: 32567selector:k8s.kuboard.cn/name: kuboardk8s.kuboard.cn/layer: monitor
8、如果使用官方镜像站,只要保证本地有对应名字和版本号即可
kubectl apply -f https://kuboard.cn/install-script/kuboard.yaml
eipwork/kuboard:latest
9、查看部署情况
kubectl get pods -n kuboard
10、查看 kuboard 运行情况
➜ Kuboard git:(master) ✗ kubectl get svc -n kuboard
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kuboard NodePort 10.110.101.148 80:31623/TCP 2m4s
11、设计端口映射访问
➜ Kuboard git:(master) ✗ minikube service kuboard -n kuboard
┌───── ┬──── ┬────── ┬───────────── ┐
│ NAMESPACE │ NAME │ TARGET PORT │ URL │
├───── ┼──── ┼────── ┼───────────── ┤
│ kuboard │ kuboard │ http/80 │ http://192.168.49.2:31623 │
└───── ┴──── ┴────── ┴───────────── ┘
🏃 为服务 kuboard 启动隧道。/┌───── ┬──── ┬────── ┬────────────┐
│ NAMESPACE │ NAME │ TARGET PORT │ URL │
├───── ┼──── ┼────── ┼────────────┤
│ kuboard │ kuboard │ │ http://127.0.0.1:63366 │
└───── ┴──── ┴────── ┴────────────┘
🏃 为服务 kuboard 启动隧道。
🎉 正通过默认浏览器打开服务 kuboard/kuboard…
❗ 因为你正在使用 darwin 上的 Docker 驱动程序,所以需要打开终端才能运行它。
12、访问 http://127.0.0.1:63366/dashboard
获取 token
https://www.kuboard.cn/install/install-dashboard.html#%E8%8E%B7%E5%8F%96token
# 如果您参考 www.kuboard.cn 提供的文档安装 Kuberenetes,可在第一个 Master 节点上执行此命令
echo $(kubectl -n kube-system get secret $(kubectl -n kube-system get secret | grep ^kuboard-user | awk '{print $1}') -o go-template='{{.data.token}}' | base64 -d)