You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by nd...@apache.org on 2023/05/09 13:09:55 UTC

[hbase-operator-tools] 05/06: HBASE-27833 Introduce zookeeper-ha_ensemble component

This is an automated email from the ASF dual-hosted git repository.

ndimiduk pushed a commit to branch 27834-introduce-ha-hdfs-overlay
in repository https://gitbox.apache.org/repos/asf/hbase-operator-tools.git

commit 50aa25dc3fa23866347ff0e2de7bb153be72f9e0
Author: Nick Dimiduk <nd...@apache.org>
AuthorDate: Tue May 2 13:27:50 2023 +0200

    HBASE-27833 Introduce zookeeper-ha_ensemble component
---
 .../zookeeper/ha-ensemble/kustomization.yaml       |  45 +++++++
 .../zookeeper/ha-ensemble/patch-zookeeper.yaml     |  51 ++++++++
 .../zookeeper/ha-ensemble/zk-service.yaml          | 130 +++++++++++++++++++++
 .../00-assert-zookeeper.yaml                       |  26 +++++
 .../00-kustomize.yaml                              |  21 ++++
 .../kustomization.yaml                             |  21 ++++
 .../00-assert-zookeeper.yaml                       | 111 ++++++++++++++++++
 .../00-kustomize.yaml                              |  21 ++++
 .../kustomization.yaml                             |  21 ++++
 9 files changed, 447 insertions(+)

diff --git a/hbase-kubernetes-deployment/components/zookeeper/ha-ensemble/kustomization.yaml b/hbase-kubernetes-deployment/components/zookeeper/ha-ensemble/kustomization.yaml
new file mode 100644
index 0000000..3d37c7b
--- /dev/null
+++ b/hbase-kubernetes-deployment/components/zookeeper/ha-ensemble/kustomization.yaml
@@ -0,0 +1,45 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+---
+apiVersion: kustomize.config.k8s.io/v1alpha1
+kind: Component
+
+replicas:
+- name: zookeeper
+  count: 5
+
+configMapGenerator:
+- name: zookeeper-quorum
+  behavior: merge
+  literals:
+  # Hard-coded. Default we expect a simple standalone zk at this location.
+  # One define is for hbase, the other for hadoop.
+  - HBASE_ZOOKEEPER_QUORUM="zookeeper-0,zookeeper-1,zookeeper-2,zookeeper-3,zookeeper-4"
+  - HA_ZOOKEEPER_QUORUM="zookeeper-0:2181,zookeeper-1:2181,zookeeper-2:2181,zookeeper-3:2181,zookeeper-4:2181"
+  options:
+    disableNameSuffixHash: true
+
+patches:
+- target:
+    kind: StatefulSet
+    name: zookeeper
+  path: patch-zookeeper.yaml
+
+components:
+- ../single-instance
+
+resources:
+- zk-service.yaml
diff --git a/hbase-kubernetes-deployment/components/zookeeper/ha-ensemble/patch-zookeeper.yaml b/hbase-kubernetes-deployment/components/zookeeper/ha-ensemble/patch-zookeeper.yaml
new file mode 100644
index 0000000..d59fc77
--- /dev/null
+++ b/hbase-kubernetes-deployment/components/zookeeper/ha-ensemble/patch-zookeeper.yaml
@@ -0,0 +1,51 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+---
+- # increase container resource allocations
+  op: replace
+  path: /spec/template/spec/containers/0/resources
+  value:
+    requests:
+      cpu: '1.0'
+      memory: 1Gi
+    limits:
+      cpu: '2.0'
+      memory: 4Gi
+- # update the launch command
+  op: add
+  path: /spec/template/spec/containers/0/command
+  value:
+  - sh
+  - -c
+  - |-
+    # Make the heap be a fraction of the requested memory size.
+    # Make 'servers' count agree with replicas count.
+    /usr/bin/zookeeper/start.sh --servers=5 --percentage=50 --max_client_cnxns=300 --quorum_listen_on_all_ips=true
+- # increase storage volume size
+  op: replace
+  path: /spec/volumeClaimTemplates/0/spec/resources/requests/storage
+  value: 5Gi
+- # specify pod scheduling anti-affinity
+  op: add
+  path: /spec/template/spec/affinity
+  value:
+    podAntiAffinity:
+      requiredDuringSchedulingIgnoredDuringExecution:
+      - labelSelector:
+          matchLabels:
+            app: hadoop
+            role: zookeeper
+        topologyKey: kubernetes.io/hostname
diff --git a/hbase-kubernetes-deployment/components/zookeeper/ha-ensemble/zk-service.yaml b/hbase-kubernetes-deployment/components/zookeeper/ha-ensemble/zk-service.yaml
new file mode 100644
index 0000000..d0c1c37
--- /dev/null
+++ b/hbase-kubernetes-deployment/components/zookeeper/ha-ensemble/zk-service.yaml
@@ -0,0 +1,130 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Put a Service in front of each zookeeper so ip doesn't change on clients/admin.
+# The service is at zookeeper-?.svc.domain. The pod
+# it is proxying will be at zookeeper-?.${env.ZOOKEEPER_HEADLESS_SERVICE}.NAMESPACE.svc.domain.
+# TODO: Port for prometheus to scape.
+---
+kind: Service
+apiVersion: v1
+metadata:
+  name: zookeeper-0
+  labels:
+    # So helm prometheus standalone install will scrape this zk; TODO
+    # jmxexporter: enabled
+spec:
+  ports:
+  - port: 2181
+    name: client
+  - port: 2888
+    name: server
+  - port: 3888
+    name: leader-election
+  - port: 8080
+    name: http
+  selector:
+    role: zookeeper
+    statefulset.kubernetes.io/pod-name: zookeeper-0
+    cluster: zookeeper
+---
+kind: Service
+apiVersion: v1
+metadata:
+  name: zookeeper-1
+  labels:
+    # So helm prometheus standalone install will scrape this zk; TODO
+    # jmxexporter: enabled
+spec:
+  ports:
+  - port: 2181
+    name: client
+  - port: 2888
+    name: server
+  - port: 3888
+    name: leader-election
+  - port: 8080
+    name: http
+  selector:
+    role: zookeeper
+    statefulset.kubernetes.io/pod-name: zookeeper-1
+    cluster: zookeeper
+---
+kind: Service
+apiVersion: v1
+metadata:
+  name: zookeeper-2
+  labels:
+    # So helm prometheus standalone install will scrape this zk; TODO
+    # jmxexporter: enabled
+spec:
+  ports:
+  - port: 2181
+    name: client
+  - port: 2888
+    name: server
+  - port: 3888
+    name: leader-election
+  - port: 8080
+    name: http
+  selector:
+    role: zookeeper
+    statefulset.kubernetes.io/pod-name: zookeeper-2
+    cluster: zookeeper
+---
+kind: Service
+apiVersion: v1
+metadata:
+  name: zookeeper-3
+  labels:
+    # So helm prometheus standalone install will scrape this zk; TODO
+    # jmxexporter: enabled
+spec:
+  ports:
+  - port: 2181
+    name: client
+  - port: 2888
+    name: server
+  - port: 3888
+    name: leader-election
+  - port: 8080
+    name: http
+  selector:
+    role: zookeeper
+    statefulset.kubernetes.io/pod-name: zookeeper-3
+    cluster: zookeeper
+---
+kind: Service
+apiVersion: v1
+metadata:
+  name: zookeeper-4
+  labels:
+    # So helm prometheus standalone install will scrape this zk; TODO
+    # jmxexporter: enabled
+spec:
+  ports:
+  - port: 2181
+    name: client
+  - port: 2888
+    name: server
+  - port: 3888
+    name: leader-election
+  - port: 8080
+    name: http
+  selector:
+    role: zookeeper
+    statefulset.kubernetes.io/pod-name: zookeeper-4
+    cluster: zookeeper
diff --git a/hbase-kubernetes-deployment/tests/integration/components_zookeeper_ha-ensemble/00-assert-zookeeper.yaml b/hbase-kubernetes-deployment/tests/integration/components_zookeeper_ha-ensemble/00-assert-zookeeper.yaml
new file mode 100644
index 0000000..ef02b39
--- /dev/null
+++ b/hbase-kubernetes-deployment/tests/integration/components_zookeeper_ha-ensemble/00-assert-zookeeper.yaml
@@ -0,0 +1,26 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Asserts on the ZooKeeper portion of the deployment.
+#
+---
+# assert that there is a `StatefulSet` named "zookeeper" that has one live instance.
+apiVersion: apps/v1
+kind: StatefulSet
+metadata:
+  name: zookeeper
+status:
+  availableReplicas: 5
diff --git a/hbase-kubernetes-deployment/tests/integration/components_zookeeper_ha-ensemble/00-kustomize.yaml b/hbase-kubernetes-deployment/tests/integration/components_zookeeper_ha-ensemble/00-kustomize.yaml
new file mode 100644
index 0000000..b365471
--- /dev/null
+++ b/hbase-kubernetes-deployment/tests/integration/components_zookeeper_ha-ensemble/00-kustomize.yaml
@@ -0,0 +1,21 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+---
+apiVersion: kuttl.dev/v1beta1
+kind: TestStep
+
+commands:
+- script: ../../bin/kustomize_into_tmpdir.sh
diff --git a/hbase-kubernetes-deployment/tests/integration/components_zookeeper_ha-ensemble/kustomization.yaml b/hbase-kubernetes-deployment/tests/integration/components_zookeeper_ha-ensemble/kustomization.yaml
new file mode 100644
index 0000000..cc21a69
--- /dev/null
+++ b/hbase-kubernetes-deployment/tests/integration/components_zookeeper_ha-ensemble/kustomization.yaml
@@ -0,0 +1,21 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+---
+apiVersion: kustomize.config.k8s.io/v1beta1
+kind: Kustomization
+
+components:
+  - ../../../components/zookeeper/ha-ensemble
diff --git a/hbase-kubernetes-deployment/tests/unit/components_zookeeper_ha-ensemble/00-assert-zookeeper.yaml b/hbase-kubernetes-deployment/tests/unit/components_zookeeper_ha-ensemble/00-assert-zookeeper.yaml
new file mode 100644
index 0000000..9deb631
--- /dev/null
+++ b/hbase-kubernetes-deployment/tests/unit/components_zookeeper_ha-ensemble/00-assert-zookeeper.yaml
@@ -0,0 +1,111 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Asserts on the ZooKeeper portion of the deployment.
+#
+---
+# assert that there is a `ConfigMap` named "zookeeper-scripts-XXX"
+# TODO: kuttl does not support generated names
+#apiVersion: v1
+#kind: ConfigMap
+#metadata:
+#  name: zookeeper-scripts-c94h8k249d
+---
+# assert that there is a `ConfigMap` named "zookeeper-quorum"
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: zookeeper-quorum
+---
+# assert that there is a `PodDisruptionBudget` named "zookeeper-pdb"
+apiVersion: policy/v1
+kind: PodDisruptionBudget
+metadata:
+  name: zookeeper-pdb
+---
+# assert that there is a `StatefulSet` named "zookeeper" that:
+# - provides pods labeled role:zookeeper
+# - has 5 replicas
+apiVersion: apps/v1
+kind: StatefulSet
+metadata:
+  name: zookeeper
+spec:
+  replicas: 5
+  template:
+    metadata:
+      labels:
+        role: zookeeper
+---
+# assert that there is a `Service` named "zookeeper-0" that:
+# - points to pods labeled role:zookeeper
+# - points the pod of the same name
+apiVersion: v1
+kind: Service
+metadata:
+  name: zookeeper-0
+spec:
+  selector:
+    role: zookeeper
+    statefulset.kubernetes.io/pod-name: zookeeper-0
+---
+# assert that there is a `Service` named "zookeeper-1" that:
+# - points to pods labeled role:zookeeper
+# - points the pod of the same name
+apiVersion: v1
+kind: Service
+metadata:
+  name: zookeeper-1
+spec:
+  selector:
+    role: zookeeper
+    statefulset.kubernetes.io/pod-name: zookeeper-1
+---
+# assert that there is a `Service` named "zookeeper-2" that:
+# - points to pods labeled role:zookeeper
+# - points the pod of the same name
+apiVersion: v1
+kind: Service
+metadata:
+  name: zookeeper-2
+spec:
+  selector:
+    role: zookeeper
+    statefulset.kubernetes.io/pod-name: zookeeper-2
+---
+# assert that there is a `Service` named "zookeeper-3" that:
+# - points to pods labeled role:zookeeper
+# - points the pod of the same name
+apiVersion: v1
+kind: Service
+metadata:
+  name: zookeeper-3
+spec:
+  selector:
+    role: zookeeper
+    statefulset.kubernetes.io/pod-name: zookeeper-3
+---
+# assert that there is a `Service` named "zookeeper-4" that:
+# - points to pods labeled role:zookeeper
+# - points the pod of the same name
+apiVersion: v1
+kind: Service
+metadata:
+  name: zookeeper-4
+spec:
+  selector:
+    role: zookeeper
+    statefulset.kubernetes.io/pod-name: zookeeper-4
diff --git a/hbase-kubernetes-deployment/tests/unit/components_zookeeper_ha-ensemble/00-kustomize.yaml b/hbase-kubernetes-deployment/tests/unit/components_zookeeper_ha-ensemble/00-kustomize.yaml
new file mode 100644
index 0000000..b365471
--- /dev/null
+++ b/hbase-kubernetes-deployment/tests/unit/components_zookeeper_ha-ensemble/00-kustomize.yaml
@@ -0,0 +1,21 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+---
+apiVersion: kuttl.dev/v1beta1
+kind: TestStep
+
+commands:
+- script: ../../bin/kustomize_into_tmpdir.sh
diff --git a/hbase-kubernetes-deployment/tests/unit/components_zookeeper_ha-ensemble/kustomization.yaml b/hbase-kubernetes-deployment/tests/unit/components_zookeeper_ha-ensemble/kustomization.yaml
new file mode 100644
index 0000000..cc21a69
--- /dev/null
+++ b/hbase-kubernetes-deployment/tests/unit/components_zookeeper_ha-ensemble/kustomization.yaml
@@ -0,0 +1,21 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+---
+apiVersion: kustomize.config.k8s.io/v1beta1
+kind: Kustomization
+
+components:
+  - ../../../components/zookeeper/ha-ensemble