k8s学习 — (运维)第十二章 Kubernetes 可视化界面
※ 各章节重要知识点
1 Kubernetes Dashboard
1.1 安装
下载官方部署配置文件
wget https://raw.githubusercontent.com/kubernetes/dashboard/v2.7.0/aio/deploy/recommended.yaml
# 修改属性
kind: Service
apiVersion: v1
metadata:
labels:
k8s-app: kubernetes-dashboard
name: kubernetes-dashboard
namespace: kubernetes-dashboard
spec:
type: NodePort #新增
ports:
- port: 443
targetPort: 8443
selector:
k8s-app: kubernetes-dashboard
创建资源
kubectl apply -f recommend.yaml
查看资源是否已经就绪
kubectl get all -n kubernetes-dashboard -o wide
访问测试
https://节点ip:端口
1.2 配置所有权限账号
创建账号配置文件
touch dashboard-admin.yaml
# 配置文件
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
k8s-app: kubernetes-dashboard
name: dashboard-admin
namespace: kubernetes-dashboard
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: dashboard-admin-cluster-role
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: dashboard-admin
namespace: kubernetes-dashboard
创建资源
kubectl apply -f dashboard-admin.yaml
查看账号信息
kubectl describe serviceaccount dashboard-admin -n kubernetes-dashboard
获取账号的 token 登录 dashboard
kubectl describe secrets dashboard-admin-token-5crbd -n kubernetes-dashboard
1.3 Dashboard 的使用
2 kubesphere
KubeSphere 愿景是打造一个以 Kubernetes 为内核的云原生分布式操作系统,它的架构可以非常方便地使第三方应用与云原生生态组件进行即插即用(plug-and-play)的集成,支持云原生
应用在多云与多集群的统一分发和运维管理。
2.1 本地存储动态 PVC
在所有节点安装 iSCSI 协议客户端(OpenEBS 需要该协议提供存储支持)
yum install iscsi-initiator-utils -y
设置开机启动
systemctl enable --now iscsid
启动服务
systemctl start iscsid
查看服务状态
systemctl status iscsid
安装 OpenEBS
kubectl apply -f https://openebs.github.io/charts/openebs-operator.yaml
查看状态(下载镜像可能需要一些时间)
kubectl get all -n openebs
在主节点创建本地 storage class
kubectl apply -f default-storage-class.yaml
2.2 安装
安装资源
kubectl apply -f https://github.com/kubesphere/ks-installer/releases/download/v3.3.1/kubesphere-installer.yaml
kubectl apply -f https://github.com/kubesphere/ks-installer/releases/download/v3.3.1/cluster-configuration.yaml
检查安装日志
kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l 'app in (ks-install, ks-installer)' -o jsonpath='{.items[0].metadata.name}') -f
查看端口
kubectl get svc/ks-console -n kubesphere-system
默认端口是 30880,如果是云服务商,或开启了防火墙,记得要开放该端口
登录控制台访问,账号密码:admin/P@88w0rd
2.3 启用可插拔组件
https://kubesphere.io/zh/docs/v3.3/pluggable-components