Define Required Metadata Labels on deployment definitions (#603)
* Add default kubernetes labels Signed-off-by: Anatolii Bazko <abazko@redhat.com>pull/647/head
parent
d5ea65afdd
commit
49bf7c8635
|
|
@ -12,6 +12,10 @@ kind: ClusterRole
|
|||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
metadata:
|
||||
name: che-operator
|
||||
labels:
|
||||
app.kubernetes.io/name: che
|
||||
app.kubernetes.io/instance: che
|
||||
app.kubernetes.io/component: che-operator
|
||||
rules:
|
||||
- apiGroups:
|
||||
- oauth.openshift.io
|
||||
|
|
|
|||
|
|
@ -12,6 +12,10 @@ kind: ClusterRoleBinding
|
|||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
metadata:
|
||||
name: che-operator
|
||||
labels:
|
||||
app.kubernetes.io/name: che
|
||||
app.kubernetes.io/instance: che
|
||||
app.kubernetes.io/component: che-operator
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: che-operator
|
||||
|
|
@ -19,4 +23,4 @@ subjects:
|
|||
roleRef:
|
||||
kind: ClusterRole
|
||||
name: che-operator
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
|
|
|
|||
|
|
@ -12,6 +12,10 @@ apiVersion: rbac.authorization.k8s.io/v1
|
|||
kind: ClusterRole
|
||||
metadata:
|
||||
name: che-namespace-editor
|
||||
labels:
|
||||
app.kubernetes.io/name: che
|
||||
app.kubernetes.io/instance: che
|
||||
app.kubernetes.io/component: che-operator
|
||||
rules:
|
||||
- apiGroups:
|
||||
- ""
|
||||
|
|
|
|||
|
|
@ -12,6 +12,10 @@ apiVersion: rbac.authorization.k8s.io/v1
|
|||
kind: ClusterRoleBinding
|
||||
metadata:
|
||||
name: che-operator-namespace-editor
|
||||
labels:
|
||||
app.kubernetes.io/name: che
|
||||
app.kubernetes.io/instance: che
|
||||
app.kubernetes.io/component: che-operator
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: che-operator
|
||||
|
|
|
|||
|
|
@ -84,13 +84,13 @@ metadata:
|
|||
categories: Developer Tools
|
||||
certified: "false"
|
||||
containerImage: quay.io/eclipse/che-operator:nightly
|
||||
createdAt: "2021-01-25T10:14:35Z"
|
||||
createdAt: "2021-01-26T08:16:35Z"
|
||||
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-operator
|
||||
support: Eclipse Foundation
|
||||
name: eclipse-che-preview-kubernetes.v7.25.0-82.nightly
|
||||
name: eclipse-che-preview-kubernetes.v7.25.0-72.nightly
|
||||
namespace: placeholder
|
||||
spec:
|
||||
apiservicedefinitions: {}
|
||||
|
|
@ -297,6 +297,10 @@ spec:
|
|||
metadata:
|
||||
labels:
|
||||
app: che-operator
|
||||
app.kubernetes.io/component: che-operator
|
||||
app.kubernetes.io/instance: che
|
||||
app.kubernetes.io/managed-by: olm
|
||||
app.kubernetes.io/name: che
|
||||
spec:
|
||||
containers:
|
||||
- command:
|
||||
|
|
@ -524,4 +528,4 @@ spec:
|
|||
maturity: stable
|
||||
provider:
|
||||
name: Eclipse Foundation
|
||||
version: 7.25.0-82.nightly
|
||||
version: 7.25.0-72.nightly
|
||||
|
|
|
|||
|
|
@ -75,13 +75,13 @@ metadata:
|
|||
categories: Developer Tools, OpenShift Optional
|
||||
certified: "false"
|
||||
containerImage: quay.io/eclipse/che-operator:nightly
|
||||
createdAt: "2021-01-25T10:14:44Z"
|
||||
createdAt: "2021-01-26T08:16:44Z"
|
||||
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-operator
|
||||
support: Eclipse Foundation
|
||||
name: eclipse-che-preview-openshift.v7.25.0-82.nightly
|
||||
name: eclipse-che-preview-openshift.v7.25.0-72.nightly
|
||||
namespace: placeholder
|
||||
spec:
|
||||
apiservicedefinitions: {}
|
||||
|
|
@ -312,6 +312,10 @@ spec:
|
|||
metadata:
|
||||
labels:
|
||||
app: che-operator
|
||||
app.kubernetes.io/component: che-operator
|
||||
app.kubernetes.io/instance: che
|
||||
app.kubernetes.io/managed-by: olm
|
||||
app.kubernetes.io/name: che
|
||||
spec:
|
||||
containers:
|
||||
- command:
|
||||
|
|
@ -543,4 +547,4 @@ spec:
|
|||
maturity: stable
|
||||
provider:
|
||||
name: Eclipse Foundation
|
||||
version: 7.25.0-82.nightly
|
||||
version: 7.25.0-72.nightly
|
||||
|
|
|
|||
|
|
@ -23,6 +23,9 @@ spec:
|
|||
metadata:
|
||||
labels:
|
||||
app: che-operator
|
||||
app.kubernetes.io/name: che
|
||||
app.kubernetes.io/instance: che
|
||||
app.kubernetes.io/component: che-operator
|
||||
spec:
|
||||
containers:
|
||||
- name: che-operator
|
||||
|
|
|
|||
|
|
@ -13,6 +13,10 @@ kind: Role
|
|||
metadata:
|
||||
creationTimestamp: null
|
||||
name: che-operator
|
||||
labels:
|
||||
app.kubernetes.io/name: che
|
||||
app.kubernetes.io/instance: che
|
||||
app.kubernetes.io/component: che-operator
|
||||
rules:
|
||||
- apiGroups:
|
||||
- extensions
|
||||
|
|
|
|||
|
|
@ -12,6 +12,10 @@ kind: RoleBinding
|
|||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
metadata:
|
||||
name: che-operator
|
||||
labels:
|
||||
app.kubernetes.io/name: che
|
||||
app.kubernetes.io/instance: che
|
||||
app.kubernetes.io/component: che-operator
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: che-operator
|
||||
|
|
|
|||
|
|
@ -12,6 +12,10 @@ kind: Template
|
|||
apiVersion: v1
|
||||
metadata:
|
||||
name: che-operator
|
||||
labels:
|
||||
app.kubernetes.io/name: che
|
||||
app.kubernetes.io/instance: che
|
||||
app.kubernetes.io/component: che-operator
|
||||
objects:
|
||||
- kind: ClusterRoleBinding
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
|
|
@ -29,4 +33,4 @@ parameters:
|
|||
- name: NAMESPACE
|
||||
displayName: Namespace
|
||||
description: Namespace
|
||||
required: true
|
||||
required: true
|
||||
|
|
|
|||
|
|
@ -12,3 +12,7 @@ apiVersion: v1
|
|||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: che-operator
|
||||
labels:
|
||||
app.kubernetes.io/name: che
|
||||
app.kubernetes.io/instance: che
|
||||
app.kubernetes.io/component: che-operator
|
||||
|
|
|
|||
|
|
@ -169,6 +169,9 @@ do
|
|||
mv "${NEW_CSV}.old" "${NEW_CSV}"
|
||||
fi
|
||||
|
||||
# set `app.kubernetes.io/managed-by` label
|
||||
yq -riSY '(.spec.install.spec.deployments[0].spec.template.metadata.labels."app.kubernetes.io/managed-by") = "olm"' "${NEW_CSV}"
|
||||
|
||||
# Format code.
|
||||
yq -rY "." "${NEW_CSV}" > "${NEW_CSV}.old"
|
||||
mv "${NEW_CSV}.old" "${NEW_CSV}"
|
||||
|
|
|
|||
|
|
@ -461,7 +461,7 @@ func (r *ReconcileChe) Reconcile(request reconcile.Request) (reconcile.Result, e
|
|||
}
|
||||
|
||||
// Make sure that CA certificates from all marked config maps are merged into single config map to be propageted to Che components
|
||||
cm, err := deploy.SyncAdditionalCACertsConfigMapToCluster(instance, deployContext)
|
||||
cm, err := deploy.SyncAdditionalCACertsConfigMapToCluster(deployContext)
|
||||
if err != nil {
|
||||
logrus.Errorf("Error updating additional CA config map: %v", err)
|
||||
return reconcile.Result{}, err
|
||||
|
|
@ -501,7 +501,7 @@ func (r *ReconcileChe) Reconcile(request reconcile.Request) (reconcile.Result, e
|
|||
|
||||
// If the devfile-registry ConfigMap exists, and we are not in airgapped mode, delete the ConfigMap
|
||||
devfileRegistryConfigMap := &corev1.ConfigMap{}
|
||||
err = r.client.Get(context.TODO(), types.NamespacedName{Namespace: instance.Namespace, Name: "devfile-registry"}, devfileRegistryConfigMap)
|
||||
err = r.client.Get(context.TODO(), types.NamespacedName{Namespace: instance.Namespace, Name: deploy.DevfileRegistryName}, devfileRegistryConfigMap)
|
||||
if err != nil && !errors.IsNotFound(err) {
|
||||
logrus.Errorf("Error getting devfile-registry ConfigMap: %v", err)
|
||||
return reconcile.Result{}, err
|
||||
|
|
@ -517,7 +517,7 @@ func (r *ReconcileChe) Reconcile(request reconcile.Request) (reconcile.Result, e
|
|||
|
||||
// If the plugin-registry ConfigMap exists, and we are not in airgapped mode, delete the ConfigMap
|
||||
pluginRegistryConfigMap := &corev1.ConfigMap{}
|
||||
err = r.client.Get(context.TODO(), types.NamespacedName{Namespace: instance.Namespace, Name: "plugin-registry"}, pluginRegistryConfigMap)
|
||||
err = r.client.Get(context.TODO(), types.NamespacedName{Namespace: instance.Namespace, Name: deploy.PluginRegistryName}, pluginRegistryConfigMap)
|
||||
if err != nil && !errors.IsNotFound(err) {
|
||||
logrus.Errorf("Error getting plugin-registry ConfigMap: %v", err)
|
||||
return reconcile.Result{}, err
|
||||
|
|
@ -658,8 +658,7 @@ func (r *ReconcileChe) Reconcile(request reconcile.Request) (reconcile.Result, e
|
|||
cheMultiUser := deploy.GetCheMultiUser(instance)
|
||||
|
||||
if cheMultiUser == "false" {
|
||||
labels := deploy.GetLabels(instance, cheFlavor)
|
||||
pvcStatus := deploy.SyncPVCToCluster(deployContext, deploy.DefaultCheVolumeClaimName, "1Gi", labels)
|
||||
pvcStatus := deploy.SyncPVCToCluster(deployContext, deploy.DefaultCheVolumeClaimName, "1Gi", cheFlavor)
|
||||
if !tests {
|
||||
if !pvcStatus.Continue {
|
||||
logrus.Infof("Waiting on pvc '%s' to be bound. Sometimes PVC can be bound only when the first consumer is created.", deploy.DefaultCheVolumeClaimName)
|
||||
|
|
@ -685,14 +684,12 @@ func (r *ReconcileChe) Reconcile(request reconcile.Request) (reconcile.Result, e
|
|||
externalDB := instance.Spec.Database.ExternalDb
|
||||
if !externalDB {
|
||||
if cheMultiUser == "false" {
|
||||
if util.K8sclient.IsDeploymentExists(postgres.PostgresDeploymentName, instance.Namespace) {
|
||||
util.K8sclient.DeleteDeployment(postgres.PostgresDeploymentName, instance.Namespace)
|
||||
if util.K8sclient.IsDeploymentExists(deploy.PostgresName, instance.Namespace) {
|
||||
util.K8sclient.DeleteDeployment(deploy.PostgresName, instance.Namespace)
|
||||
}
|
||||
} else {
|
||||
postgresLabels := deploy.GetLabels(instance, postgres.PostgresDeploymentName)
|
||||
|
||||
// Create a new postgres service
|
||||
serviceStatus := deploy.SyncServiceToCluster(deployContext, "postgres", []string{"postgres"}, []int32{5432}, postgresLabels)
|
||||
serviceStatus := deploy.SyncServiceToCluster(deployContext, deploy.PostgresName, []string{deploy.PostgresName}, []int32{5432}, deploy.PostgresName)
|
||||
if !tests {
|
||||
if !serviceStatus.Continue {
|
||||
logrus.Info("Waiting on service 'postgres' to be ready")
|
||||
|
|
@ -705,7 +702,7 @@ func (r *ReconcileChe) Reconcile(request reconcile.Request) (reconcile.Result, e
|
|||
}
|
||||
|
||||
// Create a new Postgres PVC object
|
||||
pvcStatus := deploy.SyncPVCToCluster(deployContext, deploy.DefaultPostgresVolumeClaimName, "1Gi", postgresLabels)
|
||||
pvcStatus := deploy.SyncPVCToCluster(deployContext, deploy.DefaultPostgresVolumeClaimName, "1Gi", deploy.PostgresName)
|
||||
if !tests {
|
||||
if !pvcStatus.Continue {
|
||||
logrus.Infof("Waiting on pvc '%s' to be bound. Sometimes PVC can be bound only when the first consumer is created.", deploy.DefaultPostgresVolumeClaimName)
|
||||
|
|
@ -721,7 +718,7 @@ func (r *ReconcileChe) Reconcile(request reconcile.Request) (reconcile.Result, e
|
|||
provisioned, err := postgres.SyncPostgresDeploymentToCluster(deployContext)
|
||||
if !tests {
|
||||
if !provisioned {
|
||||
logrus.Infof("Waiting on deployment '%s' to be ready", postgres.PostgresDeploymentName)
|
||||
logrus.Infof("Waiting on deployment '%s' to be ready", deploy.PostgresName)
|
||||
if err != nil {
|
||||
logrus.Error(err)
|
||||
}
|
||||
|
|
@ -746,7 +743,7 @@ func (r *ReconcileChe) Reconcile(request reconcile.Request) (reconcile.Result, e
|
|||
if !dbStatus {
|
||||
_, err := util.K8sclient.ExecIntoPod(
|
||||
instance,
|
||||
postgres.PostgresDeploymentName,
|
||||
deploy.PostgresName,
|
||||
func(cr *orgv1.CheCluster) (string, error) {
|
||||
return identity_provider.GetPostgresProvisionCommand(identityProviderPostgresPassword), nil
|
||||
},
|
||||
|
|
@ -794,7 +791,14 @@ func (r *ReconcileChe) Reconcile(request reconcile.Request) (reconcile.Result, e
|
|||
cheHost := ""
|
||||
if !isOpenShift {
|
||||
additionalLabels := deployContext.CheCluster.Spec.Server.CheServerIngress.Labels
|
||||
ingress, err := deploy.SyncIngressToCluster(deployContext, cheFlavor, instance.Spec.Server.CheHost, exposedServiceName, 8080, additionalLabels)
|
||||
ingress, err := deploy.SyncIngressToCluster(
|
||||
deployContext,
|
||||
cheFlavor,
|
||||
instance.Spec.Server.CheHost,
|
||||
exposedServiceName,
|
||||
8080,
|
||||
additionalLabels,
|
||||
cheFlavor)
|
||||
if !tests {
|
||||
if ingress == nil {
|
||||
logrus.Infof("Waiting on ingress '%s' to be ready", cheFlavor)
|
||||
|
|
@ -814,7 +818,7 @@ func (r *ReconcileChe) Reconcile(request reconcile.Request) (reconcile.Result, e
|
|||
}
|
||||
|
||||
additionalLabels := deployContext.CheCluster.Spec.Server.CheServerRoute.Labels
|
||||
route, err := deploy.SyncRouteToCluster(deployContext, cheFlavor, customHost, exposedServiceName, 8080, additionalLabels)
|
||||
route, err := deploy.SyncRouteToCluster(deployContext, cheFlavor, customHost, exposedServiceName, 8080, additionalLabels, cheFlavor)
|
||||
if route == nil {
|
||||
logrus.Infof("Waiting on route '%s' to be ready", cheFlavor)
|
||||
if err != nil {
|
||||
|
|
@ -851,7 +855,7 @@ func (r *ReconcileChe) Reconcile(request reconcile.Request) (reconcile.Result, e
|
|||
if !tests {
|
||||
if !provisioned {
|
||||
if err != nil {
|
||||
logrus.Errorf("Error provisioning '%s' to cluster: %v", deploy.DevfileRegistry, err)
|
||||
logrus.Errorf("Error provisioning '%s' to cluster: %v", deploy.DevfileRegistryName, err)
|
||||
}
|
||||
return reconcile.Result{RequeueAfter: time.Second * 1}, err
|
||||
}
|
||||
|
|
@ -861,7 +865,7 @@ func (r *ReconcileChe) Reconcile(request reconcile.Request) (reconcile.Result, e
|
|||
if !tests {
|
||||
if !provisioned {
|
||||
if err != nil {
|
||||
logrus.Errorf("Error provisioning '%s' to cluster: %v", deploy.PluginRegistry, err)
|
||||
logrus.Errorf("Error provisioning '%s' to cluster: %v", deploy.PluginRegistryName, err)
|
||||
}
|
||||
return reconcile.Result{RequeueAfter: time.Second * 1}, err
|
||||
}
|
||||
|
|
@ -993,6 +997,9 @@ func createConsoleLink(isOpenShift4 bool, protocol string, instance *orgv1.CheCl
|
|||
preparedConsoleLink := &consolev1.ConsoleLink{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: deploy.DefaultConsoleLinkName(),
|
||||
Annotations: map[string]string{
|
||||
deploy.CheEclipseOrgNamespace: instance.Namespace,
|
||||
},
|
||||
},
|
||||
Spec: consolev1.ConsoleLinkSpec{
|
||||
Link: consolev1.Link{
|
||||
|
|
@ -1047,11 +1054,11 @@ func EvaluateCheServerVersion(cr *orgv1.CheCluster) string {
|
|||
}
|
||||
|
||||
func getDefaultCheHost(deployContext *deploy.DeployContext) (string, error) {
|
||||
routeName := deploy.DefaultCheFlavor(deployContext.CheCluster)
|
||||
cheFlavor := deploy.DefaultCheFlavor(deployContext.CheCluster)
|
||||
additionalLabels := deployContext.CheCluster.Spec.Server.CheServerRoute.Labels
|
||||
route, err := deploy.SyncRouteToCluster(deployContext, routeName, "", getServerExposingServiceName(deployContext.CheCluster), 8080, additionalLabels)
|
||||
route, err := deploy.SyncRouteToCluster(deployContext, cheFlavor, "", getServerExposingServiceName(deployContext.CheCluster), 8080, additionalLabels, cheFlavor)
|
||||
if route == nil {
|
||||
logrus.Infof("Waiting on route '%s' to be ready", routeName)
|
||||
logrus.Infof("Waiting on route '%s' to be ready", cheFlavor)
|
||||
if err != nil {
|
||||
logrus.Error(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -703,7 +703,7 @@ func TestCheController(t *testing.T) {
|
|||
|
||||
// get devfile-registry configmap
|
||||
devfilecm := &corev1.ConfigMap{}
|
||||
if err := cl.Get(context.TODO(), types.NamespacedName{Name: "devfile-registry", Namespace: cheCR.Namespace}, devfilecm); err != nil {
|
||||
if err := cl.Get(context.TODO(), types.NamespacedName{Name: deploy.DevfileRegistryName, Namespace: cheCR.Namespace}, devfilecm); err != nil {
|
||||
t.Errorf("ConfigMap %s not found: %s", devfilecm.Name, err)
|
||||
}
|
||||
|
||||
|
|
@ -824,13 +824,13 @@ func TestCheController(t *testing.T) {
|
|||
t.Error("Failed to update CheCluster custom resource")
|
||||
}
|
||||
postgresDeployment := &appsv1.Deployment{}
|
||||
err = r.client.Get(context.TODO(), types.NamespacedName{Name: "postgres", Namespace: cheCR.Namespace}, postgresDeployment)
|
||||
err = r.client.Get(context.TODO(), types.NamespacedName{Name: deploy.PostgresName, Namespace: cheCR.Namespace}, postgresDeployment)
|
||||
err = r.client.Delete(context.TODO(), postgresDeployment)
|
||||
_, err = r.Reconcile(req)
|
||||
if err != nil {
|
||||
t.Fatalf("reconcile: (%v)", err)
|
||||
}
|
||||
err = r.client.Get(context.TODO(), types.NamespacedName{Name: "postgres", Namespace: cheCR.Namespace}, postgresDeployment)
|
||||
err = r.client.Get(context.TODO(), types.NamespacedName{Name: deploy.PostgresName, Namespace: cheCR.Namespace}, postgresDeployment)
|
||||
if err == nil {
|
||||
t.Fatalf("Deployment postgres shoud not exist")
|
||||
}
|
||||
|
|
@ -987,7 +987,7 @@ func TestConfiguringInternalNetworkTest(t *testing.T) {
|
|||
}
|
||||
|
||||
// Set up che host for route
|
||||
cheRoute, _ := deploy.GetSpecRoute(deployContext, deploy.DefaultCheFlavor(cheCR), "che-host", "che-host", 8080, "")
|
||||
cheRoute, _ := deploy.GetSpecRoute(deployContext, deploy.DefaultCheFlavor(cheCR), "che-host", "che-host", 8080, "", "che")
|
||||
cl.Update(context.TODO(), cheRoute)
|
||||
|
||||
// reconsile to update Che route
|
||||
|
|
@ -997,15 +997,15 @@ func TestConfiguringInternalNetworkTest(t *testing.T) {
|
|||
}
|
||||
|
||||
// Set up keycloak host for route
|
||||
keycloakRoute, _ := deploy.GetSpecRoute(deployContext, "keycloak", "keycloak", "keycloak", 8080, "")
|
||||
keycloakRoute, _ := deploy.GetSpecRoute(deployContext, deploy.IdentityProviderName, "keycloak", deploy.IdentityProviderName, 8080, "", deploy.IdentityProviderName)
|
||||
cl.Update(context.TODO(), keycloakRoute)
|
||||
|
||||
// Set up devfile registry host for route
|
||||
devfileRegistryRoute, _ := deploy.GetSpecRoute(deployContext, "devfile-registry", "devfile-registry", "devfile-registry", 8080, "")
|
||||
devfileRegistryRoute, _ := deploy.GetSpecRoute(deployContext, deploy.DevfileRegistryName, "devfile-registry", deploy.DevfileRegistryName, 8080, "", deploy.DevfileRegistryName)
|
||||
cl.Update(context.TODO(), devfileRegistryRoute)
|
||||
|
||||
// Set up plugin registry host for route
|
||||
pluginRegistryRoute, _ := deploy.GetSpecRoute(deployContext, "plugin-registry", "plugin-registry", "plugin-registry", 8080, "")
|
||||
pluginRegistryRoute, _ := deploy.GetSpecRoute(deployContext, deploy.PluginRegistryName, "plugin-registry", deploy.PluginRegistryName, 8080, "", deploy.PluginRegistryName)
|
||||
cl.Update(context.TODO(), pluginRegistryRoute)
|
||||
|
||||
_, err = r.Reconcile(req)
|
||||
|
|
@ -1112,7 +1112,7 @@ func createAPIObjects() ([]runtime.Object, discovery.DiscoveryInterface, runtime
|
|||
Name: "fake-pg-pod",
|
||||
Namespace: "eclipse-che",
|
||||
Labels: map[string]string{
|
||||
"component": "postgres",
|
||||
"component": deploy.PostgresName,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ func (r *ReconcileChe) GenerateAndSaveFields(deployContext *deploy.DeployContext
|
|||
}
|
||||
if len(deployContext.CheCluster.Spec.Auth.IdentityProviderPostgresSecret) < 1 {
|
||||
keycloakPostgresPassword := util.GeneratePasswd(12)
|
||||
keycloakDeployment, err := r.GetEffectiveDeployment(deployContext.CheCluster, "keycloak")
|
||||
keycloakDeployment, err := r.GetEffectiveDeployment(deployContext.CheCluster, deploy.IdentityProviderName)
|
||||
if err == nil {
|
||||
keycloakPostgresPassword = util.GetDeploymentEnv(keycloakDeployment, "DB_PASSWORD")
|
||||
}
|
||||
|
|
@ -72,7 +72,7 @@ func (r *ReconcileChe) GenerateAndSaveFields(deployContext *deploy.DeployContext
|
|||
keycloakAdminUserName := util.GetValue(deployContext.CheCluster.Spec.Auth.IdentityProviderAdminUserName, "admin")
|
||||
keycloakAdminPassword := util.GetValue(deployContext.CheCluster.Spec.Auth.IdentityProviderPassword, util.GeneratePasswd(12))
|
||||
|
||||
keycloakDeployment, err := r.GetEffectiveDeployment(deployContext.CheCluster, "keycloak")
|
||||
keycloakDeployment, err := r.GetEffectiveDeployment(deployContext.CheCluster, deploy.IdentityProviderName)
|
||||
if err == nil {
|
||||
keycloakAdminUserName = util.GetDeploymentEnv(keycloakDeployment, "SSO_ADMIN_USERNAME")
|
||||
keycloakAdminPassword = util.GetDeploymentEnv(keycloakDeployment, "SSO_ADMIN_PASSWORD")
|
||||
|
|
|
|||
|
|
@ -13,10 +13,10 @@ package che
|
|||
|
||||
import (
|
||||
"context"
|
||||
|
||||
identity_provider "github.com/eclipse/che-operator/pkg/deploy/identity-provider"
|
||||
"github.com/eclipse/che-operator/pkg/deploy"
|
||||
|
||||
orgv1 "github.com/eclipse/che-operator/pkg/apis/org/v1"
|
||||
identity_provider "github.com/eclipse/che-operator/pkg/deploy/identity-provider"
|
||||
"github.com/eclipse/che-operator/pkg/util"
|
||||
oauth "github.com/openshift/api/oauth/v1"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
|
@ -49,7 +49,7 @@ func (r *ReconcileChe) UpdateCheCRSpec(instance *orgv1.CheCluster, updatedField
|
|||
func (r *ReconcileChe) ReconcileIdentityProvider(instance *orgv1.CheCluster, isOpenShift4 bool) (deleted bool, err error) {
|
||||
if !util.IsOAuthEnabled(instance) && instance.Status.OpenShiftoAuthProvisioned == true {
|
||||
keycloakDeployment := &appsv1.Deployment{}
|
||||
if err := r.client.Get(context.TODO(), types.NamespacedName{Name: "keycloak", Namespace: instance.Namespace}, keycloakDeployment); err != nil {
|
||||
if err := r.client.Get(context.TODO(), types.NamespacedName{Name: deploy.IdentityProviderName, Namespace: instance.Namespace}, keycloakDeployment); err != nil {
|
||||
logrus.Errorf("Deployment %s not found: %s", keycloakDeployment.Name, err)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ package deploy
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/google/go-cmp/cmp/cmpopts"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
|
@ -91,6 +92,9 @@ func getSpecClusterRoleBinding(
|
|||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: name,
|
||||
Labels: labels,
|
||||
Annotations: map[string]string{
|
||||
CheEclipseOrgNamespace: deployContext.CheCluster.Namespace,
|
||||
},
|
||||
},
|
||||
Subjects: []rbac.Subject{
|
||||
{
|
||||
|
|
|
|||
|
|
@ -59,9 +59,9 @@ func SyncConfigMapToCluster(deployContext *DeployContext, specConfigMap *corev1.
|
|||
func GetSpecConfigMap(
|
||||
deployContext *DeployContext,
|
||||
name string,
|
||||
data map[string]string) (*corev1.ConfigMap, error) {
|
||||
data map[string]string,
|
||||
component string) (*corev1.ConfigMap, error) {
|
||||
|
||||
labels := GetLabels(deployContext.CheCluster, DefaultCheFlavor(deployContext.CheCluster))
|
||||
configMap := &corev1.ConfigMap{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
Kind: "ConfigMap",
|
||||
|
|
@ -70,7 +70,7 @@ func GetSpecConfigMap(
|
|||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: name,
|
||||
Namespace: deployContext.CheCluster.Namespace,
|
||||
Labels: labels,
|
||||
Labels: GetLabels(deployContext.CheCluster, component),
|
||||
},
|
||||
Data: data,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +0,0 @@
|
|||
package deploy
|
||||
|
||||
const (
|
||||
DevfileRegistry = "devfile-registry"
|
||||
)
|
||||
|
||||
const (
|
||||
PluginRegistry = "plugin-registry"
|
||||
)
|
||||
|
|
@ -97,6 +97,9 @@ const (
|
|||
// kubernetes default labels
|
||||
KubernetesComponentLabelKey = "app.kubernetes.io/component"
|
||||
KubernetesPartOfLabelKey = "app.kubernetes.io/part-of"
|
||||
KubernetesManagedByLabelKey = "app.kubernetes.io/managed-by"
|
||||
KubernetesInstanceLabelKey = "app.kubernetes.io/instance"
|
||||
KubernetesNameLabelKey = "app.kubernetes.io/name"
|
||||
|
||||
CheEclipseOrg = "che.eclipse.org"
|
||||
|
||||
|
|
@ -104,8 +107,15 @@ const (
|
|||
CheEclipseOrgMountPath = "che.eclipse.org/mount-path"
|
||||
CheEclipseOrgMountAs = "che.eclipse.org/mount-as"
|
||||
CheEclipseOrgEnvName = "che.eclipse.org/env-name"
|
||||
CheEclipseOrgNamespace = "che.eclipse.org/namespace"
|
||||
CheEclipseOrgGithubOAuthCredentials = "che.eclipse.org/github-oauth-credentials"
|
||||
|
||||
// components
|
||||
IdentityProviderName = "keycloak"
|
||||
DevfileRegistryName = "devfile-registry"
|
||||
PluginRegistryName = "plugin-registry"
|
||||
PostgresName = "postgres"
|
||||
|
||||
// limits
|
||||
DefaultPluginRegistryMemoryLimit = "256Mi"
|
||||
DefaultPluginRegistryMemoryRequest = "32Mi"
|
||||
|
|
@ -424,8 +434,6 @@ func InitTestDefaultsFromDeployment(deploymentFile string) error {
|
|||
}
|
||||
}
|
||||
|
||||
os.Setenv("MOCK_API", "true")
|
||||
|
||||
InitDefaultsFromEnv()
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import (
|
|||
)
|
||||
|
||||
func SyncDevfileRegistryDeploymentToCluster(deployContext *deploy.DeployContext) (bool, error) {
|
||||
clusterDeployment, err := deploy.GetClusterDeployment(deploy.DevfileRegistry, deployContext.CheCluster.Namespace, deployContext.ClusterAPI.Client)
|
||||
clusterDeployment, err := deploy.GetClusterDeployment(deploy.DevfileRegistryName, deployContext.CheCluster.Namespace, deployContext.ClusterAPI.Client)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ func SyncDevfileRegistryToCluster(deployContext *deploy.DeployContext, cheHost s
|
|||
devfileRegistryURL := deployContext.CheCluster.Spec.Server.DevfileRegistryUrl
|
||||
if !deployContext.CheCluster.Spec.Server.ExternalDevfileRegistry {
|
||||
additionalLabels := (map[bool]string{true: deployContext.CheCluster.Spec.Server.DevfileRegistryRoute.Labels, false: deployContext.CheCluster.Spec.Server.DevfileRegistryIngress.Labels})[util.IsOpenShift]
|
||||
endpoint, done, err := expose.Expose(deployContext, cheHost, deploy.DevfileRegistry, additionalLabels)
|
||||
endpoint, done, err := expose.Expose(deployContext, cheHost, deploy.DevfileRegistryName, additionalLabels, deploy.DevfileRegistryName)
|
||||
if !done {
|
||||
return false, err
|
||||
}
|
||||
|
|
@ -49,7 +49,7 @@ func SyncDevfileRegistryToCluster(deployContext *deploy.DeployContext, cheHost s
|
|||
}
|
||||
|
||||
configMapData := getDevfileRegistryConfigMapData(deployContext.CheCluster, devfileRegistryURL)
|
||||
configMapSpec, err := deploy.GetSpecConfigMap(deployContext, deploy.DevfileRegistry, configMapData)
|
||||
configMapSpec, err := deploy.GetSpecConfigMap(deployContext, deploy.DevfileRegistryName, configMapData, deploy.DevfileRegistryName)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
|
@ -60,11 +60,10 @@ func SyncDevfileRegistryToCluster(deployContext *deploy.DeployContext, cheHost s
|
|||
}
|
||||
|
||||
// Create a new registry service
|
||||
registryLabels := deploy.GetLabels(deployContext.CheCluster, deploy.DevfileRegistry)
|
||||
serviceStatus := deploy.SyncServiceToCluster(deployContext, deploy.DevfileRegistry, []string{"http"}, []int32{8080}, registryLabels)
|
||||
serviceStatus := deploy.SyncServiceToCluster(deployContext, deploy.DevfileRegistryName, []string{"http"}, []int32{8080}, deploy.DevfileRegistryName)
|
||||
if !util.IsTestMode() {
|
||||
if !serviceStatus.Continue {
|
||||
logrus.Info("Waiting on service '" + deploy.DevfileRegistry + "' to be ready")
|
||||
logrus.Info("Waiting on service '" + deploy.DevfileRegistryName + "' to be ready")
|
||||
if serviceStatus.Err != nil {
|
||||
logrus.Error(serviceStatus.Err)
|
||||
}
|
||||
|
|
@ -73,13 +72,13 @@ func SyncDevfileRegistryToCluster(deployContext *deploy.DeployContext, cheHost s
|
|||
}
|
||||
}
|
||||
|
||||
deployContext.InternalService.DevfileRegistryHost = fmt.Sprintf("http://%s.%s.svc:8080", deploy.DevfileRegistry, deployContext.CheCluster.Namespace)
|
||||
deployContext.InternalService.DevfileRegistryHost = fmt.Sprintf("http://%s.%s.svc:8080", deploy.DevfileRegistryName, deployContext.CheCluster.Namespace)
|
||||
|
||||
// Deploy devfile registry
|
||||
provisioned, err := SyncDevfileRegistryDeploymentToCluster(deployContext)
|
||||
if !util.IsTestMode() {
|
||||
if !provisioned {
|
||||
logrus.Info("Waiting on deployment '" + deploy.DevfileRegistry + "' to be ready")
|
||||
logrus.Info("Waiting on deployment '" + deploy.DevfileRegistryName + "' to be ready")
|
||||
if err != nil {
|
||||
logrus.Error(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,14 +18,19 @@ import (
|
|||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func Expose(deployContext *deploy.DeployContext, cheHost string, endpointName string, additionalLabels string) (endpont string, done bool, err error) {
|
||||
func Expose(
|
||||
deployContext *deploy.DeployContext,
|
||||
cheHost string,
|
||||
endpointName string,
|
||||
additionalLabels string,
|
||||
component string) (endpont string, done bool, err error) {
|
||||
exposureStrategy := util.GetServerExposureStrategy(deployContext.CheCluster, deploy.DefaultServerExposureStrategy)
|
||||
var domain string
|
||||
var endpoint string
|
||||
var pathPrefix string
|
||||
var stripPrefix bool
|
||||
|
||||
if endpointName == "keycloak" {
|
||||
if endpointName == deploy.IdentityProviderName {
|
||||
pathPrefix = "auth"
|
||||
stripPrefix = false
|
||||
} else {
|
||||
|
|
@ -38,7 +43,7 @@ func Expose(deployContext *deploy.DeployContext, cheHost string, endpointName st
|
|||
endpoint = domain
|
||||
} else {
|
||||
domain = cheHost
|
||||
if endpointName == "keycloak" {
|
||||
if endpointName == deploy.IdentityProviderName {
|
||||
// legacy
|
||||
endpoint = domain
|
||||
} else {
|
||||
|
|
@ -66,7 +71,7 @@ func Expose(deployContext *deploy.DeployContext, cheHost string, endpointName st
|
|||
logrus.Error(err)
|
||||
}
|
||||
} else {
|
||||
ingress, err := deploy.SyncIngressToCluster(deployContext, endpointName, domain, endpointName, 8080, additionalLabels)
|
||||
ingress, err := deploy.SyncIngressToCluster(deployContext, endpointName, domain, endpointName, 8080, additionalLabels, component)
|
||||
if !util.IsTestMode() {
|
||||
if ingress == nil {
|
||||
logrus.Infof("Waiting on ingress '%s' to be ready", endpointName)
|
||||
|
|
@ -97,7 +102,7 @@ func Expose(deployContext *deploy.DeployContext, cheHost string, endpointName st
|
|||
}
|
||||
} else {
|
||||
// the empty string for a host is intentional here - we let OpenShift decide on the hostname
|
||||
route, err := deploy.SyncRouteToCluster(deployContext, endpointName, "", endpointName, 8080, additionalLabels)
|
||||
route, err := deploy.SyncRouteToCluster(deployContext, endpointName, "", endpointName, 8080, additionalLabels, component)
|
||||
if route == nil {
|
||||
logrus.Infof("Waiting on route '%s' to be ready", endpointName)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -360,6 +360,7 @@ func getGatewayDeploymentSpec(instance *orgv1.CheCluster) appsv1.Deployment {
|
|||
terminationGracePeriodSeconds := int64(10)
|
||||
|
||||
configLabels := labels.FormatLabels(configLabelsMap)
|
||||
labels, labelsSelector := deploy.GetLabelsAndSelector(instance, GatewayServiceName)
|
||||
|
||||
return appsv1.Deployment{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
|
|
@ -369,18 +370,18 @@ func getGatewayDeploymentSpec(instance *orgv1.CheCluster) appsv1.Deployment {
|
|||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: GatewayServiceName,
|
||||
Namespace: instance.Namespace,
|
||||
Labels: deploy.GetLabels(instance, GatewayServiceName),
|
||||
Labels: labels,
|
||||
},
|
||||
Spec: appsv1.DeploymentSpec{
|
||||
Selector: &metav1.LabelSelector{
|
||||
MatchLabels: deploy.GetLabels(instance, GatewayServiceName),
|
||||
MatchLabels: labelsSelector,
|
||||
},
|
||||
Strategy: appsv1.DeploymentStrategy{
|
||||
Type: appsv1.RollingUpdateDeploymentStrategyType,
|
||||
},
|
||||
Template: corev1.PodTemplateSpec{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Labels: deploy.GetLabels(instance, GatewayServiceName),
|
||||
Labels: labels,
|
||||
},
|
||||
Spec: corev1.PodSpec{
|
||||
TerminationGracePeriodSeconds: &terminationGracePeriodSeconds,
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ import (
|
|||
|
||||
orgv1 "github.com/eclipse/che-operator/pkg/apis/org/v1"
|
||||
"github.com/eclipse/che-operator/pkg/deploy"
|
||||
"github.com/eclipse/che-operator/pkg/deploy/postgres"
|
||||
"github.com/eclipse/che-operator/pkg/util"
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
|
@ -58,7 +57,7 @@ var (
|
|||
)
|
||||
|
||||
func SyncKeycloakDeploymentToCluster(deployContext *deploy.DeployContext) (bool, error) {
|
||||
clusterDeployment, err := deploy.GetClusterDeployment(IdentityProviderDeploymentName, deployContext.CheCluster.Namespace, deployContext.ClusterAPI.Client)
|
||||
clusterDeployment, err := deploy.GetClusterDeployment(deploy.IdentityProviderName, deployContext.CheCluster.Namespace, deployContext.ClusterAPI.Client)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
|
@ -75,7 +74,7 @@ func GetSpecKeycloakDeployment(
|
|||
deployContext *deploy.DeployContext,
|
||||
clusterDeployment *appsv1.Deployment) (*appsv1.Deployment, error) {
|
||||
optionalEnv := true
|
||||
labels := deploy.GetLabels(deployContext.CheCluster, IdentityProviderDeploymentName)
|
||||
labels, labelSelector := deploy.GetLabelsAndSelector(deployContext.CheCluster, deploy.IdentityProviderName)
|
||||
cheFlavor := deploy.DefaultCheFlavor(deployContext.CheCluster)
|
||||
keycloakImage := util.GetValue(deployContext.CheCluster.Spec.Auth.IdentityProviderImage, deploy.DefaultKeycloakImage(deployContext.CheCluster))
|
||||
pullPolicy := corev1.PullPolicy(util.GetValue(string(deployContext.CheCluster.Spec.Auth.IdentityProviderImagePullPolicy), deploy.DefaultPullPolicyFromDockerImage(keycloakImage)))
|
||||
|
|
@ -547,7 +546,7 @@ func GetSpecKeycloakDeployment(
|
|||
APIVersion: "apps/v1",
|
||||
},
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: IdentityProviderDeploymentName,
|
||||
Name: deploy.IdentityProviderName,
|
||||
Namespace: deployContext.CheCluster.Namespace,
|
||||
Labels: labels,
|
||||
Annotations: map[string]string{
|
||||
|
|
@ -557,7 +556,7 @@ func GetSpecKeycloakDeployment(
|
|||
},
|
||||
},
|
||||
Spec: appsv1.DeploymentSpec{
|
||||
Selector: &metav1.LabelSelector{MatchLabels: labels},
|
||||
Selector: &metav1.LabelSelector{MatchLabels: labelSelector},
|
||||
Strategy: appsv1.DeploymentStrategy{
|
||||
Type: appsv1.RollingUpdateDeploymentStrategyType,
|
||||
},
|
||||
|
|
@ -571,7 +570,7 @@ func GetSpecKeycloakDeployment(
|
|||
},
|
||||
Containers: []corev1.Container{
|
||||
{
|
||||
Name: IdentityProviderDeploymentName,
|
||||
Name: deploy.IdentityProviderName,
|
||||
Image: keycloakImage,
|
||||
ImagePullPolicy: pullPolicy,
|
||||
Command: []string{
|
||||
|
|
@ -580,7 +579,7 @@ func GetSpecKeycloakDeployment(
|
|||
Args: args,
|
||||
Ports: []corev1.ContainerPort{
|
||||
{
|
||||
Name: IdentityProviderDeploymentName,
|
||||
Name: deploy.IdentityProviderName,
|
||||
ContainerPort: 8080,
|
||||
Protocol: "TCP",
|
||||
},
|
||||
|
|
@ -681,7 +680,7 @@ func isSslRequiredUpdatedForMasterRealm(deployContext *deploy.DeployContext) boo
|
|||
return false
|
||||
}
|
||||
|
||||
clusterDeployment, _ := deploy.GetClusterDeployment(IdentityProviderDeploymentName, deployContext.CheCluster.Namespace, deployContext.ClusterAPI.Client)
|
||||
clusterDeployment, _ := deploy.GetClusterDeployment(deploy.IdentityProviderName, deployContext.CheCluster.Namespace, deployContext.ClusterAPI.Client)
|
||||
if clusterDeployment == nil {
|
||||
return false
|
||||
}
|
||||
|
|
@ -698,7 +697,7 @@ func isSslRequiredUpdatedForMasterRealm(deployContext *deploy.DeployContext) boo
|
|||
func getSslRequiredForMasterRealm(cr *orgv1.CheCluster) (string, error) {
|
||||
stdout, err := util.K8sclient.ExecIntoPod(
|
||||
cr,
|
||||
postgres.PostgresDeploymentName,
|
||||
deploy.PostgresName,
|
||||
func(cr *orgv1.CheCluster) (string, error) {
|
||||
return selectSslRequiredCommand, nil
|
||||
},
|
||||
|
|
@ -709,7 +708,7 @@ func getSslRequiredForMasterRealm(cr *orgv1.CheCluster) (string, error) {
|
|||
func updateSslRequiredForMasterRealm(cr *orgv1.CheCluster) error {
|
||||
_, err := util.K8sclient.ExecIntoPod(
|
||||
cr,
|
||||
postgres.PostgresDeploymentName,
|
||||
deploy.PostgresName,
|
||||
func(cr *orgv1.CheCluster) (string, error) {
|
||||
return updateSslRequiredCommand, nil
|
||||
},
|
||||
|
|
@ -734,7 +733,7 @@ func ProvisionKeycloakResources(deployContext *deploy.DeployContext) error {
|
|||
|
||||
_, err := util.K8sclient.ExecIntoPod(
|
||||
deployContext.CheCluster,
|
||||
IdentityProviderDeploymentName,
|
||||
deploy.IdentityProviderName,
|
||||
GetKeycloakProvisionCommand,
|
||||
"create realm, client and user")
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -31,12 +31,6 @@ import (
|
|||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
)
|
||||
|
||||
const (
|
||||
IdentityProviderServiceName = "keycloak"
|
||||
IdentityProviderExposureName = "keycloak"
|
||||
IdentityProviderDeploymentName = "keycloak"
|
||||
)
|
||||
|
||||
var (
|
||||
oAuthClientDiffOpts = cmpopts.IgnoreFields(oauth.OAuthClient{}, "TypeMeta", "ObjectMeta")
|
||||
syncItems = []func(*deploy.DeployContext) (bool, error){
|
||||
|
|
@ -59,8 +53,8 @@ func SyncIdentityProviderToCluster(deployContext *deploy.DeployContext) (bool, e
|
|||
|
||||
cheMultiUser := deploy.GetCheMultiUser(cr)
|
||||
if cheMultiUser == "false" {
|
||||
if util.K8sclient.IsDeploymentExists("keycloak", cr.Namespace) {
|
||||
util.K8sclient.DeleteDeployment("keycloak", cr.Namespace)
|
||||
if util.K8sclient.IsDeploymentExists(deploy.IdentityProviderName, cr.Namespace) {
|
||||
util.K8sclient.DeleteDeployment(deploy.IdentityProviderName, cr.Namespace)
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
|
@ -78,15 +72,12 @@ func SyncIdentityProviderToCluster(deployContext *deploy.DeployContext) (bool, e
|
|||
}
|
||||
|
||||
func syncService(deployContext *deploy.DeployContext) (bool, error) {
|
||||
cr := deployContext.CheCluster
|
||||
labels := deploy.GetLabels(cr, IdentityProviderServiceName)
|
||||
|
||||
serviceStatus := deploy.SyncServiceToCluster(
|
||||
deployContext,
|
||||
IdentityProviderServiceName,
|
||||
deploy.IdentityProviderName,
|
||||
[]string{"http"},
|
||||
[]int32{8080},
|
||||
labels)
|
||||
deploy.IdentityProviderName)
|
||||
|
||||
return serviceStatus.Continue, serviceStatus.Err
|
||||
}
|
||||
|
|
@ -104,14 +95,15 @@ func syncExposure(deployContext *deploy.DeployContext) (bool, error) {
|
|||
endpoint, done, err := expose.Expose(
|
||||
deployContext,
|
||||
cr.Spec.Server.CheHost,
|
||||
IdentityProviderExposureName,
|
||||
additionalLabels)
|
||||
deploy.IdentityProviderName,
|
||||
additionalLabels,
|
||||
deploy.IdentityProviderName)
|
||||
if !done {
|
||||
return false, err
|
||||
}
|
||||
|
||||
keycloakURL := protocol + "://" + endpoint
|
||||
deployContext.InternalService.KeycloakHost = fmt.Sprintf("%s://%s.%s.svc:%d", "http", "keycloak", cr.Namespace, 8080)
|
||||
deployContext.InternalService.KeycloakHost = fmt.Sprintf("%s://%s.%s.svc:%d", "http", deploy.IdentityProviderName, cr.Namespace, 8080)
|
||||
|
||||
if cr.Spec.Auth.IdentityProviderURL != keycloakURL {
|
||||
cr.Spec.Auth.IdentityProviderURL = keycloakURL
|
||||
|
|
@ -196,7 +188,7 @@ func SyncOpenShiftIdentityProviderItems(deployContext *deploy.DeployContext) (bo
|
|||
// because we're not doing much of a change detection on those fields, we can't react on them changing here.
|
||||
_, err := util.K8sclient.ExecIntoPod(
|
||||
cr,
|
||||
IdentityProviderDeploymentName,
|
||||
deploy.IdentityProviderName,
|
||||
func(cr *orgv1.CheCluster) (string, error) {
|
||||
return GetOpenShiftIdentityProviderProvisionCommand(cr, oAuthClientName, oauthSecret)
|
||||
},
|
||||
|
|
@ -229,7 +221,7 @@ func SyncGitHubOAuth(deployContext *deploy.DeployContext) (bool, error) {
|
|||
secrets := &corev1.SecretList{}
|
||||
|
||||
kubernetesPartOfLabelSelectorRequirement, _ := labels.NewRequirement(deploy.KubernetesPartOfLabelKey, selection.Equals, []string{deploy.CheEclipseOrg})
|
||||
kubernetesComponentLabelSelectorRequirement, _ := labels.NewRequirement(deploy.KubernetesComponentLabelKey, selection.Equals, []string{IdentityProviderDeploymentName + "-secret"})
|
||||
kubernetesComponentLabelSelectorRequirement, _ := labels.NewRequirement(deploy.KubernetesComponentLabelKey, selection.Equals, []string{deploy.IdentityProviderName + "-secret"})
|
||||
|
||||
listOptions := &client.ListOptions{
|
||||
LabelSelector: labels.NewSelector().
|
||||
|
|
@ -253,7 +245,7 @@ func SyncGitHubOAuth(deployContext *deploy.DeployContext) (bool, error) {
|
|||
if !util.IsTestMode() {
|
||||
_, err := util.K8sclient.ExecIntoPod(
|
||||
cr,
|
||||
IdentityProviderDeploymentName,
|
||||
deploy.IdentityProviderName,
|
||||
func(cr *orgv1.CheCluster) (string, error) {
|
||||
return GetGitHubIdentityProviderCreateCommand(deployContext)
|
||||
},
|
||||
|
|
@ -273,7 +265,7 @@ func SyncGitHubOAuth(deployContext *deploy.DeployContext) (bool, error) {
|
|||
if !util.IsTestMode() {
|
||||
_, err := util.K8sclient.ExecIntoPod(
|
||||
cr,
|
||||
IdentityProviderDeploymentName,
|
||||
deploy.IdentityProviderName,
|
||||
func(cr *orgv1.CheCluster) (string, error) {
|
||||
return GetIdentityProviderDeleteCommand(cr, "github")
|
||||
},
|
||||
|
|
|
|||
|
|
@ -43,9 +43,10 @@ func SyncIngressToCluster(
|
|||
host string,
|
||||
serviceName string,
|
||||
servicePort int,
|
||||
additionalLabels string) (*v1beta1.Ingress, error) {
|
||||
additionalLabels string,
|
||||
component string) (*v1beta1.Ingress, error) {
|
||||
|
||||
specIngress, err := GetSpecIngress(deployContext, name, host, serviceName, servicePort, additionalLabels)
|
||||
specIngress, err := GetSpecIngress(deployContext, name, host, serviceName, servicePort, additionalLabels, component)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -119,13 +120,14 @@ func GetSpecIngress(
|
|||
host string,
|
||||
serviceName string,
|
||||
servicePort int,
|
||||
additionalLabels string) (*v1beta1.Ingress, error) {
|
||||
additionalLabels string,
|
||||
component string) (*v1beta1.Ingress, error) {
|
||||
|
||||
tlsSupport := deployContext.CheCluster.Spec.Server.TlsSupport
|
||||
ingressStrategy := util.GetServerExposureStrategy(deployContext.CheCluster, DefaultServerExposureStrategy)
|
||||
ingressDomain := deployContext.CheCluster.Spec.K8s.IngressDomain
|
||||
ingressClass := util.GetValue(deployContext.CheCluster.Spec.K8s.IngressClass, DefaultIngressClass)
|
||||
labels := GetLabels(deployContext.CheCluster, name)
|
||||
labels := GetLabels(deployContext.CheCluster, component)
|
||||
MergeLabels(labels, additionalLabels)
|
||||
|
||||
if host == "" {
|
||||
|
|
@ -146,12 +148,12 @@ func GetSpecIngress(
|
|||
path := "/"
|
||||
if ingressStrategy != "multi-host" {
|
||||
switch name {
|
||||
case "keycloak":
|
||||
case IdentityProviderName:
|
||||
path = "/auth"
|
||||
case DevfileRegistry:
|
||||
path = "/" + DevfileRegistry + "/(.*)"
|
||||
case PluginRegistry:
|
||||
path = "/" + PluginRegistry + "/(.*)"
|
||||
case DevfileRegistryName:
|
||||
path = "/" + DevfileRegistryName + "/(.*)"
|
||||
case PluginRegistryName:
|
||||
path = "/" + PluginRegistryName + "/(.*)"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -161,7 +163,7 @@ func GetSpecIngress(
|
|||
"nginx.ingress.kubernetes.io/proxy-connect-timeout": "3600",
|
||||
"nginx.ingress.kubernetes.io/ssl-redirect": strconv.FormatBool(tlsSupport),
|
||||
}
|
||||
if ingressStrategy != "multi-host" && (name == DevfileRegistry || name == PluginRegistry) {
|
||||
if ingressStrategy != "multi-host" && (name == DevfileRegistryName || name == PluginRegistryName) {
|
||||
annotations["nginx.ingress.kubernetes.io/rewrite-target"] = "/$1"
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -98,9 +98,7 @@ func getSpecJob(
|
|||
image string,
|
||||
serviceAccountName string,
|
||||
env map[string]string) (*batchv1.Job, error) {
|
||||
labels := GetLabels(deployContext.CheCluster, DefaultCheFlavor(deployContext.CheCluster))
|
||||
labels["component"] = component
|
||||
|
||||
labels := GetLabels(deployContext.CheCluster, component)
|
||||
backoffLimit := int32(3)
|
||||
parallelism := int32(1)
|
||||
comletions := int32(1)
|
||||
|
|
|
|||
|
|
@ -17,9 +17,27 @@ import (
|
|||
orgv1 "github.com/eclipse/che-operator/pkg/apis/org/v1"
|
||||
)
|
||||
|
||||
func GetLabels(cr *orgv1.CheCluster, component string) (labels map[string]string) {
|
||||
labels = map[string]string{"app": DefaultCheFlavor(cr), "component": component}
|
||||
return labels
|
||||
func GetLabels(cheCluster *orgv1.CheCluster, component string) map[string]string {
|
||||
cheFlavor := DefaultCheFlavor(cheCluster)
|
||||
return map[string]string{
|
||||
KubernetesNameLabelKey: cheFlavor,
|
||||
KubernetesInstanceLabelKey: cheFlavor,
|
||||
KubernetesComponentLabelKey: component,
|
||||
KubernetesManagedByLabelKey: cheFlavor + "-operator",
|
||||
}
|
||||
}
|
||||
|
||||
func GetLabelsAndSelector(cheCluster *orgv1.CheCluster, component string) (map[string]string, map[string]string) {
|
||||
labels := GetLabels(cheCluster, component)
|
||||
legacyLabels := GetLegacyLabels(cheCluster, component)
|
||||
|
||||
// For the backward compatability
|
||||
// We have to keep these labels for a deployment since this field is immutable
|
||||
for k, v := range legacyLabels {
|
||||
labels[k] = v
|
||||
}
|
||||
|
||||
return labels, legacyLabels
|
||||
}
|
||||
|
||||
func MergeLabels(labels map[string]string, additionalLabels string) {
|
||||
|
|
@ -30,3 +48,10 @@ func MergeLabels(labels map[string]string, additionalLabels string) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func GetLegacyLabels(cheCluster *orgv1.CheCluster, component string) map[string]string {
|
||||
return map[string]string{
|
||||
"app": DefaultCheFlavor(cheCluster),
|
||||
"component": component,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,36 @@
|
|||
//
|
||||
// Copyright (c) 2012-2019 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 deploy
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
orgv1 "github.com/eclipse/che-operator/pkg/apis/org/v1"
|
||||
)
|
||||
|
||||
func TestLabels(t *testing.T) {
|
||||
cheCluster := &orgv1.CheCluster{
|
||||
Spec: orgv1.CheClusterSpec{
|
||||
Server: orgv1.CheClusterSpecServer{
|
||||
CheFlavor: "che",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
labels, _ := GetLabelsAndSelector(cheCluster, "test")
|
||||
if labels[KubernetesNameLabelKey] == "" ||
|
||||
labels[KubernetesComponentLabelKey] == "" ||
|
||||
labels[KubernetesInstanceLabelKey] == "" ||
|
||||
labels[KubernetesManagedByLabelKey] == "" {
|
||||
t.Errorf("Default kubernetes labels aren't set.")
|
||||
}
|
||||
}
|
||||
|
|
@ -20,7 +20,7 @@ import (
|
|||
)
|
||||
|
||||
func SyncPluginRegistryDeploymentToCluster(deployContext *deploy.DeployContext) (bool, error) {
|
||||
clusterDeployment, err := deploy.GetClusterDeployment(deploy.PluginRegistry, deployContext.CheCluster.Namespace, deployContext.ClusterAPI.Client)
|
||||
clusterDeployment, err := deploy.GetClusterDeployment(deploy.PluginRegistryName, deployContext.CheCluster.Namespace, deployContext.ClusterAPI.Client)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ func SyncPluginRegistryToCluster(deployContext *deploy.DeployContext, cheHost st
|
|||
pluginRegistryURL := deployContext.CheCluster.Spec.Server.PluginRegistryUrl
|
||||
if !deployContext.CheCluster.Spec.Server.ExternalPluginRegistry {
|
||||
additionalLabels := (map[bool]string{true: deployContext.CheCluster.Spec.Server.PluginRegistryRoute.Labels, false: deployContext.CheCluster.Spec.Server.PluginRegistryIngress.Labels})[util.IsOpenShift]
|
||||
endpoint, done, err := expose.Expose(deployContext, cheHost, deploy.PluginRegistry, additionalLabels)
|
||||
endpoint, done, err := expose.Expose(deployContext, cheHost, deploy.PluginRegistryName, additionalLabels, deploy.PluginRegistryName)
|
||||
if !done {
|
||||
return false, err
|
||||
}
|
||||
|
|
@ -50,7 +50,7 @@ func SyncPluginRegistryToCluster(deployContext *deploy.DeployContext, cheHost st
|
|||
|
||||
if deployContext.CheCluster.IsAirGapMode() {
|
||||
configMapData := getPluginRegistryConfigMapData(deployContext.CheCluster)
|
||||
configMapSpec, err := deploy.GetSpecConfigMap(deployContext, deploy.PluginRegistry, configMapData)
|
||||
configMapSpec, err := deploy.GetSpecConfigMap(deployContext, deploy.PluginRegistryName, configMapData, deploy.PluginRegistryName)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
|
@ -62,11 +62,10 @@ func SyncPluginRegistryToCluster(deployContext *deploy.DeployContext, cheHost st
|
|||
}
|
||||
|
||||
// Create a new registry service
|
||||
registryLabels := deploy.GetLabels(deployContext.CheCluster, deploy.PluginRegistry)
|
||||
serviceStatus := deploy.SyncServiceToCluster(deployContext, deploy.PluginRegistry, []string{"http"}, []int32{8080}, registryLabels)
|
||||
serviceStatus := deploy.SyncServiceToCluster(deployContext, deploy.PluginRegistryName, []string{"http"}, []int32{8080}, deploy.PluginRegistryName)
|
||||
if !util.IsTestMode() {
|
||||
if !serviceStatus.Continue {
|
||||
logrus.Info("Waiting on service '" + deploy.PluginRegistry + "' to be ready")
|
||||
logrus.Info("Waiting on service '" + deploy.PluginRegistryName + "' to be ready")
|
||||
if serviceStatus.Err != nil {
|
||||
logrus.Error(serviceStatus.Err)
|
||||
}
|
||||
|
|
@ -75,13 +74,13 @@ func SyncPluginRegistryToCluster(deployContext *deploy.DeployContext, cheHost st
|
|||
}
|
||||
}
|
||||
|
||||
deployContext.InternalService.PluginRegistryHost = fmt.Sprintf("http://%s.%s.svc:8080/v3", deploy.PluginRegistry, deployContext.CheCluster.Namespace)
|
||||
deployContext.InternalService.PluginRegistryHost = fmt.Sprintf("http://%s.%s.svc:8080/v3", deploy.PluginRegistryName, deployContext.CheCluster.Namespace)
|
||||
|
||||
// Deploy plugin registry
|
||||
provisioned, err := SyncPluginRegistryDeploymentToCluster(deployContext)
|
||||
if !util.IsTestMode() {
|
||||
if !provisioned {
|
||||
logrus.Info("Waiting on deployment '" + deploy.PluginRegistry + "' to be ready")
|
||||
logrus.Info("Waiting on deployment '" + deploy.PluginRegistryName + "' to be ready")
|
||||
if err != nil {
|
||||
logrus.Error(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,16 +21,12 @@ import (
|
|||
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
|
||||
)
|
||||
|
||||
const (
|
||||
PostgresDeploymentName = "postgres"
|
||||
)
|
||||
|
||||
var (
|
||||
postgresAdminPassword = util.GeneratePasswd(12)
|
||||
)
|
||||
|
||||
func SyncPostgresDeploymentToCluster(deployContext *deploy.DeployContext) (bool, error) {
|
||||
clusterDeployment, err := deploy.GetClusterDeployment(PostgresDeploymentName, deployContext.CheCluster.Namespace, deployContext.ClusterAPI.Client)
|
||||
clusterDeployment, err := deploy.GetClusterDeployment(deploy.PostgresName, deployContext.CheCluster.Namespace, deployContext.ClusterAPI.Client)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
|
@ -50,7 +46,7 @@ func GetSpecPostgresDeployment(deployContext *deploy.DeployContext, clusterDeplo
|
|||
}
|
||||
|
||||
terminationGracePeriodSeconds := int64(30)
|
||||
labels := deploy.GetLabels(deployContext.CheCluster, PostgresDeploymentName)
|
||||
labels, labelSelector := deploy.GetLabelsAndSelector(deployContext.CheCluster, deploy.PostgresName)
|
||||
chePostgresDb := util.GetValue(deployContext.CheCluster.Spec.Database.ChePostgresDb, "dbche")
|
||||
postgresImage := util.GetValue(deployContext.CheCluster.Spec.Database.PostgresImage, deploy.DefaultPostgresImage(deployContext.CheCluster))
|
||||
pullPolicy := corev1.PullPolicy(util.GetValue(string(deployContext.CheCluster.Spec.Database.PostgresImagePullPolicy), deploy.DefaultPullPolicyFromDockerImage(postgresImage)))
|
||||
|
|
@ -71,12 +67,12 @@ func GetSpecPostgresDeployment(deployContext *deploy.DeployContext, clusterDeplo
|
|||
APIVersion: "apps/v1",
|
||||
},
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "postgres",
|
||||
Name: deploy.PostgresName,
|
||||
Namespace: deployContext.CheCluster.Namespace,
|
||||
Labels: labels,
|
||||
},
|
||||
Spec: appsv1.DeploymentSpec{
|
||||
Selector: &metav1.LabelSelector{MatchLabels: labels},
|
||||
Selector: &metav1.LabelSelector{MatchLabels: labelSelector},
|
||||
Strategy: appsv1.DeploymentStrategy{
|
||||
Type: appsv1.DeploymentStrategyType("Recreate"),
|
||||
},
|
||||
|
|
@ -97,12 +93,12 @@ func GetSpecPostgresDeployment(deployContext *deploy.DeployContext, clusterDeplo
|
|||
},
|
||||
Containers: []corev1.Container{
|
||||
{
|
||||
Name: PostgresDeploymentName,
|
||||
Name: deploy.PostgresName,
|
||||
Image: postgresImage,
|
||||
ImagePullPolicy: pullPolicy,
|
||||
Ports: []corev1.ContainerPort{
|
||||
{
|
||||
Name: PostgresDeploymentName,
|
||||
Name: deploy.PostgresName,
|
||||
ContainerPort: 5432,
|
||||
Protocol: "TCP",
|
||||
},
|
||||
|
|
|
|||
|
|
@ -44,9 +44,9 @@ func SyncPVCToCluster(
|
|||
deployContext *DeployContext,
|
||||
name string,
|
||||
claimSize string,
|
||||
labels map[string]string) PVCProvisioningStatus {
|
||||
component string) PVCProvisioningStatus {
|
||||
|
||||
specPVC, err := getSpecPVC(deployContext, name, claimSize, labels)
|
||||
specPVC, err := getSpecPVC(deployContext, name, claimSize, component)
|
||||
if err != nil {
|
||||
return PVCProvisioningStatus{
|
||||
ProvisioningStatus: ProvisioningStatus{Err: err},
|
||||
|
|
@ -91,8 +91,9 @@ func getSpecPVC(
|
|||
deployContext *DeployContext,
|
||||
name string,
|
||||
claimSize string,
|
||||
labels map[string]string) (*corev1.PersistentVolumeClaim, error) {
|
||||
component string) (*corev1.PersistentVolumeClaim, error) {
|
||||
|
||||
labels := GetLabels(deployContext.CheCluster, component)
|
||||
accessModes := []corev1.PersistentVolumeAccessMode{
|
||||
corev1.ReadWriteOnce,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,14 @@
|
|||
//
|
||||
// Copyright (c) 2012-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 registry
|
||||
|
||||
import (
|
||||
|
|
@ -21,7 +32,7 @@ func GetSpecRegistryDeployment(
|
|||
|
||||
terminationGracePeriodSeconds := int64(30)
|
||||
name := registryType + "-registry"
|
||||
labels := deploy.GetLabels(deployContext.CheCluster, name)
|
||||
labels, labelSelector := deploy.GetLabelsAndSelector(deployContext.CheCluster, name)
|
||||
_25Percent := intstr.FromString("25%")
|
||||
_1 := int32(1)
|
||||
_2 := int32(2)
|
||||
|
|
@ -39,7 +50,7 @@ func GetSpecRegistryDeployment(
|
|||
Spec: v12.DeploymentSpec{
|
||||
Replicas: &_1,
|
||||
RevisionHistoryLimit: &_2,
|
||||
Selector: &v13.LabelSelector{MatchLabels: labels},
|
||||
Selector: &v13.LabelSelector{MatchLabels: labelSelector},
|
||||
Strategy: v12.DeploymentStrategy{
|
||||
Type: v12.RollingUpdateDeploymentStrategyType,
|
||||
RollingUpdate: &v12.RollingUpdateDeployment{
|
||||
|
|
|
|||
|
|
@ -50,9 +50,10 @@ func SyncRouteToCluster(
|
|||
host string,
|
||||
serviceName string,
|
||||
servicePort int32,
|
||||
additionalLabels string) (*routev1.Route, error) {
|
||||
additionalLabels string,
|
||||
component string) (*routev1.Route, error) {
|
||||
|
||||
specRoute, err := GetSpecRoute(deployContext, name, host, serviceName, servicePort, additionalLabels)
|
||||
specRoute, err := GetSpecRoute(deployContext, name, host, serviceName, servicePort, additionalLabels, component)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -131,13 +132,11 @@ func GetSpecRoute(
|
|||
host string,
|
||||
serviceName string,
|
||||
servicePort int32,
|
||||
additionalLabels string) (*routev1.Route, error) {
|
||||
additionalLabels string,
|
||||
component string) (*routev1.Route, error) {
|
||||
|
||||
tlsSupport := deployContext.CheCluster.Spec.Server.TlsSupport
|
||||
labels := GetLabels(deployContext.CheCluster, DefaultCheFlavor(deployContext.CheCluster))
|
||||
if name == "keycloak" {
|
||||
labels = GetLabels(deployContext.CheCluster, name)
|
||||
}
|
||||
labels := GetLabels(deployContext.CheCluster, component)
|
||||
MergeLabels(labels, additionalLabels)
|
||||
|
||||
weight := int32(100)
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ func SyncCheConfigMapToCluster(deployContext *deploy.DeployContext) (*corev1.Con
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
specConfigMap, err := deploy.GetSpecConfigMap(deployContext, CheConfigMapName, data)
|
||||
specConfigMap, err := deploy.GetSpecConfigMap(deployContext, CheConfigMapName, data, deploy.DefaultCheFlavor(deployContext.CheCluster))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,10 +12,11 @@
|
|||
package server
|
||||
|
||||
import (
|
||||
"github.com/eclipse/che-operator/pkg/deploy"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/eclipse/che-operator/pkg/deploy"
|
||||
|
||||
orgv1 "github.com/eclipse/che-operator/pkg/apis/org/v1"
|
||||
"github.com/eclipse/che-operator/pkg/util"
|
||||
)
|
||||
|
|
@ -35,7 +36,7 @@ func TestNewCheConfigMap(t *testing.T) {
|
|||
ClusterAPI: deploy.ClusterAPI{},
|
||||
}
|
||||
cheEnv, _ := GetCheConfigMapData(deployContext)
|
||||
testCm, _ := deploy.GetSpecConfigMap(deployContext, CheConfigMapName, cheEnv)
|
||||
testCm, _ := deploy.GetSpecConfigMap(deployContext, CheConfigMapName, cheEnv, CheConfigMapName)
|
||||
identityProvider := testCm.Data["CHE_INFRA_OPENSHIFT_OAUTH__IDENTITY__PROVIDER"]
|
||||
_, isOpenshiftv4, _ := util.DetectOpenShift()
|
||||
protocol := strings.Split(testCm.Data["CHE_API"], "://")[0]
|
||||
|
|
@ -65,7 +66,7 @@ func TestConfigMapOverride(t *testing.T) {
|
|||
ClusterAPI: deploy.ClusterAPI{},
|
||||
}
|
||||
cheEnv, _ := GetCheConfigMapData(deployContext)
|
||||
testCm, _ := deploy.GetSpecConfigMap(deployContext, CheConfigMapName, cheEnv)
|
||||
testCm, _ := deploy.GetSpecConfigMap(deployContext, CheConfigMapName, cheEnv, CheConfigMapName)
|
||||
if testCm.Data["CHE_WORKSPACE_NO_PROXY"] != "myproxy.myhostname.com" {
|
||||
t.Errorf("Test failed. Expected myproxy.myhostname.com but was %s", testCm.Data["CHE_WORKSPACE_NO_PROXY"])
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ const (
|
|||
|
||||
func SyncTrustStoreConfigMapToCluster(deployContext *deploy.DeployContext) (*corev1.ConfigMap, error) {
|
||||
name := deployContext.CheCluster.Spec.Server.ServerTrustStoreConfigMapName
|
||||
specConfigMap, err := deploy.GetSpecConfigMap(deployContext, name, map[string]string{})
|
||||
specConfigMap, err := deploy.GetSpecConfigMap(deployContext, name, map[string]string{}, deploy.DefaultCheFlavor(deployContext.CheCluster))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ func GetSpecCheDeployment(deployContext *deploy.DeployContext) (*appsv1.Deployme
|
|||
|
||||
terminationGracePeriodSeconds := int64(30)
|
||||
cheFlavor := deploy.DefaultCheFlavor(deployContext.CheCluster)
|
||||
labels := deploy.GetLabels(deployContext.CheCluster, cheFlavor)
|
||||
labels, labelSelector := deploy.GetLabelsAndSelector(deployContext.CheCluster, cheFlavor)
|
||||
optionalEnv := true
|
||||
selfSignedCertEnv := corev1.EnvVar{
|
||||
Name: "CHE_SELF__SIGNED__CERT",
|
||||
|
|
@ -194,7 +194,7 @@ func GetSpecCheDeployment(deployContext *deploy.DeployContext) (*appsv1.Deployme
|
|||
Labels: labels,
|
||||
},
|
||||
Spec: appsv1.DeploymentSpec{
|
||||
Selector: &metav1.LabelSelector{MatchLabels: labels},
|
||||
Selector: &metav1.LabelSelector{MatchLabels: labelSelector},
|
||||
Strategy: appsv1.DeploymentStrategy{
|
||||
Type: appsv1.RollingUpdateDeploymentStrategyType,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ import (
|
|||
func GetSpecCheService(deployContext *deploy.DeployContext) (*v1.Service, error) {
|
||||
portName := []string{"http"}
|
||||
portNumber := []int32{8080}
|
||||
labels := deploy.GetLabels(deployContext.CheCluster, deploy.DefaultCheFlavor(deployContext.CheCluster))
|
||||
|
||||
if deployContext.CheCluster.Spec.Metrics.Enable {
|
||||
portName = append(portName, "metrics")
|
||||
|
|
@ -31,7 +30,7 @@ func GetSpecCheService(deployContext *deploy.DeployContext) (*v1.Service, error)
|
|||
portNumber = append(portNumber, deploy.DefaultCheDebugPort)
|
||||
}
|
||||
|
||||
return deploy.GetSpecService(deployContext, deploy.CheServiceName, portName, portNumber, labels)
|
||||
return deploy.GetSpecService(deployContext, deploy.CheServiceName, portName, portNumber, deploy.DefaultCheFlavor(deployContext.CheCluster))
|
||||
}
|
||||
|
||||
func SyncCheServiceToCluster(deployContext *deploy.DeployContext) deploy.ServiceProvisioningStatus {
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ package deploy
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/eclipse/che-operator/pkg/util"
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/google/go-cmp/cmp/cmpopts"
|
||||
|
|
@ -44,8 +45,8 @@ func SyncServiceToCluster(
|
|||
name string,
|
||||
portName []string,
|
||||
portNumber []int32,
|
||||
labels map[string]string) ServiceProvisioningStatus {
|
||||
specService, err := GetSpecService(deployContext, name, portName, portNumber, labels)
|
||||
component string) ServiceProvisioningStatus {
|
||||
specService, err := GetSpecService(deployContext, name, portName, portNumber, component)
|
||||
if err != nil {
|
||||
return ServiceProvisioningStatus{
|
||||
ProvisioningStatus: ProvisioningStatus{Err: err},
|
||||
|
|
@ -102,8 +103,9 @@ func GetSpecService(
|
|||
name string,
|
||||
portName []string,
|
||||
portNumber []int32,
|
||||
labels map[string]string) (*corev1.Service, error) {
|
||||
component string) (*corev1.Service, error) {
|
||||
|
||||
labels := GetLabels(deployContext.CheCluster, component)
|
||||
ports := []corev1.ServicePort{}
|
||||
for i := range portName {
|
||||
port := corev1.ServicePort{
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
orgv1 "github.com/eclipse/che-operator/pkg/apis/org/v1"
|
||||
"github.com/eclipse/che-operator/pkg/util"
|
||||
routev1 "github.com/openshift/api/route/v1"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
|
@ -131,12 +130,13 @@ func GetEndpointTLSCrtChain(deployContext *DeployContext, endpointURL string) ([
|
|||
|
||||
var useTestEndpoint bool = len(endpointURL) < 1
|
||||
var requestURL string
|
||||
cheFlavor := DefaultCheFlavor(deployContext.CheCluster)
|
||||
if useTestEndpoint {
|
||||
if util.IsOpenShift {
|
||||
// Create test route to get certificates chain.
|
||||
// Note, it is not possible to use SyncRouteToCluster here as it may cause infinite reconcile loop.
|
||||
additionalLabels := deployContext.CheCluster.Spec.Server.CheServerRoute.Labels
|
||||
routeSpec, err := GetSpecRoute(deployContext, "test", "", "test", 8080, additionalLabels)
|
||||
routeSpec, err := GetSpecRoute(deployContext, "test", "", "test", 8080, additionalLabels, cheFlavor)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -175,7 +175,7 @@ func GetEndpointTLSCrtChain(deployContext *DeployContext, endpointURL string) ([
|
|||
// Create test ingress to get certificates chain.
|
||||
// Note, it is not possible to use SyncIngressToCluster here as it may cause infinite reconcile loop.
|
||||
additionalLabels := deployContext.CheCluster.Spec.Server.CheServerIngress.Labels
|
||||
ingressSpec, err := GetSpecIngress(deployContext, "test", "", "test", 8080, additionalLabels)
|
||||
ingressSpec, err := GetSpecIngress(deployContext, "test", "", "test", 8080, additionalLabels, cheFlavor)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -482,7 +482,8 @@ func deleteJob(deployContext *DeployContext, job *batchv1.Job) {
|
|||
}
|
||||
|
||||
// SyncAdditionalCACertsConfigMapToCluster makes sure that additional CA certs config map is up to date if any
|
||||
func SyncAdditionalCACertsConfigMapToCluster(cr *orgv1.CheCluster, deployContext *DeployContext) (*corev1.ConfigMap, error) {
|
||||
func SyncAdditionalCACertsConfigMapToCluster(deployContext *DeployContext) (*corev1.ConfigMap, error) {
|
||||
cr := deployContext.CheCluster
|
||||
// Get all source config maps, if any
|
||||
caConfigMaps, err := getCACertsConfigMaps(deployContext)
|
||||
if err != nil {
|
||||
|
|
@ -548,7 +549,7 @@ func SyncAdditionalCACertsConfigMapToCluster(cr *orgv1.CheCluster, deployContext
|
|||
revisions += cm.ObjectMeta.Name + labelEqualSign + cm.ObjectMeta.ResourceVersion
|
||||
}
|
||||
|
||||
mergedCAConfigMapSpec, err := GetSpecConfigMap(deployContext, CheAllCACertsConfigMapName, data)
|
||||
mergedCAConfigMapSpec, err := GetSpecConfigMap(deployContext, CheAllCACertsConfigMapName, data, DefaultCheFlavor(cr))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,11 +12,12 @@
|
|||
package util
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/kubernetes/fake"
|
||||
"testing"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
|
|||
Loading…
Reference in New Issue