|
5 | 5 | :page-aliases: .:devworkspace-operator.adoc
|
6 | 6 |
|
7 | 7 | [id="devworkspace-operator"]
|
8 |
| -= {devworkspace} operator |
| 8 | += {devworkspace} Operator overview |
9 | 9 |
|
10 |
| -The {devworkspace} operator extends {orch-name} to provide {devworkspace} support. It introduces: |
11 | 10 |
|
12 |
| -{devworkspace} custom resource definition:: |
| 11 | +The {devworkspace} Operator (DWO) is a dependency of {prod-short}, and is an integral part of how {prod-short} functions. One of DWO's main responsibilities is to reconcile {devworkspace} custom resources (CR). |
13 | 12 |
|
14 |
| -Defines the {devworkspace} {orch-name} object from the Devfile v2 specification. |
| 13 | +The {devworkspace} CR is a {orch-name} resource representation of a {prod-short} workspace. Whenever a user creates a workspace using {prod-short} in the background, Dashboard {prod-short} creates a {devworkspace} CR in the cluster. For every {prod-short} workspace, there is an underlying {devworkspace} CR on the cluster. |
15 | 14 |
|
16 |
| -{devworkspace} controller:: |
| 15 | +Figure 1 shows an example of a {devworkspace} CR in a cluster: |
17 | 16 |
|
18 |
| -Creates and controls the necessary {orch-name} objects to run a {devworkspace}, such as pods, services, and persistent volumes. |
| 17 | +.Example of a {devworkspace} CR in a cluster |
| 18 | +image::devworkspace-operator/devworkspace-cr-example.png[DevWorkspace CR example,width=624,height=465] |
19 | 19 |
|
20 |
| -{devworkspace} custom resource:: |
| 20 | +When creating a workspace with {prod-short} with a devfile, the {devworkspace} CR contains the devfile details. Additionally, {prod-short} adds the editor definition into the {devworkspace} CR depending on which editor was chosen for the workspace. {prod-short} will also add attributes to the {devworkspace} which further configures the workspace depending on how you configured the `CheCluster` CR. |
21 | 21 |
|
22 |
| -On a cluster with the {devworkspace} operator, it is possible to create {devworkspace} custom resources (CR). A {devworkspace} CR is a {orch-name} representation of a Devfile. It defines a User workspaces in a {orch-name} cluster. |
| 22 | +A `DevWorkspaceTemplate` is a custom resource that defines a reusable `spec.template` for {devworkspace}s. |
23 | 23 |
|
| 24 | +When a workspace is started, DWO reads the corresponding {devworkspace} CR and creates the necessary resources such as deployments, secrets, configmaps, routes such that at the end a workspace pod representing the development environment defined in the devfile is created. |
| 25 | + |
| 26 | +.Custom Resources overview |
| 27 | + |
| 28 | +The following Custom Resource Definitions are provided by the {devworkspace} Operator: |
| 29 | + |
| 30 | +* `{devworkspace}` |
| 31 | +* `DevWorkspaceTemplate` |
| 32 | +* `DevWorkspaceOperatorConfig` |
| 33 | +* `DevWorkspaceRouting` |
| 34 | + |
| 35 | + |
| 36 | +.{devworkspace} |
| 37 | + |
| 38 | +The {devworkspace} custom resource contains details about an {prod-short} workspace. Notably, it contains devfile details and a reference to the editor definition. |
| 39 | + |
| 40 | +.DevWorkspaceTemplate |
| 41 | + |
| 42 | +In {prod-short} the `DevWorkspaceTemplate` custom resource is typically used to define an editor (such as Visual Studio Code - Open Source) for {prod-short} workspaces. You can use this custom resource to define reusable `spec.template` content that is reused by multiple {devworkspace}s. |
| 43 | + |
| 44 | +.DevWorkspaceOperatorConfig |
| 45 | + |
| 46 | +The `DevWorkspaceOperatorConfig` (DWOC) custom resource defines configuration options for the DWO. There are two different types of DWOC: |
| 47 | + |
| 48 | + * global configuration |
| 49 | + * non-global configuration |
| 50 | + |
| 51 | +The global configuration is a DWOC custom resource named `devworkspace-operator-config` and is usually located in the DWO installation namespace. By default, the global configuration is not created upon installation. Configuration fields set in the global configuration will apply to the DWO and all {devworkspace}s. However, the DWOC configuration can be overridden by a non-global configuration. |
| 52 | + |
| 53 | +Any other DWOC custom resource than `devworkspace-operator-config` is considered to be non-global configuration. A non-global configuration does not apply to any {devworkspace}s unless the {devworkspace} contains a reference to the DWOC. If the global configuration and non-global configuration have the same fields, the non-global configuration field takes precedence. |
| 54 | + |
| 55 | +.Global DWOC and {prod-short}-owned DWOC comparison |
| 56 | +[cols="1,1,1",options="header"] |
| 57 | +|=== |
| 58 | +| |Global DWOC |{prod-short}-owned DWOC |
| 59 | +|Resource name |`devworkspace-operator-config` |`devworkspace-config` |
| 60 | +|Namespace |DWO installation namespace |{prod-short} installation namespace |
| 61 | +|Default creation |Not created by default upon DWO installation |Created by default on {prod-short} installation |
| 62 | +|Scope |Applies to the DWO itself and all {devworkspace}s managed by DWO |Applies to {devworkspace}s created by {prod-short} |
| 63 | +|Precedence |Overridden by fields set in {prod-short}-owned config |Takes precedence over global config if both define the same field |
| 64 | +|Primary use case |Used to define default, broad settings that apply to DWO in general. |Used to define specific configuration for {devworkspace}s created by {prod-short} |
| 65 | +|=== |
| 66 | + |
| 67 | +For example, by default {prod-short} creates and manages a non-global DWOC in the {prod-short} namespace named `devworkspace-config`. This DWOC contains configuration specific to {prod-short} workspaces, and is maintained by {prod-short} depending on how you configure the CheCluster CR. When {prod-short} creates a workspace, {prod-short} adds a reference to the {prod-short}-owned DWOC with the `controller.devfile.io/devworkspace-config` attribute. |
| 68 | + |
| 69 | +.Example of {devworkspace} configuration attribute |
| 70 | +image::devworkspace-operator/devworkspace-config-attribute.png[DevWorkspace config attribute example,width=624,height=280] |
| 71 | + |
| 72 | +.DevWorkspaceRouting |
| 73 | + |
| 74 | +The `DevWorkspaceRouting` custom resource defines details about the endpoints of a {devworkspace}. Every {devworkspace} has its corresponding `DevWorkspaceRouting` object that specifies the workspace's container endpoints. Endpoints defined from the devfile, as well as endpoints defined by the editor definition will appear in the `DevWorkspaceRouting` custom resource. |
| 75 | + |
| 76 | +[source,yaml] |
| 77 | +---- |
| 78 | +apiVersion: controller.devfile.io/v1alpha1 |
| 79 | +kind: DevWorkspaceRouting |
| 80 | +metadata: |
| 81 | + annotations: |
| 82 | + controller.devfile.io/devworkspace-started: 'false' |
| 83 | + name: routing-workspaceb14aa33254674065 |
| 84 | + labels: |
| 85 | + controller.devfile.io/devworkspace_id: workspaceb14aa33254674065 |
| 86 | +spec: |
| 87 | + devworkspaceId: workspaceb14aa33254674065 |
| 88 | + endpoints: |
| 89 | + universal-developer-image: |
| 90 | + - attributes: |
| 91 | + cookiesAuthEnabled: true |
| 92 | + discoverable: false |
| 93 | + type: main |
| 94 | + urlRewriteSupported: true |
| 95 | + exposure: public |
| 96 | + name: che-code |
| 97 | + protocol: https |
| 98 | + secure: true |
| 99 | + targetPort: 3100 |
| 100 | + podSelector: |
| 101 | + controller.devfile.io/devworkspace_id: workspaceb14aa33254674065 |
| 102 | + routingClass: che |
| 103 | +status: |
| 104 | + exposedEndpoints: |
| 105 | + ... |
| 106 | +---- |
| 107 | + |
| 108 | +== {devworkspace} Operator's operands |
| 109 | + |
| 110 | +The {devworkspace} Operator has two operands: |
| 111 | + |
| 112 | +* controller deployment |
| 113 | +* webhook deployment. |
| 114 | + |
| 115 | +[source,terminal] |
| 116 | +---- |
| 117 | +$ oc get pods -l 'app.kubernetes.io/part-of=devworkspace-operator' -o custom-columns=NAME:.metadata.name -n openshift-operators |
| 118 | +NAME |
| 119 | +devworkspace-controller-manager-66c6f674f5-l7rhj <1> |
| 120 | +devworkspace-webhook-server-d4958d9cd-gh7vr <2> |
| 121 | +devworkspace-webhook-server-d4958d9cd-rfvj6 <2> |
| 122 | +---- |
| 123 | + |
| 124 | +<1> The {devworkspace} controller pod, which is responsible for reconciling custom resources |
| 125 | +<2> The {devworkspace} operator webhook server pods |
| 126 | + |
| 127 | +.Configuring the {devworkspace}-controller-manager deployment |
| 128 | + |
| 129 | +You can configure the `devworkspace-controller-manager` pod in the {devworkspace} Operator Subscription object: |
| 130 | + |
| 131 | +[source,yaml] |
| 132 | +---- |
| 133 | +apiVersion: operators.coreos.com/v1alpha1 |
| 134 | +kind: Subscription |
| 135 | +metadata: |
| 136 | + name: devworkspace-operator |
| 137 | + namespace: openshift-operators |
| 138 | +spec: |
| 139 | + config: |
| 140 | + affinity: |
| 141 | + nodeAffinity: ... |
| 142 | + podAffinity: ... |
| 143 | + resources: |
| 144 | + limits: |
| 145 | + memory: ... |
| 146 | + cpu: ... |
| 147 | + requests: |
| 148 | + memory: ... |
| 149 | + cpu: ... |
| 150 | +---- |
| 151 | + |
| 152 | +Learn more about configuration in this link:https://github.com/operator-framework/operator-lifecycle-manager/blob/master/doc/design/subscription-config.md[documentation]. |
| 153 | + |
| 154 | +.Configuring the {devworkspace}-webhook-server deployment |
| 155 | + |
| 156 | +You can configure the `devworkspace-webhook-server` deployment in the global DWOC: |
| 157 | + |
| 158 | +[source,yaml] |
| 159 | +---- |
| 160 | +apiVersion: controller.devfile.io/v1alpha1 |
| 161 | +kind: DevWorkspaceOperatorConfig |
| 162 | +metadata: |
| 163 | + name: devworkspace-operator-config |
| 164 | + namespace: <DWO install namespace> |
| 165 | +config: |
| 166 | + webhooks: |
| 167 | + nodeSelector: <map[string]string> |
| 168 | + replicas: <int> |
| 169 | + tolerations: <[]corev1.Toleration> |
| 170 | +---- |
24 | 171 |
|
25 | 172 | .Additional resources
|
26 | 173 |
|
27 |
| -* link:https://github.com/devfile/api[Devfile API repository] |
28 | 174 | include::example$snip_{project-context}-devworkspace-additional-resources.adoc[]
|
0 commit comments