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

Add ZooKeeper Quickstart #634

Merged
merged 7 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions docs/examples/zookeeper/quickstart/zoo.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.9.1"
adminServerPort: 8080
replicas: 3
storage:
resources:
requests:
storage: "1Gi"
storageClassName: "standard"
accessModes:
- ReadWriteOnce
terminationPolicy: "WipeOut"
1 change: 1 addition & 0 deletions docs/guides/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ Guides to show you how to perform tasks with KubeDB:
- [ProxySQL](/docs/guides/proxysql/README.md). Shows how to manage ProxySQL using KubeDB.
- [Redis](/docs/guides/redis/README.md). Shows how to manage Redis using KubeDB.
- [Kafka](/docs/guides/kafka/README.md). Shows how to manage Kafka using KubeDB.
- [ZooKeeper](/docs/guides/zookeeper/README.md). Shows how to manage ZooKeeper using KubeDB.
- [SingleStore](/docs/guides/singlestore/README.md). Shows how to manage SingleStore using KubeDB.
40 changes: 40 additions & 0 deletions docs/guides/zookeeper/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
title: ZooKeeper
menu:
docs_{{ .version }}:
identifier: zk-readme-zookeeper
name: ZooKeeper
parent: zk-zookeeper-guides
weight: 10
menu_name: docs_{{ .version }}
section_menu_id: guides
url: /docs/{{ .version }}/guides/zookeeper/
aliases:
- /docs/{{ .version }}/guides/zookeeper/README/
---

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

## Supported ZooKeeper Features
| Features | Community | Enterprise |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for separate | Community | Enterprise | columns. we can keep a Availability column

|------------------------------------------------------------|:---------:|:----------:|
| Ensemble | ✓ | ✓ |
| Standalone | ✓ | ✓ |
| Authentication & Autorization | ✓ | ✓ |
| Persistent Volume | ✓ | ✓ |
| Initializing from Snapshot ( [Stash](https://stash.run/) ) | ✓ | ✓ |
| Instant Backup | ✓ | ✓ |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add/Update like this -
Backup/Recovery: Instant, Scheduled ( KubeStash)
Custom Configuration
Initializing from Snapshot ( KubeStash)
TLS: Add ( Cert Manager)
Grafana Dashboards
Externally manageable Auth Secret
Reconfigurable Health Checker
Persistent volume

| Scheduled Backup | ✓ | ✓ |
| Builtin Prometheus Discovery | ✓ | ✓ |
| Using Prometheus operator | ✓ | ✓ |

## Life Cycle of a ZooKeeper Object

<p align="center">
  <img alt="lifecycle" src="/docs/images/zookeeper/zookeeper-lifecycle.png">
</p>

## User Guide

- [Quickstart ZooKeeper](/docs/guides/zookeeper/quickstart/quickstart.md) with KubeDB Operator.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add another link for concepts and contribution like this -


10 changes: 10 additions & 0 deletions docs/guides/zookeeper/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: ZooKeeper
menu:
docs_{{ .version }}:
identifier: zk-zookeeper-guides
name: ZooKeeper
parent: guides
weight: 12
menu_name: docs_{{ .version }}
---
10 changes: 10 additions & 0 deletions docs/guides/zookeeper/concepts/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: ZooKeeper Concepts
menu:
docs_{{ .version }}:
identifier: zk-concepts-zookeeper
name: Concepts
parent: zk-zookeeper-guides
weight: 20
menu_name: docs_{{ .version }}
---
140 changes: 140 additions & 0 deletions docs/guides/zookeeper/concepts/appbinding.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
---
title: AppBinding CRD
menu:
docs_{{ .version }}:
identifier: zk-appbinding-concepts
name: AppBinding
parent: zk-concepts-zookeeper
weight: 30
menu_name: docs_{{ .version }}
section_menu_id: guides
---

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

# AppBinding

## What is AppBinding

An `AppBinding` is a Kubernetes `CustomResourceDefinition`(CRD) which points to an application using either its URL (usually for a non-Kubernetes resident service instance) or a Kubernetes service object (if self-hosted in a Kubernetes cluster), some optional parameters and a credential secret. To learn more about AppBinding and the problems it solves, please read this blog post: [The case for AppBinding](https://appscode.com/blog/post/the-case-for-appbinding).

If you deploy a database using [KubeDB](https://kubedb.com/docs/0.11.0/concepts/), `AppBinding` object will be created automatically for it. Otherwise, you have to create an `AppBinding` object manually pointing to your desired database.

KubeDB uses [Stash](https://appscode.com/products/stash/) to perform backup/recovery of databases. Stash needs to know how to connect with a target database and the credentials necessary to access it. This is done via an `AppBinding`.

## AppBinding CRD Specification

Like any official Kubernetes resource, an `AppBinding` has `TypeMeta`, `ObjectMeta` and `Spec` sections. However, unlike other Kubernetes resources, it does not have a `Status` section.

An `AppBinding` object created by `KubeDB` for ZooKeeper database is shown below,

```yaml
apiVersion: appcatalog.appscode.com/v1alpha1
kind: AppBinding
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"kubedb.com/v1alpha2","kind":"ZooKeeper","metadata":{"annotations":{},"name":"zk-cluster","namespace":"demo"},"spec":{"podTemplate":{"spec":{"containers":[{"name":"zookeeper","resources":{"requests":{"cpu":"720m","memory":"846Mi"}}}]}},"replicas":3,"serviceTemplates":[{"alias":"primary","spec":{"type":"LoadBalancer"}}],"storage":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"1Gi"}},"storageClassName":"standard"},"terminationPolicy":"WipeOut","version":"3.9.1"}}
creationTimestamp: "2024-05-02T10:02:45Z"
generation: 2
labels:
app.kubernetes.io/component: database
app.kubernetes.io/instance: zk-cluster
app.kubernetes.io/managed-by: kubedb.com
app.kubernetes.io/name: zookeepers.kubedb.com
name: zk-cluster
namespace: demo
ownerReferences:
- apiVersion: kubedb.com/v1alpha2
blockOwnerDeletion: true
controller: true
kind: ZooKeeper
name: zk-cluster
uid: 20e00408-abf1-470b-a049-bdf272b3e994
resourceVersion: "3548"
uid: 8fd15549-ab9c-4523-b85d-77275f620bb5
spec:
appRef:
apiGroup: kubedb.com
kind: ZooKeeper
name: zk-cluster
namespace: demo
clientConfig:
service:
name: zk-cluster
port: 2181
scheme: http
secret:
name: zk-cluster-auth
type: kubedb.com/zookeeper
version: 3.9.1
```

Here, we are going to describe the sections of an `AppBinding` crd.

### AppBinding `Spec`

An `AppBinding` object has the following fields in the `spec` section:

#### spec.type

`spec.type` is an optional field that indicates the type of the app that this `AppBinding` is pointing to. Stash uses this field to resolve the values of `TARGET_APP_TYPE`, `TARGET_APP_GROUP` and `TARGET_APP_RESOURCE` variables of [BackupBlueprint](https://appscode.com/products/stash/latest/concepts/crds/backupblueprint/) object.

This field follows the following format: `<app group>/<resource kind>`. The above AppBinding is pointing to a `zookeeper` resource under `kubedb.com` group.

Here, the variables are parsed as follows:

| Variable | Usage |
| --------------------- |--------------------------------------------------------------------------------------------------------------------------------|
| `TARGET_APP_GROUP` | Represents the application group where the respective app belongs (i.e: `kubedb.com`). |
| `TARGET_APP_RESOURCE` | Represents the resource under that application group that this appbinding represents (i.e: `zookeeper`). |
| `TARGET_APP_TYPE` | Represents the complete type of the application. It's simply `TARGET_APP_GROUP/TARGET_APP_RESOURCE` (i.e: `kubedb.com/zookeeper`). |

#### spec.secret

`spec.secret` specifies the name of the secret which contains the credentials that are required to access the database. This secret must be in the same namespace as the `AppBinding`.

This secret must contain the following keys:

| Key | Usage |
| ---------- | ---------------------------------------------- |
| `username` | Username of the target database. |
| `password` | Password for the user specified by `username`. |



#### spec.appRef
appRef refers to the underlying application. It has 4 fields named `apiGroup`, `kind`, `name` & `namespace`.

#### spec.clientConfig

`spec.clientConfig` defines how to communicate with the target database. You can use either a URL or a Kubernetes service to connect with the database. You don't have to specify both of them.

You can configure following fields in `spec.clientConfig` section:

- **spec.clientConfig.url**

`spec.clientConfig.url` gives the location of the database, in standard URL form (i.e. `[scheme://]host:port/[path]`). This is particularly useful when the target database is running outside of the Kubernetes cluster. If your database is running inside the cluster, use `spec.clientConfig.service` section instead.

> Note that, attempting to use a user or basic auth (e.g. `user:password@host:port`) is not allowed. Stash will insert them automatically from the respective secret. Fragments ("#...") and query parameters ("?...") are not allowed either.

- **spec.clientConfig.service**

If you are running the database inside the Kubernetes cluster, you can use Kubernetes service to connect with the database. You have to specify the following fields in `spec.clientConfig.service` section if you manually create an `AppBinding` object.

- **name :** `name` indicates the name of the service that connects with the target database.
- **scheme :** `scheme` specifies the scheme (i.e. http, https) to use to connect with the database.
- **port :** `port` specifies the port where the target database is running.

- **spec.clientConfig.insecureSkipTLSVerify**

`spec.clientConfig.insecureSkipTLSVerify` is used to disable TLS certificate verification while connecting with the database. We strongly discourage to disable TLS verification during backup. You should provide the respective CA bundle through `spec.clientConfig.caBundle` field instead.

- **spec.clientConfig.caBundle**

`spec.clientConfig.caBundle` is a PEM encoded CA bundle which will be used to validate the serving certificate of the database.

## Next Steps

- Learn how to use KubeDB to manage various databases [here](/docs/guides/README.md).
- Want to hack on KubeDB? Check our [contribution guidelines](/docs/CONTRIBUTING.md).
111 changes: 111 additions & 0 deletions docs/guides/zookeeper/concepts/catalog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
---
title: ZooKeeperVersion CRD
menu:
docs_{{ .version }}:
identifier: zk-catalog-concepts
name: ZooKeeperVersion
parent: zk-concepts-zookeeper
weight: 20
menu_name: docs_{{ .version }}
section_menu_id: guides
---

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

# ZooKeeperVersion

## What is ZooKeeperVersion

`ZooKeeperVersion` is a Kubernetes `Custom Resource Definitions` (CRD). It provides a declarative configuration to specify the docker images to be used for [ZooKeeper](https://zookeeper.apache.org/) database deployed with KubeDB in a Kubernetes native way.

When you install KubeDB, a `ZooKeeperVersion` custom resource will be created automatically for every supported ZooKeeper versions. You have to specify the name of `ZooKeeperVersion` crd in `spec.version` field of [ZooKeeper](/docs/guides/zookeeper/concepts/zookeeper.md) crd. Then, KubeDB will use the docker images specified in the `ZooKeeperVersion` crd to create your expected database.

Using a separate crd for specifying respective docker images, and pod security policy names allow us to modify the images, and policies independent of KubeDB operator. This will also allow the users to use a custom image for the database.

## ZooKeeperVersion Specification

As with all other Kubernetes objects, a ZooKeeperVersion needs `apiVersion`, `kind`, and `metadata` fields. It also needs a `.spec` section.

```yaml
apiVersion: catalog.kubedb.com/v1alpha1
kind: ZooKeeperVersion
metadata:
annotations:
meta.helm.sh/release-name: kubedb
meta.helm.sh/release-namespace: kubedb
creationTimestamp: "2024-05-02T09:41:52Z"
generation: 1
labels:
app.kubernetes.io/instance: kubedb
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: kubedb-catalog
app.kubernetes.io/version: v2024.4.27
helm.sh/chart: kubedb-catalog-v2024.4.27
name: 3.9.1
resourceVersion: "1455"
uid: 3c5a4714-4ce2-4b41-8ad9-4899c3127dcc
spec:
db:
image: ghcr.io/appscode-images/zookeeper:3.9.1
initContainer:
image: ghcr.io/kubedb/zookeeper-init:3.7-v1
securityContext:
runAsUser: 1000
version: 3.9.1
```

### metadata.name

`metadata.name` is a required field that specifies the name of the `ZooKeeperVersion` crd. You have to specify this name in `spec.version` field of [ZooKeeper](/docs/guides/zookeeper/concepts/zookeeper.md) crd.


### spec.version

`spec.version` is a required field that specifies the original version of ZooKeeper server that has been used to build the docker image specified in `spec.db.image` field.

### spec.deprecated

`spec.deprecated` is an optional field that specifies whether the docker images specified here is supported by the current KubeDB operator.

The default value of this field is `false`. If `spec.deprecated` is set to `true`, KubeDB operator will skip processing this CRD object and will add a event to the CRD object specifying that the DB version is deprecated.

### spec.db.image

`spec.db.image` is a required field that specifies the docker image which will be used to create Statefulset by KubeDB operator to create expected ZooKeeper server.

### spec.initContainer.image

`spec.initContainer.image` is a required field that specifies the image for init container.

### spec.exporter.image

`spec.exporter.image` is a required field that specifies the image which will be used to export Prometheus metrics.

### spec.stash

This holds the Backup & Restore task definitions, where a `TaskRef` has a `Name` & `Params` section. Params specifies a list of parameters to pass to the task.
To learn more, visit [stash documentation](https://stash.run/)

### spec.updateConstraints

updateConstraints specifies the constraints that need to be considered during version update. Here `allowList` contains the versions those are allowed for updating from the current version.
An empty list of AllowList indicates all the versions are accepted except the denyList.
On the other hand, `DenyList` contains all the rejected versions for the update request. An empty list indicates no version is rejected.

### spec.podSecurityPolicies.databasePolicyName

`spec.podSecurityPolicies.databasePolicyName` is a required field that specifies the name of the pod security policy required to get the database server pod(s) running. To use a user-defined policy, the name of the policy has to be set in `spec.podSecurityPolicies` and in the list of allowed policy names in KubeDB operator like below:

```bash
helm upgrade -i kubedb oci://ghcr.io/appscode-charts/kubedb \
--namespace kubedb --create-namespace \
--set additionalPodSecurityPolicies[0]=custom-db-policy \
--set-file global.license=/path/to/the/license.txt \
--set gloabal.featureGates.ZooKeeper=true \
--wait --burst-limit=10000 --debug
```

## Next Steps

- Learn about ZooKeeper crd [here](/docs/guides/zookeeper/concepts/zookeeper.md).
- Deploy your first ZooKeeper server with KubeDB by following the guide [here](/docs/guides/zookeeper/quickstart/quickstart.md).
Loading
Loading