Skip to content

Commit

Permalink
Run dashboard as separate deployment (#684)
Browse files Browse the repository at this point in the history
* Run dashboard in a dedicated deployment

* Add info how to fix go imports

* Include dashboard image into release process

* Regenerate CRD & manifests

* Update nightly bundle

Signed-off-by: Anatolii Bazko <abazko@redhat.com>

Co-authored-by: Anatolii Bazko <abazko@redhat.com>
  • Loading branch information
sleshchenko and tolusha authored Apr 21, 2021
1 parent 3c1dafe commit 0353a44
Show file tree
Hide file tree
Showing 20 changed files with 594 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ jobs:
git reset HEAD --hard
if [[ $(find . -not -path "./vendor/*" -name '*.go' -exec goimports -l {} \;) != "" ]]
then
echo "not well formatted sources are found:"
echo "not well organized imports are found."
echo "execute `find . -not -path "./vendor/*" -name '*.go' -exec goimports -l {} \;` to fix the following:"
find . -not -path "./vendor/*" -name '*.go' -exec goimports -l {} \;
exit 1
fi
26 changes: 26 additions & 0 deletions deploy/crds/org_v1_che_crd-v1beta1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,32 @@ spec:
ConfigMap from other CR fields, the value defined in the `customCheProperties`
is used instead.
type: object
dashboardCpuLimit:
description: Overrides the CPU limit used in the dashboard deployment.
In cores. (500m = .5 cores). Default to 500m.
type: string
dashboardCpuRequest:
description: Overrides the CPU request used in the dashboard deployment.
In cores. (500m = .5 cores). Default to 100m.
type: string
dashboardImage:
description: Overrides the container image used in the dashboard
deployment. This includes the image tag. Omit it or leave it empty
to use the default container image provided by the Operator.
type: string
dashboardImagePullPolicy:
description: Overrides the image pull policy used in the dashboard
deployment. Default value is `Always` for `nightly` or `latest`
images, and `IfNotPresent` in other cases.
type: string
dashboardMemoryLimit:
description: Overrides the memory limit used in the dashboard deployment.
Defaults to 256Mi.
type: string
dashboardMemoryRequest:
description: Overrides the memory request used in the dashboard
deployment. Defaults to 16Mi.
type: string
devfileRegistryCpuLimit:
description: Overrides the CPU limit used in the devfile registry
deployment. In cores. (500m = .5 cores). Default to 500m.
Expand Down
26 changes: 26 additions & 0 deletions deploy/crds/org_v1_che_crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,32 @@ spec:
generated in `che` ConfigMap from other CR fields, the value
defined in the `customCheProperties` is used instead.
type: object
dashboardCpuLimit:
description: Overrides the CPU limit used in the dashboard deployment.
In cores. (500m = .5 cores). Default to 500m.
type: string
dashboardCpuRequest:
description: Overrides the CPU request used in the dashboard deployment.
In cores. (500m = .5 cores). Default to 100m.
type: string
dashboardImage:
description: Overrides the container image used in the dashboard
deployment. This includes the image tag. Omit it or leave it
empty to use the default container image provided by the Operator.
type: string
dashboardImagePullPolicy:
description: Overrides the image pull policy used in the dashboard
deployment. Default value is `Always` for `nightly` or `latest`
images, and `IfNotPresent` in other cases.
type: string
dashboardMemoryLimit:
description: Overrides the memory limit used in the dashboard
deployment. Defaults to 256Mi.
type: string
dashboardMemoryRequest:
description: Overrides the memory request used in the dashboard
deployment. Defaults to 16Mi.
type: string
devfileRegistryCpuLimit:
description: Overrides the CPU limit used in the devfile registry
deployment. In cores. (500m = .5 cores). Default to 500m.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ metadata:
categories: Developer Tools
certified: "false"
containerImage: quay.io/eclipse/che-operator:nightly
createdAt: "2021-04-20T09:53:09Z"
createdAt: "2021-04-21T14:41:38Z"
description: A Kube-native development solution that delivers portable and collaborative
developer workspaces.
operatorframework.io/suggested-namespace: eclipse-che
repository: https://github.com/eclipse-che/che-operator
support: Eclipse Foundation
name: eclipse-che-preview-kubernetes.v7.30.0-164.nightly
name: eclipse-che-preview-kubernetes.v7.30.0-168.nightly
namespace: placeholder
spec:
apiservicedefinitions: {}
Expand Down Expand Up @@ -901,6 +901,8 @@ spec:
value: nightly
- name: RELATED_IMAGE_che_server
value: quay.io/eclipse/che-server:nightly
- name: RELATED_IMAGE_dashboard
value: quay.io/eclipse/che-dashboard:next
- name: RELATED_IMAGE_plugin_registry
value: quay.io/eclipse/che-plugin-registry:nightly
- name: RELATED_IMAGE_devfile_registry
Expand Down Expand Up @@ -1111,4 +1113,4 @@ spec:
maturity: stable
provider:
name: Eclipse Foundation
version: 7.30.0-164.nightly
version: 7.30.0-168.nightly
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,32 @@ spec:
generated in `che` ConfigMap from other CR fields, the value
defined in the `customCheProperties` is used instead.
type: object
dashboardCpuLimit:
description: Overrides the CPU limit used in the dashboard deployment.
In cores. (500m = .5 cores). Default to 500m.
type: string
dashboardCpuRequest:
description: Overrides the CPU request used in the dashboard deployment.
In cores. (500m = .5 cores). Default to 100m.
type: string
dashboardImage:
description: Overrides the container image used in the dashboard
deployment. This includes the image tag. Omit it or leave it
empty to use the default container image provided by the Operator.
type: string
dashboardImagePullPolicy:
description: Overrides the image pull policy used in the dashboard
deployment. Default value is `Always` for `nightly` or `latest`
images, and `IfNotPresent` in other cases.
type: string
dashboardMemoryLimit:
description: Overrides the memory limit used in the dashboard
deployment. Defaults to 256Mi.
type: string
dashboardMemoryRequest:
description: Overrides the memory request used in the dashboard
deployment. Defaults to 16Mi.
type: string
devfileRegistryCpuLimit:
description: Overrides the CPU limit used in the devfile registry
deployment. In cores. (500m = .5 cores). Default to 500m.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ metadata:
categories: Developer Tools, OpenShift Optional
certified: "false"
containerImage: quay.io/eclipse/che-operator:nightly
createdAt: "2021-04-20T09:53:20Z"
createdAt: "2021-04-21T14:41:47Z"
description: A Kube-native development solution that delivers portable and collaborative
developer workspaces in OpenShift.
operatorframework.io/suggested-namespace: eclipse-che
repository: https://github.com/eclipse-che/che-operator
support: Eclipse Foundation
name: eclipse-che-preview-openshift.v7.30.0-164.nightly
name: eclipse-che-preview-openshift.v7.30.0-168.nightly
namespace: placeholder
spec:
apiservicedefinitions: {}
Expand Down Expand Up @@ -970,6 +970,8 @@ spec:
value: nightly
- name: RELATED_IMAGE_che_server
value: quay.io/eclipse/che-server:nightly
- name: RELATED_IMAGE_dashboard
value: quay.io/eclipse/che-dashboard:next
- name: RELATED_IMAGE_plugin_registry
value: quay.io/eclipse/che-plugin-registry:nightly
- name: RELATED_IMAGE_devfile_registry
Expand Down Expand Up @@ -1184,4 +1186,4 @@ spec:
maturity: stable
provider:
name: Eclipse Foundation
version: 7.30.0-164.nightly
version: 7.30.0-168.nightly
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,33 @@ spec:
be normally generated in `che` ConfigMap from other CR fields,
the value defined in the `customCheProperties` is used instead.
type: object
dashboardCpuLimit:
description: Overrides the CPU limit used in the dashboard deployment.
In cores. (500m = .5 cores). Default to 500m.
type: string
dashboardCpuRequest:
description: Overrides the CPU request used in the dashboard
deployment. In cores. (500m = .5 cores). Default to 100m.
type: string
dashboardImage:
description: Overrides the container image used in the dashboard
deployment. This includes the image tag. Omit it or leave
it empty to use the default container image provided by the
Operator.
type: string
dashboardImagePullPolicy:
description: Overrides the image pull policy used in the dashboard
deployment. Default value is `Always` for `nightly` or `latest`
images, and `IfNotPresent` in other cases.
type: string
dashboardMemoryLimit:
description: Overrides the memory limit used in the dashboard
deployment. Defaults to 256Mi.
type: string
dashboardMemoryRequest:
description: Overrides the memory request used in the dashboard
deployment. Defaults to 16Mi.
type: string
devfileRegistryCpuLimit:
description: Overrides the CPU limit used in the devfile registry
deployment. In cores. (500m = .5 cores). Default to 500m.
Expand Down
2 changes: 2 additions & 0 deletions deploy/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ spec:
value: nightly
- name: RELATED_IMAGE_che_server
value: quay.io/eclipse/che-server:nightly
- name: RELATED_IMAGE_dashboard
value: quay.io/eclipse/che-dashboard:next
- name: RELATED_IMAGE_plugin_registry
value: quay.io/eclipse/che-plugin-registry:nightly
- name: RELATED_IMAGE_devfile_registry
Expand Down
4 changes: 4 additions & 0 deletions make-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ checkImageReferences() {
echo "[ERROR] Unable to find Che server image with version ${RELEASE} in the $filename"; exit 1
fi

if ! grep -q "value: quay.io/eclipse/che-dashboard:$RELEASE" $filename; then
echo "[ERROR] Unable to find dashboard image with version ${RELEASE} in the $filename"; exit 1
fi

if ! grep -q "value: quay.io/eclipse/che-plugin-registry:$RELEASE" $filename; then
echo "[ERROR] Unable to find plugin registry image with version ${RELEASE} in the $filename"; exit 1
fi
Expand Down
1 change: 1 addition & 0 deletions olm/release-olm-files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ do
sed \
-e 's/imagePullPolicy: *Always/imagePullPolicy: IfNotPresent/' \
-e 's/"cheImageTag": *"nightly"/"cheImageTag": ""/' \
-e 's|quay.io/eclipse/che-dashboard:next|quay.io/eclipse/che-dashboard:${RELEASE}|' \
-e 's|"identityProviderImage": *"quay.io/eclipse/che-keycloak:nightly"|"identityProviderImage": ""|' \
-e 's|"devfileRegistryImage": *"quay.io/eclipse/che-devfile-registry:nightly"|"devfileRegistryImage": ""|' \
-e 's|"pluginRegistryImage": *"quay.io/eclipse/che-plugin-registry:nightly"|"pluginRegistryImage": ""|' \
Expand Down
22 changes: 22 additions & 0 deletions pkg/apis/org/v1/che_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,28 @@ type CheClusterSpecServer struct {
// The default value is `true`.
// +optional
UseInternalClusterSVCNames bool `json:"useInternalClusterSVCNames"`
// Overrides the container image used in the dashboard deployment.
// This includes the image tag. Omit it or leave it empty to use the default container image provided by the Operator.
// +optional
DashboardImage string `json:"dashboardImage,omitempty"`
// Overrides the image pull policy used in the dashboard deployment.
// Default value is `Always` for `nightly` or `latest` images, and `IfNotPresent` in other cases.
// +optional
DashboardImagePullPolicy string `json:"dashboardImagePullPolicy,omitempty"`
// Overrides the memory limit used in the dashboard deployment. Defaults to 256Mi.
// +optional
DashboardMemoryLimit string `json:"dashboardMemoryLimit,omitempty"`
// Overrides the memory request used in the dashboard deployment. Defaults to 16Mi.
// +optional
DashboardMemoryRequest string `json:"dashboardMemoryRequest,omitempty"`
// Overrides the CPU limit used in the dashboard deployment.
// In cores. (500m = .5 cores). Default to 500m.
// +optional
DashboardCpuLimit string `json:"dashboardCpuLimit,omitempty"`
// Overrides the CPU request used in the dashboard deployment.
// In cores. (500m = .5 cores). Default to 100m.
// +optional
DashboardCpuRequest string `json:"dashboardCpuRequest,omitempty"`
// Public URL of the devfile registry, that serves sample, ready-to-use devfiles.
// Set this ONLY when a use of an external devfile registry is needed. See the `externalDevfileRegistry` field.
// By default, this will be automatically calculated by the Operator.
Expand Down
10 changes: 10 additions & 0 deletions pkg/controller/che/che_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (

orgv1 "github.com/eclipse-che/che-operator/pkg/apis/org/v1"
"github.com/eclipse-che/che-operator/pkg/deploy"
"github.com/eclipse-che/che-operator/pkg/deploy/dashboard"
devworkspace "github.com/eclipse-che/che-operator/pkg/deploy/dev-workspace"
"github.com/eclipse-che/che-operator/pkg/deploy/devfileregistry"
"github.com/eclipse-che/che-operator/pkg/deploy/gateway"
Expand Down Expand Up @@ -803,6 +804,15 @@ func (r *ReconcileChe) Reconcile(request reconcile.Request) (reconcile.Result, e
}
}

d := dashboard.NewDashboard(deployContext)
done, err = d.SyncAll()
if !done {
if err != nil {
logrus.Errorf("Error provisioning '%s' to cluster: %v", dashboard.DashboardComponent, err)
}
return reconcile.Result{}, err
}

// create Che ConfigMap which is synced with CR and is not supposed to be manually edited
// controller will reconcile this CM with CR spec
done, err = server.SyncCheConfigMapToCluster(deployContext)
Expand Down
57 changes: 57 additions & 0 deletions pkg/deploy/dashboard/dashboard.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
//
// Copyright (c) 2021 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/
//
// SPDX-License-Identifier: EPL-2.0
//
// Contributors:
// Red Hat, Inc. - initial API and implementation
//
package dashboard

import (
"github.com/eclipse-che/che-operator/pkg/deploy"
"github.com/eclipse-che/che-operator/pkg/deploy/expose"
)

const (
// DashboardComponent which is supposed to be used for the naming related objects
DashboardComponent = "dashboard"
)

type Dashboard struct {
deployContext *deploy.DeployContext
}

func NewDashboard(deployContext *deploy.DeployContext) *Dashboard {
return &Dashboard{
deployContext: deployContext,
}
}

func (d *Dashboard) SyncAll() (done bool, err error) {
// Create a new dashboard service
done, err = deploy.SyncServiceToCluster(d.deployContext, DashboardComponent, []string{"http"}, []int32{8080}, DashboardComponent)
if !done {
return false, err
}

// Expose dashboard service with route or ingress
_, done, err = expose.ExposeWithHostPath(d.deployContext, DashboardComponent, d.deployContext.CheCluster.Spec.Server.CheHost,
"/dashboard",
d.deployContext.CheCluster.Spec.Server.CheServerRoute,
d.deployContext.CheCluster.Spec.Server.CheServerIngress,
)
if !done {
return false, err
}

// Deploy dashboard
spec, err := d.getDashboardDeploymentSpec()
if err != nil {
return false, err
}
return deploy.SyncDeploymentSpecToCluster(d.deployContext, spec, deploy.DefaultDeploymentDiffOpts)
}
Loading

0 comments on commit 0353a44

Please sign in to comment.