#!/bin/bash

mkdir /root/.kube
cp kube_config_cluster.yml /root/.kube/config

kubectl apply -f k8s-dashboard.yaml
kubectl delete -f k8s-dashboard.yaml

kubectl create token admin-user -n kubernetes-dashboard --duration=26280h
kubectl create token read-only-user -n kubernetes-dashboard --duration=26280h 1 token的管控

# 删除旧的绑定（为了保险起见，避免残留）
kubectl delete clusterrolebinding admin-user
# 重新创建绑定
kubectl create clusterrolebinding admin-user \
 --clusterrole=cluster-admin \
 --serviceaccount=kubernetes-dashboard:admin-user 3 重新生成token
kubectl create token admin-user -n kubernetes-dashboard --duration=26280h

## 你无法查看已经生成的 Token 列表。

kubectl apply -f k8s-nfs.yaml
kubectl delete -f k8s-nfs.yaml

kubectl -n kube-system describe pod $(kubectl -n kube-system get pods | grep nfs-client-provisioner |  awk '{print$1}')

kubectl apply -f k8s-nfs-test.yaml
kubectl delete -f k8s-nfs-test.yaml

# 在NFS-Server机器上执行
cd /var/lib/docker/nfs_data


kubectl create ns cq-ws-260319

kubectl apply -f k8s-pvc.yaml
kubectl delete -f k8s-pvc.yaml

#飞行服务不需要
kubectl apply -f k8s-mongo.yaml
kubectl delete -f k8s-mongo.yaml

vim k8s-emqx.yaml
kubectl apply -f k8s-emqx.yaml
kubectl delete -f k8s-emqx.yaml

kubectl apply -f k8s-rabbitmq.yaml
kubectl delete -f k8s-rabbitmq.yaml

kubectl apply -f k8s-redis.yaml
kubectl delete -f k8s-redis.yaml

# 监管平台不需要
kubectl apply -f k8s-influxdb.yaml
kubectl delete -f k8s-influxdb.yaml

kubectl apply -f k8s-mysql.yaml
kubectl delete -f k8s-mysql.yaml


----
 doris部署-监管
---
kubectl apply -f doris-pvc.yaml
kubectl apply -f doris-fe-configmap.yaml
kubectl apply -f doris-be-configmap.yaml
kubectl apply -f doris-be-internal-service.yaml
kubectl apply -f doris-be-service.yaml
kubectl apply -f doris-fe-internal-service.yaml
kubectl apply -f doris-fe-service.yaml


kubectl apply -f doris-fe-statusfulset.yaml
kubectl delete -f doris-fe-statusfulset.yaml

kubectl apply -f doris-be-statusfulset.yaml
kubectl delete -f doris-be-statusfulset.yaml

---
数据库初始化

参照 999-数据库脚本/a_rmdc-db-operator.sh
---

--- 飞服务不需要
kubectl apply -f k8s-nacos.yaml
kubectl delete -f k8s-nacos.yaml


vim k8s-configmap.yaml
kubectl apply -f k8s-configmap.yaml
kubectl delete -f k8s-configmap.yaml

vi k8s-ingress.yaml
kubectl apply -f k8s-ingress.yaml
kubectl delete -f k8s-ingress.yaml

vi k8s-minio.yaml
kubectl apply -f k8s-minio.yaml
kubectl delete -f k8s-minio.yaml

vi k8s-frontend.yaml
kubectl apply -f k8s-frontend.yaml
kubectl delete -f k8s-frontend.yaml

vi k8s-backend.yaml
kubectl apply -f k8s-backend.yaml
kubectl delete -f k8s-backend.yaml

kubectl -n kube-system get pods -o jsonpath='{.items[*].metadata.name}' 

vi k8s-srs.yaml
kubectl apply -f k8s-srs.yaml
kubectl delete -f k8s-srs.yaml