Skip to content

Commit

Permalink
Issue 34: Handling znode deletion in non-default namespace (#35)
Browse files Browse the repository at this point in the history
* Issue 34: Handling znode deletion in non-default namespace

Signed-off-by: SrishT <[email protected]>

* Issue 34: Handling znode deletion in non-default namespace

Signed-off-by: SrishT <[email protected]>

* Issue 34: Handling znode deletion in non-default namespace

Signed-off-by: SrishT <[email protected]>

* Issue 34: Handling znode deletion in non-default namespace

Signed-off-by: SrishT <[email protected]>

* Issue 34: Adding documentation

Signed-off-by: SrishT <[email protected]>

* Issue 34: Adding documentation

Signed-off-by: SrishT <[email protected]>

Co-authored-by: SrishT <[email protected]>
  • Loading branch information
SrishT and SrishT authored Apr 29, 2020
1 parent 6bd560c commit ed09d17
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 8 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ pr-bookkeeper-operator 1 1 1 1 17s
The Operator can be run in `test mode` if we want to deploy the Bookkeeper Cluster on minikube or on a cluster with very limited resources by setting `testmode: true` in `values.yaml` file. Operator running in test mode skips the minimum replica requirement checks. Test mode provides a bare minimum setup and is not recommended to be used in production environments.

### Install a sample Bookkeeper cluster
> Note that the Bookkeeper cluster must be installed in the same namespace as the Zookeeper cluster.
If the BookKeeper cluster is expected to work with Pravega, we need to create a ConfigMap which needs to have the following values

Expand All @@ -82,7 +83,7 @@ $ helm install charts/bookkeeper --name pravega-bk --set zookeeperUri=[ZOOKEEPER

where:

- `[ZOOKEEPER_HOST]` is the host or IP address of your Zookeeper deployment (e.g. `zookeeper-client:2181`). Multiple Zookeeper URIs can be specified, use a comma-separated list and DO NOT leave any spaces in between (e.g. `zookeeper-0:2181,zookeeper-1:2181,zookeeper-2:2181`).
- `[ZOOKEEPER_HOST]` is the Zookeeper service endpoint of your Zookeeper deployment (e.g. `zookeeper-client:2181`). It expects the zookeeper service URL in the given format `<service-name>:<port-number>`

Check out the [Bookkeeper Helm Chart](charts/bookkeeper) for more a complete list of installation parameters.

Expand Down Expand Up @@ -144,13 +145,14 @@ $ helm delete pravega-bk --purge
### Uninstall the Operator
> Note that the Bookkeeper clusters managed by the Bookkeeper operator will NOT be deleted even if the operator is uninstalled.
If you want to delete the Bookkeeper cluster, make sure to do it before uninstalling the operator. Also, once the Bookkeeper cluster has been deleted, make sure to check that the zookeeper metadata has been cleaned up before proceeding with the deletion of the operator. This can be confirmed with the presence of the following log message in the operator logs.
```
$ helm delete pr --purge
zookeeper metadata deleted
```
If you want to delete the Bookkeeper cluster, make sure to do it before uninstalling the operator. Also, once the Bookkeeper cluster has been deleted, make sure to check that the zookeeper metadata has been cleaned up before proceeding with the deletion of the operator. This can be confirmed with the presence of the following log message in the operator logs.

You can then delete the operator
```
zookeeper metadata deleted
$ helm delete pr --purge
```

### Manual installation
Expand Down
9 changes: 7 additions & 2 deletions doc/manual-installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ containers:
For more details check [this](../README.md#install-the-operator-in-test-mode)

### Install the Bookkeeper cluster manually
> Note that the Bookkeeper cluster must be installed in the same namespace as the Zookeeper cluster.
If the BookKeeper cluster is expected to work with Pravega, we need to create a ConfigMap which needs to have the following values

Expand Down Expand Up @@ -89,7 +90,7 @@ spec:
where:
- `[ZOOKEEPER_HOST]` is the host or IP address of your Zookeeper deployment.
- `[ZOOKEEPER_HOST]` is the Zookeeper service endpoint of your Zookeeper deployment (e.g. `zookeeper-client:2181`). It expects the zookeeper service URL in the given format `<service-name>:<port-number>`

Check out other sample CR files in the [`example`](../example) directory.

Expand Down Expand Up @@ -117,8 +118,12 @@ $ kubectl delete -f bookkeeper.yaml
> Note that the Bookkeeper cluster managed by the Bookkeeper operator will NOT be deleted even if the operator is uninstalled.
To delete all clusters, delete all cluster CR objects before uninstalling the operator.
If you want to delete the Bookkeeper cluster, make sure to do it before uninstalling the operator (to delete all clusters, delete all cluster CR objects before uninstalling the operator). Also, once the Bookkeeper cluster has been deleted, make sure to check that the zookeeper metadata has been cleaned up before proceeding with the deletion of the operator. This can be confirmed with the presence of the following log message in the operator logs.
```
zookeeper metadata deleted
```
You can then delete the operator
```
$ kubectl delete -f deploy
```
1 change: 1 addition & 0 deletions pkg/util/k8sutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ func PodAntiAffinity(component string, clusterName string) *corev1.Affinity {
// Wait for pods in cluster to be terminated
func WaitForClusterToTerminate(kubeClient client.Client, p *v1alpha1.BookkeeperCluster) (err error) {
listOptions := &client.ListOptions{
Namespace: p.Namespace,
LabelSelector: labels.SelectorFromSet(LabelsForBookkeeperCluster(p)),
}

Expand Down
17 changes: 15 additions & 2 deletions pkg/util/zookeeper_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"container/list"
"fmt"
"log"
"strings"
"time"

"github.com/pravega/bookkeeper-operator/pkg/apis/bookkeeper/v1alpha1"
Expand All @@ -28,10 +29,22 @@ const (

// Delete all znodes related to a specific Bookkeeper cluster
func DeleteAllZnodes(bk *v1alpha1.BookkeeperCluster, pravegaClusterName string) (err error) {
host := []string{bk.Spec.ZookeeperUri}
zkUri := strings.Split(bk.Spec.ZookeeperUri, ":")
zkSvcName := ""
zkSvcPort := ""
if len(zkUri) >= 1 {
zkSvcName = zkUri[0]
if len(zkUri) == 1 {
zkSvcPort = "2181"
} else {
zkSvcPort = zkUri[1]
}
}
hostname := zkSvcName + "." + bk.Namespace + ".svc.cluster.local:" + zkSvcPort
host := []string{hostname}
conn, _, err := zk.Connect(host, time.Second*5)
if err != nil {
return fmt.Errorf("failed to connect to zookeeper: %v", err)
return fmt.Errorf("failed to connect to zookeeper (%s): %v", hostname, err)
}
defer conn.Close()

Expand Down

0 comments on commit ed09d17

Please sign in to comment.