Skip to content

Commit

Permalink
chore: Add article about limiting the number of running workspaces ac… (
Browse files Browse the repository at this point in the history
#2788)

* chore: Add article about limiting the number of running workspaces across the cluster and concealing editors

Signed-off-by: Anatolii Bazko <[email protected]>
Co-authored-by: Jana Vrbkova <[email protected]>
  • Loading branch information
tolusha and deerskindoll authored Sep 11, 2024
1 parent 186138a commit dcbd82a
Show file tree
Hide file tree
Showing 10 changed files with 271 additions and 6 deletions.
2 changes: 2 additions & 0 deletions antora.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ asciidoc:
prod-operator-index: registry.access.redhat.com/redhat/community-operator-index:v{ocp4-ver}
prod-operator-package-name: eclipse-che
prod-operator: che-operator
prod-operator-subscription: eclipse-che
prod-prev-short: Che
prod-prev-id-short: che
prod-prev-ver: "previous minor version"
Expand All @@ -109,6 +110,7 @@ asciidoc:
rh-os-local: Red Hat OpenShift Local
theia-endpoint-image: eclipse/che-theia-endpoint-runtime:next
editor-definition-samples-link: link:https://github.com/eclipse-che/che-operator/tree/main/editors-definitions[Editors definitions samples]
devfile-api-version: 2.3.0
ext:
collector:
- run:
Expand Down
3 changes: 3 additions & 0 deletions modules/administration-guide/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
*** xref:configuring-machine-autoscaling.adoc[]
** xref:configuring-workspaces-globally.adoc[]
*** xref:limiting-the-number-of-workspaces-that-a-user-can-keep.adoc[]
*** xref:limiting-the-number-of-workspaces-that-all-users-can-run-simultaneously.adoc[]
*** xref:enabling-users-to-run-multiple-workspaces-simultaneously.adoc[]
*** xref:deploying-che-with-support-for-git-repositories-with-self-signed-certificates.adoc[]
*** xref:configuring-workspaces-nodeselector.adoc[]
Expand Down Expand Up @@ -74,6 +75,8 @@
** xref:configuring-dashboard.adoc[]
*** xref:configuring-getting-started-samples.adoc[]
*** xref:configuring-editors-definitions.adoc[]
*** xref:configuring-default-editor-definition.adoc[]
*** xref:concealing-editors-definitions.adoc[]
*** xref:customizing-openshift-che-consolelink-icon.adoc[]
** xref:managing-identities-and-authorizations.adoc[]
*** xref:configuring-oauth-for-git-providers.adoc[]
Expand Down
172 changes: 172 additions & 0 deletions modules/administration-guide/pages/concealing-editors-definitions.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
:_content-type: PROCEDURE
:description: Concealing editors definitions
:keywords: administration guide, concealing, dashboard, editors
:navtitle: Concealing editors definitions

[id="concealing-editors-definitions"]
= Concealing editors definitions

Learn how to conceal {prod-short} editor definitions. This is useful when you want to hide selected editors from the Dashboard UI, e.g. hide the IntelliJ IDEA Ultimate and have only Visual Studio Code - Open Source visible.

.Prerequisites

* An active `{orch-cli}` session with administrative permissions to the {orch-name} cluster. See {orch-cli-link}.

* `jq`. See link:https://stedolan.github.io/jq/download/[Downloading `jq`].

.Procedure

. Find out the namespace where the {prod-short} Operator is deployed:
+
[source,subs="+attributes"]
----
OPERATOR_NAMESPACE=$({orch-cli} get pods -l app.kubernetes.io/component={prod-operator} -o jsonpath={".items[0].metadata.namespace"} --all-namespaces)
----

. Find out the available editors definitions files:
+
[source,subs="+attributes"]
----
{orch-cli} exec -n $OPERATOR_NAMESPACE deploy/{prod-operator} -- ls /tmp/editors-definitions
----
The output should look similar to the following example:
+
[source]
----
che-code-insiders.yaml
che-code-latest.yaml
che-idea-latest.yaml
che-idea-next.yaml
----

. Choose an editor definition to conceal.
For example, to conceal the `che-idea-next.yaml` editor definition, set the editor definition file name:
+
[source,subs="+attributes"]
----
CHE_EDITOR_CONCEAL_FILE_NAME=che-idea-next.yaml
----

. Define the ConfigMap name for the concealed editor definition:
+
[source,subs="+attributes"]
----
CHE_EDITOR_CONCEAL_CONFIGMAP_NAME=che-conceal-$CHE_EDITOR_CONCEAL_FILE_NAME
----

. Create the ConfigMap:
+
[source,subs="+attributes"]
----
{orch-cli} create configmap $CHE_EDITOR_CONCEAL_CONFIGMAP_NAME \
--namespace $OPERATOR_NAMESPACE \
--from-literal=$CHE_EDITOR_CONCEAL_FILE_NAME=""
----

. Find out the Operator subscription namespace (if it exists):
+
[source,subs="+attributes"]
----
SUBSCRIPTION_NAMESPACE=$({orch-cli} get subscription \
--all-namespaces \
--field-selector=metadata.name={prod-operator-subscription} \
--output jsonpath='{.items[0].metadata.namespace}' 2>/dev/null
)
----

. Patch the {kubernetes} resource to mount the ConfigMap with the empty editor definition. The resource to patch depends on the existence of the Operator subscription. If the subscription exists, then the subscription should be patched. If not, patch the Operator deployment:
+
[source,subs="+attributes"]
----
if [[ -n $SUBSCRIPTION_NAMESPACE ]]; then
if [[ $({orch-cli} get subscription {prod-operator-subscription} --namespace $SUBSCRIPTION_NAMESPACE --output jsonpath='{.spec.config}') == "" ]]; then
{orch-cli} patch subscription {prod-operator-subscription} \
--namespace $SUBSCRIPTION_NAMESPACE \
--type json \
--patch '[{
"op":"add",
"path":"/spec/config",
"value": {}
}]'
fi
if [[ $({orch-cli} get subscription {prod-operator-subscription} --namespace $SUBSCRIPTION_NAMESPACE --output jsonpath='{.spec.config.volumes}') == "" ]]; then
{orch-cli} patch subscription {prod-operator-subscription} \
--namespace $SUBSCRIPTION_NAMESPACE \
--type json \
--patch '[{
"op":"add",
"path":"/spec/config/volumes",
"value": []
}]'
fi
if [[ $({orch-cli} get subscription {prod-operator-subscription} --namespace $SUBSCRIPTION_NAMESPACE --output jsonpath='{.spec.config.volumeMounts}') == "" ]]; then
{orch-cli} patch subscription {prod-operator-subscription} \
--namespace $SUBSCRIPTION_NAMESPACE \
--type json \
--patch '[{
"op":"add",
"path":"/spec/config/volumeMounts",
"value": []
}]'
fi
{orch-cli} patch subscription {prod-operator-subscription} \
--namespace $SUBSCRIPTION_NAMESPACE \
--type json \
--patch '[{
"op":"add",
"path":"/spec/config/volumes/-",
"value": {
"name":"'$(echo ${CHE_EDITOR_CONCEAL_FILE_NAME%.*})'",
"configMap": {
"name": "'$CHE_EDITOR_CONCEAL_CONFIGMAP_NAME'"
}
}
},
{
"op":"add",
"path":"/spec/config/volumeMounts/-",
"value":{
"name": "'$(echo ${CHE_EDITOR_CONCEAL_FILE_NAME%.*})'",
"subPath":"'$CHE_EDITOR_CONCEAL_FILE_NAME'",
"mountPath": "/tmp/editors-definitions/'$CHE_EDITOR_CONCEAL_FILE_NAME'"
}
}]'
else
{orch-cli} patch deployment {prod-operator} \
--namespace $OPERATOR_NAMESPACE \
--type json \
--patch '[{
"op":"add",
"path":"/spec/template/spec/volumes/-",
"value": {
"name":"'$(echo ${CHE_EDITOR_CONCEAL_FILE_NAME%.*})'",
"configMap": {
"name": "'$CHE_EDITOR_CONCEAL_CONFIGMAP_NAME'"
}
}
},
{
"op":"add",
"path":"/spec/template/spec/containers/0/volumeMounts/-",
"value":{
"name": "'$(echo ${CHE_EDITOR_CONCEAL_FILE_NAME%.*})'",
"subPath":"'$CHE_EDITOR_CONCEAL_FILE_NAME'",
"mountPath": "/tmp/editors-definitions/'$CHE_EDITOR_CONCEAL_FILE_NAME'"
}
}
]'
fi
----


.Additional resources

* xref:configuring-editors-definitions.adoc[]

* xref:configuring-default-editor-definition.adoc[]

* {editor-definition-samples-link}

Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ stringData:
----
NOTE: Run `update-ca-trust` command on workspace startup to import certificates.
It can be achieved manually or by adding this command to a `postStart` event in a devfile.
See the link:https://devfile.io/docs/2.2.2/adding-event-bindings#post-start-object[Adding event bindings in a devfile].
See the link:https://devfile.io/docs/{devfile-api-version}/adding-event-bindings#post-start-object[Adding event bindings in a devfile].
====
+
.Mounting environment variables to a user workspace:
Expand Down
4 changes: 4 additions & 0 deletions modules/administration-guide/pages/configuring-dashboard.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,9 @@

* xref:configuring-editors-definitions.adoc[]

* xref:configuring-default-editor-definition.adoc[]

* xref:concealing-editors-definitions.adoc[]

* xref:customizing-openshift-che-consolelink-icon.adoc[]

Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
:_content-type: PROCEDURE
:description: Configuring default editor
:keywords: administration guide, dashboard, editors
:navtitle: Configuring default editor definition

[id="configuring-default-editor-definition"]
= Configuring default editor definition

Learn how to configure {prod-short} default editor definition.

.Prerequisites

* An active `{orch-cli}` session with administrative permissions to the {orch-name} cluster. See {orch-cli-link}.

* `jq`. See link:https://stedolan.github.io/jq/download/[Downloading `jq`].

.Procedure

. Find out the IDs of the available editors:
+
[source,subs="+quotes,+attributes"]
----
{orch-cli} exec deploy/{prod-id-short}-dashboard -n {prod-namespace} \
-- curl -s http://localhost:8080/dashboard/api/editors | jq -r '.[] | "\(.metadata.attributes.publisher)/\(.metadata.name)/\(.metadata.attributes.version)"'
----

. Configure the `defaultEditor`:
+
[source,subs="+quotes,+attributes"]
----
{orch-cli} patch checluster/{prod-checluster} \
--namespace {prod-namespace} \
--type='merge' \
-p '{"spec":{"devEnvironments":{"defaultEditor": "__<default_editor>__"}}}'# <1>
----
<1> The default editor for creating a workspace can be specified using either a plugin ID or a URI. The plugin ID should follow the format: `publisher/name/version`. See available editors IDs in the first step.

.Additional resources

* xref:configuring-editors-definitions.adoc[]

* xref:concealing-editors-definitions.adoc[]

* {editor-definition-samples-link}

Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,13 @@ commands:

The editor definition is also served by the {prod-short} dashboard API from the following URL:

`pass:c,a,q[{prod-url}]/dashboard/api/editors/devfile?che-editor=__<editor id>__`
`pass:c,a,q[{prod-url}]/dashboard/api/editors`

For the example from xref:configuring-editors-definitions.adoc[], the editor definition can be retrieved by accessing the following URL:

`pass:c,a,q[{prod-url}]/dashboard/api/editors/devfile?che-editor=publisher/editor-name/version`

TIP: When retrieving the editor definition from within the {orch-name} cluster, the {prod-short} dashboard API can be accessed via the dashboard service: `pass:c,a,q[http://{prod-id-short}-dashboard.{prod-namespace}.svc.cluster.local:8080]/dashboard/api/editors/devfile?che-editor=__<editor id>__`
TIP: When retrieving the editor definition from within the {orch-name} cluster, the {prod-short} dashboard API can be accessed via the dashboard service: `pass:c,a,q[http://{prod-id-short}-dashboard.{prod-namespace}.svc.cluster.local:8080]/dashboard/api/editors`

.Additional resources

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ This section describes how an administrator can configure workspaces globally.

* xref:limiting-the-number-of-workspaces-that-a-user-can-keep.adoc[]

* xref:limiting-the-number-of-workspaces-that-all-users-can-run-simultaneously.adoc[]

* xref:enabling-users-to-run-multiple-workspaces-simultaneously.adoc[]

* xref:deploying-che-with-support-for-git-repositories-with-self-signed-certificates.adoc[]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
:_content-type: PROCEDURE
:description: Limiting the number of workspaces that all users can run simultaneously
:keywords: administration guide, number, workspaces
:navtitle: Limiting the number of workspaces that all users can run simultaneously
:page-aliases:

[id="limiting-the-number-of-workspaces-that-all-users-can-run-simultaneously"]
= Limiting the number of workspaces that all users can run simultaneously

By default, all users can run unlimited number of workspaces. You can limit the number of workspaces that all users can run simultaneously. This configuration is part of the `CheCluster` Custom Resource:

[source,yaml,subs="+quotes"]
----
spec:
devEnvironments:
maxNumberOfRunningWorkspacesPerCluster: __<running_workspaces_limit>__#<1>
----
<1> The maximum number of concurrently running workspaces across the entire Kubernetes cluster.
This applies to all users in the system. If the value is set to -1, it means there is
no limit on the number of running workspaces.

.Procedure

. Configure the `maxNumberOfRunningWorkspacesPerCluster`:
+
[source,subs="+quotes,attributes"]
----
{orch-cli} patch checluster/{prod-checluster} -n {prod-namespace} \
--type='merge' -p \
'{"spec":{"devEnvironments":{"maxNumberOfRunningWorkspacesPerCluster": __<running_workspaces_limit>__}}}'# <1>
----
<1> Your choice of the `__<running_workspaces_limit>__` value.

.Additional resources

* xref:using-the-cli-to-configure-the-checluster-custom-resource.adoc[]
6 changes: 3 additions & 3 deletions modules/end-user-guide/pages/devfile-introduction.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ link:https://registry.devfile.io/viewer[Devfile Registry] contains ready-to-use

.Additional resources

* link:https://devfile.io/docs/2.2.2/what-is-a-devfile[What is a devfile]
* link:https://devfile.io/docs/2.2.0/benefits-of-devfile[Benefits of devfile]
* link:https://devfile.io/docs/2.2.2/overview[Devfile customization overview]
* link:https://devfile.io/docs/{devfile-api-version}/what-is-a-devfile[What is a devfile]
* link:https://devfile.io/docs/{devfile-api-version}/benefits-of-devfile[Benefits of devfile]
* link:https://devfile.io/docs/{devfile-api-version}/overview[Devfile customization overview]
* link:https://devfile.io/[Devfile.io]
* link:https://che.eclipseprojects.io/2024/02/05/@mario.loriedo-cde-customization.html[Customizing Cloud Development Environments]

0 comments on commit dcbd82a

Please sign in to comment.