Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I increase the number of ZooKeeper instances? #35

Closed
investlab opened this issue Dec 4, 2024 · 4 comments · Fixed by #36
Closed

Can I increase the number of ZooKeeper instances? #35

investlab opened this issue Dec 4, 2024 · 4 comments · Fixed by #36
Assignees
Labels
enhancement New feature or request question Further information is requested

Comments

@investlab
Copy link

Can I increase the number of ZooKeeper instances?

1x NiFi Namespace (all the items will be deployed here)
3x Apache NiFi Instances (can be increased)
3x Apache Zookeeper (accessible within the cluster only)
1x Secrets (basic auth username/passowrd: admin:admin)
1x Ingress (access endpoint)

Copy link

github-actions bot commented Dec 4, 2024

👋 Thanks for Reporting!

@investlab
Copy link
Author

Zookeeper multi instance here!

apiVersion: v1
kind: ConfigMap
metadata:
  name: zookeeper-config
  namespace: kafka
data:
  ZOO_DATA_LOG_DIR: "/datalog"
  ZOO_DATA_DIR: "/data"
  ZOO_CONF_DIR: "/conf"
  ZOO_SERVERS: "server.1=zookeeper-0.zookeeper:2888:3888;2181 server.2=zookeeper-1.zookeeper:2888:3888;2181 server.3=zookeeper-2.zookeeper:2888:3888;2181"
---
apiVersion: v1
kind: Service
metadata:
  name: zookeeper
  namespace: kafka
  labels:
    app: zookeeper
spec:
  ports:
    - port: 2888
      name: server
    - port: 3888
      name: leader-election
    - port: 2181
      name: client
  clusterIP: None
  selector:
    app: zookeeper
---
apiVersion: v1
kind: Service
metadata:
  name: zookeeper-service
  namespace: kafka
  labels:
    app: zookeeper
spec:
  ports:
    - port: 2181
      name: client
  type: ClusterIP
  selector:
    app: zookeeper
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: zookeeper
  namespace: kafka
spec:
  serviceName: zookeeper
  replicas: 3
  updateStrategy:
    type: RollingUpdate
  podManagementPolicy: OrderedReady
  selector:
    matchLabels:
      app: zookeeper
  template:
    metadata:
      labels:
        app: zookeeper
    spec:
      initContainers:
        - command:
            - /bin/sh
            - -c
            - |-
              set -ex;
              mkdir -p "$ZOO_DATA_LOG_DIR" "$ZOO_DATA_DIR" "$ZOO_CONF_DIR";
              if [[ ! -f "$ZOO_DATA_DIR/myid" ]]; then
                IDX="$(echo $HOSTNAME| rev | cut -d "-" -f1 | rev)"
                SVR_INDEX=$((IDX+1))
                echo $SVR_INDEX > "$ZOO_DATA_DIR/myid"
              fi
          env:
            - name: HOSTNAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
          envFrom:
            - configMapRef:
                name: zookeeper-config
          image: busybox:1.28
          imagePullPolicy: IfNotPresent
          name: zookeeper-init
          securityContext:
            runAsUser: 0
          volumeMounts:
            - mountPath: /data
              name: data
      containers:
        - image: zookeeper
          imagePullPolicy: Always
          name: zookeeper
          ports:
            - containerPort: 2181
              name: client
            - containerPort: 2888
              name: server
            - containerPort: 3888
              name: leader-election
          resources: {}
          envFrom:
            - configMapRef:
                name: zookeeper-config
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          volumeMounts:
            - mountPath: /data
              name: data
            - mountPath: /datalog
              name: datalog
  volumeClaimTemplates:
    - metadata:
        name: data
      spec:
        accessModes: ["ReadWriteOnce"]
        storageClassName: nfs-client
        resources:
          requests:
            storage: 100Mi
    - metadata:
        name: datalog
      spec:
        accessModes: ["ReadWriteOnce"]
        storageClassName: nfs-client
        resources:
          requests:
            storage: 100Mi

@saidsef saidsef added the question Further information is requested label Dec 7, 2024
@saidsef saidsef self-assigned this Dec 7, 2024
@saidsef
Copy link
Owner

saidsef commented Dec 7, 2024

Hi @investlab,

The current Zookeeper is set to standalone mode:
https://github.com/saidsef/k8s-nifi-cluster/blob/main/deployment/zookeeper/configmap.yml#L12

Thanks for providing the configuration for multi-instance mode.

It might be a better approach to automate the Zookeeper service name(s) lookup and add that to the cluster.

@saidsef
Copy link
Owner

saidsef commented Dec 7, 2024

Hi @investlab, I've added in PR #36 a Zookeeper cluster mode configuration that auto-discovers services. As this is a cluster mode it will require quorum hence K8s cluster must have at least 4 nodes.

K8s Zookeeper cluster is in deployment/zookeeper-cluster in PR #36

@saidsef saidsef added the enhancement New feature or request label Dec 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants