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

Initial work for the migration tool & ZooKeeper #50

Merged
merged 6 commits into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
improve add examples
  • Loading branch information
nicoloboschi committed Feb 15, 2023
commit 6d488bacd278f498fb20217bfeed62da8282d770
5 changes: 5 additions & 0 deletions bin/migration-tool
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

this_dir=$( dirname -- "${BASH_SOURCE[0]}" )
CP=$(cat $this_dir/../migration-tool/target/classpath.txt)
exec java -cp "$CP:$this_dir/../migration-tool/target/*" com.datastax.oss.pulsaroperator.migrationtool.Main "$@"
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@ spec:
type: string
description: Labels to add to each pod.
type: object
matchLabels:
additionalProperties:
type: string
description: Match labels selectors to add to each pod.
type: object
type: object
global:
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@ spec:
type: string
description: Labels to add to each pod.
type: object
matchLabels:
additionalProperties:
type: string
description: Match labels selectors to add to each pod.
type: object
type: object
global:
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1038,6 +1038,11 @@ spec:
type: string
description: Labels to add to each pod.
type: object
matchLabels:
additionalProperties:
type: string
description: Match labels selectors to add to each pod.
type: object
type: object
global:
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1014,6 +1014,11 @@ spec:
type: string
description: Labels to add to each pod.
type: object
matchLabels:
additionalProperties:
type: string
description: Match labels selectors to add to each pod.
type: object
type: object
global:
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1456,6 +1456,11 @@ spec:
type: string
description: Labels to add to each pod.
type: object
matchLabels:
additionalProperties:
type: string
description: Match labels selectors to add to each pod.
type: object
type: object
type: object
status:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,11 @@ spec:
type: string
description: Labels to add to each pod.
type: object
matchLabels:
additionalProperties:
type: string
description: Match labels selectors to add to each pod.
type: object
type: object
global:
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,11 @@ spec:
type: string
description: Labels to add to each pod.
type: object
matchLabels:
additionalProperties:
type: string
description: Match labels selectors to add to each pod.
type: object
type: object
bookkeeper:
properties:
Expand Down Expand Up @@ -2019,6 +2024,11 @@ spec:
type: string
description: Labels to add to each pod.
type: object
matchLabels:
additionalProperties:
type: string
description: Match labels selectors to add to each pod.
type: object
type: object
bastion:
properties:
Expand Down Expand Up @@ -2183,6 +2193,11 @@ spec:
type: string
description: Labels to add to each pod.
type: object
matchLabels:
additionalProperties:
type: string
description: Match labels selectors to add to each pod.
type: object
type: object
broker:
properties:
Expand Down Expand Up @@ -3179,6 +3194,11 @@ spec:
type: string
description: Labels to add to each pod.
type: object
matchLabels:
additionalProperties:
type: string
description: Match labels selectors to add to each pod.
type: object
type: object
zookeeper:
properties:
Expand Down Expand Up @@ -4147,6 +4167,11 @@ spec:
type: string
description: Labels to add to each pod.
type: object
matchLabels:
additionalProperties:
type: string
description: Match labels selectors to add to each pod.
type: object
type: object
proxy:
properties:
Expand Down Expand Up @@ -5110,6 +5135,11 @@ spec:
type: string
description: Labels to add to each pod.
type: object
matchLabels:
additionalProperties:
type: string
description: Match labels selectors to add to each pod.
type: object
type: object
autorecovery:
properties:
Expand Down Expand Up @@ -5270,6 +5300,11 @@ spec:
type: string
description: Labels to add to each pod.
type: object
matchLabels:
additionalProperties:
type: string
description: Match labels selectors to add to each pod.
type: object
type: object
global:
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,11 @@ spec:
type: string
description: Labels to add to each pod.
type: object
matchLabels:
additionalProperties:
type: string
description: Match labels selectors to add to each pod.
type: object
type: object
global:
properties:
Expand Down
8 changes: 6 additions & 2 deletions migration-tool/README.md → migration-examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
- Edit the file `bin/input-cluster-specs.yaml` with the coordinates of the cluster you want to migrate.
- Run the CLI with the following command:
```bash
bin/migration-tool.sh
bin/migration-tool.sh generate
```
- Check the output for the comparisons between the existing chart and the operator.
- If OK, proceed with the migration.
Expand All @@ -20,7 +20,7 @@
4. Wait for the operator to take control of the cluster. Check the PulsarCluster status to be ready.
5. Delete the existing chart release.
```
helm delete <release-name>
kubectl delete secret -l name=<release-name>,owner=helm
```
6. Cleanup helm annotations and labels from the Pulsar CRD.

Expand All @@ -35,3 +35,7 @@
- heritage



## Examples
Run a simple migration example with `install-and-migrate.sh` script.

40 changes: 40 additions & 0 deletions migration-examples/install-and-migrate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash

set -e -o pipefail


yes_or_no() {
read -p " $1 (y/n)? " choice
case "$choice" in
y|Y ) ;;
n|N ) exit 1;;
* ) yes_or_no $1;;
esac
}

this_dir=$( dirname -- "${BASH_SOURCE[0]}" )

current_context=$(kubectl config current-context)
if [[ -z "$current_context" ]]; then
echo "No kubectl context is set. Please set a context and try again."
exit 1
fi
current_namespace=$(kubectl config get-contexts "$current_context" | tail -n1 | awk '{print $5}')
yes_or_no "The pulsar cluster will be installed in the context $current_context, namespace $current_namespace."

helm repo add datastax-pulsar https://datastax.github.io/pulsar-helm-chart && helm repo update
helm install pulsar -f $this_dir/pulsar-chart-values.yaml --wait datastax-pulsar/pulsar --debug

tempdir=$(mktemp -d)
echo "context: $current_context
namespace: $current_namespace
clusterName: pulsar" > $tempdir/input-specs.yaml

$this_dir/../bin/migration-tool generate -i $tempdir/input-specs.yaml -o $tempdir/outputs

# Install the pulsar operator
helm install pulsar-operator $this_dir/../helm/pulsar-operator -f $this_dir/pulsar-operator-values.yaml --debug

kubectl apply -f $tempdir/outputs/$current_context/crd-generated-pulsar-cluster-*.json

kubectl delete secret -l name=pulsar,owner=helm
122 changes: 122 additions & 0 deletions migration-examples/pulsar-chart-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
#
# Copyright 2022 DataStax, Inc.
#
# Licensed 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.
#
#
enableAntiAffinity: false
enableTls: false
enableTokenAuth: false
restartOnConfigMapChange:
enabled: true
extra:
#function: true
function: false

image:
broker:
repository: datastax/lunastreaming-all
pullPolicy: IfNotPresent
tag: 2.10_2.4
brokerSts:
repository: datastax/lunastreaming-all
pullPolicy: IfNotPresent
tag: 2.10_2.4
function:
repository: datastax/lunastreaming-all
pullPolicy: IfNotPresent
tag: 2.10_2.4
zookeeper:
repository: datastax/lunastreaming-all
pullPolicy: IfNotPresent
tag: 2.10_2.4
bookkeeper:
repository: datastax/lunastreaming-all
pullPolicy: IfNotPresent
tag: 2.10_2.4
proxy:
repository: datastax/lunastreaming-all
pullPolicy: IfNotPresent
tag: 2.10_2.4
bastion:
repository: datastax/lunastreaming-all
pullPolicy: IfNotPresent
tag: 2.10_2.4

zookeeper:
replicaCount: 1
resources:
requests:
memory: 300Mi
cpu: 0.3
configData:
PULSAR_MEM: "-Xms300m -Xmx300m -Djute.maxbuffer=10485760 -XX:+ExitOnOutOfMemoryError"

bookkeeper:
replicaCount: 0
resources:
requests:
memory: 512Mi
cpu: 0.3
configData:
BOOKIE_MEM: "-Xms312m -Xmx312m -XX:MaxDirectMemorySize=200m -XX:+ExitOnOutOfMemoryError"

broker:
component: broker
replicaCount: 0
ledger:
defaultEnsembleSize: 1
defaultAckQuorum: 1
defaultWriteQuorum: 1
resources:
requests:
memory: 600Mi
cpu: 0.3
configData:
PULSAR_MEM: "-Xms400m -Xmx400m -XX:MaxDirectMemorySize=200m -XX:+ExitOnOutOfMemoryError"

autoRecovery:
replicaCount: 0
resources:
requests:
memory: 300Mi
cpu: 0.3

function:
replicaCount: 0
functionReplicaCount: 1
resources:
requests:
memory: 512Mi
cpu: 0.3
configData:
PULSAR_MEM: "-Xms312m -Xmx312m -XX:MaxDirectMemorySize=200m -XX:+ExitOnOutOfMemoryError"

proxy:
#replicaCount: 1
replicaCount: 0
resources:
requests:
memory: 512Mi
cpu: 0.3
wsResources:
requests:
memory: 512Mi
cpu: 0.3
configData:
PULSAR_MEM: "-Xms400m -Xmx400m -XX:MaxDirectMemorySize=112m"
autoPortAssign:
enablePlainTextWithTLS: true
service:
autoPortAssign:
enabled: true
18 changes: 18 additions & 0 deletions migration-examples/pulsar-operator-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# Copyright 2022 DataStax, Inc.
#
# Licensed 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.
#
#
operator:
image: datastax/lunastreaming-operator:latest-dev
Loading