Skip to content

Commit

Permalink
Add Zookeeper Ops Docs (restart, version-upgrade)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rudro-25 committed Oct 23, 2024
1 parent c30f73b commit fcd41c1
Show file tree
Hide file tree
Showing 10 changed files with 619 additions and 0 deletions.
11 changes: 11 additions & 0 deletions docs/examples/zookeeper/restart/ops.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: ops.kubedb.com/v1alpha1
kind: ZooKeeperOpsRequest
metadata:
name: zk-restart
namespace: demo
spec:
type: Restart
databaseRef:
name: zk-quickstart
timeout: 3m
apply: Always
17 changes: 17 additions & 0 deletions docs/examples/zookeeper/restart/zookeeper.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: kubedb.com/v1alpha2
kind: ZooKeeper
metadata:
name: zk-quickstart
namespace: demo
spec:
version: "3.8.3"
adminServerPort: 8080
replicas: 3
storage:
resources:
requests:
storage: "1Gi"
storageClassName: "standard"
accessModes:
- ReadWriteOnce
deletionPolicy: "WipeOut"
13 changes: 13 additions & 0 deletions docs/examples/zookeeper/update-version/zk-version-upgrade-ops.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: ops.kubedb.com/v1alpha1
kind: ZooKeeperOpsRequest
metadata:
name: upgrade-topology
namespace: demo
spec:
databaseRef:
name: zk-quickstart
type: UpdateVersion
updateVersion:
targetVersion: 3.9.1
timeout: 5m
apply: IfReady
17 changes: 17 additions & 0 deletions docs/examples/zookeeper/update-version/zookeeper.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: kubedb.com/v1alpha2
kind: ZooKeeper
metadata:
name: zk-quickstart
namespace: demo
spec:
version: "3.8.3"
adminServerPort: 8080
replicas: 3
storage:
resources:
requests:
storage: "1Gi"
storageClassName: "standard"
accessModes:
- ReadWriteOnce
deletionPolicy: "WipeOut"
10 changes: 10 additions & 0 deletions docs/guides/zookeeper/restart/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: Restart ZooKeeper
menu:
docs_{{ .version }}:
identifier: zk-restart
name: Restart
parent: zk-zookeeper-guides
weight: 100
menu_name: docs_{{ .version }}
---
208 changes: 208 additions & 0 deletions docs/guides/zookeeper/restart/restart.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
---
title: Restart ZooKeeper
menu:
docs_{{ .version }}:
identifier: zk-restart-details
name: Restart Cluster
parent: zk-restart
weight: 10
menu_name: docs_{{ .version }}
section_menu_id: guides
---

> New to KubeDB? Please start [here](/docs/README.md).
# Restart ZooKeeper

KubeDB supports restarting the ZooKeeper database via a ZooKeeperOpsRequest. Restarting is useful if some pods are got stuck in some phase, or they are not working correctly. This tutorial will show you how to use that.

## Before You Begin

- At first, you need to have a Kubernetes cluster, and the kubectl command-line tool must be configured to communicate with your cluster. If you do not already have a cluster, you can create one by using [kind](https://kind.sigs.k8s.io/docs/user/quick-start/).

- Now, install KubeDB cli on your workstation and KubeDB operator in your cluster following the steps [here](/docs/setup/README.md).

- To keep things isolated, this tutorial uses a separate namespace called `demo` throughout this tutorial.

```bash
$ kubectl create ns demo
namespace/demo created
```

> Note: YAML files used in this tutorial are stored in [docs/examples/zookeeper](https://github.com/kubedb/docs/tree/{{< param "info.version" >}}/docs/examples/zookeeper) folder in GitHub repository [kubedb/docs](https://github.com/kubedb/docs).
## Deploy ZooKeeper

In this section, we are going to deploy a ZooKeeper database using KubeDB.

```yaml
apiVersion: kubedb.com/v1alpha2
kind: ZooKeeper
metadata:
name: zk-quickstart
namespace: demo
spec:
version: "3.8.3"
adminServerPort: 8080
replicas: 3
storage:
resources:
requests:
storage: "1Gi"
storageClassName: "standard"
accessModes:
- ReadWriteOnce
deletionPolicy: "WipeOut"

```

Let's create the `ZooKeeper` CR we have shown above,

```bash
$ kubectl create -f https://github.com/kubedb/docs/raw/{{< param "info.version" >}}/docs/examples/zookeeper/restart/zookeeper.yaml
zookeeper.kubedb.com/zk-quickstart created
```

## Apply Restart opsRequest

```yaml
apiVersion: ops.kubedb.com/v1alpha1
kind: ZooKeeperOpsRequest
metadata:
name: zk-restart
namespace: demo
spec:
type: Restart
databaseRef:
name: zk-quickstart
timeout: 3m
apply: Always
```
- `spec.type` specifies the Type of the ops Request
- `spec.databaseRef` holds the name of the ZooKeeper database. The db should be available in the same namespace as the opsRequest
- The meaning of `spec.timeout` & `spec.apply` fields will be found [here](/docs/guides/zookeeper/concepts/opsrequest.md#spectimeout)

> Note: The method of restarting the standalone & clustered zookeeper is exactly same as above. All you need, is to specify the corresponding ZooKeeper name in `spec.databaseRef.name` section.

Let's create the `ZooKeeperOpsRequest` CR we have shown above,

```bash
$ kubectl create -f https://github.com/kubedb/docs/raw/{{< param "info.version" >}}/docs/examples/zookeeper/restart/ops.yaml
zookeeperopsrequest.ops.kubedb.com/zk-restart created
```

Now the Ops-manager operator will restart the pods sequentially by their cardinal suffix.

```shell
$ kubectl get zookeeperopsrequest -n demo
NAME TYPE STATUS AGE
restart Restart Successful 10m
$ kubectl get zookeeperopsrequest -n demo -oyaml zk-restart
apiVersion: ops.kubedb.com/v1alpha1
kind: ZooKeeperOpsRequest
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"ops.kubedb.com/v1alpha1","kind":"ZooKeeperOpsRequest","metadata":{"annotations":{},"name":"zk-restart","namespace":"demo"},"spec":{"apply":"Always","databaseRef":{"name":"zk-quickstart"},"timeout":"3m","type":"Restart"}}
creationTimestamp: "2024-10-22T09:22:57Z"
generation: 1
name: zk-restart
namespace: demo
resourceVersion: "1072309"
uid: 6091d9fa-1c2b-4734-bdd1-1ace91460bea
spec:
apply: Always
databaseRef:
name: zk-quickstart
timeout: 3m
type: Restart
status:
conditions:
- lastTransitionTime: "2024-10-22T09:22:57Z"
message: ZooKeeper ops-request has started to restart zookeeper nodes
observedGeneration: 1
reason: Restart
status: "True"
type: Restart
- lastTransitionTime: "2024-10-22T09:25:45Z"
message: Successfully Restarted ZooKeeper nodes
observedGeneration: 1
reason: RestartNodes
status: "True"
type: RestartNodes
- lastTransitionTime: "2024-10-22T09:23:05Z"
message: get pod; ConditionStatus:True; PodName:zk-quickstart-0
observedGeneration: 1
status: "True"
type: GetPod--zk-quickstart-0
- lastTransitionTime: "2024-10-22T09:23:05Z"
message: evict pod; ConditionStatus:True; PodName:zk-quickstart-0
observedGeneration: 1
status: "True"
type: EvictPod--zk-quickstart-0
- lastTransitionTime: "2024-10-22T09:23:10Z"
message: running pod; ConditionStatus:False
observedGeneration: 1
status: "False"
type: RunningPod
- lastTransitionTime: "2024-10-22T09:23:45Z"
message: get pod; ConditionStatus:True; PodName:zk-quickstart-1
observedGeneration: 1
status: "True"
type: GetPod--zk-quickstart-1
- lastTransitionTime: "2024-10-22T09:23:45Z"
message: evict pod; ConditionStatus:True; PodName:zk-quickstart-1
observedGeneration: 1
status: "True"
type: EvictPod--zk-quickstart-1
- lastTransitionTime: "2024-10-22T09:24:25Z"
message: get pod; ConditionStatus:True; PodName:zk-quickstart-2
observedGeneration: 1
status: "True"
type: GetPod--zk-quickstart-2
- lastTransitionTime: "2024-10-22T09:24:25Z"
message: evict pod; ConditionStatus:True; PodName:zk-quickstart-2
observedGeneration: 1
status: "True"
type: EvictPod--zk-quickstart-2
- lastTransitionTime: "2024-10-22T09:25:05Z"
message: get pod; ConditionStatus:True; PodName:zk-quickstart-3
observedGeneration: 1
status: "True"
type: GetPod--zk-quickstart-3
- lastTransitionTime: "2024-10-22T09:25:05Z"
message: evict pod; ConditionStatus:True; PodName:zk-quickstart-3
observedGeneration: 1
status: "True"
type: EvictPod--zk-quickstart-3
- lastTransitionTime: "2024-10-22T09:25:45Z"
message: Controller has successfully restart the ZooKeeper replicas
observedGeneration: 1
reason: Successful
status: "True"
type: Successful
observedGeneration: 1
phase: Successful
```


## Cleaning up

To cleanup the Kubernetes resources created by this tutorial, run:

```bash
kubectl delete zookeeperopsrequest -n demo zk-restart
kubectl delete zookeeper -n demo zk-quickstart
kubectl delete ns demo
```

## Next Steps

- Detail concepts of [ZooKeeper object](/docs/guides/zookeeper/concepts/zookeeper.md).
- Monitor your ZooKeeper database with KubeDB using [out-of-the-box Prometheus operator](/docs/guides/zookeeper/monitoring/using-prometheus-operator.md).
- Monitor your ZooKeeper database with KubeDB using [out-of-the-box builtin-Prometheus](/docs/guides/zookeeper/monitoring/using-builtin-prometheus.md).
- Detail concepts of [ZooKeeper object](/docs/guides/zookeeper/concepts/zookeeper.md).
- Want to hack on KubeDB? Check our [contribution guidelines](/docs/CONTRIBUTING.md).
10 changes: 10 additions & 0 deletions docs/guides/zookeeper/update-version/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: Updating ZooKeeper
menu:
docs_{{ .version }}:
identifier: zk-update-version
name: Update Version
parent: zk-zookeeper-guides
weight: 50
menu_name: docs_{{ .version }}
---
54 changes: 54 additions & 0 deletions docs/guides/zookeeper/update-version/overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
title: Updating ZooKeeper Overview
menu:
docs_{{ .version }}:
identifier: zk-update-version-overview
name: Overview
parent: zk-update-version
weight: 10
menu_name: docs_{{ .version }}
section_menu_id: guides
---

> New to KubeDB? Please start [here](/docs/README.md).
# updating ZooKeeper version Overview

This guide will give you an overview on how KubeDB Ops-manager operator update the version of `ZooKeeper` database.

## Before You Begin

- You should be familiar with the following `KubeDB` concepts:
- [ZooKeeper](/docs/guides/zookeeper/concepts/zookeeper.md)
- [ZooKeeperOpsRequest](/docs/guides/zookeeper/concepts/opsrequest.md)

## How update version Process Works

The following diagram shows how KubeDB Ops-manager operator used to update the version of `ZooKeeper`. Open the image in a new tab to see the enlarged version.

<figure align="center">
  <img alt="updating Process of ZooKeeper" src="/docs/images/day-2-operation/zookeeper/zk-version-update.svg">
<figcaption align="center">Fig: updating Process of ZooKeeper</figcaption>
</figure>

The updating process consists of the following steps:

1. At first, a user creates a `ZooKeeper` Custom Resource (CR).

2. `KubeDB` Provisioner operator watches the `ZooKeeper` CR.

3. When the operator finds a `ZooKeeper` CR, it creates required number of `PetSets` and other kubernetes native resources like secrets, services, etc.

4. Then, in order to update the version of the `ZooKeeper` database the user creates a `ZooKeeperOpsRequest` CR with the desired version.

5. `KubeDB` Ops-manager operator watches the `ZooKeeperOpsRequest` CR.

6. When it finds a `ZooKeeperOpsRequest` CR, it halts the `ZooKeeper` object which is referred from the `ZooKeeperOpsRequest`. So, the `KubeDB` Provisioner operator doesn't perform any operations on the `ZooKeeper` object during the updating process.

7. By looking at the target version from `ZooKeeperOpsRequest` CR, `KubeDB` Ops-manager operator updates the images of all the `PetSets`. After each image update, the operator performs some checks such as if the oplog is synced and database size is almost same or not.

8. After successfully updating the `PetSets` and their `Pods` images, the `KubeDB` Ops-manager operator updates the image of the `ZooKeeper` object to reflect the updated state of the database.

9. After successfully updating of `ZooKeeper` object, the `KubeDB` Ops-manager operator resumes the `ZooKeeper` object so that the `KubeDB` Provisioner operator can resume its usual operations.

In the next doc, we are going to show a step-by-step guide on updating of a ZooKeeper database using updateVersion operation.
Loading

0 comments on commit fcd41c1

Please sign in to comment.