-
Notifications
You must be signed in to change notification settings - Fork 26
[CIE-5419] CDH migration from appliance to k8s edge #3853
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
Open
raghuvamsi-d
wants to merge
20
commits into
release/y2025
Choose a base branch
from
edge-cdh-migration
base: release/y2025
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 8 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
b538bde
draft1
raghuvamsi-d dbcbba2
Merge branch 'release/y2025' into edge-cdh-migration
raghuvamsi-d bb8a4b0
draft 2
raghuvamsi-d 060d692
Merge branch 'edge-cdh-migration' of https://github.com/Cumulocity-Io…
raghuvamsi-d b5f3867
Draft 3
raghuvamsi-d 2e758b0
Correction
raghuvamsi-d 8eafeb9
draft - cdh
raghuvamsi-d 0bc6928
Merge branch 'release/y2025' into edge-cdh-migration
raghuvamsi-d 6c9b3d4
minor doc edits
raghuvamsi-d a1a4a2d
Update content/edge-kubernetes/manage-edge-bundle/migrating-edge-appl…
raghuvamsi-d 0ed5515
Apply suggestions from code review
raghuvamsi-d 31b43a8
Update backup instructions for Edge appliance
raghuvamsi-d 2f763a7
Merge branch 'release/y2025' into edge-cdh-migration
raghuvamsi-d dae0804
Optimising the document
raghuvamsi-d e5ff78d
Merge branch 'edge-cdh-migration' of https://github.com/Cumulocity-Io…
raghuvamsi-d 6428470
Instructions to install helm if needed
raghuvamsi-d 0243f1d
minor changes
raghuvamsi-d b452eca
Corrections
raghuvamsi-d 15f141e
jar step misplaced
raghuvamsi-d c3bd615
correcting the helm usage
raghuvamsi-d File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,145 @@ | ||
| #!/bin/bash | ||
| set -euo pipefail | ||
| trap 'echo "Error on line $LINENO"; exit 1' ERR | ||
|
|
||
| # ------- Configuration (no manual inputs) ------- | ||
| NAMESPACE="c8yedge" | ||
| SOURCE_NAME="c8y_source" | ||
| MONGO_SECRET="internal-edge-db-users" | ||
| DREMIO_SECRET="dremio-admin-credentials" | ||
| MONGO_SVC="edge-db-rs0" | ||
| DREMIO_SVC="cumulocity-ontoplb" | ||
| DREMIO_PORT=9047 | ||
|
|
||
| # ------- Fetch Dremio admin credentials ------- | ||
| DREMIO_USER=$(kubectl get secret -n "$NAMESPACE" "$DREMIO_SECRET" -o jsonpath='{.data.DREMIO_ADMIN_USER}' | base64 -d) | ||
| DREMIO_PASS=$(kubectl get secret -n "$NAMESPACE" "$DREMIO_SECRET" -o jsonpath='{.data.DREMIO_ADMIN_PASSWORD}' | base64 -d) | ||
|
|
||
| # ------- Resolve Dremio endpoint (LoadBalancer IP or ClusterIP fallback) ------- | ||
| DREMIO_IP=$(kubectl get svc -n "$NAMESPACE" "$DREMIO_SVC" -o jsonpath='{.status.loadBalancer.ingress[0].ip}' 2>/dev/null || true) | ||
| if [[ -z "$DREMIO_IP" || "$DREMIO_IP" == "null" ]]; then | ||
| DREMIO_IP=$(kubectl get svc -n "$NAMESPACE" "$DREMIO_SVC" -o jsonpath='{.spec.clusterIP}') | ||
| fi | ||
| if [[ -z "$DREMIO_IP" ]]; then | ||
| echo "Failed to locate Dremio service IP for $DREMIO_SVC in namespace $NAMESPACE" | ||
| exit 1 | ||
| fi | ||
| DREMIO_URL="https://${DREMIO_IP}:${DREMIO_PORT}" | ||
|
|
||
| # ------- Login to Dremio and build Authorization header ------- | ||
| LOGIN_JSON=$(curl -sk -X POST "$DREMIO_URL/apiv2/login" \ | ||
| -H "Content-Type: application/json" \ | ||
| -d "{\"userName\":\"$DREMIO_USER\",\"password\":\"$DREMIO_PASS\"}") | ||
|
|
||
| AUTH_TOKEN=$(echo "$LOGIN_JSON" | jq -r '.token') | ||
| if [[ -z "$AUTH_TOKEN" || "$AUTH_TOKEN" == "null" ]]; then | ||
| echo "Failed to obtain Dremio auth token. Response:" | ||
| echo "$LOGIN_JSON" | jq . | ||
| exit 1 | ||
| fi | ||
| AUTH_HEADER="_dremio${AUTH_TOKEN}" | ||
|
|
||
| # ------- Fetch Mongo credentials ------- | ||
| MONGO_USER=$(kubectl get secret -n "$NAMESPACE" "$MONGO_SECRET" -o jsonpath='{.data.MONGODB_DATABASE_ADMIN_USER}' | base64 -d) | ||
| MONGO_PASS=$(kubectl get secret -n "$NAMESPACE" "$MONGO_SECRET" -o jsonpath='{.data.MONGODB_DATABASE_ADMIN_PASSWORD}' | base64 -d) | ||
|
|
||
| # ------- Resolve Mongo service host and port ------- | ||
| MONGO_HOSTNAME=$(kubectl get svc -n "$NAMESPACE" "$MONGO_SVC" -o jsonpath='{.metadata.name}' 2>/dev/null || true) | ||
| if [[ -z "$MONGO_HOSTNAME" ]]; then | ||
| echo "Failed to find MongoDB service $MONGO_SVC in namespace $NAMESPACE" | ||
| exit 1 | ||
| fi | ||
| MONGO_PORT=$(kubectl get svc -n "$NAMESPACE" "$MONGO_SVC" -o jsonpath='{.spec.ports[0].port}') | ||
| MONGO_FQDN="${MONGO_HOSTNAME}.${NAMESPACE}.svc.cluster.local" | ||
|
|
||
| # ------- Fetch existing source JSON from Dremio ------- | ||
| SOURCE_JSON=$(curl -sk -H "Authorization: ${AUTH_HEADER}" "$DREMIO_URL/apiv2/source/$SOURCE_NAME") | ||
| SOURCE_ID=$(echo "$SOURCE_JSON" | jq -r '.id // empty') | ||
| SOURCE_TAG=$(echo "$SOURCE_JSON" | jq -r '.tag // empty') | ||
|
|
||
| if [[ -z "$SOURCE_ID" ]]; then | ||
| echo "Source '$SOURCE_NAME' not found in Dremio at $DREMIO_URL" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # ------- Enable keep_metadata_on_replace (true) ------- | ||
| curl -sk -X PUT "$DREMIO_URL/apiv2/settings/store.plugin.keep_metadata_on_replace" \ | ||
| -H "Authorization: ${AUTH_HEADER}" \ | ||
| -H "Content-Type: application/json" \ | ||
| --data '{"type":"BOOLEAN","id":"store.plugin.keep_metadata_on_replace","value":true}' >/dev/null | ||
|
|
||
| # ------- Build minimal update payload based on requested layout ------- | ||
| # Layout: | ||
| # { | ||
| # "config": { hostList:[{hostname,port}], useSsl:true, authenticationType, authDatabase, ... } | ||
| # } | ||
| UPDATE_PAYLOAD=$(jq -n \ | ||
| --arg id "$SOURCE_ID" \ | ||
| --arg tag "$SOURCE_TAG" \ | ||
| --arg name "$SOURCE_NAME" \ | ||
| --arg type "MONGO" \ | ||
| --arg host "$MONGO_FQDN" \ | ||
| --argjson port "$MONGO_PORT" \ | ||
| --arg user "$MONGO_USER" \ | ||
| --arg pass "$MONGO_PASS" \ | ||
| '{ | ||
| id: $id, | ||
| tag: $tag, | ||
| type: $type, | ||
| name: $name, | ||
| config: { | ||
| hostList: [{ hostname: $host, port: $port }], | ||
| useSsl: true, | ||
| authenticationType: "MASTER", | ||
| username: $user, | ||
| password: $pass, | ||
| authDatabase: "admin", | ||
| authenticationTimeoutMillis: 2000, | ||
| secondaryReadsOnly: false, | ||
| subpartitionSize: 0, | ||
| sampleSize: 4095, | ||
| sampleMethod: "FIRST", | ||
| propertyList: [{ name: "maxPoolSize", value: "100" }], | ||
| useCaseInsensitiveFieldNames: false | ||
| } | ||
| }') | ||
|
|
||
| # ------- PUT update to Dremio ------- | ||
| UPDATE_RESPONSE=$(curl -sk -X PUT "$DREMIO_URL/apiv2/source/$SOURCE_NAME/?nocache=$(date +%s)" \ | ||
| -H "Authorization: ${AUTH_HEADER}" \ | ||
| -H "Content-Type: application/json" \ | ||
| --data "$UPDATE_PAYLOAD") | ||
|
|
||
| # If Dremio returned an errorMessage, show and exit | ||
| if echo "$UPDATE_RESPONSE" | jq -e 'has("errorMessage")' >/dev/null 2>&1; then | ||
| echo "Dremio returned error while updating source:" | ||
| echo "$UPDATE_RESPONSE" | jq . | ||
| # Attempt to restore the keep_metadata flag to false before exiting | ||
| curl -sk -X PUT "$DREMIO_URL/apiv2/settings/store.plugin.keep_metadata_on_replace" \ | ||
| -H "Authorization: ${AUTH_HEADER}" \ | ||
| -H "Content-Type: application/json" \ | ||
| --data '{"type":"BOOLEAN","id":"store.plugin.keep_metadata_on_replace","value":false}' >/dev/null || true | ||
| exit 1 | ||
| fi | ||
|
|
||
| # ------- Restore keep_metadata_on_replace (false) ------- | ||
| curl -sk -X PUT "$DREMIO_URL/apiv2/settings/store.plugin.keep_metadata_on_replace" \ | ||
| -H "Authorization: ${AUTH_HEADER}" \ | ||
| -H "Content-Type: application/json" \ | ||
| --data '{"type":"BOOLEAN","id":"store.plugin.keep_metadata_on_replace","value":false}' >/dev/null | ||
|
|
||
| # ------- Verify connection/status ------- | ||
| VERIFY_JSON=$(curl -sk -H "Authorization: ${AUTH_HEADER}" "$DREMIO_URL/apiv2/source/$SOURCE_NAME") | ||
| STATUS=$(echo "$VERIFY_JSON" | jq -r '.state.status // empty') | ||
| MSG=$(echo "$VERIFY_JSON" | jq -r '.state.messages[0].message // empty') | ||
|
|
||
| if [[ "$STATUS" == "good" ]]; then | ||
| echo "SUCCESS: Dremio source '$SOURCE_NAME' updated and MongoDB is connected." | ||
| echo "Message: $MSG" | ||
| exit 0 | ||
| else | ||
| echo "WARNING: Dremio source updated but status is not 'good'." | ||
| echo "Status: $STATUS" | ||
| echo "Message: $MSG" | ||
| exit 2 | ||
| fi |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.