kubesphere / ks-installer

Install KubeSphere on existing Kubernetes cluster
https://kubesphere.io
Apache License 2.0
532 stars 747 forks source link

kubeasz单机群下部署kubesphere-出错后的修改脚本 #1136

Open wushifeng opened 4 years ago

wushifeng commented 4 years ago

使用kubeasz在单机k8s群,具体的步骤

# https://github.com/easzlab/kubeasz

chmod +x ./easzup2.2.1

echo "#########download packages#########"
# 1 下载安装包
# docker: 19.03.8
# k8s: 1.18.3
./easzup2.2.1 -D

# 2 rpm包之类
# 可选下载离线系统包 (适用于无法使用 yum/apt 仓库情形)
./easzup2.2.1 -P

echo "#########run ansible controller#########"
# 3 容器化运行 kubeasz,详见文档
./easzup2.2.1 -S

echo "#########setup aio#########"
sed -i 's/^INSTALL_SOURCE.*$/INSTALL_SOURCE: "offline"/g' /etc/ansible/roles/chrony/defaults/main.yml
sed -i 's/^INSTALL_SOURCE.*$/INSTALL_SOURCE: "offline"/g' /etc/ansible/roles/ex-lb/defaults/main.yml
sed -i 's/^INSTALL_SOURCE.*$/INSTALL_SOURCE: "offline"/g' /etc/ansible/roles/kube-node/defaults/main.yml
sed -i 's/^INSTALL_SOURCE.*$/INSTALL_SOURCE: "offline"/g' /etc/ansible/roles/prepare/defaults/main.yml
# 4 使用默认配置安装 aio 集群
docker exec -it kubeasz easzctl start-aio

在上面的群上安装kubesphere 安装前提条件 https://kubesphere.io/zh/docs/installing-on-kubernetes/introduction/prerequisites/ kubectl apply -f https://raw.githubusercontent.com/kubesphere/ks-installer/v3.0.0/deploy/kubesphere-installer.yaml kubectl apply -f https://raw.githubusercontent.com/kubesphere/ks-installer/v3.0.0/deploy/cluster-configuration.yaml

安装后,出现问题,没有minikube方便,看日志需要配置存储

如下提供了一个主机的sc.yaml

#使用本机提供默认的存储
#https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/
apiVersion: v1
kind: Namespace
metadata:
  name: kubesphere-system

---
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  namespace: kube-system
  name: standard
  annotations:
    storageclass.beta.kubernetes.io/is-default-class: "true"
  labels:
    addonmanager.kubernetes.io/mode: Reconcile
provisioner: kubernetes.io/host-path

#1 redis
---
kind: PersistentVolume
apiVersion: v1
metadata:
  name: redis-pv
  namespace: kubesphere-system
  labels:
    type: local-redis
spec:
  storageClassName: standard
  capacity:
    storage: 200Mi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "/opt/data/redis"

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: redis-pvc
  namespace: kubesphere-system
spec:
  accessModes:
    - ReadWriteOnce
  volumeMode: Filesystem
  resources:
    requests:
      storage: 200Mi
  selector:
    matchLabels:
      type: local-redis

#2 etcd
---
kind: PersistentVolume
apiVersion: v1
metadata:
  name: etcd-pv
  namespace: kubesphere-system
  labels:
    type: local-etcd
spec:
  storageClassName: standard
  capacity:
    storage: 200Mi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "/opt/data/etcd"
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: etcd-pvc
  namespace: kubesphere-system
  labels:
    app: kubesphere
    tier: etcd
spec:
  accessModes:
    - ReadWriteOnce
  volumeMode: Filesystem
  resources:
    requests:
      storage: 200Mi
  selector:
    matchLabels:
      type: local-etcd

#3 minio
---
kind: PersistentVolume
apiVersion: v1
metadata:
  name: minio-pv
  namespace: kubesphere-system
  labels:
    type: local-minio
spec:
  storageClassName: standard
  capacity:
    storage: 200Mi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "/opt/data/minio"
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: minio-pvc
  namespace: kubesphere-system
  labels:
    app: kubesphere
    tier: minio
spec:
  accessModes:
    - ReadWriteOnce
  volumeMode: Filesystem
  resources:
    requests:
      storage: 200Mi
  selector:
    matchLabels:
      type: local-minio

#4 mysql
---
kind: PersistentVolume
apiVersion: v1
metadata:
  name: mysql-pv
  namespace: kubesphere-system
  labels:
    type: local-mysql
spec:
  storageClassName: standard
  capacity:
    storage: 200Mi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "/opt/data/mysql"
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mysql-pvc
  namespace: kubesphere-system
  labels:
    app: kubesphere
    tier: db
spec:
  accessModes:
    - ReadWriteOnce
  volumeMode: Filesystem
  resources:
    requests:
      storage: 200Mi
  selector:
    matchLabels:
      type: local-mysql

#5 openldap
---
kind: PersistentVolume
apiVersion: v1
metadata:
  name: openldap-pv
  namespace: kubesphere-system
  labels:
    type: local-openldap
spec:
  storageClassName: standard
  capacity:
    storage: 200Mi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "/opt/data/openldap"
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: openldap-pvc-openldap-0
  namespace: kubesphere-system
  labels:
    app.kubernetes.io/instance: ks-openldap
    app.kubernetes.io/name: openldap-ha
spec:
  accessModes:
    - ReadWriteOnce
  volumeMode: Filesystem
  resources:
    requests:
      storage: 200Mi
  selector:
    matchLabels:
      type: local-openldap

#6 prometheus
---
kind: PersistentVolume
apiVersion: v1
metadata:
  name: prometheus-pv
  namespace: kubesphere-monitoring-system
  labels:
    type: local-prometheus
spec:
  storageClassName: standard
  capacity:
    storage: 200Mi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "/opt/data/prometues"
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: prometheus-k8s-db-prometheus-k8s-0
  namespace: kubesphere-monitoring-system
  labels:
    app: prometheus
    prometheus: k8s
spec:
  accessModes:
    - ReadWriteOnce
  volumeMode: Filesystem
  resources:
    requests:
      storage: 200Mi
  selector:
    matchLabels:
      type: local-prometheus

安装kubesphere步骤

# kubectl --kubeconfig=./config  #在没有预先配置的kubeconfig的主机上执行时可以使用这个方式
kubectl delete -f kubesphere-installer.yaml
kubectl delete -f cluster-configuration.yaml
kubectl delete -f sc.yaml
rm -rf /opt/data/*

mkdir -p /opt/data/{redis,etcd,minio,mysql,openldap,prometues}
kubectl apply -f sc.yaml #需要在k8s dashboard中看下pvc的状态是否正常
kubectl apply -f kubesphere-installer.yaml
kubectl apply -f cluster-configuration.yaml

sleep 5
kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l app=ks-install -o jsonpath='{.items[0].metadata.name}') -f
yunkunrao commented 3 years ago

/kind support