Kubernetes上手动安装KubeSphere v3.2.1

k8s   docker   kubesphere  

安装Docker

sudo yum remove docker*  
sudo yum install -y yum-utils

#配置docker的yum地址
sudo yum-config-manager \  
--add-repo \
http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

# 安装依赖
yum install ipset socat chrony -y

#ceph client ceph支持动态扩容,nfs不再支持
yum -y install ceph-common

# 低版的centos可以升级一下kernel
yum update kernel 

#安装指定版本
sudo yum install -y docker-ce-20.10.14 docker-ce-cli-20.10.14 containerd.io-1.5.11

#    启动&开机启动docker
systemctl enable docker --now

# docker加速配置
sudo mkdir -p /etc/docker  
sudo tee /etc/docker/daemon.json <<-'EOF'  
{
  "registry-mirrors": ["https://xet0ja6w.mirror.aliyuncs.com"]
}
EOF  
sudo systemctl daemon-reload  
sudo systemctl restart docker  

安装Kubernetes

  • 基本环境
    每个机器使用内网ip互通
    每个机器配置自己的hostname,不能用localhost
#设置每个机器自己的hostname(三台主机)
hostnamectl set-hostname k8s-master-001  
hostnamectl set-hostname k8s-node-001  
hostnamectl set-hostname k8s-node-002

# 将 SELinux 设置为 permissive 模式(相当于将其禁用)
sudo setenforce 0  
sudo sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config

#关闭swap
swapoff -a  
sed -ri 's/.*swap.*/#&/' /etc/fstab

#允许 iptables 检查桥接流量
cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf  
br_netfilter  
EOF

cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf  
net.bridge.bridge-nf-call-ip6tables = 1  
net.bridge.bridge-nf-call-iptables = 1  
EOF  
sudo sysctl --system  
  • 安装kubelet、kubeadm、kubectl
#配置k8s的yum源地址
cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo  
[kubernetes]
name=Kubernetes  
baseurl=http://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64  
enabled=1  
gpgcheck=0  
repo_gpgcheck=0  
gpgkey=http://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg  
   http://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF


#安装 kubelet,kubeadm,kubectl
sudo yum install -y kubelet-1.20.9 kubeadm-1.20.9 kubectl-1.20.9

#启动kubelet
sudo systemctl enable --now kubelet

# 使用kubeadm引导集群下载镜像
sudo tee ./images.sh <<-'EOF'  
#!/bin/bash
images=(  
kube-apiserver:v1.20.9  
kube-proxy:v1.20.9  
kube-controller-manager:v1.20.9  
kube-scheduler:v1.20.9  
coredns:1.7.0  
etcd:3.4.13-0  
pause:3.2  
)
for imageName in ${images[@]} ; do  
docker pull registry.cn-guangzhou.aliyuncs.com/leoiceo_k8s_images/$imageName  
done  
EOF

chmod +x ./images.sh && ./images.sh  

#所有机器配置master域名
echo "10.3.100.66  k8s-master-001" >> /etc/hosts  
  • 初始化master节点
kubeadm init \  
--apiserver-advertise-address=10.3.100.66 \
--control-plane-endpoint=k8s-master-001 \
--image-repository registry.cn-guangzhou.aliyuncs.com/leoiceo_k8s_images \
--kubernetes-version v1.20.9 \
--service-cidr=10.96.0.0/16 \
--pod-network-cidr=192.168.88.0/16
  • 记录关键信息
    记录master执行完成后的日志
###出现如下提示
Your Kubernetes control-plane has initialized successfully!

#要开始使用您的集群,您以普通用户身份需要运行以下命令:(设置.kube/config)

  mkdir -p $HOME/.kube
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
  sudo chown $(id -u):$(id -g) $HOME/.kube/config

#或者,如果您是 root 用户,您可以运行:

  export KUBECONFIG=/etc/kubernetes/admin.conf

您现在应该将 pod 网络部署到集群。
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:  
  https://kubernetes.io/docs/concepts/cluster-administration/addons/

# 可以通过以下命令增加master节点 (24小时内有效)

  kubeadm join k8s-master-001:6443 --token 7fp3hw.ut74cse9vp33o75j \
    --discovery-token-ca-cert-hash sha256:008de1606eccddaded0b138223471b933076397861f1f2e4b7ad62074d7078f5 \
    --control-plane 

# 可以通过以下命令增加node节点,在k8s-node-001和k8s-node-002中执行 (24小时内有效)

kubeadm join k8s-master-001:6443 --token 7fp3hw.ut74cse9vp33o75j \  
    --discovery-token-ca-cert-hash sha256:008de1606eccddaded0b138223471b933076397861f1f2e4b7ad62074d7078f5

# 过期后可以创建新令牌,在master节点运行
kubeadm token create --print-join-command  
kubeadm join cluster-endpoint:6443 --token cx4xmx.rngwmypbh6yg7w5d     --discovery-token-ca-cert-hash sha256:c058080c1322afab578dc6804507cefed3bbd99c7104366458496f588a9a9048  
  • 安装Calico网络插件
curl https://docs.projectcalico.org/manifests/calico.yaml -O

# 由于本机使用了 192.168.0.0 所以修改网段 192.168.88.0/16,修改calico.yaml 如下两行
- name: CALICO_IPV4POOL_CIDR
              value: "192.168.88.0/16"

kubectl apply -f calico.yaml  
  • 加入worker节点
kubeadm join cluster-endpoint:6443 --token skud4g.314dud5shes5ed8j \  
    --discovery-token-ca-cert-hash sha256:c058080c1322afab578dc6804507cefed3bbd99c7104366458496f588a9a9048

安装KubeSphere前置环境

  • nfs文件系统
# 在每个机器。
yum install -y nfs-utils


# 在master 执行以下命令 
echo "/nfs/data/ *(insecure,rw,sync,no_root_squash)" > /etc/exports


# 执行以下命令,启动 nfs 服务;创建共享目录
mkdir -p /nfs/data


# 在master执行
systemctl enable rpcbind  
systemctl enable nfs-server  
systemctl start rpcbind  
systemctl start nfs-server

# 使配置生效
exportfs -r


#检查配置是否生效
exportfs  
  • 配置nfs-client
showmount -e 10.3.100.66  
mkdir -p /nfs/data

mount -t nfs 10.3.100.66:/nfs/data /nfs/data

# 开机自动挂载
echo "10.3.100.66:/nfs/data /nfs/data nfs  defaults,_rnetdev  1  1" >> /etc/fstab  

_rnetdev表示主机无法挂载直接跳过,避免无法挂载主机无法启动

  • 配置默认存储
## 创建了一个存储类
apiVersion: storage.k8s.io/v1  
kind: StorageClass  
metadata:  
  name: nfs-storage
  annotations:
    storageclass.kubernetes.io/is-default-class: "true"
provisioner: k8s-sigs.io/nfs-subdir-external-provisioner  
parameters:  
  archiveOnDelete: "true"  ## 删除pv的时候,pv的内容是否要备份
allowVolumeExpansion: true  ## 是否允许pvc动态扩容  
---
apiVersion: apps/v1  
kind: Deployment  
metadata:  
  name: nfs-client-provisioner
  labels:
    app: nfs-client-provisioner
  # replace with namespace where provisioner is deployed
  namespace: default
spec:  
  replicas: 1
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app: nfs-client-provisioner
  template:
    metadata:
      labels:
        app: nfs-client-provisioner
    spec:
      serviceAccountName: nfs-client-provisioner
      containers:
        - name: nfs-client-provisioner
          image: registry.cn-guangzhou.aliyuncs.com/leoiceo_k8s_images/nfs-subdir-external-provisioner:v4.0.2
          # resources:
          #    limits:
          #      cpu: 10m
          #    requests:
          #      cpu: 10m
          volumeMounts:
            - name: nfs-client-root
              mountPath: /persistentvolumes
          env:
            - name: PROVISIONER_NAME
              value: k8s-sigs.io/nfs-subdir-external-provisioner
            - name: NFS_SERVER
              value: 172.31.0.4 ## 指定自己nfs服务器地址
            - name: NFS_PATH  
              value: /nfs/data  ## nfs服务器共享的目录
      volumes:
        - name: nfs-client-root
          nfs:
            server: 172.31.0.4
            path: /nfs/data
---
apiVersion: v1  
kind: ServiceAccount  
metadata:  
  name: nfs-client-provisioner
  # replace with namespace where provisioner is deployed
  namespace: default
---
kind: ClusterRole  
apiVersion: rbac.authorization.k8s.io/v1  
metadata:  
  name: nfs-client-provisioner-runner
rules:  
  - apiGroups: [""]
    resources: ["nodes"]
    verbs: ["get", "list", "watch"]
  - apiGroups: [""]
    resources: ["persistentvolumes"]
    verbs: ["get", "list", "watch", "create", "delete"]
  - apiGroups: [""]
    resources: ["persistentvolumeclaims"]
    verbs: ["get", "list", "watch", "update"]
  - apiGroups: ["storage.k8s.io"]
    resources: ["storageclasses"]
    verbs: ["get", "list", "watch"]
  - apiGroups: [""]
    resources: ["events"]
    verbs: ["create", "update", "patch"]
---
kind: ClusterRoleBinding  
apiVersion: rbac.authorization.k8s.io/v1  
metadata:  
  name: run-nfs-client-provisioner
subjects:  
  - kind: ServiceAccount
    name: nfs-client-provisioner
    # replace with namespace where provisioner is deployed
    namespace: default
roleRef:  
  kind: ClusterRole
  name: nfs-client-provisioner-runner
  apiGroup: rbac.authorization.k8s.io
---
kind: Role  
apiVersion: rbac.authorization.k8s.io/v1  
metadata:  
  name: leader-locking-nfs-client-provisioner
  # replace with namespace where provisioner is deployed
  namespace: default
rules:  
  - apiGroups: [""]
    resources: ["endpoints"]
    verbs: ["get", "list", "watch", "create", "update", "patch"]
---
kind: RoleBinding  
apiVersion: rbac.authorization.k8s.io/v1  
metadata:  
  name: leader-locking-nfs-client-provisioner
  # replace with namespace where provisioner is deployed
  namespace: default
subjects:  
  - kind: ServiceAccount
    name: nfs-client-provisioner
    # replace with namespace where provisioner is deployed
    namespace: default
roleRef:  
  kind: Role
  name: leader-locking-nfs-client-provisioner
  apiGroup: rbac.authorization.k8s.io
  • 安装和确认配置是否生效
[root@k8s-master-001 docker]# kubectl apply -f storege.yaml
[root@k8s-master-001 docker]# kubectl get sc
NAME                    PROVISIONER                                   RECLAIMPOLICY   VOLUMEBINDINGMODE   ALLOWVOLUMEEXPANSION   AGE  
nfs-storage (default)   k8s-sigs.io/nfs-subdir-external-provisioner   Delete          Immediate           false                  12m  
  • 测试申请,200M的存储空间
kind: PersistentVolumeClaim  
apiVersion: v1  
metadata:  
  name: nginx-pvc2
spec:  
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 200Mi
[root@k8s-master-001 ~]# kubectl apply -f pvc.yaml
# 查看已经下发成功
[root@k8s-master-001 ~]# kubectl get pvc
NAME         STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS   AGE  
nginx-pvc2   Bound    pvc-ed8b1349-6717-44c4-914b-7b28c2be0102   200Mi      RWX            nfs-storage    11s  
  • 集群指标监控组件 (metrics-server)
apiVersion: v1  
kind: ServiceAccount  
metadata:  
  labels:
    k8s-app: metrics-server
  name: metrics-server
  namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1  
kind: ClusterRole  
metadata:  
  labels:
    k8s-app: metrics-server
    rbac.authorization.k8s.io/aggregate-to-admin: "true"
    rbac.authorization.k8s.io/aggregate-to-edit: "true"
    rbac.authorization.k8s.io/aggregate-to-view: "true"
  name: system:aggregated-metrics-reader
rules:  
- apiGroups:
  - metrics.k8s.io
  resources:
  - pods
  - nodes
  verbs:
  - get
  - list
  - watch
---
apiVersion: rbac.authorization.k8s.io/v1  
kind: ClusterRole  
metadata:  
  labels:
    k8s-app: metrics-server
  name: system:metrics-server
rules:  
- apiGroups:
  - ""
  resources:
  - pods
  - nodes
  - nodes/stats
  - namespaces
  - configmaps
  verbs:
  - get
  - list
  - watch
---
apiVersion: rbac.authorization.k8s.io/v1  
kind: RoleBinding  
metadata:  
  labels:
    k8s-app: metrics-server
  name: metrics-server-auth-reader
  namespace: kube-system
roleRef:  
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: extension-apiserver-authentication-reader
subjects:  
- kind: ServiceAccount
  name: metrics-server
  namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1  
kind: ClusterRoleBinding  
metadata:  
  labels:
    k8s-app: metrics-server
  name: metrics-server:system:auth-delegator
roleRef:  
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: system:auth-delegator
subjects:  
- kind: ServiceAccount
  name: metrics-server
  namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1  
kind: ClusterRoleBinding  
metadata:  
  labels:
    k8s-app: metrics-server
  name: system:metrics-server
roleRef:  
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: system:metrics-server
subjects:  
- kind: ServiceAccount
  name: metrics-server
  namespace: kube-system
---
apiVersion: v1  
kind: Service  
metadata:  
  labels:
    k8s-app: metrics-server
  name: metrics-server
  namespace: kube-system
spec:  
  ports:
  - name: https
    port: 443
    protocol: TCP
    targetPort: https
  selector:
    k8s-app: metrics-server
---
apiVersion: apps/v1  
kind: Deployment  
metadata:  
  labels:
    k8s-app: metrics-server
  name: metrics-server
  namespace: kube-system
spec:  
  selector:
    matchLabels:
      k8s-app: metrics-server
  strategy:
    rollingUpdate:
      maxUnavailable: 0
  template:
    metadata:
      labels:
        k8s-app: metrics-server
    spec:
      containers:
      - args:
        - --cert-dir=/tmp
        - --kubelet-insecure-tls
        - --secure-port=4443
        - --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname
        - --kubelet-use-node-status-port
        image: registry.cn-guangzhou.aliyuncs.com/leoiceo_k8s_images/metrics-server:v0.4.3
        imagePullPolicy: IfNotPresent
        livenessProbe:
          failureThreshold: 3
          httpGet:
            path: /livez
            port: https
            scheme: HTTPS
          periodSeconds: 10
        name: metrics-server
        ports:
        - containerPort: 4443
          name: https
          protocol: TCP
        readinessProbe:
          failureThreshold: 3
          httpGet:
            path: /readyz
            port: https
            scheme: HTTPS
          periodSeconds: 10
        securityContext:
          readOnlyRootFilesystem: true
          runAsNonRoot: true
          runAsUser: 1000
        volumeMounts:
        - mountPath: /tmp
          name: tmp-dir
      nodeSelector:
        kubernetes.io/os: linux
      priorityClassName: system-cluster-critical
      serviceAccountName: metrics-server
      volumes:
      - emptyDir: {}
        name: tmp-dir
---
apiVersion: apiregistration.k8s.io/v1  
kind: APIService  
metadata:  
  labels:
    k8s-app: metrics-server
  name: v1beta1.metrics.k8s.io
spec:  
  group: metrics.k8s.io
  groupPriorityMinimum: 100
  insecureSkipTLSVerify: true
  service:
    name: metrics-server
    namespace: kube-system
  version: v1beta1
  versionPriority: 100
  • 安装完成后可以查看k8s监控信息
[root@k8s-master-001 ~]# kubectl top nodes
NAME             CPU(cores)   CPU%   MEMORY(bytes)   MEMORY%  
k8s-master-001   121m         3%     2226Mi          60%  
k8s-node-001     66m          1%     1336Mi          36%  
k8s-node-002     72m          1%     1489Mi          40%  
# 不加 -A 默认查看default命名空间下面的状态
[root@k8s-master-001 ~]# kubectl top pods -A
NAME                                      CPU(cores)   MEMORY(bytes)  
hello-server-6cbb679d85-j2z8t             0m           1Mi  
hello-server-6cbb679d85-jpmk8             0m           1Mi  
nfs-client-provisioner-58bfb68ddd-dzds4   1m           7Mi  
nginx-demo-7d56b74b84-69r5l               0m           6Mi  
nginx-demo-7d56b74b84-9hr9v               0m           6Mi  
nginx-deploy-pvc-79fc8558c7-6svkd         0m           5Mi  
nginx-deploy-pvc-79fc8558c7-dsfjv         0m           5Mi  
private-php-fpm                           1m           6Mi  
redis                                     1m           3Mi  

安装KubeSphere

https://kubesphere.com.cn/

  • 下载核心文件
wget https://github.com/kubesphere/ks-installer/releases/download/v3.2.1/kubesphere-installer.yaml

wget https://github.com/kubesphere/ks-installer/releases/download/v3.2.1/cluster-configuration.yaml  
---
apiVersion: installer.kubesphere.io/v1alpha1  
kind: ClusterConfiguration  
metadata:  
  name: ks-installer
  namespace: kubesphere-system
  labels:
    version: v3.2.1
spec:  
  persistence:
    storageClass: ""        # If there is no default StorageClass in your cluster, you need to specify an existing StorageClass here.
  authentication:
    jwtSecret: ""           # Keep the jwtSecret consistent with the Host Cluster. Retrieve the jwtSecret by executing "kubectl -n kubesphere-system get cm kubesphere-config -o yaml | grep -v "apiVersion" | grep jwtSecret" on the Host Cluster.
  local_registry: ""        # Add your private registry address if it is needed.
  # dev_tag: ""               # Add your kubesphere image tag you want to install, by default it's same as ks-install release version.
  etcd:
    monitoring: true       # Enable or disable etcd monitoring dashboard installation. You have to create a Secret for etcd before you enable it.
    endpointIps: 10.3.100.66  # etcd cluster EndpointIps. It can be a bunch of IPs here.
    port: 2379              # etcd port.
    tlsEnable: true
  common:
    core:
      console:
        enableMultiLogin: true  # Enable or disable simultaneous logins. It allows different users to log in with the same account at the same time.
        port: 30880
        type: NodePort
    # apiserver:            # Enlarge the apiserver and controller manager's resource requests and limits for the large cluster
    #  resources: {}
    # controllerManager:
    #  resources: {}
    redis:
      enabled: true
      volumeSize: 2Gi # Redis PVC size.
    openldap:
      enabled: true
      volumeSize: 2Gi   # openldap PVC size.
    minio:
      volumeSize: 20Gi # Minio PVC size.
    monitoring:
      # type: external   # Whether to specify the external prometheus stack, and need to modify the endpoint at the next line.
      endpoint: http://prometheus-operated.kubesphere-monitoring-system.svc:9090 # Prometheus endpoint to get metrics data.
      GPUMonitoring:     # Enable or disable the GPU-related metrics. If you enable this switch but have no GPU resources, Kubesphere will set it to zero. 
        enabled: true
    gpu:                 # Install GPUKinds. The default GPU kind is nvidia.com/gpu. Other GPU kinds can be added here according to your needs. 
      kinds:         
      - resourceName: "nvidia.com/gpu"
        resourceType: "GPU"
        default: true
    es:   # Storage backend for logging, events and auditing.
      # master:
      #   volumeSize: 4Gi  # The volume size of Elasticsearch master nodes.
      #   replicas: 1      # The total number of master nodes. Even numbers are not allowed.
      #   resources: {}
      # data:
      #   volumeSize: 20Gi  # The volume size of Elasticsearch data nodes.
      #   replicas: 1       # The total number of data nodes.
      #   resources: {}
      logMaxAge: 7             # Log retention time in built-in Elasticsearch. It is 7 days by default.
      elkPrefix: logstash      # The string making up index names. The index name will be formatted as ks-<elk_prefix>-log.
      basicAuth:
        enabled: false
        username: ""
        password: ""
      externalElasticsearchUrl: ""
      externalElasticsearchPort: ""
  alerting:                # (CPU: 0.1 Core, Memory: 100 MiB) It enables users to customize alerting policies to send messages to receivers in time with different time intervals and alerting levels to choose from.
    enabled: true         # Enable or disable the KubeSphere Alerting System.
    # thanosruler:
    #   replicas: 1
    #   resources: {}
  auditing:                # Provide a security-relevant chronological set of records,recording the sequence of activities happening on the platform, initiated by different tenants.
    enabled: true         # Enable or disable the KubeSphere Auditing Log System.
    # operator:
    #   resources: {}
    # webhook:
    #   resources: {}
  devops:                  # (CPU: 0.47 Core, Memory: 8.6 G) Provide an out-of-the-box CI/CD system based on Jenkins, and automated workflow tools including Source-to-Image & Binary-to-Image.
    enabled: true             # Enable or disable the KubeSphere DevOps System.
    # resources: {}
    jenkinsMemoryLim: 2Gi      # Jenkins memory limit.
    jenkinsMemoryReq: 1500Mi   # Jenkins memory request.
    jenkinsVolumeSize: 8Gi     # Jenkins volume size.
    jenkinsJavaOpts_Xms: 512m  # The following three fields are JVM parameters.
    jenkinsJavaOpts_Xmx: 512m
    jenkinsJavaOpts_MaxRAM: 2g
  events:                  # Provide a graphical web console for Kubernetes Events exporting, filtering and alerting in multi-tenant Kubernetes clusters.
    enabled: true         # Enable or disable the KubeSphere Events System.
    # operator:
    #   resources: {}
    # exporter:
    #   resources: {}
    # ruler:
    #   enabled: true
    #   replicas: 2
    #   resources: {}
  logging:                 # (CPU: 57 m, Memory: 2.76 G) Flexible logging functions are provided for log query, collection and management in a unified console. Additional log collectors can be added, such as Elasticsearch, Kafka and Fluentd.
    enabled: true         # Enable or disable the KubeSphere Logging System.
    containerruntime: docker
    logsidecar:
      enabled: true
      replicas: 2
      # resources: {}
  metrics_server:                    # (CPU: 56 m, Memory: 44.35 MiB) It enables HPA (Horizontal Pod Autoscaler).
    enabled: false
  monitoring:
    storageClass: ""                 # If there is an independent StorageClass you need for Prometheus, you can specify it here. The default StorageClass is used by default.
    # kube_rbac_proxy:
    #   resources: {}
    # kube_state_metrics:
    #   resources: {}
    # prometheus:
    #   replicas: 1  # Prometheus replicas are responsible for monitoring different segments of data source and providing high availability.
    #   volumeSize: 20Gi  # Prometheus PVC size.
    #   resources: {}
    #   operator:
    #     resources: {}
    #   adapter:
    #     resources: {}
    # node_exporter:
    #   resources: {}
    # alertmanager:
    #   replicas: 1          # AlertManager Replicas.
    #   resources: {}
    # notification_manager:
    #   resources: {}
    #   operator:
    #     resources: {}
    #   proxy:
    #     resources: {}
    gpu:                           # GPU monitoring-related plug-in installation. 
      nvidia_dcgm_exporter:        # Ensure that gpu resources on your hosts can be used normally, otherwise this plug-in will not work properly.
        enabled: true             # Check whether the labels on the GPU hosts contain "nvidia.com/gpu.present=true" to ensure that the DCGM pod is scheduled to these nodes.
        # resources: {}
  multicluster:
    clusterRole: none  # host | member | none  # You can install a solo cluster, or specify it as the Host or Member Cluster.
  network:
    networkpolicy: # Network policies allow network isolation within the same cluster, which means firewalls can be set up between certain instances (Pods).
      # Make sure that the CNI network plugin used by the cluster supports NetworkPolicy. There are a number of CNI network plugins that support NetworkPolicy, including Calico, Cilium, Kube-router, Romana and Weave Net.
      enabled: true # Enable or disable network policies.
    ippool: # Use Pod IP Pools to manage the Pod network address space. Pods to be created can be assigned IP addresses from a Pod IP Pool.
      type: calico # Specify "calico" for this field if Calico is used as your CNI plugin. "none" means that Pod IP Pools are disabled.
    topology: # Use Service Topology to view Service-to-Service communication based on Weave Scope.
      type: none # Specify "weave-scope" for this field to enable Service Topology. "none" means that Service Topology is disabled.
  openpitrix: # An App Store that is accessible to all platform tenants. You can use it to manage apps across their entire lifecycle.
    store:
      enabled: true # Enable or disable the KubeSphere App Store.
  servicemesh:         # (0.3 Core, 300 MiB) Provide fine-grained traffic management, observability and tracing, and visualized traffic topology.
    enabled: true     # Base component (pilot). Enable or disable KubeSphere Service Mesh (Istio-based).
  kubeedge:          # Add edge nodes to your cluster and deploy workloads on edge nodes.
    enabled: false # Enable or disable KubeEdge.
    cloudCore:
      nodeSelector: {"node-role.kubernetes.io/worker": ""}
      tolerations: []
      cloudhubPort: "10000"
      cloudhubQuicPort: "10001"
      cloudhubHttpsPort: "10002"
      cloudstreamPort: "10003"
      tunnelPort: "10004"
      cloudHub:
        advertiseAddress: # At least a public IP address or an IP address which can be accessed by edge nodes must be provided.
          - ""            # Note that once KubeEdge is enabled, CloudCore will malfunction if the address is not provided.
        nodeLimit: "100"
      service:
        cloudhubNodePort: "30000"
        cloudhubQuicNodePort: "30001"
        cloudhubHttpsNodePort: "30002"
        cloudstreamNodePort: "30003"
        tunnelNodePort: "30004"
    edgeWatcher:
      nodeSelector: {"node-role.kubernetes.io/worker": ""}
      tolerations: []
      edgeWatcherAgent:
        nodeSelector: {"node-role.kubernetes.io/worker": ""}
        tolerations: []
  • 开始安装
kubectl apply -f https://github.com/kubesphere/ks-installer/releases/download/v3.2.1/kubesphere-installer.yaml

kubectl apply -f https://github.com/kubesphere/ks-installer/releases/download/v3.2.1/cluster-configuration.yaml  
  • 检查安装日志
kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l app=ks-install -o jsonpath='{.items[0].metadata.name}') -f  
  • 提示以下日志则安装成功
task alerting status is successful  (1/11)  
task network status is successful  (2/11)  
task multicluster status is successful  (3/11)  
task openpitrix status is successful  (4/11)  
task auditing status is successful  (5/11)  
task events status is successful  (6/11)  
task logging status is successful  (7/11)  
task kubeedge status is successful  (8/11)  
task devops status is successful  (9/11)  
task monitoring status is successful  (10/11)  
task servicemesh status is successful  (11/11)  
Collecting installation results ...  
#####################################################
###              Welcome to KubeSphere!           ###
#####################################################

Console: http://10.3.100.66:30880  
Account: admin  
Password: P@88w0rd
  • prometheus-operator容器运行卡住时,根据报错提示解决etcd监控证书找不到问题
kubectl -n kubesphere-monitoring-system create secret generic kube-etcd-client-certs  --from-file=etcd-client-ca.crt=/etc/kubernetes/pki/etcd/ca.crt  --from-file=etcd-client.crt=/etc/kubernetes/pki/apiserver-etcd-client.crt  --from-file=etcd-client.key=/etc/kubernetes/pki/apiserver-etcd-client.key