diff --git a/antora.yml b/antora.yml index e17789cf10..eebc535d3b 100644 --- a/antora.yml +++ b/antora.yml @@ -69,10 +69,17 @@ asciidoc: prod-id-short: che prod-id: eclipse-che prod-namespace: eclipse-che + prod-next-channel: next + prod-next-channel-catalog-source: eclipse-che-openshift-catalog-next + prod-next-channel-catalog-source-image: quay.io/eclipse/eclipse-che-openshift-opm-catalog:next + prod-next-channel-package: eclipse-che-preview-openshift prod-operator-image-name: che-operator prod-operator: che-operator prod-prev-ver: "previous minor version" prod-short: Che + prod-stable-channel: stable + prod-stable-channel-catalog-source: community-operators + prod-stable-channel-package: eclipse-che prod-upstream: Eclipse{nbsp}Che prod-url: "https://__<che_fqdn>__" prod-ver-major: "7" diff --git a/modules/administration-guide/nav.adoc b/modules/administration-guide/nav.adoc index 7b5d5ca750..02df4ca3f2 100644 --- a/modules/administration-guide/nav.adoc +++ b/modules/administration-guide/nav.adoc @@ -69,6 +69,7 @@ ** xref:upgrading-che-using-operatorhub.adoc[] ** xref:upgrading-che-using-the-cli-management-tool.adoc[] ** xref:upgrading-che-using-the-cli-management-tool-in-restricted-environment.adoc[] +** xref:migration-to-devworkspace-engine.adoc[] * xref:uninstalling-che.adoc[] ** xref:uninstalling-che-after-operatorhub-installation-using-openshift-web-console.adoc[] ** xref:uninstalling-che-after-operatorhub-installation-using-openshift-cli.adoc[] diff --git a/modules/administration-guide/pages/migration-to-devworkspace-engine.adoc b/modules/administration-guide/pages/migration-to-devworkspace-engine.adoc new file mode 100644 index 0000000000..85e4dbd2e3 --- /dev/null +++ b/modules/administration-guide/pages/migration-to-devworkspace-engine.adoc @@ -0,0 +1,7 @@ +[id="migration-to-devworkspace-engine"] + +:navtitle: Migration to DevWorkspace engine +:keywords: administration-guide, migration, devworkspace +:page-aliases: .:migration-to-devworskpace-engine + +include::partial$proc_migration-to-devworkspace-engine.adoc[] diff --git a/modules/administration-guide/partials/proc_migration-to-devworkspace-engine.adoc b/modules/administration-guide/partials/proc_migration-to-devworkspace-engine.adoc new file mode 100644 index 0000000000..26539fafee --- /dev/null +++ b/modules/administration-guide/partials/proc_migration-to-devworkspace-engine.adoc @@ -0,0 +1,263 @@ + +[id="migration-to-devworkspace-engine_{context}"] += Migration to {devworkspace} engine. + +This procedure describes how to migrate to {devworkspace} engine using https://docs.openshift.com/container-platform/latest/operators/understanding/olm/olm-understanding-olm.html[OLM] to support the Devfile 2.0.0 file format and mentions how to do so on existing instances. + +.Prerequisites + +* The `{orch-cli}` tool is available. +* An instance of {prod-short} deployed using xref:installation-guide:installing-che-on-openshift-4-using-operatorhub.adoc[Operator Hub] from `{prod-stable-channel}` channel on OpenShift cluster version greater or equal to 4.8 +* OpenShift OAuth is enabled. See xref:configuring-openshift-oauth.adoc[]. +* Bundled PostgreSQL + +.Procedure + +. All workspaces must be stopped and changes pushed back to Git repositories. + +. Backup {prod-short} data. See xref:managing-backups-using-chectl.adoc[]. + +include::partial$snip_scaling-down-che.adoc[] + +. Create the script to get all {prod-short} users: ++ +[source,shell,subs="+attributes"] +---- +cat >get-all-{prod-id}-users.sh<> \${ALL_USERS_DUMP} + fi + done +} + +run +echo "[INFO] Done." +EOF + +bash get-all-{prod-id}-users.sh +---- + +include::partial$snip_scaling-down-keycloak.adoc[] + +include::partial$snip_finding-che-database-name.adoc[] + +include::partial$snip_dumping-che-database.adoc[] + +include::partial$snip_terminate-connections-to-postgresql-database.adoc[] + +include::partial$snip_droping-che-database.adoc[] + +include::partial$snip_creating-che-database.adoc[] + +. Migrate {prod-short} users: ++ +[subs="+quotes,+attributes"] +---- +DUMP="che.sql" +ALL_USERS_DUMP={prod-id}-users.txt +while IFS= read -r line +do + IDS=($line) + USER_ID=${IDS[0]} + OPENSHIFT_USER_ID=${IDS[1]} + + sed -i -e "s|${USER_ID}|${OPENSHIFT_USER_ID}|g" "${DUMP}" + + echo "[INFO] Migrated User ID from \"${USER_ID}\" to \"${OPENSHIFT_USER_ID}\"" +done < "${ALL_USERS_DUMP}" +---- + +include::partial$snip_restoring-che-database.adoc[] + +. Migrate users profiles: ++ +[subs="+quotes,+attributes"] +---- +ALL_USERS_DUMP={prod-id}-users.txt +while IFS= read -r line +do + IDS=($line) + OPENSHIFT_USER_ID=${IDS[1]} + USER_NAME=$(echo ${IDS[2]} | cut -d ":" -f 2- | base64 -d) + USER_EMAIL=$(echo ${IDS[3]} | cut -d ":" -f 2- | base64 -d) + USER_FIRST_NAME=$(echo ${IDS[4]} | cut -d ":" -f 2- | base64 -d) + USER_LAST_NAME=$(echo ${IDS[5]} | cut -d ":" -f 2- | base64 -d) + + {orch-cli} exec deploy/postgres -n {prod-namespace} -- bash -c "psql ${CHE_POSTGRES_DB} -tAc \"INSERT INTO profile(userid) VALUES ('${OPENSHIFT_USER_ID}');\"" + {orch-cli} exec deploy/postgres -n {prod-namespace} -- bash -c "psql ${CHE_POSTGRES_DB} -tAc \"INSERT INTO profile_attributes(user_id,name, value) VALUES ('${OPENSHIFT_USER_ID}', 'preferred_username', '${USER_NAME}');\"" + {orch-cli} exec deploy/postgres -n {prod-namespace} -- bash -c "psql ${CHE_POSTGRES_DB} -tAc \"INSERT INTO profile_attributes(user_id,name, value) VALUES ('${OPENSHIFT_USER_ID}', 'email', '${USER_EMAIL}');\"" + {orch-cli} exec deploy/postgres -n {prod-namespace} -- bash -c "psql ${CHE_POSTGRES_DB} -tAc \"INSERT INTO profile_attributes(user_id,name, value) VALUES ('${OPENSHIFT_USER_ID}', 'firstName', '${USER_FIRST_NAME}');\"" + {orch-cli} exec deploy/postgres -n {prod-namespace} -- bash -c "psql ${CHE_POSTGRES_DB} -tAc \"INSERT INTO profile_attributes(user_id,name, value) VALUES ('${OPENSHIFT_USER_ID}', 'lastName', '${USER_LAST_NAME}');\"" + + echo "[INFO] Added profile for \"${OPENSHIFT_USER_ID}\"" +done < "${ALL_USERS_DUMP}" +---- + +. Delete Cluster Service Version: ++ +[subs="+quotes,+attributes"] +---- +{orch-cli} delete csv $({orch-cli} get subscription {prod-id} -n {prod-namespace} -o jsonpath="{.status.currentCSV}") -n {prod-namespace} +---- + +. Delete Subscription: ++ +[subs="+quotes,+attributes"] +---- +{orch-cli} delete subscription {prod-id} -n {prod-namespace} +---- + +. Enable {devworkspace} engine: ++ +[subs="+quotes,+attributes"] +---- +{orch-cli} patch checluster/{prod-checluster} -n {prod-namespace} --type=json -p \ +'[{"op": "replace", "path": "/spec/devWorkspace/enable", "value": true}]' +---- + +. Enable single-host exposure strategy: ++ +[subs="+quotes,+attributes"] +---- +{orch-cli} patch checluster/{prod-checluster} -n {prod-namespace} --type=json -p \ +'[{"op": "replace", "path": "/spec/server/serverExposureStrategy", "value": "single-host"}]' +---- + +. Delete {identity-provider} route: ++ +[subs="+quotes,+attributes"] +---- +{orch-cli} delete route keycloak -n {prod-namespace} +---- + +. Delete {identity-provider} service: ++ +[subs="+quotes,+attributes"] +---- +{orch-cli} delete service keycloak -n {prod-namespace} +---- + +. Delete {identity-provider} deployment: ++ +[subs="+quotes,+attributes"] +---- +{orch-cli} delete deployment keycloak -n {prod-namespace} +---- + +ifeval::["{project-context}" == "che"] +. To deploy {prod} from `{prod-next-channel}` channel, create a catalog source: ++ +[subs="+quotes,+attributes"] +---- +{orch-cli} apply -f - < /tmp/che.sql" +---- + +. Copy {prod-short} database to a local file system: ++ +[subs="+quotes,+attributes"] +---- +{orch-cli} cp {prod-namespace}/$({orch-cli} get pods -l app.kubernetes.io/component=postgres -n {prod-namespace} --no-headers=true -o custom-columns=":metadata.name"):/tmp/che.sql che.sql +---- diff --git a/modules/administration-guide/partials/snip_finding-che-database-name.adoc b/modules/administration-guide/partials/snip_finding-che-database-name.adoc new file mode 100644 index 0000000000..8c57d0cfdd --- /dev/null +++ b/modules/administration-guide/partials/snip_finding-che-database-name.adoc @@ -0,0 +1,7 @@ +. Find {prod-short} database name: ++ +[subs="+quotes,+attributes"] +---- +CHE_POSTGRES_DB=$({orch-cli} get cm/che -n {prod-namespace} -o jsonpath='{.data.CHE_JDBC_URL}' | awk -F '/' '{print $NF}') +if [ -z "$CHE_POSTGRES_DB" ] || [ $CHE_POSTGRES_DB = "null" ]; then CHE_POSTGRES_DB="dbche"; fi +---- diff --git a/modules/administration-guide/partials/snip_finding-che-user-name.adoc b/modules/administration-guide/partials/snip_finding-che-user-name.adoc new file mode 100644 index 0000000000..f4204c2554 --- /dev/null +++ b/modules/administration-guide/partials/snip_finding-che-user-name.adoc @@ -0,0 +1,2 @@ +POSTGRES_SECRET=$({orch-cli} get checluster/{prod-checluster} -n {prod-namespace} -o json | jq -r '.spec.database.chePostgresSecret') +CHE_USER_NAME=$(if [ -z "$POSTGRES_SECRET" ] || [ $POSTGRES_SECRET = "null" ]; then {orch-cli} get checluster/{prod-checluster} -n {prod-namespace} -o json | jq -r '.spec.database.chePostgresUser'; else {orch-cli} get secret $POSTGRES_SECRET -n {prod-namespace} -o json | jq -r '.data.user' | base64 -d; fi) diff --git a/modules/administration-guide/partials/snip_finding-postgresql-pod.adoc b/modules/administration-guide/partials/snip_finding-postgresql-pod.adoc new file mode 100644 index 0000000000..a1f36ae4fc --- /dev/null +++ b/modules/administration-guide/partials/snip_finding-postgresql-pod.adoc @@ -0,0 +1,6 @@ +. Find PostgreSQL pod: ++ +[subs="+quotes,+attributes"] +---- +POSTGRES_POD=$({orch-cli} get pods -n {prod-namespace} | grep postgres | awk '{print $1}') +---- diff --git a/modules/administration-guide/partials/snip_restoring-che-database.adoc b/modules/administration-guide/partials/snip_restoring-che-database.adoc new file mode 100644 index 0000000000..cce1433eb2 --- /dev/null +++ b/modules/administration-guide/partials/snip_restoring-che-database.adoc @@ -0,0 +1,13 @@ +. Copy {prod-short} database from a local file system: ++ +[subs="+quotes,+attributes"] +---- +{orch-cli} cp che.sql {prod-namespace}/$({orch-cli} get pods -l app.kubernetes.io/component=postgres -n {prod-namespace} --no-headers=true -o custom-columns=":metadata.name"):/tmp/che.sql +---- + +. Restore {prod-short} database: ++ +[subs="+quotes,+attributes"] +---- +{orch-cli} exec deploy/postgres -n {prod-namespace} -- bash -c "psql $CHE_POSTGRES_DB < /tmp/che.sql" +---- diff --git a/modules/administration-guide/partials/snip_scaling-down-che.adoc b/modules/administration-guide/partials/snip_scaling-down-che.adoc new file mode 100644 index 0000000000..52b53b6a08 --- /dev/null +++ b/modules/administration-guide/partials/snip_scaling-down-che.adoc @@ -0,0 +1,6 @@ +. Scale down the {prod-short} deployment: ++ +[subs="+quotes,+attributes"] +---- +{orch-cli} scale deployment {prod-deployment} --replicas=0 -n {prod-namespace} +---- diff --git a/modules/administration-guide/partials/snip_scaling-down-keycloak.adoc b/modules/administration-guide/partials/snip_scaling-down-keycloak.adoc new file mode 100644 index 0000000000..0538d06b0a --- /dev/null +++ b/modules/administration-guide/partials/snip_scaling-down-keycloak.adoc @@ -0,0 +1,6 @@ +. Scale down the {identity-provider} deployment: ++ +[subs="+quotes,+attributes"] +---- +{orch-cli} scale deployment keycloak --replicas=0 -n {prod-namespace} +---- diff --git a/modules/administration-guide/partials/snip_terminate-connections-to-postgresql-database.adoc b/modules/administration-guide/partials/snip_terminate-connections-to-postgresql-database.adoc new file mode 100644 index 0000000000..9df6194516 --- /dev/null +++ b/modules/administration-guide/partials/snip_terminate-connections-to-postgresql-database.adoc @@ -0,0 +1,6 @@ +. Terminate connections to PostgreSQL database: ++ +[subs="+quotes,+attributes"] +---- +{orch-cli} exec deploy/postgres -n {prod-namespace} -- bash -c "psql -c \"SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = '${CHE_POSTGRES_DB}'\"" +---- diff --git a/modules/administration-guide/partials/snip_verification-che-working.adoc b/modules/administration-guide/partials/snip_verification-che-working.adoc new file mode 100644 index 0000000000..6816b44baf --- /dev/null +++ b/modules/administration-guide/partials/snip_verification-che-working.adoc @@ -0,0 +1,8 @@ +. Open Dashboard: ++ +[subs="+quotes,+attributes"] +---- +{prod-cli} dashboard:open -n {prod-namespace} +---- + +. Log in the {prod}. diff --git a/modules/administration-guide/partials/snip_waiting-for-component.adoc b/modules/administration-guide/partials/snip_waiting-for-component.adoc new file mode 100644 index 0000000000..78a172260a --- /dev/null +++ b/modules/administration-guide/partials/snip_waiting-for-component.adoc @@ -0,0 +1,9 @@ +[subs="+quotes,+attributes"] +---- +while [[ $({orch-cli} get pod -l app.kubernetes.io/component={k8s-component} -n {k8s-namespace} -o go-template='{{len .items}}') == 0 ]] +do + echo "Waiting..." + sleep 10s +done +{orch-cli} wait --for=condition=ready pod -l app.kubernetes.io/component={k8s-component} -n {k8s-namespace} --timeout=120s +----