Merge pull request #839 from eclipse-che/dashboard_flav
Fix dashboard component names depending on che flavorpull/841/head
commit
37f80138a0
|
|
@ -803,7 +803,7 @@ func (r *ReconcileChe) Reconcile(request reconcile.Request) (reconcile.Result, e
|
|||
done, err = d.SyncAll()
|
||||
if !done {
|
||||
if err != nil {
|
||||
logrus.Errorf("Error provisioning '%s' to cluster: %v", dashboard.DashboardComponent, err)
|
||||
logrus.Errorf("Error provisioning '%s' to cluster: %v", d.GetComponentName(), err)
|
||||
}
|
||||
return reconcile.Result{}, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,30 +16,27 @@ import (
|
|||
"github.com/eclipse-che/che-operator/pkg/deploy/expose"
|
||||
)
|
||||
|
||||
const (
|
||||
// DashboardComponent which is supposed to be used for the naming related objects
|
||||
DashboardComponent = "che-dashboard"
|
||||
)
|
||||
|
||||
type Dashboard struct {
|
||||
deployContext *deploy.DeployContext
|
||||
component string
|
||||
}
|
||||
|
||||
func NewDashboard(deployContext *deploy.DeployContext) *Dashboard {
|
||||
return &Dashboard{
|
||||
deployContext: deployContext,
|
||||
component: deploy.DefaultCheFlavor(deployContext.CheCluster) + "-dashboard",
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
done, err = deploy.SyncServiceToCluster(d.deployContext, d.component, []string{"http"}, []int32{8080}, d.component)
|
||||
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,
|
||||
_, done, err = expose.ExposeWithHostPath(d.deployContext, d.component, d.deployContext.CheCluster.Spec.Server.CheHost,
|
||||
"/dashboard",
|
||||
d.deployContext.CheCluster.Spec.Server.CheServerRoute,
|
||||
d.deployContext.CheCluster.Spec.Server.CheServerIngress,
|
||||
|
|
@ -55,3 +52,7 @@ func (d *Dashboard) SyncAll() (done bool, err error) {
|
|||
}
|
||||
return deploy.SyncDeploymentSpecToCluster(d.deployContext, spec, deploy.DefaultDeploymentDiffOpts)
|
||||
}
|
||||
|
||||
func (d *Dashboard) GetComponentName() string {
|
||||
return d.component
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,21 +60,21 @@ func TestDashboardAll(t *testing.T) {
|
|||
|
||||
// check service
|
||||
service := &corev1.Service{}
|
||||
err = cli.Get(context.TODO(), types.NamespacedName{Name: DashboardComponent, Namespace: "eclipse-che"}, service)
|
||||
err = cli.Get(context.TODO(), types.NamespacedName{Name: dashboard.component, Namespace: "eclipse-che"}, service)
|
||||
if err != nil {
|
||||
t.Fatalf("Service not found: %v", err)
|
||||
}
|
||||
|
||||
// check endpoint
|
||||
route := &routev1.Route{}
|
||||
err = cli.Get(context.TODO(), types.NamespacedName{Name: DashboardComponent, Namespace: "eclipse-che"}, route)
|
||||
err = cli.Get(context.TODO(), types.NamespacedName{Name: dashboard.component, Namespace: "eclipse-che"}, route)
|
||||
if err != nil {
|
||||
t.Fatalf("Route not found: %v", err)
|
||||
}
|
||||
|
||||
// check deployment
|
||||
deployment := &appsv1.Deployment{}
|
||||
err = cli.Get(context.TODO(), types.NamespacedName{Name: DashboardComponent, Namespace: "eclipse-che"}, deployment)
|
||||
err = cli.Get(context.TODO(), types.NamespacedName{Name: dashboard.component, Namespace: "eclipse-che"}, deployment)
|
||||
if err != nil {
|
||||
t.Fatalf("Deployment not found: %v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,12 +22,12 @@ import (
|
|||
"k8s.io/apimachinery/pkg/util/intstr"
|
||||
)
|
||||
|
||||
func (p *Dashboard) getDashboardDeploymentSpec() (*appsv1.Deployment, error) {
|
||||
func (d *Dashboard) getDashboardDeploymentSpec() (*appsv1.Deployment, error) {
|
||||
terminationGracePeriodSeconds := int64(30)
|
||||
labels, labelsSelector := deploy.GetLabelsAndSelector(p.deployContext.CheCluster, DashboardComponent)
|
||||
labels, labelsSelector := deploy.GetLabelsAndSelector(d.deployContext.CheCluster, d.component)
|
||||
|
||||
dashboardImageAndTag := util.GetValue(p.deployContext.CheCluster.Spec.Server.DashboardImage, deploy.DefaultDashboardImage(p.deployContext.CheCluster))
|
||||
pullPolicy := corev1.PullPolicy(util.GetValue(p.deployContext.CheCluster.Spec.Server.DashboardImagePullPolicy, deploy.DefaultPullPolicyFromDockerImage(dashboardImageAndTag)))
|
||||
dashboardImageAndTag := util.GetValue(d.deployContext.CheCluster.Spec.Server.DashboardImage, deploy.DefaultDashboardImage(d.deployContext.CheCluster))
|
||||
pullPolicy := corev1.PullPolicy(util.GetValue(d.deployContext.CheCluster.Spec.Server.DashboardImagePullPolicy, deploy.DefaultPullPolicyFromDockerImage(dashboardImageAndTag)))
|
||||
|
||||
deployment := &appsv1.Deployment{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
|
|
@ -35,8 +35,8 @@ func (p *Dashboard) getDashboardDeploymentSpec() (*appsv1.Deployment, error) {
|
|||
APIVersion: "apps/v1",
|
||||
},
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: DashboardComponent,
|
||||
Namespace: p.deployContext.CheCluster.Namespace,
|
||||
Name: d.component,
|
||||
Namespace: d.deployContext.CheCluster.Namespace,
|
||||
Labels: labels,
|
||||
},
|
||||
Spec: appsv1.DeploymentSpec{
|
||||
|
|
@ -51,7 +51,7 @@ func (p *Dashboard) getDashboardDeploymentSpec() (*appsv1.Deployment, error) {
|
|||
Spec: corev1.PodSpec{
|
||||
Containers: []corev1.Container{
|
||||
{
|
||||
Name: "dashboard",
|
||||
Name: d.component,
|
||||
ImagePullPolicy: pullPolicy,
|
||||
Image: dashboardImageAndTag,
|
||||
Ports: []corev1.ContainerPort{
|
||||
|
|
@ -64,18 +64,18 @@ func (p *Dashboard) getDashboardDeploymentSpec() (*appsv1.Deployment, error) {
|
|||
Resources: corev1.ResourceRequirements{
|
||||
Requests: corev1.ResourceList{
|
||||
corev1.ResourceMemory: util.GetResourceQuantity(
|
||||
p.deployContext.CheCluster.Spec.Server.DashboardMemoryRequest,
|
||||
d.deployContext.CheCluster.Spec.Server.DashboardMemoryRequest,
|
||||
deploy.DefaultDashboardMemoryRequest),
|
||||
corev1.ResourceCPU: util.GetResourceQuantity(
|
||||
p.deployContext.CheCluster.Spec.Server.DashboardCpuRequest,
|
||||
d.deployContext.CheCluster.Spec.Server.DashboardCpuRequest,
|
||||
deploy.DefaultDashboardCpuRequest),
|
||||
},
|
||||
Limits: corev1.ResourceList{
|
||||
corev1.ResourceMemory: util.GetResourceQuantity(
|
||||
p.deployContext.CheCluster.Spec.Server.DashboardMemoryLimit,
|
||||
d.deployContext.CheCluster.Spec.Server.DashboardMemoryLimit,
|
||||
deploy.DefaultDashboardMemoryLimit),
|
||||
corev1.ResourceCPU: util.GetResourceQuantity(
|
||||
p.deployContext.CheCluster.Spec.Server.DashboardCpuLimit,
|
||||
d.deployContext.CheCluster.Spec.Server.DashboardCpuLimit,
|
||||
deploy.DefaultDashboardCpuLimit),
|
||||
},
|
||||
},
|
||||
|
|
@ -128,11 +128,11 @@ func (p *Dashboard) getDashboardDeploymentSpec() (*appsv1.Deployment, error) {
|
|||
}
|
||||
|
||||
if !util.IsOpenShift {
|
||||
runAsUser, err := strconv.ParseInt(util.GetValue(p.deployContext.CheCluster.Spec.K8s.SecurityContextRunAsUser, deploy.DefaultSecurityContextRunAsUser), 10, 64)
|
||||
runAsUser, err := strconv.ParseInt(util.GetValue(d.deployContext.CheCluster.Spec.K8s.SecurityContextRunAsUser, deploy.DefaultSecurityContextRunAsUser), 10, 64)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
fsGroup, err := strconv.ParseInt(util.GetValue(p.deployContext.CheCluster.Spec.K8s.SecurityContextFsGroup, deploy.DefaultSecurityContextFsGroup), 10, 64)
|
||||
fsGroup, err := strconv.ParseInt(util.GetValue(d.deployContext.CheCluster.Spec.K8s.SecurityContextFsGroup, deploy.DefaultSecurityContextFsGroup), 10, 64)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue