From 38f6cb63811dee80d6ad08d09ed2afc203df0249 Mon Sep 17 00:00:00 2001 From: Anatolii Bazko Date: Wed, 22 Jun 2022 11:02:08 +0300 Subject: [PATCH] feat: CheCluster defaults (#1407) * feat: CheCluster defaults Signed-off-by: Anatolii Bazko --- Makefile | 4 +- api/v2/checluster_types.go | 35 +++++-- .../che-operator.clusterserviceversion.yaml | 33 ++----- .../org.eclipse.che_checlusters.yaml | 99 ++++++++++++++++++- .../bases/org.eclipse.che_checlusters.yaml | 99 ++++++++++++++++++- config/samples/org_v2_checluster.yaml | 21 +--- controllers/che/checluster_validator.go | 14 +-- deploy/deployment/kubernetes/combined.yaml | 97 +++++++++++++++++- ....eclipse.che.CustomResourceDefinition.yaml | 97 +++++++++++++++++- .../kubernetes/org_v2_checluster.yaml | 21 +--- deploy/deployment/openshift/combined.yaml | 97 +++++++++++++++++- ....eclipse.che.CustomResourceDefinition.yaml | 97 +++++++++++++++++- .../openshift/org_v2_checluster.yaml | 21 +--- ....eclipse.che.CustomResourceDefinition.yaml | 97 +++++++++++++++++- .../next/templates/org_v2_checluster.yaml | 19 ++-- pkg/common/k8s-helper/k8s_helper.go | 7 +- 16 files changed, 714 insertions(+), 144 deletions(-) diff --git a/Makefile b/Makefile index dd2b90c6db..4738bbb170 100644 --- a/Makefile +++ b/Makefile @@ -65,7 +65,6 @@ mkfile_dir := $(dir $(mkfile_path)) # Default Eclipse Che operator image IMG ?= quay.io/eclipse/che-operator:next -CRD_OPTIONS ?= "crd:crdVersions=v1" CONFIG_MANAGER="config/manager/manager.yaml" INTERNAL_TMP_DIR=/tmp/che-operator-dev @@ -215,6 +214,7 @@ update-helmcharts: ## Update Helm Charts yq -rYi --arg examples "$${CRDS_SAMPLES}" ".annotations.\"artifacthub.io/crdsExamples\" = \$$examples" $${chartYaml} rm -rf $${HELMCHARTS_TEMPLATES}/org_v2_checluster.yaml else + yq -riY '.spec.networking = null' $${HELMCHARTS_TEMPLATES}/org_v2_checluster.yaml yq -riY '.spec.networking.tlsSecretName = "che-tls"' $${HELMCHARTS_TEMPLATES}/org_v2_checluster.yaml yq -riY '.spec.networking.domain = "{{ .Values.networking.domain }}"' $${HELMCHARTS_TEMPLATES}/org_v2_checluster.yaml yq -riY '.spec.networking.auth.oAuthSecret = "{{ .Values.networking.auth.oAuthSecret }}"' $${HELMCHARTS_TEMPLATES}/org_v2_checluster.yaml @@ -346,7 +346,7 @@ docker-push: ## Push Eclipse Che operator image to a registry ${IMAGE_TOOL} push ${IMG} manifests: download-controller-gen download-addlicense ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects. - $(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases + $(CONTROLLER_GEN) crd:crdVersions=v1 rbac:roleName=manager-role paths="./..." output:crd:artifacts:config=config/crd/bases # remove yaml delimitier, which makes OLM catalog source image broken. sed -i '/---/d' "$(CHECLUSTER_CRD_PATH)" diff --git a/api/v2/checluster_types.go b/api/v2/checluster_types.go index 1bcb4e3a7a..358a381e67 100644 --- a/api/v2/checluster_types.go +++ b/api/v2/checluster_types.go @@ -1,5 +1,5 @@ // -// Copyright (c) 2019-2021 Red Hat, Inc. +// Copyright (c) 2019-2022 Red Hat, Inc. // This program and the accompanying materials are made // available under the terms of the Eclipse Public License 2.0 // which is available at https://www.eclipse.org/legal/epl-2.0/ @@ -36,17 +36,20 @@ type CheClusterSpec struct { // +optional // +operator-sdk:csv:customresourcedefinitions:type=spec,order=1 // +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Development environments" + // +kubebuilder:default:={storage: {pvcStrategy: common}, defaultNamespace: {template: -che}} DevEnvironments CheClusterDevEnvironments `json:"devEnvironments"` // Che components configuration. // +optional // +operator-sdk:csv:customresourcedefinitions:type=spec,order=2 // +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Components" + // +kubebuilder:default:={cheServer: {logLevel: INFO, debug: false}, metrics: {enable: true}, database: {externalDb: false, credentialsSecretName: postgres-credentials, postgresHostName: postgres, postgresPort: "5432", postgresDb: dbche, pvc: {claimSize: "1Gi"}}} Components CheClusterComponents `json:"components"` // Networking, Che authentication, and TLS configuration. // +optional // +operator-sdk:csv:customresourcedefinitions:type=spec,order=3 // +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Networking" - Networking CheClusterSpecNetworking `json:"networking,omitempty"` + // +kubebuilder:default:={auth: {gateway: {configLabels: {app: che, component: che-gateway-config}}}} + Networking CheClusterSpecNetworking `json:"networking"` // Configuration of an alternative registry that stores Che images. // +optional // +operator-sdk:csv:customresourcedefinitions:type=spec,order=4 @@ -59,7 +62,8 @@ type CheClusterSpec struct { type CheClusterDevEnvironments struct { // Workspaces persistent storage. // +optional - Storage WorkspaceStorage `json:"storage"` + // +kubebuilder:default:={pvcStrategy: common} + Storage WorkspaceStorage `json:"storage,omitempty"` // Default plug-ins applied to DevWorkspaces. // +optional DefaultPlugins []WorkspaceDefaultPlugins `json:"defaultPlugins,omitempty"` @@ -71,6 +75,7 @@ type CheClusterDevEnvironments struct { Tolerations []corev1.Toleration `json:"tolerations,omitempty"` // User's default namespace. // +optional + // +kubebuilder:default:={template: -che} DefaultNamespace DefaultNamespace `json:"defaultNamespace,omitempty"` // Trusted certificate settings. // +optional @@ -85,6 +90,7 @@ type CheClusterComponents struct { DevWorkspace DevWorkspace `json:"devWorkspace"` // General configuration settings related to the Che server. // +optional + // +kubebuilder:default:={logLevel: INFO, debug: false} CheServer CheServer `json:"cheServer"` // Configuration settings related to the plug-in registry used by the Che installation. // +optional @@ -94,6 +100,7 @@ type CheClusterComponents struct { DevfileRegistry DevfileRegistry `json:"devfileRegistry"` // Configuration settings related to the database used by the Che installation. // +optional + // +kubebuilder:default:={externalDb: false, credentialsSecretName: postgres-credentials, postgresHostName: postgres, postgresPort: "5432", postgresDb: dbche, pvc: {claimSize: "1Gi"}} Database Database `json:"database"` // Configuration settings related to the dashboard used by the Che installation. // +optional @@ -103,6 +110,7 @@ type CheClusterComponents struct { ImagePuller ImagePuller `json:"imagePuller"` // Che server metrics configuration. // +optional + // +kubebuilder:default:={enable: true} Metrics ServerMetrics `json:"metrics"` } @@ -136,6 +144,7 @@ type CheClusterSpecNetworking struct { TlsSecretName string `json:"tlsSecretName,omitempty"` // Authentication settings. // +optional + // +kubebuilder:default:={gateway: {configLabels: {app: che, component: che-gateway-config}}} Auth Auth `json:"auth"` } @@ -166,6 +175,7 @@ type CheServer struct { LogLevel string `json:"logLevel,omitempty"` // Enables the debug mode for Che server. // +optional + // +kubebuilder:default:=false Debug *bool `json:"debug,omitempty"` // ClusterRoles assigned to Che ServiceAccount. // The defaults roles are: @@ -236,6 +246,7 @@ type Database struct { // When `externalDb` is set as `true`, no dedicated database is deployed by the // Operator and you need to provide connection details about the external database you want to use. // +optional + // +kubebuilder:default:=false ExternalDb bool `json:"externalDb"` // Deployment override options. // +optional @@ -261,14 +272,15 @@ type Database struct { CredentialsSecretName string `json:"credentialsSecretName,omitempty"` // PVC settings for PostgreSQL database. // +optional + // +kubebuilder:default:={claimSize: "1Gi"} Pvc PVC `json:"pvc,omitempty"` } // Che server metrics configuration type ServerMetrics struct { // Enables `metrics` for the Che server endpoint. - // +kubebuilder:default:=true // +optional + // +kubebuilder:default:=true Enable bool `json:"enable"` } @@ -284,6 +296,7 @@ type ImagePuller struct { // pre-pulled after installation. // Note that while this Operator and its behavior is community-supported, its payload may be commercially-supported // for pulling commercially-supported images. + // +optional Enable bool `json:"enable"` // A Kubernetes Image Puller spec to configure the image puller in the CheCluster. // +optional @@ -304,8 +317,10 @@ type DevWorkspace struct { type DefaultNamespace struct { // If you don't create the user namespaces in advance, this field defines the Kubernetes namespace created when you start your first workspace. - // You can use ``, `` and `` placeholders, such as che-workspace-. + // You can use `` and `` placeholders, such as che-workspace-. // +optional + // +kubebuilder:default:=-che + // +kubebuilder:validation:Pattern=| Template string `json:"template,omitempty"` } @@ -336,6 +351,7 @@ type WorkspaceStorage struct { // For details, see https://github.com/eclipse/che/issues/21185. // +optional // +kubebuilder:default:="common" + // +kubebuilder:validation:Enum=common;per-workspace PvcStrategy string `json:"pvcStrategy,omitempty"` } @@ -349,10 +365,13 @@ type WorkspaceDefaultPlugins struct { // Authentication settings. type Auth struct { // Public URL of the Identity Provider server. + // +optional IdentityProviderURL string `json:"identityProviderURL,omitempty"` // Name of the OpenShift `OAuthClient` resource used to set up identity federation on the OpenShift side. + // +optional OAuthClientName string `json:"oAuthClientName,omitempty"` // Name of the secret set in the OpenShift `OAuthClient` resource used to set up identity federation on the OpenShift side. + // +optional OAuthSecret string `json:"oAuthSecret,omitempty"` // Access Token Scope. // This field is specific to Che installations made for Kubernetes only and ignored for OpenShift. @@ -366,6 +385,7 @@ type Auth struct { IdentityToken string `json:"identityToken,omitempty"` // Gateway settings. // +optional + // +kubebuilder:default:={configLabels: {app: che, component: che-gateway-config}} Gateway Gateway `json:"gateway,omitempty"` } @@ -379,8 +399,9 @@ type Gateway struct { // - `kube-rbac-proxy` // +optional Deployment Deployment `json:"deployment,omitempty"` - // Gate configuration labels. + // Gateway configuration labels. // +optional + // +kubebuilder:default:={app: che, component: che-gateway-config} ConfigLabels map[string]string `json:"configLabels,omitempty"` } @@ -403,6 +424,7 @@ type Proxy struct { // Use only when a proxy configuration is required. The Operator respects OpenShift cluster-wide proxy configuration, // defining `nonProxyHosts` in a custom resource leads to merging non-proxy hosts lists from the cluster proxy configuration, and the ones defined in the custom resources. // See the following page: https://docs.openshift.com/container-platform/4.4/networking/enable-cluster-wide-proxy.html. See also the `proxyURL` fields. + // +optional NonProxyHosts []string `json:"nonProxyHosts,omitempty"` // The secret name that contains `user` and `password` for a proxy server. // The secret must have a `app.kubernetes.io/part-of=che.eclipse.org` label. @@ -454,6 +476,7 @@ type Container struct { Image string `json:"image,omitempty"` // Image pull policy. Default value is `Always` for `nightly`, `next` or `latest` images, and `IfNotPresent` in other cases. // +optional + // +kubebuilder:validation:Enum=Always;IfNotPresent;Never ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty"` // Compute resources required by this container. // +optional diff --git a/bundle/next/eclipse-che-preview-openshift/manifests/che-operator.clusterserviceversion.yaml b/bundle/next/eclipse-che-preview-openshift/manifests/che-operator.clusterserviceversion.yaml index b8974e9ae0..44c61c2bd8 100644 --- a/bundle/next/eclipse-che-preview-openshift/manifests/che-operator.clusterserviceversion.yaml +++ b/bundle/next/eclipse-che-preview-openshift/manifests/che-operator.clusterserviceversion.yaml @@ -55,31 +55,10 @@ metadata: "namespace": "eclipse-che" }, "spec": { - "components": { - "database": { - "externalDb": false - }, - "metrics": { - "enable": true - } - }, - "devEnvironments": { - "defaultNamespace": { - "template": "-che" - }, - "storage": { - "pvcStrategy": "common" - } - }, - "networking": { - "auth": { - "identityProviderURL": "", - "oAuthClientName": "", - "oAuthSecret": "" - }, - "domain": "", - "tlsSecretName": "" - } + "components": {}, + "containerRegistry": {}, + "devEnvironments": {}, + "networking": {} } } ] @@ -97,7 +76,7 @@ metadata: operators.operatorframework.io/project_layout: go.kubebuilder.io/v3 repository: https://github.com/eclipse-che/che-operator support: Eclipse Foundation - name: eclipse-che-preview-openshift.v7.50.0-568.next + name: eclipse-che-preview-openshift.v7.50.0-606.next namespace: placeholder spec: apiservicedefinitions: {} @@ -1408,7 +1387,7 @@ spec: maturity: stable provider: name: Eclipse Foundation - version: 7.50.0-568.next + version: 7.50.0-606.next webhookdefinitions: - admissionReviewVersions: - v1 diff --git a/bundle/next/eclipse-che-preview-openshift/manifests/org.eclipse.che_checlusters.yaml b/bundle/next/eclipse-che-preview-openshift/manifests/org.eclipse.che_checlusters.yaml index 7d5175ff0c..84fb8d4a1c 100644 --- a/bundle/next/eclipse-che-preview-openshift/manifests/org.eclipse.che_checlusters.yaml +++ b/bundle/next/eclipse-che-preview-openshift/manifests/org.eclipse.che_checlusters.yaml @@ -1283,9 +1283,26 @@ spec: description: Desired configuration of Eclipse Che installation. properties: components: + default: + cheServer: + debug: false + logLevel: INFO + database: + credentialsSecretName: postgres-credentials + externalDb: false + postgresDb: dbche + postgresHostName: postgres + postgresPort: "5432" + pvc: + claimSize: 1Gi + metrics: + enable: true description: Che components configuration. properties: cheServer: + default: + debug: false + logLevel: INFO description: General configuration settings related to the Che server. properties: @@ -1301,6 +1318,7 @@ spec: type: string type: array debug: + default: false description: Enables the debug mode for Che server. type: boolean deployment: @@ -1320,6 +1338,10 @@ spec: description: Image pull policy. Default value is `Always` for `nightly`, `next` or `latest` images, and `IfNotPresent` in other cases. + enum: + - Always + - IfNotPresent + - Never type: string name: description: Container name. @@ -1466,6 +1488,10 @@ spec: description: Image pull policy. Default value is `Always` for `nightly`, `next` or `latest` images, and `IfNotPresent` in other cases. + enum: + - Always + - IfNotPresent + - Never type: string name: description: Container name. @@ -1547,6 +1573,14 @@ spec: type: object type: object database: + default: + credentialsSecretName: postgres-credentials + externalDb: false + postgresDb: dbche + postgresHostName: postgres + postgresPort: "5432" + pvc: + claimSize: 1Gi description: Configuration settings related to the database used by the Che installation. properties: @@ -1574,6 +1608,10 @@ spec: description: Image pull policy. Default value is `Always` for `nightly`, `next` or `latest` images, and `IfNotPresent` in other cases. + enum: + - Always + - IfNotPresent + - Never type: string name: description: Container name. @@ -1644,6 +1682,7 @@ spec: type: object type: object externalDb: + default: false description: Instructs the Operator to deploy a dedicated database. By default, a dedicated PostgreSQL database is deployed as part of the Che installation. When `externalDb` @@ -1669,6 +1708,8 @@ spec: See field `externalDb`. type: string pvc: + default: + claimSize: 1Gi description: PVC settings for PostgreSQL database. properties: claimSize: @@ -1703,6 +1744,10 @@ spec: description: Image pull policy. Default value is `Always` for `nightly`, `next` or `latest` images, and `IfNotPresent` in other cases. + enum: + - Always + - IfNotPresent + - Never type: string name: description: Container name. @@ -1798,6 +1843,10 @@ spec: description: Image pull policy. Default value is `Always` for `nightly`, `next` or `latest` images, and `IfNotPresent` in other cases. + enum: + - Always + - IfNotPresent + - Never type: string name: description: Container name. @@ -1931,10 +1980,10 @@ spec: nodeSelector: type: string type: object - required: - - enable type: object metrics: + default: + enable: true description: Che server metrics configuration. properties: enable: @@ -1963,6 +2012,10 @@ spec: description: Image pull policy. Default value is `Always` for `nightly`, `next` or `latest` images, and `IfNotPresent` in other cases. + enum: + - Always + - IfNotPresent + - Never type: string name: description: Container name. @@ -2067,16 +2120,25 @@ spec: type: string type: object devEnvironments: + default: + defaultNamespace: + template: -che + storage: + pvcStrategy: common description: Development environment default configuration options. properties: defaultNamespace: + default: + template: -che description: User's default namespace. properties: template: + default: -che description: If you don't create the user namespaces in advance, this field defines the Kubernetes namespace created - when you start your first workspace. You can use ``, - `` and `` placeholders, such as che-workspace-. + when you start your first workspace. You can use `` + and `` placeholders, such as che-workspace-. + pattern: | type: string type: object defaultPlugins: @@ -2101,6 +2163,8 @@ spec: the workspace pods. type: object storage: + default: + pvcStrategy: common description: Workspaces persistent storage. properties: pvc: @@ -2122,6 +2186,9 @@ spec: description: Persistent volume claim strategy for the Che server. Only the `common` strategy (all workspaces PVCs in one volume) is supported . For details, see https://github.com/eclipse/che/issues/21185. + enum: + - common + - per-workspace type: string type: object tolerations: @@ -2180,6 +2247,12 @@ spec: type: object type: object networking: + default: + auth: + gateway: + configLabels: + app: che + component: che-gateway-config description: Networking, Che authentication, and TLS configuration. properties: annotations: @@ -2191,15 +2264,27 @@ spec: "3600", nginx.ingress.kubernetes.io/ssl-redirect: "true"' type: object auth: + default: + gateway: + configLabels: + app: che + component: che-gateway-config description: Authentication settings. properties: gateway: + default: + configLabels: + app: che + component: che-gateway-config description: Gateway settings. properties: configLabels: additionalProperties: type: string - description: Gate configuration labels. + default: + app: che + component: che-gateway-config + description: Gateway configuration labels. type: object deployment: description: 'Deployment override options. Since gateway @@ -2222,6 +2307,10 @@ spec: description: Image pull policy. Default value is `Always` for `nightly`, `next` or `latest` images, and `IfNotPresent` in other cases. + enum: + - Always + - IfNotPresent + - Never type: string name: description: Container name. diff --git a/config/crd/bases/org.eclipse.che_checlusters.yaml b/config/crd/bases/org.eclipse.che_checlusters.yaml index 878b3a91de..fe7437e0d8 100644 --- a/config/crd/bases/org.eclipse.che_checlusters.yaml +++ b/config/crd/bases/org.eclipse.che_checlusters.yaml @@ -1244,9 +1244,26 @@ spec: description: Desired configuration of Eclipse Che installation. properties: components: + default: + cheServer: + debug: false + logLevel: INFO + database: + credentialsSecretName: postgres-credentials + externalDb: false + postgresDb: dbche + postgresHostName: postgres + postgresPort: "5432" + pvc: + claimSize: 1Gi + metrics: + enable: true description: Che components configuration. properties: cheServer: + default: + debug: false + logLevel: INFO description: General configuration settings related to the Che server. properties: @@ -1262,6 +1279,7 @@ spec: type: string type: array debug: + default: false description: Enables the debug mode for Che server. type: boolean deployment: @@ -1281,6 +1299,10 @@ spec: description: Image pull policy. Default value is `Always` for `nightly`, `next` or `latest` images, and `IfNotPresent` in other cases. + enum: + - Always + - IfNotPresent + - Never type: string name: description: Container name. @@ -1425,6 +1447,10 @@ spec: description: Image pull policy. Default value is `Always` for `nightly`, `next` or `latest` images, and `IfNotPresent` in other cases. + enum: + - Always + - IfNotPresent + - Never type: string name: description: Container name. @@ -1504,6 +1530,14 @@ spec: type: object type: object database: + default: + credentialsSecretName: postgres-credentials + externalDb: false + postgresDb: dbche + postgresHostName: postgres + postgresPort: "5432" + pvc: + claimSize: 1Gi description: Configuration settings related to the database used by the Che installation. properties: @@ -1531,6 +1565,10 @@ spec: description: Image pull policy. Default value is `Always` for `nightly`, `next` or `latest` images, and `IfNotPresent` in other cases. + enum: + - Always + - IfNotPresent + - Never type: string name: description: Container name. @@ -1599,6 +1637,7 @@ spec: type: object type: object externalDb: + default: false description: Instructs the Operator to deploy a dedicated database. By default, a dedicated PostgreSQL database is deployed as part of the Che installation. When `externalDb` @@ -1624,6 +1663,8 @@ spec: See field `externalDb`. type: string pvc: + default: + claimSize: 1Gi description: PVC settings for PostgreSQL database. properties: claimSize: @@ -1658,6 +1699,10 @@ spec: description: Image pull policy. Default value is `Always` for `nightly`, `next` or `latest` images, and `IfNotPresent` in other cases. + enum: + - Always + - IfNotPresent + - Never type: string name: description: Container name. @@ -1751,6 +1796,10 @@ spec: description: Image pull policy. Default value is `Always` for `nightly`, `next` or `latest` images, and `IfNotPresent` in other cases. + enum: + - Always + - IfNotPresent + - Never type: string name: description: Container name. @@ -1882,10 +1931,10 @@ spec: nodeSelector: type: string type: object - required: - - enable type: object metrics: + default: + enable: true description: Che server metrics configuration. properties: enable: @@ -1914,6 +1963,10 @@ spec: description: Image pull policy. Default value is `Always` for `nightly`, `next` or `latest` images, and `IfNotPresent` in other cases. + enum: + - Always + - IfNotPresent + - Never type: string name: description: Container name. @@ -2016,16 +2069,25 @@ spec: type: string type: object devEnvironments: + default: + defaultNamespace: + template: -che + storage: + pvcStrategy: common description: Development environment default configuration options. properties: defaultNamespace: + default: + template: -che description: User's default namespace. properties: template: + default: -che description: If you don't create the user namespaces in advance, this field defines the Kubernetes namespace created when - you start your first workspace. You can use ``, - `` and `` placeholders, such as che-workspace-. + you start your first workspace. You can use `` + and `` placeholders, such as che-workspace-. + pattern: | type: string type: object defaultPlugins: @@ -2049,6 +2111,8 @@ spec: workspace pods. type: object storage: + default: + pvcStrategy: common description: Workspaces persistent storage. properties: pvc: @@ -2070,6 +2134,9 @@ spec: description: Persistent volume claim strategy for the Che server. Only the `common` strategy (all workspaces PVCs in one volume) is supported . For details, see https://github.com/eclipse/che/issues/21185. + enum: + - common + - per-workspace type: string type: object tolerations: @@ -2127,6 +2194,12 @@ spec: type: object type: object networking: + default: + auth: + gateway: + configLabels: + app: che + component: che-gateway-config description: Networking, Che authentication, and TLS configuration. properties: annotations: @@ -2138,15 +2211,27 @@ spec: "3600", nginx.ingress.kubernetes.io/ssl-redirect: "true"' type: object auth: + default: + gateway: + configLabels: + app: che + component: che-gateway-config description: Authentication settings. properties: gateway: + default: + configLabels: + app: che + component: che-gateway-config description: Gateway settings. properties: configLabels: additionalProperties: type: string - description: Gate configuration labels. + default: + app: che + component: che-gateway-config + description: Gateway configuration labels. type: object deployment: description: 'Deployment override options. Since gateway @@ -2168,6 +2253,10 @@ spec: description: Image pull policy. Default value is `Always` for `nightly`, `next` or `latest` images, and `IfNotPresent` in other cases. + enum: + - Always + - IfNotPresent + - Never type: string name: description: Container name. diff --git a/config/samples/org_v2_checluster.yaml b/config/samples/org_v2_checluster.yaml index 44f6f381c5..3a7667cf16 100644 --- a/config/samples/org_v2_checluster.yaml +++ b/config/samples/org_v2_checluster.yaml @@ -16,20 +16,7 @@ metadata: name: eclipse-che namespace: eclipse-che spec: - devEnvironments: - defaultNamespace: - template: '-che' - storage: - pvcStrategy: 'common' - components: - database: - externalDb: false - metrics: - enable: true - networking: - domain: '' - tlsSecretName: '' - auth: - identityProviderURL: '' - oAuthClientName: '' - oAuthSecret: '' + components: {} + devEnvironments: {} + networking: {} + containerRegistry: {} diff --git a/controllers/che/checluster_validator.go b/controllers/che/checluster_validator.go index becbb9fd12..74a0111546 100644 --- a/controllers/che/checluster_validator.go +++ b/controllers/che/checluster_validator.go @@ -14,7 +14,6 @@ package che import ( "fmt" - "strings" "github.com/devfile/devworkspace-operator/pkg/infrastructure" "github.com/eclipse-che/che-operator/pkg/common/chetypes" @@ -22,15 +21,9 @@ import ( "sigs.k8s.io/controller-runtime/pkg/reconcile" ) -const ( - NamespaceStrategyErrorMessage = "Namespace strategies other than 'per user' is not supported anymore. Using the or placeholder is required in the 'spec.server.workspaceNamespaceDefault' field. The current value is: %s" -) - // CheClusterValidator checks CheCluster CR configuration. -// It detect: +// It detects: // - configurations which miss required field(s) to deploy Che -// - self-contradictory configurations -// - configurations with which it is impossible to deploy Che type CheClusterValidator struct { deploy.Reconcilable } @@ -46,11 +39,6 @@ func (v *CheClusterValidator) Reconcile(ctx *chetypes.DeployContext) (reconcile. } } - workspaceNamespaceDefault := ctx.CheCluster.GetDefaultNamespace() - if strings.Index(workspaceNamespaceDefault, "") == -1 && strings.Index(workspaceNamespaceDefault, "") == -1 { - return reconcile.Result{}, false, fmt.Errorf(NamespaceStrategyErrorMessage, workspaceNamespaceDefault) - } - return reconcile.Result{}, true, nil } diff --git a/deploy/deployment/kubernetes/combined.yaml b/deploy/deployment/kubernetes/combined.yaml index 061c8ac115..79ad8f7902 100644 --- a/deploy/deployment/kubernetes/combined.yaml +++ b/deploy/deployment/kubernetes/combined.yaml @@ -795,9 +795,26 @@ spec: description: Desired configuration of Eclipse Che installation. properties: components: + default: + cheServer: + debug: false + logLevel: INFO + database: + credentialsSecretName: postgres-credentials + externalDb: false + postgresDb: dbche + postgresHostName: postgres + postgresPort: "5432" + pvc: + claimSize: 1Gi + metrics: + enable: true description: Che components configuration. properties: cheServer: + default: + debug: false + logLevel: INFO description: General configuration settings related to the Che server. properties: clusterRoles: @@ -806,6 +823,7 @@ spec: type: string type: array debug: + default: false description: Enables the debug mode for Che server. type: boolean deployment: @@ -821,6 +839,10 @@ spec: type: string imagePullPolicy: description: Image pull policy. Default value is `Always` for `nightly`, `next` or `latest` images, and `IfNotPresent` in other cases. + enum: + - Always + - IfNotPresent + - Never type: string name: description: Container name. @@ -924,6 +946,10 @@ spec: type: string imagePullPolicy: description: Image pull policy. Default value is `Always` for `nightly`, `next` or `latest` images, and `IfNotPresent` in other cases. + enum: + - Always + - IfNotPresent + - Never type: string name: description: Container name. @@ -995,6 +1021,14 @@ spec: type: object type: object database: + default: + credentialsSecretName: postgres-credentials + externalDb: false + postgresDb: dbche + postgresHostName: postgres + postgresPort: "5432" + pvc: + claimSize: 1Gi description: Configuration settings related to the database used by the Che installation. properties: credentialsSecretName: @@ -1014,6 +1048,10 @@ spec: type: string imagePullPolicy: description: Image pull policy. Default value is `Always` for `nightly`, `next` or `latest` images, and `IfNotPresent` in other cases. + enum: + - Always + - IfNotPresent + - Never type: string name: description: Container name. @@ -1074,6 +1112,7 @@ spec: type: object type: object externalDb: + default: false description: Instructs the Operator to deploy a dedicated database. By default, a dedicated PostgreSQL database is deployed as part of the Che installation. When `externalDb` is set as `true`, no dedicated database is deployed by the Operator and you need to provide connection details about the external database you want to use. type: boolean postgresDb: @@ -1089,6 +1128,8 @@ spec: description: PostgreSQL Database port the Che server connects to. Override this value only when using an external database. See field `externalDb`. type: string pvc: + default: + claimSize: 1Gi description: PVC settings for PostgreSQL database. properties: claimSize: @@ -1115,6 +1156,10 @@ spec: type: string imagePullPolicy: description: Image pull policy. Default value is `Always` for `nightly`, `next` or `latest` images, and `IfNotPresent` in other cases. + enum: + - Always + - IfNotPresent + - Never type: string name: description: Container name. @@ -1194,6 +1239,10 @@ spec: type: string imagePullPolicy: description: Image pull policy. Default value is `Always` for `nightly`, `next` or `latest` images, and `IfNotPresent` in other cases. + enum: + - Always + - IfNotPresent + - Never type: string name: description: Container name. @@ -1303,10 +1352,10 @@ spec: nodeSelector: type: string type: object - required: - - enable type: object metrics: + default: + enable: true description: Che server metrics configuration. properties: enable: @@ -1330,6 +1379,10 @@ spec: type: string imagePullPolicy: description: Image pull policy. Default value is `Always` for `nightly`, `next` or `latest` images, and `IfNotPresent` in other cases. + enum: + - Always + - IfNotPresent + - Never type: string name: description: Container name. @@ -1415,13 +1468,22 @@ spec: type: string type: object devEnvironments: + default: + defaultNamespace: + template: -che + storage: + pvcStrategy: common description: Development environment default configuration options. properties: defaultNamespace: + default: + template: -che description: User's default namespace. properties: template: - description: If you don't create the user namespaces in advance, this field defines the Kubernetes namespace created when you start your first workspace. You can use ``, `` and `` placeholders, such as che-workspace-. + default: -che + description: If you don't create the user namespaces in advance, this field defines the Kubernetes namespace created when you start your first workspace. You can use `` and `` placeholders, such as che-workspace-. + pattern: | type: string type: object defaultPlugins: @@ -1444,6 +1506,8 @@ spec: description: The node selector limits the nodes that can run the workspace pods. type: object storage: + default: + pvcStrategy: common description: Workspaces persistent storage. properties: pvc: @@ -1459,6 +1523,9 @@ spec: pvcStrategy: default: common description: Persistent volume claim strategy for the Che server. Only the `common` strategy (all workspaces PVCs in one volume) is supported . For details, see https://github.com/eclipse/che/issues/21185. + enum: + - common + - per-workspace type: string type: object tolerations: @@ -1493,6 +1560,12 @@ spec: type: object type: object networking: + default: + auth: + gateway: + configLabels: + app: che + component: che-gateway-config description: Networking, Che authentication, and TLS configuration. properties: annotations: @@ -1501,15 +1574,27 @@ spec: description: 'Defines annotations which will be set for an Ingress (a route for OpenShift platform). The defaults for kubernetes platforms are: kubernetes.io/ingress.class: "nginx" nginx.ingress.kubernetes.io/proxy-read-timeout: "3600", nginx.ingress.kubernetes.io/proxy-connect-timeout: "3600", nginx.ingress.kubernetes.io/ssl-redirect: "true"' type: object auth: + default: + gateway: + configLabels: + app: che + component: che-gateway-config description: Authentication settings. properties: gateway: + default: + configLabels: + app: che + component: che-gateway-config description: Gateway settings. properties: configLabels: additionalProperties: type: string - description: Gate configuration labels. + default: + app: che + component: che-gateway-config + description: Gateway configuration labels. type: object deployment: description: 'Deployment override options. Since gateway deployment consists of several containers, they must be distinguished in the configuration by their names: - `gateway` - `configbump` - `oauth-proxy` - `kube-rbac-proxy`' @@ -1524,6 +1609,10 @@ spec: type: string imagePullPolicy: description: Image pull policy. Default value is `Always` for `nightly`, `next` or `latest` images, and `IfNotPresent` in other cases. + enum: + - Always + - IfNotPresent + - Never type: string name: description: Container name. diff --git a/deploy/deployment/kubernetes/objects/checlusters.org.eclipse.che.CustomResourceDefinition.yaml b/deploy/deployment/kubernetes/objects/checlusters.org.eclipse.che.CustomResourceDefinition.yaml index a1d522d430..281422d1c2 100644 --- a/deploy/deployment/kubernetes/objects/checlusters.org.eclipse.che.CustomResourceDefinition.yaml +++ b/deploy/deployment/kubernetes/objects/checlusters.org.eclipse.che.CustomResourceDefinition.yaml @@ -790,9 +790,26 @@ spec: description: Desired configuration of Eclipse Che installation. properties: components: + default: + cheServer: + debug: false + logLevel: INFO + database: + credentialsSecretName: postgres-credentials + externalDb: false + postgresDb: dbche + postgresHostName: postgres + postgresPort: "5432" + pvc: + claimSize: 1Gi + metrics: + enable: true description: Che components configuration. properties: cheServer: + default: + debug: false + logLevel: INFO description: General configuration settings related to the Che server. properties: clusterRoles: @@ -801,6 +818,7 @@ spec: type: string type: array debug: + default: false description: Enables the debug mode for Che server. type: boolean deployment: @@ -816,6 +834,10 @@ spec: type: string imagePullPolicy: description: Image pull policy. Default value is `Always` for `nightly`, `next` or `latest` images, and `IfNotPresent` in other cases. + enum: + - Always + - IfNotPresent + - Never type: string name: description: Container name. @@ -919,6 +941,10 @@ spec: type: string imagePullPolicy: description: Image pull policy. Default value is `Always` for `nightly`, `next` or `latest` images, and `IfNotPresent` in other cases. + enum: + - Always + - IfNotPresent + - Never type: string name: description: Container name. @@ -990,6 +1016,14 @@ spec: type: object type: object database: + default: + credentialsSecretName: postgres-credentials + externalDb: false + postgresDb: dbche + postgresHostName: postgres + postgresPort: "5432" + pvc: + claimSize: 1Gi description: Configuration settings related to the database used by the Che installation. properties: credentialsSecretName: @@ -1009,6 +1043,10 @@ spec: type: string imagePullPolicy: description: Image pull policy. Default value is `Always` for `nightly`, `next` or `latest` images, and `IfNotPresent` in other cases. + enum: + - Always + - IfNotPresent + - Never type: string name: description: Container name. @@ -1069,6 +1107,7 @@ spec: type: object type: object externalDb: + default: false description: Instructs the Operator to deploy a dedicated database. By default, a dedicated PostgreSQL database is deployed as part of the Che installation. When `externalDb` is set as `true`, no dedicated database is deployed by the Operator and you need to provide connection details about the external database you want to use. type: boolean postgresDb: @@ -1084,6 +1123,8 @@ spec: description: PostgreSQL Database port the Che server connects to. Override this value only when using an external database. See field `externalDb`. type: string pvc: + default: + claimSize: 1Gi description: PVC settings for PostgreSQL database. properties: claimSize: @@ -1110,6 +1151,10 @@ spec: type: string imagePullPolicy: description: Image pull policy. Default value is `Always` for `nightly`, `next` or `latest` images, and `IfNotPresent` in other cases. + enum: + - Always + - IfNotPresent + - Never type: string name: description: Container name. @@ -1189,6 +1234,10 @@ spec: type: string imagePullPolicy: description: Image pull policy. Default value is `Always` for `nightly`, `next` or `latest` images, and `IfNotPresent` in other cases. + enum: + - Always + - IfNotPresent + - Never type: string name: description: Container name. @@ -1298,10 +1347,10 @@ spec: nodeSelector: type: string type: object - required: - - enable type: object metrics: + default: + enable: true description: Che server metrics configuration. properties: enable: @@ -1325,6 +1374,10 @@ spec: type: string imagePullPolicy: description: Image pull policy. Default value is `Always` for `nightly`, `next` or `latest` images, and `IfNotPresent` in other cases. + enum: + - Always + - IfNotPresent + - Never type: string name: description: Container name. @@ -1410,13 +1463,22 @@ spec: type: string type: object devEnvironments: + default: + defaultNamespace: + template: -che + storage: + pvcStrategy: common description: Development environment default configuration options. properties: defaultNamespace: + default: + template: -che description: User's default namespace. properties: template: - description: If you don't create the user namespaces in advance, this field defines the Kubernetes namespace created when you start your first workspace. You can use ``, `` and `` placeholders, such as che-workspace-. + default: -che + description: If you don't create the user namespaces in advance, this field defines the Kubernetes namespace created when you start your first workspace. You can use `` and `` placeholders, such as che-workspace-. + pattern: | type: string type: object defaultPlugins: @@ -1439,6 +1501,8 @@ spec: description: The node selector limits the nodes that can run the workspace pods. type: object storage: + default: + pvcStrategy: common description: Workspaces persistent storage. properties: pvc: @@ -1454,6 +1518,9 @@ spec: pvcStrategy: default: common description: Persistent volume claim strategy for the Che server. Only the `common` strategy (all workspaces PVCs in one volume) is supported . For details, see https://github.com/eclipse/che/issues/21185. + enum: + - common + - per-workspace type: string type: object tolerations: @@ -1488,6 +1555,12 @@ spec: type: object type: object networking: + default: + auth: + gateway: + configLabels: + app: che + component: che-gateway-config description: Networking, Che authentication, and TLS configuration. properties: annotations: @@ -1496,15 +1569,27 @@ spec: description: 'Defines annotations which will be set for an Ingress (a route for OpenShift platform). The defaults for kubernetes platforms are: kubernetes.io/ingress.class: "nginx" nginx.ingress.kubernetes.io/proxy-read-timeout: "3600", nginx.ingress.kubernetes.io/proxy-connect-timeout: "3600", nginx.ingress.kubernetes.io/ssl-redirect: "true"' type: object auth: + default: + gateway: + configLabels: + app: che + component: che-gateway-config description: Authentication settings. properties: gateway: + default: + configLabels: + app: che + component: che-gateway-config description: Gateway settings. properties: configLabels: additionalProperties: type: string - description: Gate configuration labels. + default: + app: che + component: che-gateway-config + description: Gateway configuration labels. type: object deployment: description: 'Deployment override options. Since gateway deployment consists of several containers, they must be distinguished in the configuration by their names: - `gateway` - `configbump` - `oauth-proxy` - `kube-rbac-proxy`' @@ -1519,6 +1604,10 @@ spec: type: string imagePullPolicy: description: Image pull policy. Default value is `Always` for `nightly`, `next` or `latest` images, and `IfNotPresent` in other cases. + enum: + - Always + - IfNotPresent + - Never type: string name: description: Container name. diff --git a/deploy/deployment/kubernetes/org_v2_checluster.yaml b/deploy/deployment/kubernetes/org_v2_checluster.yaml index 44f6f381c5..3a7667cf16 100644 --- a/deploy/deployment/kubernetes/org_v2_checluster.yaml +++ b/deploy/deployment/kubernetes/org_v2_checluster.yaml @@ -16,20 +16,7 @@ metadata: name: eclipse-che namespace: eclipse-che spec: - devEnvironments: - defaultNamespace: - template: '-che' - storage: - pvcStrategy: 'common' - components: - database: - externalDb: false - metrics: - enable: true - networking: - domain: '' - tlsSecretName: '' - auth: - identityProviderURL: '' - oAuthClientName: '' - oAuthSecret: '' + components: {} + devEnvironments: {} + networking: {} + containerRegistry: {} diff --git a/deploy/deployment/openshift/combined.yaml b/deploy/deployment/openshift/combined.yaml index c99853ae43..07514e311c 100644 --- a/deploy/deployment/openshift/combined.yaml +++ b/deploy/deployment/openshift/combined.yaml @@ -795,9 +795,26 @@ spec: description: Desired configuration of Eclipse Che installation. properties: components: + default: + cheServer: + debug: false + logLevel: INFO + database: + credentialsSecretName: postgres-credentials + externalDb: false + postgresDb: dbche + postgresHostName: postgres + postgresPort: "5432" + pvc: + claimSize: 1Gi + metrics: + enable: true description: Che components configuration. properties: cheServer: + default: + debug: false + logLevel: INFO description: General configuration settings related to the Che server. properties: clusterRoles: @@ -806,6 +823,7 @@ spec: type: string type: array debug: + default: false description: Enables the debug mode for Che server. type: boolean deployment: @@ -821,6 +839,10 @@ spec: type: string imagePullPolicy: description: Image pull policy. Default value is `Always` for `nightly`, `next` or `latest` images, and `IfNotPresent` in other cases. + enum: + - Always + - IfNotPresent + - Never type: string name: description: Container name. @@ -924,6 +946,10 @@ spec: type: string imagePullPolicy: description: Image pull policy. Default value is `Always` for `nightly`, `next` or `latest` images, and `IfNotPresent` in other cases. + enum: + - Always + - IfNotPresent + - Never type: string name: description: Container name. @@ -995,6 +1021,14 @@ spec: type: object type: object database: + default: + credentialsSecretName: postgres-credentials + externalDb: false + postgresDb: dbche + postgresHostName: postgres + postgresPort: "5432" + pvc: + claimSize: 1Gi description: Configuration settings related to the database used by the Che installation. properties: credentialsSecretName: @@ -1014,6 +1048,10 @@ spec: type: string imagePullPolicy: description: Image pull policy. Default value is `Always` for `nightly`, `next` or `latest` images, and `IfNotPresent` in other cases. + enum: + - Always + - IfNotPresent + - Never type: string name: description: Container name. @@ -1074,6 +1112,7 @@ spec: type: object type: object externalDb: + default: false description: Instructs the Operator to deploy a dedicated database. By default, a dedicated PostgreSQL database is deployed as part of the Che installation. When `externalDb` is set as `true`, no dedicated database is deployed by the Operator and you need to provide connection details about the external database you want to use. type: boolean postgresDb: @@ -1089,6 +1128,8 @@ spec: description: PostgreSQL Database port the Che server connects to. Override this value only when using an external database. See field `externalDb`. type: string pvc: + default: + claimSize: 1Gi description: PVC settings for PostgreSQL database. properties: claimSize: @@ -1115,6 +1156,10 @@ spec: type: string imagePullPolicy: description: Image pull policy. Default value is `Always` for `nightly`, `next` or `latest` images, and `IfNotPresent` in other cases. + enum: + - Always + - IfNotPresent + - Never type: string name: description: Container name. @@ -1194,6 +1239,10 @@ spec: type: string imagePullPolicy: description: Image pull policy. Default value is `Always` for `nightly`, `next` or `latest` images, and `IfNotPresent` in other cases. + enum: + - Always + - IfNotPresent + - Never type: string name: description: Container name. @@ -1303,10 +1352,10 @@ spec: nodeSelector: type: string type: object - required: - - enable type: object metrics: + default: + enable: true description: Che server metrics configuration. properties: enable: @@ -1330,6 +1379,10 @@ spec: type: string imagePullPolicy: description: Image pull policy. Default value is `Always` for `nightly`, `next` or `latest` images, and `IfNotPresent` in other cases. + enum: + - Always + - IfNotPresent + - Never type: string name: description: Container name. @@ -1415,13 +1468,22 @@ spec: type: string type: object devEnvironments: + default: + defaultNamespace: + template: -che + storage: + pvcStrategy: common description: Development environment default configuration options. properties: defaultNamespace: + default: + template: -che description: User's default namespace. properties: template: - description: If you don't create the user namespaces in advance, this field defines the Kubernetes namespace created when you start your first workspace. You can use ``, `` and `` placeholders, such as che-workspace-. + default: -che + description: If you don't create the user namespaces in advance, this field defines the Kubernetes namespace created when you start your first workspace. You can use `` and `` placeholders, such as che-workspace-. + pattern: | type: string type: object defaultPlugins: @@ -1444,6 +1506,8 @@ spec: description: The node selector limits the nodes that can run the workspace pods. type: object storage: + default: + pvcStrategy: common description: Workspaces persistent storage. properties: pvc: @@ -1459,6 +1523,9 @@ spec: pvcStrategy: default: common description: Persistent volume claim strategy for the Che server. Only the `common` strategy (all workspaces PVCs in one volume) is supported . For details, see https://github.com/eclipse/che/issues/21185. + enum: + - common + - per-workspace type: string type: object tolerations: @@ -1493,6 +1560,12 @@ spec: type: object type: object networking: + default: + auth: + gateway: + configLabels: + app: che + component: che-gateway-config description: Networking, Che authentication, and TLS configuration. properties: annotations: @@ -1501,15 +1574,27 @@ spec: description: 'Defines annotations which will be set for an Ingress (a route for OpenShift platform). The defaults for kubernetes platforms are: kubernetes.io/ingress.class: "nginx" nginx.ingress.kubernetes.io/proxy-read-timeout: "3600", nginx.ingress.kubernetes.io/proxy-connect-timeout: "3600", nginx.ingress.kubernetes.io/ssl-redirect: "true"' type: object auth: + default: + gateway: + configLabels: + app: che + component: che-gateway-config description: Authentication settings. properties: gateway: + default: + configLabels: + app: che + component: che-gateway-config description: Gateway settings. properties: configLabels: additionalProperties: type: string - description: Gate configuration labels. + default: + app: che + component: che-gateway-config + description: Gateway configuration labels. type: object deployment: description: 'Deployment override options. Since gateway deployment consists of several containers, they must be distinguished in the configuration by their names: - `gateway` - `configbump` - `oauth-proxy` - `kube-rbac-proxy`' @@ -1524,6 +1609,10 @@ spec: type: string imagePullPolicy: description: Image pull policy. Default value is `Always` for `nightly`, `next` or `latest` images, and `IfNotPresent` in other cases. + enum: + - Always + - IfNotPresent + - Never type: string name: description: Container name. diff --git a/deploy/deployment/openshift/objects/checlusters.org.eclipse.che.CustomResourceDefinition.yaml b/deploy/deployment/openshift/objects/checlusters.org.eclipse.che.CustomResourceDefinition.yaml index f5b13ee845..75ea02d29d 100644 --- a/deploy/deployment/openshift/objects/checlusters.org.eclipse.che.CustomResourceDefinition.yaml +++ b/deploy/deployment/openshift/objects/checlusters.org.eclipse.che.CustomResourceDefinition.yaml @@ -790,9 +790,26 @@ spec: description: Desired configuration of Eclipse Che installation. properties: components: + default: + cheServer: + debug: false + logLevel: INFO + database: + credentialsSecretName: postgres-credentials + externalDb: false + postgresDb: dbche + postgresHostName: postgres + postgresPort: "5432" + pvc: + claimSize: 1Gi + metrics: + enable: true description: Che components configuration. properties: cheServer: + default: + debug: false + logLevel: INFO description: General configuration settings related to the Che server. properties: clusterRoles: @@ -801,6 +818,7 @@ spec: type: string type: array debug: + default: false description: Enables the debug mode for Che server. type: boolean deployment: @@ -816,6 +834,10 @@ spec: type: string imagePullPolicy: description: Image pull policy. Default value is `Always` for `nightly`, `next` or `latest` images, and `IfNotPresent` in other cases. + enum: + - Always + - IfNotPresent + - Never type: string name: description: Container name. @@ -919,6 +941,10 @@ spec: type: string imagePullPolicy: description: Image pull policy. Default value is `Always` for `nightly`, `next` or `latest` images, and `IfNotPresent` in other cases. + enum: + - Always + - IfNotPresent + - Never type: string name: description: Container name. @@ -990,6 +1016,14 @@ spec: type: object type: object database: + default: + credentialsSecretName: postgres-credentials + externalDb: false + postgresDb: dbche + postgresHostName: postgres + postgresPort: "5432" + pvc: + claimSize: 1Gi description: Configuration settings related to the database used by the Che installation. properties: credentialsSecretName: @@ -1009,6 +1043,10 @@ spec: type: string imagePullPolicy: description: Image pull policy. Default value is `Always` for `nightly`, `next` or `latest` images, and `IfNotPresent` in other cases. + enum: + - Always + - IfNotPresent + - Never type: string name: description: Container name. @@ -1069,6 +1107,7 @@ spec: type: object type: object externalDb: + default: false description: Instructs the Operator to deploy a dedicated database. By default, a dedicated PostgreSQL database is deployed as part of the Che installation. When `externalDb` is set as `true`, no dedicated database is deployed by the Operator and you need to provide connection details about the external database you want to use. type: boolean postgresDb: @@ -1084,6 +1123,8 @@ spec: description: PostgreSQL Database port the Che server connects to. Override this value only when using an external database. See field `externalDb`. type: string pvc: + default: + claimSize: 1Gi description: PVC settings for PostgreSQL database. properties: claimSize: @@ -1110,6 +1151,10 @@ spec: type: string imagePullPolicy: description: Image pull policy. Default value is `Always` for `nightly`, `next` or `latest` images, and `IfNotPresent` in other cases. + enum: + - Always + - IfNotPresent + - Never type: string name: description: Container name. @@ -1189,6 +1234,10 @@ spec: type: string imagePullPolicy: description: Image pull policy. Default value is `Always` for `nightly`, `next` or `latest` images, and `IfNotPresent` in other cases. + enum: + - Always + - IfNotPresent + - Never type: string name: description: Container name. @@ -1298,10 +1347,10 @@ spec: nodeSelector: type: string type: object - required: - - enable type: object metrics: + default: + enable: true description: Che server metrics configuration. properties: enable: @@ -1325,6 +1374,10 @@ spec: type: string imagePullPolicy: description: Image pull policy. Default value is `Always` for `nightly`, `next` or `latest` images, and `IfNotPresent` in other cases. + enum: + - Always + - IfNotPresent + - Never type: string name: description: Container name. @@ -1410,13 +1463,22 @@ spec: type: string type: object devEnvironments: + default: + defaultNamespace: + template: -che + storage: + pvcStrategy: common description: Development environment default configuration options. properties: defaultNamespace: + default: + template: -che description: User's default namespace. properties: template: - description: If you don't create the user namespaces in advance, this field defines the Kubernetes namespace created when you start your first workspace. You can use ``, `` and `` placeholders, such as che-workspace-. + default: -che + description: If you don't create the user namespaces in advance, this field defines the Kubernetes namespace created when you start your first workspace. You can use `` and `` placeholders, such as che-workspace-. + pattern: | type: string type: object defaultPlugins: @@ -1439,6 +1501,8 @@ spec: description: The node selector limits the nodes that can run the workspace pods. type: object storage: + default: + pvcStrategy: common description: Workspaces persistent storage. properties: pvc: @@ -1454,6 +1518,9 @@ spec: pvcStrategy: default: common description: Persistent volume claim strategy for the Che server. Only the `common` strategy (all workspaces PVCs in one volume) is supported . For details, see https://github.com/eclipse/che/issues/21185. + enum: + - common + - per-workspace type: string type: object tolerations: @@ -1488,6 +1555,12 @@ spec: type: object type: object networking: + default: + auth: + gateway: + configLabels: + app: che + component: che-gateway-config description: Networking, Che authentication, and TLS configuration. properties: annotations: @@ -1496,15 +1569,27 @@ spec: description: 'Defines annotations which will be set for an Ingress (a route for OpenShift platform). The defaults for kubernetes platforms are: kubernetes.io/ingress.class: "nginx" nginx.ingress.kubernetes.io/proxy-read-timeout: "3600", nginx.ingress.kubernetes.io/proxy-connect-timeout: "3600", nginx.ingress.kubernetes.io/ssl-redirect: "true"' type: object auth: + default: + gateway: + configLabels: + app: che + component: che-gateway-config description: Authentication settings. properties: gateway: + default: + configLabels: + app: che + component: che-gateway-config description: Gateway settings. properties: configLabels: additionalProperties: type: string - description: Gate configuration labels. + default: + app: che + component: che-gateway-config + description: Gateway configuration labels. type: object deployment: description: 'Deployment override options. Since gateway deployment consists of several containers, they must be distinguished in the configuration by their names: - `gateway` - `configbump` - `oauth-proxy` - `kube-rbac-proxy`' @@ -1519,6 +1604,10 @@ spec: type: string imagePullPolicy: description: Image pull policy. Default value is `Always` for `nightly`, `next` or `latest` images, and `IfNotPresent` in other cases. + enum: + - Always + - IfNotPresent + - Never type: string name: description: Container name. diff --git a/deploy/deployment/openshift/org_v2_checluster.yaml b/deploy/deployment/openshift/org_v2_checluster.yaml index 44f6f381c5..3a7667cf16 100644 --- a/deploy/deployment/openshift/org_v2_checluster.yaml +++ b/deploy/deployment/openshift/org_v2_checluster.yaml @@ -16,20 +16,7 @@ metadata: name: eclipse-che namespace: eclipse-che spec: - devEnvironments: - defaultNamespace: - template: '-che' - storage: - pvcStrategy: 'common' - components: - database: - externalDb: false - metrics: - enable: true - networking: - domain: '' - tlsSecretName: '' - auth: - identityProviderURL: '' - oAuthClientName: '' - oAuthSecret: '' + components: {} + devEnvironments: {} + networking: {} + containerRegistry: {} diff --git a/helmcharts/next/crds/checlusters.org.eclipse.che.CustomResourceDefinition.yaml b/helmcharts/next/crds/checlusters.org.eclipse.che.CustomResourceDefinition.yaml index a1d522d430..281422d1c2 100644 --- a/helmcharts/next/crds/checlusters.org.eclipse.che.CustomResourceDefinition.yaml +++ b/helmcharts/next/crds/checlusters.org.eclipse.che.CustomResourceDefinition.yaml @@ -790,9 +790,26 @@ spec: description: Desired configuration of Eclipse Che installation. properties: components: + default: + cheServer: + debug: false + logLevel: INFO + database: + credentialsSecretName: postgres-credentials + externalDb: false + postgresDb: dbche + postgresHostName: postgres + postgresPort: "5432" + pvc: + claimSize: 1Gi + metrics: + enable: true description: Che components configuration. properties: cheServer: + default: + debug: false + logLevel: INFO description: General configuration settings related to the Che server. properties: clusterRoles: @@ -801,6 +818,7 @@ spec: type: string type: array debug: + default: false description: Enables the debug mode for Che server. type: boolean deployment: @@ -816,6 +834,10 @@ spec: type: string imagePullPolicy: description: Image pull policy. Default value is `Always` for `nightly`, `next` or `latest` images, and `IfNotPresent` in other cases. + enum: + - Always + - IfNotPresent + - Never type: string name: description: Container name. @@ -919,6 +941,10 @@ spec: type: string imagePullPolicy: description: Image pull policy. Default value is `Always` for `nightly`, `next` or `latest` images, and `IfNotPresent` in other cases. + enum: + - Always + - IfNotPresent + - Never type: string name: description: Container name. @@ -990,6 +1016,14 @@ spec: type: object type: object database: + default: + credentialsSecretName: postgres-credentials + externalDb: false + postgresDb: dbche + postgresHostName: postgres + postgresPort: "5432" + pvc: + claimSize: 1Gi description: Configuration settings related to the database used by the Che installation. properties: credentialsSecretName: @@ -1009,6 +1043,10 @@ spec: type: string imagePullPolicy: description: Image pull policy. Default value is `Always` for `nightly`, `next` or `latest` images, and `IfNotPresent` in other cases. + enum: + - Always + - IfNotPresent + - Never type: string name: description: Container name. @@ -1069,6 +1107,7 @@ spec: type: object type: object externalDb: + default: false description: Instructs the Operator to deploy a dedicated database. By default, a dedicated PostgreSQL database is deployed as part of the Che installation. When `externalDb` is set as `true`, no dedicated database is deployed by the Operator and you need to provide connection details about the external database you want to use. type: boolean postgresDb: @@ -1084,6 +1123,8 @@ spec: description: PostgreSQL Database port the Che server connects to. Override this value only when using an external database. See field `externalDb`. type: string pvc: + default: + claimSize: 1Gi description: PVC settings for PostgreSQL database. properties: claimSize: @@ -1110,6 +1151,10 @@ spec: type: string imagePullPolicy: description: Image pull policy. Default value is `Always` for `nightly`, `next` or `latest` images, and `IfNotPresent` in other cases. + enum: + - Always + - IfNotPresent + - Never type: string name: description: Container name. @@ -1189,6 +1234,10 @@ spec: type: string imagePullPolicy: description: Image pull policy. Default value is `Always` for `nightly`, `next` or `latest` images, and `IfNotPresent` in other cases. + enum: + - Always + - IfNotPresent + - Never type: string name: description: Container name. @@ -1298,10 +1347,10 @@ spec: nodeSelector: type: string type: object - required: - - enable type: object metrics: + default: + enable: true description: Che server metrics configuration. properties: enable: @@ -1325,6 +1374,10 @@ spec: type: string imagePullPolicy: description: Image pull policy. Default value is `Always` for `nightly`, `next` or `latest` images, and `IfNotPresent` in other cases. + enum: + - Always + - IfNotPresent + - Never type: string name: description: Container name. @@ -1410,13 +1463,22 @@ spec: type: string type: object devEnvironments: + default: + defaultNamespace: + template: -che + storage: + pvcStrategy: common description: Development environment default configuration options. properties: defaultNamespace: + default: + template: -che description: User's default namespace. properties: template: - description: If you don't create the user namespaces in advance, this field defines the Kubernetes namespace created when you start your first workspace. You can use ``, `` and `` placeholders, such as che-workspace-. + default: -che + description: If you don't create the user namespaces in advance, this field defines the Kubernetes namespace created when you start your first workspace. You can use `` and `` placeholders, such as che-workspace-. + pattern: | type: string type: object defaultPlugins: @@ -1439,6 +1501,8 @@ spec: description: The node selector limits the nodes that can run the workspace pods. type: object storage: + default: + pvcStrategy: common description: Workspaces persistent storage. properties: pvc: @@ -1454,6 +1518,9 @@ spec: pvcStrategy: default: common description: Persistent volume claim strategy for the Che server. Only the `common` strategy (all workspaces PVCs in one volume) is supported . For details, see https://github.com/eclipse/che/issues/21185. + enum: + - common + - per-workspace type: string type: object tolerations: @@ -1488,6 +1555,12 @@ spec: type: object type: object networking: + default: + auth: + gateway: + configLabels: + app: che + component: che-gateway-config description: Networking, Che authentication, and TLS configuration. properties: annotations: @@ -1496,15 +1569,27 @@ spec: description: 'Defines annotations which will be set for an Ingress (a route for OpenShift platform). The defaults for kubernetes platforms are: kubernetes.io/ingress.class: "nginx" nginx.ingress.kubernetes.io/proxy-read-timeout: "3600", nginx.ingress.kubernetes.io/proxy-connect-timeout: "3600", nginx.ingress.kubernetes.io/ssl-redirect: "true"' type: object auth: + default: + gateway: + configLabels: + app: che + component: che-gateway-config description: Authentication settings. properties: gateway: + default: + configLabels: + app: che + component: che-gateway-config description: Gateway settings. properties: configLabels: additionalProperties: type: string - description: Gate configuration labels. + default: + app: che + component: che-gateway-config + description: Gateway configuration labels. type: object deployment: description: 'Deployment override options. Since gateway deployment consists of several containers, they must be distinguished in the configuration by their names: - `gateway` - `configbump` - `oauth-proxy` - `kube-rbac-proxy`' @@ -1519,6 +1604,10 @@ spec: type: string imagePullPolicy: description: Image pull policy. Default value is `Always` for `nightly`, `next` or `latest` images, and `IfNotPresent` in other cases. + enum: + - Always + - IfNotPresent + - Never type: string name: description: Container name. diff --git a/helmcharts/next/templates/org_v2_checluster.yaml b/helmcharts/next/templates/org_v2_checluster.yaml index c9cfb61519..d4a5461c2d 100644 --- a/helmcharts/next/templates/org_v2_checluster.yaml +++ b/helmcharts/next/templates/org_v2_checluster.yaml @@ -16,20 +16,13 @@ metadata: name: eclipse-che namespace: eclipse-che spec: - devEnvironments: - defaultNamespace: - template: '-che' - storage: - pvcStrategy: 'common' - components: - database: - externalDb: false - metrics: - enable: true + components: {} + devEnvironments: {} networking: + tlsSecretName: che-tls domain: '{{ .Values.networking.domain }}' - tlsSecretName: 'che-tls' auth: - identityProviderURL: '{{ .Values.networking.auth.identityProviderURL }}' - oAuthClientName: '{{ .Values.networking.auth.oAuthClientName }}' oAuthSecret: '{{ .Values.networking.auth.oAuthSecret }}' + oAuthClientName: '{{ .Values.networking.auth.oAuthClientName }}' + identityProviderURL: '{{ .Values.networking.auth.identityProviderURL }}' + containerRegistry: {} diff --git a/pkg/common/k8s-helper/k8s_helper.go b/pkg/common/k8s-helper/k8s_helper.go index 77395fb2b7..c4c49c3eaa 100644 --- a/pkg/common/k8s-helper/k8s_helper.go +++ b/pkg/common/k8s-helper/k8s_helper.go @@ -16,8 +16,8 @@ import ( "context" "fmt" "io" + "os" - "github.com/eclipse-che/che-operator/pkg/common/test" "k8s.io/client-go/kubernetes/fake" "github.com/sirupsen/logrus" @@ -42,7 +42,7 @@ func New() *K8sHelper { return k8sHelper } - if test.IsTestMode() { + if isTestMode() { return initializeForTesting() } @@ -181,3 +181,6 @@ func initialize() *K8sHelper { return k8sHelper } +func isTestMode() bool { + return len(os.Getenv("MOCK_API")) != 0 +}