diff --git a/README.md b/README.md index 0cc33c8f..f7a80cb1 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,7 @@ Learn about Kubez Ansible by reading the documentation online [kubez-ansible](ht - [Kafka](docs/paas/kafka.md) - [RabbitMQ](docs/paas/rabbitmq.md) - [MongoDB](docs/paas/mongodb.md) + - [Zookeeper](docs/paas/zookeeper.md) - 微服务 - [Isito](docs/apply/istio.md) - CICD diff --git a/ansible/group_vars/all.yml b/ansible/group_vars/all.yml index 9eb16805..15a1f110 100644 --- a/ansible/group_vars/all.yml +++ b/ansible/group_vars/all.yml @@ -240,6 +240,28 @@ enable_kuberhealthy: "no" kuberhealthy_namespace: "{{ kubez_namespace }}" kuberhealthy_version: "104" +###################### +# zookeeper +###################### +enable_zookeeper: "no" +# helm 配置 +zookeeper_repository_name: "{{ default_repo_name }}" +zookeeper_repository_url: "{{ default_repo_url }}" +zookeeper_repository_path: "{{ default_repo_name }}/zookeeper" +# zookeeper配置 +zookeeper_replicas: 1 +zookeeper_requests_cpu: 1 +zookeeper_requests_memory: "1Gi" +zookeeper_namespace: "{{ kubez_namespace }}" +zookeeper_image_registry: "{{ app_image_repository }}" +zookeeper_image_repository: "zookeeper" +zookeeper_version: "11.4.9" +# zookeeper持久化设置 +zookeeper_persistence_enabled: "false" +zookeeper_persistence_size: "8Gi" +zookeeper_persistence_storageclass: "{{ nfs_storage_class }}" +zookeeper_context_fsgroup: "0" + #################### # Chaos Mesh Options #################### @@ -578,6 +600,8 @@ enable_charts: enabled: "{{ enable_kuberhealthy | bool }}" - name: loggie enabled: "{{ enable_loggie | bool }}" + - name: zookeeper + enabled: "{{ enable_zookeeper | bool }}" charts: prometheus: @@ -911,3 +935,25 @@ charts: version: "{{ kuberhealthy_version }}" chart_extra_vars: {} chart_extra_flags: {} + + zookeeper: + name: zookeeper + namespace: "{{ zookeeper_namespace }}" + repository: + name: "{{ zookeeper_repository_name }}" + url: "{{ zookeeper_repository_url }}" + chart: + path: "{{ zookeeper_repository_path }}" + version: "{{ zookeeper_version }}" + chart_extra_vars: + image.registry: "{{ zookeeper_image_registry }}" + image.repository: "{{ zookeeper_image_repository }}" + replicaCount: "{{ zookeeper_replicas }}" + persistence.enabled: "{{ zookeeper_persistence_enabled }}" + persistence.size: "{{ zookeeper_persistence_size }}" + persistence.storageClass: "{{ zookeeper_persistence_storageclass }}" + resources.requests.cpu: "{{ zookeeper_requests_cpu }}" + resources.requests.memory: "{{ zookeeper_requests_memory }}" + podSecurityContext.fsGroup: "{{ zookeeper_context_fsgroup }}" + chart_extra_flags: + - create-namespace diff --git a/docs/paas/zookeeper.md b/docs/paas/zookeeper.md new file mode 100644 index 00000000..eb5dc667 --- /dev/null +++ b/docs/paas/zookeeper.md @@ -0,0 +1,54 @@ +# Zookeeper 安装 + +### 依赖条件 +- 运行正常的 `kubernetes` ( v1.21+ )环境。安装手册参考 [高可用集群](../install/multinode.md) 或 [单节点集群](../install/all-in-one.md) +- StorageClass + +### 开启 Zookeeper 组件 +1. 编辑 `/etc/kubez/globals.yml` + +2. 取消 `enable_zookeeper: "no"` 的注释,设置为 `"yes"`,并取消如下参数注释 + ```shell + ###################### + # zookeeper + ###################### + enable_zookeeper: "yes" + # helm 配置 + #zookeeper_repository_name: "{{ default_repo_name }}" + #zookeeper_repository_url: "{{ default_repo_url }}" + #zookeeper_repository_path: "{{ default_repo_name }}/zookeeper" + # zookeeper配置 + zookeeper_replicas: 3 + #zookeeper_requests_cpu: 1 + #zookeeper_requests_memory: "1Gi" + #zookeeper_namespace: "{{ kubez_namespace }}" + #zookeeper_image_registry: "{{ app_image_repository }}" + #zookeeper_image_repository: "zookeeper" + #zookeeper_version: "11.4.9" + # zookeeper持久化设置 + zookeeper_persistence_enabled: "true" + #zookeeper_persistence_size: "8Gi" + #zookeeper_persistence_storageclass: "{{ nfs_storage_class }}" + #zookeeper_context_fsgroup: "0" + ``` +3. 执行安装命令(根据实际情况选择) + ```shell + # 单节点集群场景 + kubez-ansible apply + + # 高可用集群场景 + kubez-ansible -i multinode apply + ``` +4. 部署完验证 + ```shell + root@VM-0-16-ubuntu:/home/ubuntu# kubectl get pod -n pixiu-system + zookeeper-0 1/1 Running 0 16s + zookeeper-1 1/1 Running 0 16s + zookeeper-2 1/1 Running 0 16s + root@VM-0-16-ubuntu:/home/ubuntu# kubectl get pvc -n pixiu-system + NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE + data-zookeeper-0 Bound pvc-9723f14b-e87c-4276-ba6a-55497068757e 8Gi RWO managed-nfs-storage 3m23s + data-zookeeper-1 Bound pvc-5c73b82c-0312-4c67-8929-037d8fc1b0bb 8Gi RWO managed-nfs-storage 19s + data-zookeeper-2 Bound pvc-1b6e23f0-0f90-496a-a7ec-433796b5d06d 8Gi RWO managed-nfs-storage 19s + ``` +至此 `zookeeper` 已安装至集群中。 \ No newline at end of file diff --git a/etc/kubez/globals.yml b/etc/kubez/globals.yml index c377492e..84f2e2bf 100644 --- a/etc/kubez/globals.yml +++ b/etc/kubez/globals.yml @@ -456,3 +456,25 @@ s3: #enable_kuberhealthy: "no" #kuberhealthy_namespace: pixiu-system #kuberhealthy_version: "100" + +###################### +# zookeeper +###################### +#enable_zookeeper: "no" +# helm 配置 +#zookeeper_repository_name: "{{ default_repo_name }}" +#zookeeper_repository_url: "{{ default_repo_url }}" +#zookeeper_repository_path: "{{ default_repo_name }}/zookeeper" +# zookeeper配置 +#zookeeper_replicas: 1 +#zookeeper_requests_cpu: 1 +#zookeeper_requests_memory: "1Gi" +#zookeeper_namespace: "{{ kubez_namespace }}" +#zookeeper_image_registry: "{{ app_image_repository }}" +#zookeeper_image_repository: "zookeeper" +#zookeeper_version: "11.4.9" +# zookeeper持久化设置 +#zookeeper_persistence_enabled: "false" +#zookeeper_persistence_size: "8Gi" +#zookeeper_persistence_storageclass: "{{ nfs_storage_class }}" +#zookeeper_context_fsgroup: "0"