[关闭]
@zhangyy 2021-10-09T00:38:19.000000Z 字数 7457 阅读 98

关于二进制k8s1.17.16 部署kubesphere 填坑

kubernetes系列


一: 部署metric-0.3.6

  1. 下载:components.yaml
  2. wget https://github.com/kubernetes-sigs/metrics-server/releases/download/v0.3.6/components.yaml
  3. 下载:k8s.gcr.io/metrics-server-amd64:v0.3.6 镜像导入主机
  4. docker load -i k8s.gcr.io/metrics-server-amd64:v0.3.6
  5. kubectl apply -f components.yaml
  6. kubectl get pod -n kube-system

image_1eqc7oorr1b511ais1kbj1pll7uj9.png-101.2kB


二:关于metric 的报错问题

  1. kubectl top node
  2. 报错:
  3. Error from server (ServiceUnavailable): the server is currently unable to handle the request (get pods.metrics.k8s.io)
  4. 参考:
  5. https://blog.csdn.net/zorsea/article/details/105037533

  1. vim components.yaml
  2. ---
  3. - --kubelet-insecure-tls
  4. - --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname
  5. ---

image_1eqc80en1fv41m83qab1uvds9qm.png-100.4kB

  1. 生成metric key 授权:
  2. vim metrics-server-csr.json
  3. ---
  4. {
  5. "CN": "system:metrics-server",
  6. "hosts": [],
  7. "key": {
  8. "algo": "rsa",
  9. "size": 2048
  10. },
  11. "names": [
  12. {
  13. "C": "CN",
  14. "ST": "BeiJing",
  15. "L": "BeiJing",
  16. "O": "k8s",
  17. "OU": "system"
  18. }
  19. ]
  20. }
  21. ---
  22. cd TLS/k8s/
  23. ---
  24. cfssl gencert -ca=/opt/kubernetes/ssl/ca.pem -ca-key=/opt/kubernetes/ssl/ca-key.pem -config=ca-config.json -profile=kubernetes metrics-server-csr.json | cfssljson -bare metrics-server
  25. ---
  1. cp -p metrics-server-key.pem metrics-server.pem /opt/kubernetes/ssl/
  2. 同步到所有的master 节点
  1. 配置metrics-server RBAC授权
  2. cat > auth-metrics-server.yaml << EOF
  3. ---
  4. apiVersion: rbac.authorization.k8s.io/v1
  5. kind: ClusterRole
  6. metadata:
  7. name: system:auth-metrics-server-reader
  8. labels:
  9. rbac.authorization.k8s.io/aggregate-to-view: "true"
  10. rbac.authorization.k8s.io/aggregate-to-edit: "true"
  11. rbac.authorization.k8s.io/aggregate-to-admin: "true"
  12. rules:
  13. - apiGroups: ["metrics.k8s.io"]
  14. resources: ["pods", "nodes"]
  15. verbs: ["get", "list", "watch"]
  16. ---
  17. apiVersion: rbac.authorization.k8s.io/v1
  18. kind: ClusterRoleBinding
  19. metadata:
  20. name: metrics-server:system:auth-metrics-server
  21. roleRef:
  22. apiGroup: rbac.authorization.k8s.io
  23. kind: ClusterRole
  24. name: system:auth-metrics-server-reader
  25. subjects:
  26. - kind: User
  27. name: system:metrics-server
  28. namespace: kube-system
  29. EOF
  30. kubectl apply -f auth-metrics-server.yaml
  1. k8s apiserver 配置文件的当中加上 metrics 的认证:
  2. cd /opt/kubernetes/cfg/
  3. ---
  4. --proxy-client-cert-file=/opt/kubernetes/ssl/metrics-server.pem --proxy-client-key-file=/opt/kubernetes/ssl/metrics-server-key.pem
  5. ---
  6. 然后重启kubeapiserve

image_1eqc8f4jj1s8gs9j1m1ss7ci7413.png-50.1kB

  1. kubectl create clusterrolebinding system:anonymous --clusterrole=cluster-admin --user=system:anonymous

  1. 保证
  2. kubectl top node

image_1eqc8hfumjmv4t7cblgte1diu1g.png-62.3kB


安装 kubesphere

  1. https://kubesphere.com.cn/docs/quick-start/minimal-kubesphere-on-k8s/
  2. wget https://github.com/kubesphere/ks-installer/releases/download/v3.0.0/kubesphere-installer.yaml
  3. wget https://github.com/kubesphere/ks-installer/releases/download/v3.0.0/cluster-configuration.yaml

image_1eq1sh9uictr14gdneh17fr1p0meg.png-472.3kB


  1. vim cluster-configuration.yaml
  2. ----
  3. apiVersion: installer.kubesphere.io/v1alpha1
  4. kind: ClusterConfiguration
  5. metadata:
  6. name: ks-installer
  7. namespace: kubesphere-system
  8. labels:
  9. version: v3.0.0
  10. spec:
  11. persistence:
  12. storageClass: "" # If there is not a default StorageClass in your cluster, you need to specify an existing StorageClass here.
  13. authentication:
  14. jwtSecret: "" # Keep the jwtSecret consistent with the host cluster. Retrive the jwtSecret by executing "kubectl -n kubesphere-system get cm kubesphere-config -o yaml | grep -v "apiVersion" | grep jwtSecret" on the host cluster.
  15. etcd:
  16. monitoring: true # Whether to enable etcd monitoring dashboard installation. You have to create a secret for etcd before you enable it.
  17. endpointIps: 192.168.100.11 # etcd cluster EndpointIps, it can be a bunch of IPs here.
  18. port: 2379 # etcd port
  19. tlsEnable: true
  20. common:
  21. mysqlVolumeSize: 20Gi # MySQL PVC size.
  22. minioVolumeSize: 20Gi # Minio PVC size.
  23. etcdVolumeSize: 20Gi # etcd PVC size.
  24. openldapVolumeSize: 2Gi # openldap PVC size.
  25. redisVolumSize: 2Gi # Redis PVC size.
  26. es: # Storage backend for logging, events and auditing.
  27. # elasticsearchMasterReplicas: 1 # total number of master nodes, it's not allowed to use even number
  28. # elasticsearchDataReplicas: 1 # total number of data nodes.
  29. elasticsearchMasterVolumeSize: 4Gi # Volume size of Elasticsearch master nodes.
  30. elasticsearchDataVolumeSize: 20Gi # Volume size of Elasticsearch data nodes.
  31. logMaxAge: 7 # Log retention time in built-in Elasticsearch, it is 7 days by default.
  32. elkPrefix: logstash # The string making up index names. The index name will be formatted as ks-<elk_prefix>-log.
  33. console:
  34. enableMultiLogin: true # enable/disable multiple sing on, it allows an account can be used by different users at the same time.
  35. port: 30880
  36. alerting: # (CPU: 0.3 Core, Memory: 300 MiB) Whether to install KubeSphere alerting system. It enables Users to customize alerting policies to send messages to receivers in time with different time intervals and alerting levels to choose from.
  37. enabled: true
  38. auditing: # Whether to install KubeSphere audit log system. It provides a security-relevant chronological set of records,recording the sequence of activities happened in platform, initiated by different tenants.
  39. enabled: true
  40. devops: # (CPU: 0.47 Core, Memory: 8.6 G) Whether to install KubeSphere DevOps System. It provides out-of-box CI/CD system based on Jenkins, and automated workflow tools including Source-to-Image & Binary-to-Image.
  41. enabled: true
  42. jenkinsMemoryLim: 2Gi # Jenkins memory limit.
  43. jenkinsMemoryReq: 1500Mi # Jenkins memory request.
  44. jenkinsVolumeSize: 8Gi # Jenkins volume size.
  45. jenkinsJavaOpts_Xms: 512m # The following three fields are JVM parameters.
  46. jenkinsJavaOpts_Xmx: 512m
  47. jenkinsJavaOpts_MaxRAM: 2g
  48. events: # Whether to install KubeSphere events system. It provides a graphical web console for Kubernetes Events exporting, filtering and alerting in multi-tenant Kubernetes clusters.
  49. enabled: true
  50. ruler:
  51. enabled: true
  52. replicas: 2
  53. logging: # (CPU: 57 m, Memory: 2.76 G) Whether to install KubeSphere logging system. 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.
  54. enabled: true
  55. logsidecarReplicas: 2
  56. metrics_server: # (CPU: 56 m, Memory: 44.35 MiB) Whether to install metrics-server. IT enables HPA (Horizontal Pod Autoscaler).
  57. enabled: false
  58. monitoring:
  59. # prometheusReplicas: 1 # Prometheus replicas are responsible for monitoring different segments of data source and provide high availability as well.
  60. prometheusMemoryRequest: 400Mi # Prometheus request memory.
  61. prometheusVolumeSize: 20Gi # Prometheus PVC size.
  62. # alertmanagerReplicas: 1 # AlertManager Replicas.
  63. multicluster:
  64. clusterRole: none # host | member | none # You can install a solo cluster, or specify it as the role of host or member cluster.
  65. networkpolicy: # Network policies allow network isolation within the same cluster, which means firewalls can be set up between certain instances (Pods).
  66. # 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.
  67. enabled: true
  68. notification: # Email Notification support for the legacy alerting system, should be enabled/disabled together with the above alerting option.
  69. enabled: true
  70. openpitrix: # (2 Core, 3.6 G) Whether to install KubeSphere Application Store. It provides an application store for Helm-based applications, and offer application lifecycle management.
  71. enabled: true
  72. servicemesh: # (0.3 Core, 300 MiB) Whether to install KubeSphere Service Mesh (Istio-based). It provides fine-grained traffic management, observability and tracing, and offer visualization for traffic topology.
  73. enabled: true
  74. ----
  75. kubectl apply -f kubesphere-installer.yaml
  76. kubectl apply -f cluster-configuration1.yaml

image_1eq1t3e60udqdui1k16agtftqet.png-125.2kB


  1. 查看安装进度:
  2. kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l app=ks-install -o jsonpath='{.items[0].metadata.name}') -f

image_1eq1vjdj2b5jam1c9q3lfdltlt.png-355.6kB

  1. kubectl get pod -A

image_1eq1u209o1njh1v1v85i1vf11r0pg7.png-381.3kB

image_1eq1u2tel7g916pf1ln214hqcjogk.png-413.5kB

  1. kubesphere-monitoring-system prometheus-k8s-0 0/3 ContainerCreating 0 7m20s
  2. kubesphere-monitoring-system prometheus-k8s-1 0/3 ContainerCreating 0 7m20s
  3. prometheus-k8s-1 这个一直在 ContainerCreating 这个 状态

image_1eq1u9dlvbfjsg8f0kpvnhl9he.png-180.6kB


  1. kubectl describe pod prometheus-k8s-0 -n kubesphere-monitoring-system
  2. kube-etcd-client-certs 这个证书没有找到:

image_1eq1uc2rl8v81p22s598uo15eehr.png-299.3kB

  1. kubectl -n kubesphere-monitoring-system create secret generic kube-etcd-client-certs \
  2. --from-file=etcd-client-ca.crt=/opt/etcd/ssl/ca.pem \
  3. --from-file=etcd-client.crt=/opt/etcd/ssl/ca-key.pem

  1. kubectl get pod -n kubesphere-monitoring-system

image_1eqc90ksq1sf0ud419bg7g5sd99.png-167kB


  1. 参考 日志 打开 页面:
  2. kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l app=ks-install -o jsonpath='{.items[0].metadata.name}') -f

image_1eqc93h0r1kuuh9i1q1j4b1fcfp.png-704.2kB

image_1eqc96rcv19291kvj1u0912kqd6n9.png-543.8kB

image_1eqc97kbp3kn16ta1absb491hrvm.png-667.9kB

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注