本实验采用ingress所暴露的域名:https://web.odocker.com
方式一:token访问
可使用kubectl describe secret -n kubernetes-dashboard ${ADMIN_SECRET} | grep -E '^token' | awk '{print $2}'所获取的token访问。
方式二:kubeconfig访问
local-ngkeconk8s-1-21-admin.kubeconfig文件访问。
提示:
更多dashboard访问方式及认证可参考附004.Kubernetes Dashboard简介及使用。
dashboard登录整个流程可参考:https://www.cnadn.net/post/2613.html
Longhorn是用于Kubernetes的开源分布式块存储系统。
提示:更多介绍参考:https://github.com/longhorn/longhorn。
提示:所有节点都需要安装。
提示:ui图形界面可复用master高可用,因此部署在master节点。
默认longhorn使用/var/lib/longhorn/作为设备路径,因此建议提前挂载。
[root@master01 ~]# source environment.sh [root@master01 ~]# for node_ip in ${NODE_IPS[@]} do echo ">>> ${node_ip}" ssh root@${node_ip} "mkfs.xfs -f /dev/sdb && mkdir -p /var/lib/longhorn/ && echo '/dev/sdb /var/lib/longhorn xfs defaults 0 0' >> /etc/fstab && mount -a" done 配置Longhorn [root@master01 ~]# mkdir longhorn [root@master01 ~]# cd longhorn/ [root@master01 longhorn]# wget \ https://raw.githubusercontent.com/longhorn/longhorn/master/deploy/longhorn.yaml [root@master01 longhorn]# vi longhorn.yaml …… --- apiVersion: apps/v1 kind: DaemonSet metadata: labels: app: longhorn-manager name: longhorn-manager …… imagePullPolicy: IfNotPresent …… --- apiVersion: apps/v1 kind: Deployment metadata: labels: app: longhorn-ui name: longhorn-ui …… nodeSelector: longhorn-ui: enabled #追加标签选择 tolerations: - key: node-role.kubernetes.io/master #添加容忍 effect: NoSchedule # imagePullSecrets: # - name: …… --- kind: Service apiVersion: v1 metadata: labels: app: longhorn-ui name: longhorn-frontend namespace: longhorn-system spec: type: NodePort #修改为nodeport selector: app: longhorn-ui ports: - port: 80 targetPort: 8000 nodePort: 30002 --- …… [root@master01 longhorn]# kubectl apply -f longhorn.yaml [root@master01 longhorn]# kubectl -n longhorn-system get pods -o wide提示:若部署异常可删除重建,若出现无法删除namespace,可通过如下操作进行删除:
提示:默认longhorn部署完成已创建一个sc,也可通过如下手动编写yaml创建。
[root@master01 longhorn]# kubectl apply -f longhornsc.yaml
测试PV及PVC [root@master01 longhorn]# cat <<EOF > longhornpod.yaml apiVersion: v1 kind: PersistentVolumeClaim metadata: name: longhorn-pvc spec: accessModes: - ReadWriteOnce storageClassName: longhorn resources: requests: storage: 500Mi --- apiVersion: v1 kind: Pod metadata: name: longhorn-pod namespace: default spec: containers: - name: volume-test image: nginx:stable-alpine imagePullPolicy: IfNotPresent volumeMounts: - name: volv mountPath: /data ports: - containerPort: 80 volumes: - name: volv persistentVolumeClaim: claimName: longhorn-pvc EOF [root@master01 longhorn]# kubectl apply -f longhornpod.yaml [root@master01 longhorn]# kubectl get pods [root@master01 longhorn]# kubectl get pvc [root@master01 longhorn]# kubectl get pv