feat: Remove PostgreSQL component (#1630)

* feat: Remove PostgreSQL component

Signed-off-by: Anatolii Bazko <abazko@redhat.com>
pull/1634/head
Anatolii Bazko 2023-02-28 15:42:22 +02:00 committed by GitHub
parent 8d0ee22923
commit 12169def8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
33 changed files with 74 additions and 1305 deletions

View File

@ -110,45 +110,6 @@ func TestConvertFrom(t *testing.T) {
Metrics: chev2.ServerMetrics{
Enable: true,
},
Database: chev2.Database{
ExternalDb: true,
Deployment: &chev2.Deployment{
Containers: []chev2.Container{
{
Image: "DatabaseImage",
ImagePullPolicy: corev1.PullAlways,
Resources: &chev2.ResourceRequirements{
Requests: &chev2.ResourceList{
Memory: resource.MustParse("128Mi"),
Cpu: resource.MustParse("1"),
},
Limits: &chev2.ResourceList{
Memory: resource.MustParse("228Mi"),
Cpu: resource.MustParse("2"),
},
},
Env: []corev1.EnvVar{
{
Name: "database-name",
Value: "database-value",
},
},
},
},
SecurityContext: &chev2.PodSecurityContext{
RunAsUser: pointer.Int64Ptr(64),
FsGroup: pointer.Int64Ptr(65),
},
},
PostgresHostName: "PostgresHostName",
PostgresPort: "PostgresPort",
PostgresDb: "PostgresDb",
CredentialsSecretName: "DatabaseCredentialsSecretName",
Pvc: &chev2.PVC{
ClaimSize: "DatabaseClaimSize",
StorageClass: "DatabaseStorageClass",
},
},
PluginRegistry: chev2.PluginRegistry{
Deployment: &chev2.Deployment{
Containers: []chev2.Container{
@ -430,7 +391,6 @@ func TestConvertFrom(t *testing.T) {
ChePhase: "Active",
Message: "Message",
Reason: "Reason",
PostgresVersion: "PostgresVersion",
},
}
@ -466,22 +426,6 @@ func TestConvertFrom(t *testing.T) {
assert.Equal(t, checlusterv1.Spec.Auth.GatewayConfigBumpEnv[0].Name, "configbump-name")
assert.Equal(t, checlusterv1.Spec.Auth.GatewayConfigBumpEnv[0].Value, "configbump-value")
assert.Equal(t, checlusterv1.Spec.Database.ChePostgresContainerResources.Limits.Cpu, "2")
assert.Equal(t, checlusterv1.Spec.Database.ChePostgresContainerResources.Limits.Memory, "228Mi")
assert.Equal(t, checlusterv1.Spec.Database.ChePostgresContainerResources.Requests.Cpu, "1")
assert.Equal(t, checlusterv1.Spec.Database.ChePostgresContainerResources.Requests.Memory, "128Mi")
assert.Equal(t, checlusterv1.Spec.Database.ChePostgresDb, "PostgresDb")
assert.Equal(t, checlusterv1.Spec.Database.ChePostgresHostName, "PostgresHostName")
assert.Equal(t, checlusterv1.Spec.Database.ChePostgresPort, "PostgresPort")
assert.Equal(t, checlusterv1.Spec.Database.ChePostgresSecret, "DatabaseCredentialsSecretName")
assert.Equal(t, checlusterv1.Spec.Database.ExternalDb, true)
assert.Equal(t, checlusterv1.Spec.Database.PostgresImage, "DatabaseImage")
assert.Equal(t, checlusterv1.Spec.Database.PostgresImagePullPolicy, corev1.PullAlways)
assert.Equal(t, checlusterv1.Spec.Database.PostgresVersion, "PostgresVersion")
assert.Equal(t, checlusterv1.Spec.Database.PvcClaimSize, "DatabaseClaimSize")
assert.Equal(t, checlusterv1.Spec.Database.PostgresEnv[0].Name, "database-name")
assert.Equal(t, checlusterv1.Spec.Database.PostgresEnv[0].Value, "database-value")
assert.Equal(t, checlusterv1.Spec.DevWorkspace.RunningLimit, "10")
assert.Equal(t, checlusterv1.Spec.DevWorkspace.SecondsOfInactivityBeforeIdling, pointer.Int32Ptr(1800))
assert.Equal(t, checlusterv1.Spec.DevWorkspace.SecondsOfRunBeforeIdling, pointer.Int32Ptr(-1))
@ -560,7 +504,6 @@ func TestConvertFrom(t *testing.T) {
assert.Equal(t, checlusterv1.Spec.Server.WorkspacesDefaultPlugins, []chev1.WorkspacesDefaultPlugins{{Editor: "Editor", Plugins: []string{"Plugins_1", "Plugins_2"}}})
assert.Equal(t, checlusterv1.Spec.Storage.PvcStrategy, "PvcStrategy")
assert.Equal(t, checlusterv1.Spec.Storage.PostgresPVCStorageClassName, "DatabaseStorageClass")
assert.Equal(t, checlusterv1.Spec.Storage.PvcClaimSize, "StorageClaimSize")
assert.Equal(t, checlusterv1.Spec.Storage.WorkspacePVCStorageClassName, "StorageClass")
assert.Equal(t, checlusterv1.Spec.Storage.PerWorkspaceStrategyPvcClaimSize, "PerWorkspaceStorageClaimSize")

View File

@ -254,33 +254,6 @@ func TestConvertTo(t *testing.T) {
},
OpenVSXRegistryURL: pointer.StringPtr("open-vsx-registry"),
},
Database: chev1.CheClusterSpecDB{
ExternalDb: true,
ChePostgresHostName: "ChePostgresHostName",
ChePostgresPort: "ChePostgresPort",
ChePostgresDb: "ChePostgresDb",
ChePostgresSecret: "ChePostgresSecret",
PostgresImage: "PostgresImage",
PostgresVersion: "PostgresVersion",
PostgresImagePullPolicy: "Always",
PvcClaimSize: "DatabasePvcClaimSize",
ChePostgresContainerResources: chev1.ResourcesCustomSettings{
Requests: chev1.Resources{
Memory: "100Mi",
Cpu: "1",
},
Limits: chev1.Resources{
Memory: "200Mi",
Cpu: "2",
},
},
PostgresEnv: []corev1.EnvVar{
{
Name: "database-name",
Value: "database-value",
},
},
},
Auth: chev1.CheClusterSpecAuth{
IdentityProviderURL: "IdentityProviderURL",
OAuthClientName: "OAuthClientName",
@ -317,7 +290,6 @@ func TestConvertTo(t *testing.T) {
Storage: chev1.CheClusterSpecStorage{
PvcStrategy: "PvcStrategy",
PvcClaimSize: "WorkspacePvcClaimSize",
PostgresPVCStorageClassName: "PostgresPVCStorageClassName",
WorkspacePVCStorageClassName: "WorkspacePVCStorageClassName",
PerWorkspaceStrategyPVCStorageClassName: "PerWorkspaceStrategyPVCStorageClassName",
PerWorkspaceStrategyPvcClaimSize: "PerWorkspaceStrategyPvcClaimSize",
@ -456,23 +428,6 @@ func TestConvertTo(t *testing.T) {
assert.Equal(t, checlusterv2.Spec.Components.Dashboard.HeaderMessage.Text, "DashboardWarning")
assert.True(t, checlusterv2.Spec.Components.Dashboard.HeaderMessage.Show)
assert.Equal(t, checlusterv2.Spec.Components.Database.CredentialsSecretName, "ChePostgresSecret")
assert.Equal(t, checlusterv2.Spec.Components.Database.Deployment.Containers[0].Name, constants.PostgresName)
assert.Equal(t, checlusterv2.Spec.Components.Database.Deployment.Containers[0].Image, "PostgresImage")
assert.Equal(t, checlusterv2.Spec.Components.Database.Deployment.Containers[0].Env[0].Name, "database-name")
assert.Equal(t, checlusterv2.Spec.Components.Database.Deployment.Containers[0].Env[0].Value, "database-value")
assert.Equal(t, checlusterv2.Spec.Components.Database.Deployment.Containers[0].ImagePullPolicy, corev1.PullPolicy("Always"))
assert.Equal(t, checlusterv2.Spec.Components.Database.Deployment.Containers[0].Resources.Limits.Cpu, resource.MustParse("2"))
assert.Equal(t, checlusterv2.Spec.Components.Database.Deployment.Containers[0].Resources.Limits.Memory, resource.MustParse("200Mi"))
assert.Equal(t, checlusterv2.Spec.Components.Database.Deployment.Containers[0].Resources.Requests.Cpu, resource.MustParse("1"))
assert.Equal(t, checlusterv2.Spec.Components.Database.Deployment.Containers[0].Resources.Requests.Memory, resource.MustParse("100Mi"))
assert.Equal(t, checlusterv2.Spec.Components.Database.ExternalDb, true)
assert.Equal(t, checlusterv2.Spec.Components.Database.PostgresDb, "ChePostgresDb")
assert.Equal(t, checlusterv2.Spec.Components.Database.PostgresHostName, "ChePostgresHostName")
assert.Equal(t, checlusterv2.Spec.Components.Database.PostgresPort, "ChePostgresPort")
assert.Equal(t, checlusterv2.Spec.Components.Database.Pvc.ClaimSize, "DatabasePvcClaimSize")
assert.Equal(t, checlusterv2.Spec.Components.Database.Pvc.StorageClass, "PostgresPVCStorageClassName")
assert.Equal(t, checlusterv2.Spec.Components.ImagePuller.Enable, true)
assert.Equal(t, checlusterv2.Spec.Components.Metrics.Enable, true)
@ -523,7 +478,6 @@ func TestConvertTo(t *testing.T) {
assert.Equal(t, checlusterv2.Status.ChePhase, chev2.CheClusterPhase("Active"))
assert.Equal(t, checlusterv2.Status.PluginRegistryURL, "PluginRegistryURL")
assert.Equal(t, checlusterv2.Status.Reason, "Reason")
assert.Equal(t, checlusterv2.Status.PostgresVersion, "PostgresVersion")
assert.Equal(t, checlusterv2.Spec.GitServices.GitHub[0].SecretName, "github-secret-name")
assert.Equal(t, checlusterv2.Spec.GitServices.GitLab[0].SecretName, "gitlab-secret-name")

View File

@ -85,36 +85,6 @@ func TestRoundConvertCheClusterV2(t *testing.T) {
Metrics: chev2.ServerMetrics{
Enable: true,
},
Database: chev2.Database{
ExternalDb: true,
Deployment: &chev2.Deployment{
Containers: []chev2.Container{
{
Name: "postgres",
Image: "DatabaseImage",
ImagePullPolicy: corev1.PullAlways,
Resources: &chev2.ResourceRequirements{
Requests: &chev2.ResourceList{
Memory: resource.MustParse("148Mi"),
Cpu: resource.MustParse("1"),
},
Limits: &chev2.ResourceList{
Memory: resource.MustParse("228Mi"),
Cpu: resource.MustParse("2"),
},
},
},
},
},
PostgresHostName: "PostgresHostName",
PostgresPort: "PostgresPort",
PostgresDb: "PostgresDb",
CredentialsSecretName: "DatabaseCredentialsSecretName",
Pvc: &chev2.PVC{
ClaimSize: "DatabaseClaimSize",
StorageClass: "DatabaseStorageClass",
},
},
PluginRegistry: chev2.PluginRegistry{
Deployment: &chev2.Deployment{
Containers: []chev2.Container{
@ -320,7 +290,6 @@ func TestRoundConvertCheClusterV2(t *testing.T) {
ChePhase: "Active",
Message: "Message",
Reason: "Reason",
PostgresVersion: "PostgresVersion",
},
}

View File

@ -45,10 +45,6 @@ func (dst *CheCluster) ConvertFrom(srcRaw conversion.Hub) error {
return err
}
if err := dst.convertFrom_Database(src); err != nil {
return err
}
if err := dst.convertFrom_DevWorkspace(src); err != nil {
return err
}
@ -349,38 +345,6 @@ func (dst *CheCluster) convertFrom_Auth(src *chev2.CheCluster) error {
return nil
}
func (dst *CheCluster) convertFrom_Database(src *chev2.CheCluster) error {
dst.Spec.Database.ExternalDb = src.Spec.Components.Database.ExternalDb
dst.Spec.Database.ChePostgresDb = src.Spec.Components.Database.PostgresDb
dst.Spec.Database.ChePostgresHostName = src.Spec.Components.Database.PostgresHostName
dst.Spec.Database.ChePostgresPort = src.Spec.Components.Database.PostgresPort
dst.Spec.Database.PostgresVersion = src.Status.PostgresVersion
if src.Spec.Components.Database.Pvc != nil {
dst.Spec.Database.PvcClaimSize = src.Spec.Components.Database.Pvc.ClaimSize
}
dst.Spec.Database.ChePostgresSecret = src.Spec.Components.Database.CredentialsSecretName
if src.Spec.Components.Database.Deployment != nil {
if len(src.Spec.Components.Database.Deployment.Containers) != 0 {
dst.Spec.Database.PostgresEnv = src.Spec.Components.Database.Deployment.Containers[0].Env
dst.Spec.Database.PostgresImage = src.Spec.Components.Database.Deployment.Containers[0].Image
dst.Spec.Database.PostgresImagePullPolicy = src.Spec.Components.Database.Deployment.Containers[0].ImagePullPolicy
if src.Spec.Components.Database.Deployment.Containers[0].Resources != nil {
if src.Spec.Components.Database.Deployment.Containers[0].Resources.Requests != nil {
dst.Spec.Database.ChePostgresContainerResources.Requests.Memory = resource2String(src.Spec.Components.Database.Deployment.Containers[0].Resources.Requests.Memory)
dst.Spec.Database.ChePostgresContainerResources.Requests.Cpu = resource2String(src.Spec.Components.Database.Deployment.Containers[0].Resources.Requests.Cpu)
}
if src.Spec.Components.Database.Deployment.Containers[0].Resources.Limits != nil {
dst.Spec.Database.ChePostgresContainerResources.Limits.Memory = resource2String(src.Spec.Components.Database.Deployment.Containers[0].Resources.Limits.Memory)
dst.Spec.Database.ChePostgresContainerResources.Limits.Cpu = resource2String(src.Spec.Components.Database.Deployment.Containers[0].Resources.Limits.Cpu)
}
}
}
}
return nil
}
func (dst *CheCluster) convertFrom_DevWorkspace(src *chev2.CheCluster) error {
if src.Spec.DevEnvironments.MaxNumberOfRunningWorkspacesPerUser != nil {
dst.Spec.DevWorkspace.RunningLimit = strconv.FormatInt(*src.Spec.DevEnvironments.MaxNumberOfRunningWorkspacesPerUser, 10)
@ -443,10 +407,6 @@ func (dst *CheCluster) convertFrom_Status(src *chev2.CheCluster) error {
}
func (dst *CheCluster) convertFrom_Storage(src *chev2.CheCluster) error {
if src.Spec.Components.Database.Pvc != nil {
dst.Spec.Storage.PostgresPVCStorageClassName = src.Spec.Components.Database.Pvc.StorageClass
}
dst.Spec.Storage.PvcStrategy = src.Spec.DevEnvironments.Storage.PvcStrategy
if src.Spec.DevEnvironments.Storage.PerUserStrategyPvcConfig != nil {
dst.Spec.Storage.PvcClaimSize = src.Spec.DevEnvironments.Storage.PerUserStrategyPvcConfig.ClaimSize

View File

@ -101,7 +101,6 @@ func (src *CheCluster) convertTo_GitServices(dst *chev2.CheCluster) error {
}
func (src *CheCluster) convertTo_Status(dst *chev2.CheCluster) error {
dst.Status.PostgresVersion = src.Spec.Database.PostgresVersion
dst.Status.CheURL = src.Status.CheURL
dst.Status.CheVersion = src.Status.CheVersion
dst.Status.DevfileRegistryURL = src.Status.DevfileRegistryURL
@ -267,10 +266,6 @@ func (src *CheCluster) convertTo_Components(dst *chev2.CheCluster) error {
return err
}
if err := src.convertTo_Components_Database(dst); err != nil {
return err
}
if err := src.convertTo_Components_Metrics(dst); err != nil {
return err
}
@ -433,42 +428,6 @@ func (src *CheCluster) convertTo_Components_DevfileRegistry(dst *chev2.CheCluste
return nil
}
func (src *CheCluster) convertTo_Components_Database(dst *chev2.CheCluster) error {
dst.Spec.Components.Database.CredentialsSecretName = src.Spec.Database.ChePostgresSecret
if src.Spec.Database.ChePostgresSecret == "" && src.Spec.Database.ChePostgresUser != "" && src.Spec.Database.ChePostgresPassword != "" {
if err := createCredentialsSecret(
src.Spec.Database.ChePostgresUser,
src.Spec.Database.ChePostgresPassword,
constants.DefaultPostgresCredentialsSecret,
src.ObjectMeta.Namespace); err != nil {
return err
}
dst.Spec.Components.Database.CredentialsSecretName = constants.DefaultPostgresCredentialsSecret
}
dst.Spec.Components.Database.Deployment = toCheV2Deployment(
constants.PostgresName,
src.Spec.Database.PostgresImage,
src.Spec.Database.PostgresImagePullPolicy,
src.Spec.Database.ChePostgresContainerResources.Requests.Memory,
src.Spec.Database.ChePostgresContainerResources.Limits.Memory,
src.Spec.Database.ChePostgresContainerResources.Requests.Cpu,
src.Spec.Database.ChePostgresContainerResources.Limits.Cpu,
nil,
nil,
src.Spec.Database.PostgresEnv,
)
dst.Spec.Components.Database.ExternalDb = src.Spec.Database.ExternalDb
dst.Spec.Components.Database.PostgresDb = src.Spec.Database.ChePostgresDb
dst.Spec.Components.Database.PostgresHostName = src.Spec.Database.ChePostgresHostName
dst.Spec.Components.Database.PostgresPort = src.Spec.Database.ChePostgresPort
dst.Spec.Components.Database.Pvc = toCheV2Pvc(src.Spec.Database.PvcClaimSize, src.Spec.Storage.PostgresPVCStorageClassName)
return nil
}
func (src *CheCluster) convertTo_Components_Dashboard(dst *chev2.CheCluster) error {
runAsUser, fsGroup, err := parseSecurityContext(src)
if err != nil {

View File

@ -43,7 +43,7 @@ type CheClusterSpec struct {
// +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"}}}
// +kubebuilder:default:={cheServer: {logLevel: INFO, debug: false}, metrics: {enable: true}}
Components CheClusterComponents `json:"components"`
// A configuration that allows users to work with remote Git repositories.
// +optional
@ -160,8 +160,9 @@ type CheClusterComponents struct {
// +optional
DevfileRegistry DevfileRegistry `json:"devfileRegistry"`
// Configuration settings related to the database used by the Che installation.
// Database component is Deprecated. All properties will be ignored.
// +optional
// +kubebuilder:default:={externalDb: false, credentialsSecretName: postgres-credentials, postgresHostName: postgres, postgresPort: "5432", postgresDb: dbche, pvc: {claimSize: "1Gi"}}
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors="urn:alm:descriptor:com.tectonic.ui:hidden"
Database Database `json:"database"`
// Configuration settings related to the dashboard used by the Che installation.
// +optional
@ -302,6 +303,7 @@ type DevfileRegistry struct {
ExternalDevfileRegistries []ExternalDevfileRegistry `json:"externalDevfileRegistries,omitempty"`
}
// Database component is Deprecated. All properties will be ignored.
// Configuration settings related to the database used by the Che installation.
// +k8s:openapi-gen=true
type Database struct {
@ -310,33 +312,27 @@ 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
Deployment *Deployment `json:"deployment,omitempty"`
// PostgreSQL database hostname that the Che server connects to.
// Override this value only when using an external database. See field `externalDb`.
// +kubebuilder:default:="postgres"
// +optional
PostgresHostName string `json:"postgresHostName,omitempty"`
// PostgreSQL Database port the Che server connects to.
// Override this value only when using an external database. See field `externalDb`.
// +optional
// +kubebuilder:default:="5432"
PostgresPort string `json:"postgresPort,omitempty"`
// PostgreSQL database name that the Che server uses to connect to the database.
// +optional
// +kubebuilder:default:="dbche"
PostgresDb string `json:"postgresDb,omitempty"`
// The secret that contains PostgreSQL `user` and `password` that the Che server uses to connect to the database.
// The secret must have a `app.kubernetes.io/part-of=che.eclipse.org` label.
// +optional
// +kubebuilder:default:="postgres-credentials"
CredentialsSecretName string `json:"credentialsSecretName,omitempty"`
// PVC settings for PostgreSQL database.
// +optional
// +kubebuilder:default:={claimSize: "1Gi"}
Pvc *PVC `json:"pvc,omitempty"`
}
@ -754,6 +750,7 @@ type CheClusterStatus struct {
// +operator-sdk:csv:customresourcedefinitions:type=status
// +operator-sdk:csv:customresourcedefinitions:type=status,displayName="PostgreSQL version"
// +operator-sdk:csv:customresourcedefinitions:type=status,xDescriptors="urn:alm:descriptor:text"
// +operator-sdk:csv:customresourcedefinitions:type=status,xDescriptors="urn:alm:descriptor:com.tectonic.ui:hidden"
PostgresVersion string `json:"postgresVersion,omitempty"`
// The resolved workspace base domain. This is either the copy of the explicitly defined property of the
// same name in the spec or, if it is undefined in the spec and we're running on OpenShift, the automatically

View File

@ -44,14 +44,6 @@ spec:
cpu: '50m'
limits:
cpu: '50m'
database:
deployment:
containers:
- resources:
request:
cpu: '50m'
limits:
cpu: '50m'
networking:
auth:
gateway:

View File

@ -59,7 +59,7 @@ runTest() {
CHECLUSTER_CR="${HELMCHART_DIR}"/templates/org_v2_checluster.yaml
yq -riY '.spec.components = null' ${CHECLUSTER_CR}
yq -riY '.spec.components.pluginRegistry.openVSXURL = "https://open-vsx.org"' ${CHECLUSTER_CR}
for component in pluginRegistry devfileRegistry database dashboard; do
for component in pluginRegistry devfileRegistry dashboard; do
yq -riY '.spec.components.'${component}'.deployment.containers[0].resources = {limits: {cpu: "50m"}, request: {cpu: "50m"}}' ${CHECLUSTER_CR}
done
yq -riY '.spec.components.cheServer.deployment.containers[0].resources.limits.cpu = "500m"' ${CHECLUSTER_CR}

View File

@ -77,7 +77,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.v7.61.0-764.next
name: eclipse-che.v7.62.0-765.next
namespace: placeholder
spec:
apiservicedefinitions: {}
@ -141,6 +141,13 @@ spec:
images.
displayName: Container registry
path: containerRegistry
- description: Configuration settings related to the database used by the
Che installation. Database component is Deprecated. All properties will
be ignored.
displayName: Database
path: components.database
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:hidden
- description: Enables users to work with repositories hosted on Azure DevOps
Service (dev.azure.com).
displayName: Azure
@ -225,6 +232,7 @@ spec:
path: postgresVersion
x-descriptors:
- urn:alm:descriptor:text
- urn:alm:descriptor:com.tectonic.ui:hidden
- description: A brief CamelCase message indicating details about why the
Che deployment is in the current phase.
displayName: Reason
@ -920,10 +928,6 @@ spec:
value: quay.io/eclipse/che-devfile-registry:next
- name: RELATED_IMAGE_che_tls_secrets_creation_job
value: quay.io/eclipse/che-tls-secret-creator:alpine-01a4c34
- name: RELATED_IMAGE_postgres
value: quay.io/eclipse/che--centos--postgresql-96-centos7:9.6-b681d78125361519180a6ac05242c296f8906c11eab7e207b5ca9a89b6344392
- name: RELATED_IMAGE_postgres_13_3
value: quay.io/eclipse/che--centos--postgresql-13-centos7:1-71b24684d64da46f960682cc4216222a7e4ed8b1a31dd5a865b3e71afdea20d2
- name: RELATED_IMAGE_single_host_gateway
value: quay.io/eclipse/che--traefik:v2.9.6-bb7be8d50edf73d8d3a812ac8873ef354a0fe9b40d7f3880747b43a3525855d2
- name: RELATED_IMAGE_single_host_gateway_config_sidecar
@ -950,8 +954,6 @@ spec:
value: /dashboard/assets/branding/loader.svg
- name: MAX_CONCURRENT_RECONCILES
value: "1"
- name: ADD_COMPONENT_READINESS_INIT_CONTAINERS
value: "false"
image: quay.io/eclipse/che-operator:next
imagePullPolicy: Always
livenessProbe:
@ -1231,7 +1233,7 @@ spec:
minKubeVersion: 1.19.0
provider:
name: Eclipse Foundation
version: 7.61.0-764.next
version: 7.62.0-765.next
webhookdefinitions:
- admissionReviewVersions:
- v1

View File

@ -4032,14 +4032,6 @@ spec:
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.
@ -4562,19 +4554,11 @@ 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.
used by the Che installation. Database component is Deprecated.
All properties will be ignored.
properties:
credentialsSecretName:
default: postgres-credentials
description: The secret that contains PostgreSQL `user`
and `password` that the Che server uses to connect to
the database. The secret must have a `app.kubernetes.io/part-of=che.eclipse.org`
@ -4794,7 +4778,6 @@ 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`
@ -4803,25 +4786,20 @@ spec:
about the external database you want to use.
type: boolean
postgresDb:
default: dbche
description: PostgreSQL database name that the Che server
uses to connect to the database.
type: string
postgresHostName:
default: postgres
description: PostgreSQL database hostname that the Che server
connects to. Override this value only when using an external
database. See field `externalDb`.
type: string
postgresPort:
default: "5432"
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:

View File

@ -3913,14 +3913,6 @@ spec:
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.
@ -4435,19 +4427,11 @@ 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.
by the Che installation. Database component is Deprecated. All
properties will be ignored.
properties:
credentialsSecretName:
default: postgres-credentials
description: The secret that contains PostgreSQL `user` and
`password` that the Che server uses to connect to the database.
The secret must have a `app.kubernetes.io/part-of=che.eclipse.org`
@ -4663,7 +4647,6 @@ 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`
@ -4672,25 +4655,20 @@ spec:
the external database you want to use.
type: boolean
postgresDb:
default: dbche
description: PostgreSQL database name that the Che server
uses to connect to the database.
type: string
postgresHostName:
default: postgres
description: PostgreSQL database hostname that the Che server
connects to. Override this value only when using an external
database. See field `externalDb`.
type: string
postgresPort:
default: "5432"
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:

View File

@ -71,10 +71,6 @@ spec:
value: quay.io/eclipse/che-devfile-registry:next
- name: RELATED_IMAGE_che_tls_secrets_creation_job
value: quay.io/eclipse/che-tls-secret-creator:alpine-01a4c34
- name: RELATED_IMAGE_postgres
value: quay.io/eclipse/che--centos--postgresql-96-centos7:9.6-b681d78125361519180a6ac05242c296f8906c11eab7e207b5ca9a89b6344392
- name: RELATED_IMAGE_postgres_13_3
value: quay.io/eclipse/che--centos--postgresql-13-centos7:1-71b24684d64da46f960682cc4216222a7e4ed8b1a31dd5a865b3e71afdea20d2
- name: RELATED_IMAGE_single_host_gateway
value: quay.io/eclipse/che--traefik:v2.9.6-bb7be8d50edf73d8d3a812ac8873ef354a0fe9b40d7f3880747b43a3525855d2
- name: RELATED_IMAGE_single_host_gateway_config_sidecar
@ -101,8 +97,6 @@ spec:
value: /dashboard/assets/branding/loader.svg
- name: MAX_CONCURRENT_RECONCILES
value: "1"
- name: ADD_COMPONENT_READINESS_INIT_CONTAINERS
value: "false"
livenessProbe:
httpGet:
path: /healthz

View File

@ -88,6 +88,12 @@ spec:
- description: Configuration of an alternative registry that stores Che images.
displayName: Container registry
path: containerRegistry
- description: Configuration settings related to the database used by the Che
installation. Database component is Deprecated. All properties will be ignored.
displayName: Database
path: components.database
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:hidden
- description: Enables users to work with repositories hosted on Azure DevOps
Service (dev.azure.com).
displayName: Azure
@ -172,6 +178,7 @@ spec:
path: postgresVersion
x-descriptors:
- urn:alm:descriptor:text
- urn:alm:descriptor:com.tectonic.ui:hidden
- description: A brief CamelCase message indicating details about why the Che
deployment is in the current phase.
displayName: Reason

View File

@ -3932,14 +3932,6 @@ spec:
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.
@ -4454,19 +4446,11 @@ 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.
by the Che installation. Database component is Deprecated. All
properties will be ignored.
properties:
credentialsSecretName:
default: postgres-credentials
description: The secret that contains PostgreSQL `user` and
`password` that the Che server uses to connect to the database.
The secret must have a `app.kubernetes.io/part-of=che.eclipse.org`
@ -4682,7 +4666,6 @@ 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`
@ -4691,25 +4674,20 @@ spec:
the external database you want to use.
type: boolean
postgresDb:
default: dbche
description: PostgreSQL database name that the Che server
uses to connect to the database.
type: string
postgresHostName:
default: postgres
description: PostgreSQL database hostname that the Che server
connects to. Override this value only when using an external
database. See field `externalDb`.
type: string
postgresPort:
default: "5432"
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:
@ -8176,10 +8154,6 @@ spec:
value: quay.io/eclipse/che-devfile-registry:next
- name: RELATED_IMAGE_che_tls_secrets_creation_job
value: quay.io/eclipse/che-tls-secret-creator:alpine-01a4c34
- name: RELATED_IMAGE_postgres
value: quay.io/eclipse/che--centos--postgresql-96-centos7:9.6-b681d78125361519180a6ac05242c296f8906c11eab7e207b5ca9a89b6344392
- name: RELATED_IMAGE_postgres_13_3
value: quay.io/eclipse/che--centos--postgresql-13-centos7:1-71b24684d64da46f960682cc4216222a7e4ed8b1a31dd5a865b3e71afdea20d2
- name: RELATED_IMAGE_single_host_gateway
value: quay.io/eclipse/che--traefik:v2.9.6-bb7be8d50edf73d8d3a812ac8873ef354a0fe9b40d7f3880747b43a3525855d2
- name: RELATED_IMAGE_single_host_gateway_config_sidecar
@ -8206,8 +8180,6 @@ spec:
value: /dashboard/assets/branding/loader.svg
- name: MAX_CONCURRENT_RECONCILES
value: "1"
- name: ADD_COMPONENT_READINESS_INIT_CONTAINERS
value: "false"
image: quay.io/eclipse/che-operator:next
imagePullPolicy: Always
livenessProbe:

View File

@ -65,10 +65,6 @@ spec:
value: quay.io/eclipse/che-devfile-registry:next
- name: RELATED_IMAGE_che_tls_secrets_creation_job
value: quay.io/eclipse/che-tls-secret-creator:alpine-01a4c34
- name: RELATED_IMAGE_postgres
value: quay.io/eclipse/che--centos--postgresql-96-centos7:9.6-b681d78125361519180a6ac05242c296f8906c11eab7e207b5ca9a89b6344392
- name: RELATED_IMAGE_postgres_13_3
value: quay.io/eclipse/che--centos--postgresql-13-centos7:1-71b24684d64da46f960682cc4216222a7e4ed8b1a31dd5a865b3e71afdea20d2
- name: RELATED_IMAGE_single_host_gateway
value: quay.io/eclipse/che--traefik:v2.9.6-bb7be8d50edf73d8d3a812ac8873ef354a0fe9b40d7f3880747b43a3525855d2
- name: RELATED_IMAGE_single_host_gateway_config_sidecar
@ -95,8 +91,6 @@ spec:
value: /dashboard/assets/branding/loader.svg
- name: MAX_CONCURRENT_RECONCILES
value: "1"
- name: ADD_COMPONENT_READINESS_INIT_CONTAINERS
value: "false"
image: quay.io/eclipse/che-operator:next
imagePullPolicy: Always
livenessProbe:

View File

@ -3927,14 +3927,6 @@ spec:
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.
@ -4449,19 +4441,11 @@ 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.
by the Che installation. Database component is Deprecated. All
properties will be ignored.
properties:
credentialsSecretName:
default: postgres-credentials
description: The secret that contains PostgreSQL `user` and
`password` that the Che server uses to connect to the database.
The secret must have a `app.kubernetes.io/part-of=che.eclipse.org`
@ -4677,7 +4661,6 @@ 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`
@ -4686,25 +4669,20 @@ spec:
the external database you want to use.
type: boolean
postgresDb:
default: dbche
description: PostgreSQL database name that the Che server
uses to connect to the database.
type: string
postgresHostName:
default: postgres
description: PostgreSQL database hostname that the Che server
connects to. Override this value only when using an external
database. See field `externalDb`.
type: string
postgresPort:
default: "5432"
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:

View File

@ -3932,14 +3932,6 @@ spec:
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.
@ -4454,19 +4446,11 @@ 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.
by the Che installation. Database component is Deprecated. All
properties will be ignored.
properties:
credentialsSecretName:
default: postgres-credentials
description: The secret that contains PostgreSQL `user` and
`password` that the Che server uses to connect to the database.
The secret must have a `app.kubernetes.io/part-of=che.eclipse.org`
@ -4682,7 +4666,6 @@ 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`
@ -4691,25 +4674,20 @@ spec:
the external database you want to use.
type: boolean
postgresDb:
default: dbche
description: PostgreSQL database name that the Che server
uses to connect to the database.
type: string
postgresHostName:
default: postgres
description: PostgreSQL database hostname that the Che server
connects to. Override this value only when using an external
database. See field `externalDb`.
type: string
postgresPort:
default: "5432"
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:
@ -8178,10 +8156,6 @@ spec:
value: quay.io/eclipse/che-devfile-registry:next
- name: RELATED_IMAGE_che_tls_secrets_creation_job
value: quay.io/eclipse/che-tls-secret-creator:alpine-01a4c34
- name: RELATED_IMAGE_postgres
value: quay.io/eclipse/che--centos--postgresql-96-centos7:9.6-b681d78125361519180a6ac05242c296f8906c11eab7e207b5ca9a89b6344392
- name: RELATED_IMAGE_postgres_13_3
value: quay.io/eclipse/che--centos--postgresql-13-centos7:1-71b24684d64da46f960682cc4216222a7e4ed8b1a31dd5a865b3e71afdea20d2
- name: RELATED_IMAGE_single_host_gateway
value: quay.io/eclipse/che--traefik:v2.9.6-bb7be8d50edf73d8d3a812ac8873ef354a0fe9b40d7f3880747b43a3525855d2
- name: RELATED_IMAGE_single_host_gateway_config_sidecar
@ -8208,8 +8182,6 @@ spec:
value: /dashboard/assets/branding/loader.svg
- name: MAX_CONCURRENT_RECONCILES
value: "1"
- name: ADD_COMPONENT_READINESS_INIT_CONTAINERS
value: "false"
image: quay.io/eclipse/che-operator:next
imagePullPolicy: Always
livenessProbe:

View File

@ -65,10 +65,6 @@ spec:
value: quay.io/eclipse/che-devfile-registry:next
- name: RELATED_IMAGE_che_tls_secrets_creation_job
value: quay.io/eclipse/che-tls-secret-creator:alpine-01a4c34
- name: RELATED_IMAGE_postgres
value: quay.io/eclipse/che--centos--postgresql-96-centos7:9.6-b681d78125361519180a6ac05242c296f8906c11eab7e207b5ca9a89b6344392
- name: RELATED_IMAGE_postgres_13_3
value: quay.io/eclipse/che--centos--postgresql-13-centos7:1-71b24684d64da46f960682cc4216222a7e4ed8b1a31dd5a865b3e71afdea20d2
- name: RELATED_IMAGE_single_host_gateway
value: quay.io/eclipse/che--traefik:v2.9.6-bb7be8d50edf73d8d3a812ac8873ef354a0fe9b40d7f3880747b43a3525855d2
- name: RELATED_IMAGE_single_host_gateway_config_sidecar
@ -95,8 +91,6 @@ spec:
value: /dashboard/assets/branding/loader.svg
- name: MAX_CONCURRENT_RECONCILES
value: "1"
- name: ADD_COMPONENT_READINESS_INIT_CONTAINERS
value: "false"
image: quay.io/eclipse/che-operator:next
imagePullPolicy: Always
livenessProbe:

View File

@ -3927,14 +3927,6 @@ spec:
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.
@ -4449,19 +4441,11 @@ 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.
by the Che installation. Database component is Deprecated. All
properties will be ignored.
properties:
credentialsSecretName:
default: postgres-credentials
description: The secret that contains PostgreSQL `user` and
`password` that the Che server uses to connect to the database.
The secret must have a `app.kubernetes.io/part-of=che.eclipse.org`
@ -4677,7 +4661,6 @@ 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`
@ -4686,25 +4669,20 @@ spec:
the external database you want to use.
type: boolean
postgresDb:
default: dbche
description: PostgreSQL database name that the Che server
uses to connect to the database.
type: string
postgresHostName:
default: postgres
description: PostgreSQL database hostname that the Che server
connects to. Override this value only when using an external
database. See field `externalDb`.
type: string
postgresPort:
default: "5432"
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:

View File

@ -3927,14 +3927,6 @@ spec:
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.
@ -4449,19 +4441,11 @@ 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.
by the Che installation. Database component is Deprecated. All
properties will be ignored.
properties:
credentialsSecretName:
default: postgres-credentials
description: The secret that contains PostgreSQL `user` and
`password` that the Che server uses to connect to the database.
The secret must have a `app.kubernetes.io/part-of=che.eclipse.org`
@ -4677,7 +4661,6 @@ 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`
@ -4686,25 +4669,20 @@ spec:
the external database you want to use.
type: boolean
postgresDb:
default: dbche
description: PostgreSQL database name that the Che server
uses to connect to the database.
type: string
postgresHostName:
default: postgres
description: PostgreSQL database hostname that the Che server
connects to. Override this value only when using an external
database. See field `externalDb`.
type: string
postgresPort:
default: "5432"
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:

View File

@ -65,10 +65,6 @@ spec:
value: quay.io/eclipse/che-devfile-registry:next
- name: RELATED_IMAGE_che_tls_secrets_creation_job
value: quay.io/eclipse/che-tls-secret-creator:alpine-01a4c34
- name: RELATED_IMAGE_postgres
value: quay.io/eclipse/che--centos--postgresql-96-centos7:9.6-b681d78125361519180a6ac05242c296f8906c11eab7e207b5ca9a89b6344392
- name: RELATED_IMAGE_postgres_13_3
value: quay.io/eclipse/che--centos--postgresql-13-centos7:1-71b24684d64da46f960682cc4216222a7e4ed8b1a31dd5a865b3e71afdea20d2
- name: RELATED_IMAGE_single_host_gateway
value: quay.io/eclipse/che--traefik:v2.9.6-bb7be8d50edf73d8d3a812ac8873ef354a0fe9b40d7f3880747b43a3525855d2
- name: RELATED_IMAGE_single_host_gateway_config_sidecar
@ -95,8 +91,6 @@ spec:
value: /dashboard/assets/branding/loader.svg
- name: MAX_CONCURRENT_RECONCILES
value: "1"
- name: ADD_COMPONENT_READINESS_INIT_CONTAINERS
value: "false"
image: quay.io/eclipse/che-operator:next
imagePullPolicy: Always
livenessProbe:

View File

@ -18,19 +18,6 @@ import (
)
const (
// PostgresSQL
DefaultPostgresUser = "pgche"
DefaultPostgresHostName = "postgres"
DefaultPostgresPort = "5432"
DefaultPostgresDb = "dbche"
DefaultPostgresMemoryLimit = "1024Mi"
DefaultPostgresMemoryRequest = "512Mi"
DefaultPostgresCpuLimit = "500m"
DefaultPostgresCpuRequest = "100m"
DefaultPostgresCredentialsSecret = "postgres-credentials"
DefaultPostgresVolumeClaimName = "postgres-data"
DefaultPostgresPvcClaimSize = "1Gi"
// Dashboard
DefaultDashboardMemoryLimit = "256Mi"
DefaultDashboardMemoryRequest = "32Mi"
@ -127,7 +114,6 @@ const (
// components name
DevfileRegistryName = "devfile-registry"
PluginRegistryName = "plugin-registry"
PostgresName = "postgres"
GatewayContainerName = "gateway"
GatewayConfigSideCarContainerName = "configbump"
GatewayAuthenticationContainerName = "oauth-proxy"

View File

@ -18,6 +18,9 @@ import (
"io"
"os"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
fakeclient "sigs.k8s.io/controller-runtime/pkg/client/fake"
@ -25,8 +28,6 @@ import (
"k8s.io/client-go/kubernetes/fake"
"github.com/sirupsen/logrus"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/tools/remotecommand"
@ -62,63 +63,6 @@ func (cl *K8sHelper) GetClient() client.Client {
return cl.client
}
func (cl *K8sHelper) ExecIntoPod(
deploymentName string,
command string,
reason string,
namespace string) (string, error) {
pod, err := cl.GetDeploymentPod(deploymentName, namespace)
if err != nil {
return "", err
}
return cl.DoExecIntoPod(namespace, pod, command, reason)
}
func (cl *K8sHelper) DoExecIntoPod(namespace string, podName string, command string, reason string) (string, error) {
var stdin io.Reader
return cl.DoExecIntoPodWithStdin(namespace, podName, command, stdin, reason)
}
func (cl *K8sHelper) DoExecIntoPodWithStdin(namespace string, podName string, command string, stdin io.Reader, reason string) (string, error) {
if reason != "" {
logrus.Infof("Running exec for '%s' in the pod '%s'", reason, podName)
}
args := []string{"/bin/bash", "-c", command}
stdout, stderr, err := cl.RunExec(args, podName, namespace, stdin)
if err != nil {
logrus.Errorf("Error running exec: %v, command: %s", err, args)
if stderr != "" {
logrus.Errorf("Stderr: %s", stderr)
}
return stdout, err
}
if reason != "" {
logrus.Info("Exec successfully completed.")
}
return stdout, nil
}
//GetDeploymentPod queries all pods is a selected namespace by LabelSelector
func (cl *K8sHelper) GetDeploymentPod(name string, ns string) (podName string, err error) {
api := cl.clientset.CoreV1()
listOptions := metav1.ListOptions{
LabelSelector: "component=" + name,
}
podList, _ := api.Pods(ns).List(context.TODO(), listOptions)
podListItems := podList.Items
if len(podListItems) == 0 {
logrus.Errorf("Failed to find pod for component %s. List of pods: %v", name, podListItems)
return "", err
}
// expecting only one pod to be there so, taking the first one
// todo maybe add a unique label to deployments?
podName = podListItems[0].Name
return podName, nil
}
func (cl *K8sHelper) GetPodsByComponent(name string, ns string) []string {
names := []string{}
api := cl.clientset.CoreV1()

View File

@ -31,8 +31,6 @@ var (
defaultPluginRegistryImage string
defaultDevfileRegistryImage string
defaultCheTLSSecretsCreationJobImage string
defaultPostgresImage string
defaultPostgres13Image string
defaultSingleHostGatewayImage string
defaultSingleHostGatewayConfigSidecarImage string
defaultGatewayAuthenticationSidecarImage string
@ -77,12 +75,6 @@ func Initialize() {
defaultDashboardImage = ensureEnv(util.GetArchitectureDependentEnvName("RELATED_IMAGE_dashboard"))
defaultPluginRegistryImage = ensureEnv(util.GetArchitectureDependentEnvName("RELATED_IMAGE_plugin_registry"))
defaultDevfileRegistryImage = ensureEnv(util.GetArchitectureDependentEnvName("RELATED_IMAGE_devfile_registry"))
defaultPostgresImage = ensureEnv(util.GetArchitectureDependentEnvName("RELATED_IMAGE_postgres"))
// allow not to set env variable into a container
// while downstream is not migrated to PostgreSQL 13.3 yet
defaultPostgres13Image = os.Getenv(util.GetArchitectureDependentEnvName("RELATED_IMAGE_postgres_13_3"))
defaultSingleHostGatewayImage = ensureEnv(util.GetArchitectureDependentEnvName("RELATED_IMAGE_single_host_gateway"))
defaultSingleHostGatewayConfigSidecarImage = ensureEnv(util.GetArchitectureDependentEnvName("RELATED_IMAGE_single_host_gateway_config_sidecar"))
defaultGatewayAuthenticationSidecarImage = ensureEnv(util.GetArchitectureDependentEnvName("RELATED_IMAGE_gateway_authentication_sidecar"))
@ -131,22 +123,6 @@ func GetCheVersion() string {
return defaultCheVersion
}
func GetPostgresImage(checluster *chev2.CheCluster) string {
if !initialized {
logrus.Fatalf("Operator defaults are not initialized.")
}
return PatchDefaultImageName(checluster, defaultPostgresImage)
}
func GetPostgres13Image(checluster *chev2.CheCluster) string {
if !initialized {
logrus.Fatalf("Operator defaults are not initialized.")
}
return PatchDefaultImageName(checluster, defaultPostgres13Image)
}
func GetDashboardImage(checluster *chev2.CheCluster) string {
if !initialized {
logrus.Fatalf("Operator defaults are not initialized.")
@ -235,10 +211,6 @@ func GetCheFlavor() string {
return defaultCheFlavor
}
func IsComponentReadinessInitContainersConfigured() bool {
return os.Getenv("ADD_COMPONENT_READINESS_INIT_CONTAINERS") == "true"
}
func GetConsoleLinkName() string {
if !initialized {
logrus.Fatalf("Operator defaults are not initialized.")

View File

@ -42,10 +42,10 @@ func TestCorrectAirGapPatchedImage(t *testing.T) {
}
var (
airGapRegistryHostname = "myregistry.org"
airGapRegistryOrganization = "myorg"
expectedAirGapPostgresUpstreamImage = makeAirGapImagePath(airGapRegistryHostname, airGapRegistryOrganization, getImageNameFromFullImage(defaultPostgresImage))
expectedAirGapPostgresUpstreamImageOnlyOrgChanged = makeAirGapImagePath(getHostnameFromImage(defaultPostgresImage), airGapRegistryOrganization, getImageNameFromFullImage(defaultPostgresImage))
airGapRegistryHostname = "myregistry.org"
airGapRegistryOrganization = "myorg"
expectedAirGapServerUpstreamImage = makeAirGapImagePath(airGapRegistryHostname, airGapRegistryOrganization, getImageNameFromFullImage(defaultCheServerImage))
expectedAirGapServerUpstreamImageOnlyOrgChanged = makeAirGapImagePath(getHostnameFromImage(defaultCheServerImage), airGapRegistryOrganization, getImageNameFromFullImage(defaultCheServerImage))
)
upstream := &chev2.CheCluster{}
@ -66,9 +66,9 @@ func TestCorrectAirGapPatchedImage(t *testing.T) {
}
testCases := map[string]testcase{
"default postgres": {image: defaultPostgresImage, expected: defaultPostgresImage, cr: upstream},
"airgap postgres": {image: defaultPostgresImage, expected: expectedAirGapPostgresUpstreamImage, cr: airGapUpstream},
"with only the org changed": {image: defaultPostgresImage, expected: expectedAirGapPostgresUpstreamImageOnlyOrgChanged, cr: upstreamOnlyOrg},
"default che-server": {image: defaultCheServerImage, expected: defaultCheServerImage, cr: upstream},
"airgap che-server": {image: defaultCheServerImage, expected: expectedAirGapServerUpstreamImage, cr: airGapUpstream},
"with only the org changed": {image: defaultCheServerImage, expected: expectedAirGapServerUpstreamImageOnlyOrgChanged, cr: upstreamOnlyOrg},
}
for name, tc := range testCases {
t.Run(name, func(*testing.T) {

View File

@ -93,7 +93,6 @@ func (m *Migrator) migrate(ctx *chetypes.DeployContext) (bool, error) {
// - spec.server.cheWorkspaceClusterRole
// - spec.server.serverTrustStoreConfigMapName
// - spec.server.proxy.credentialssecretname
// - spec.database.credentialssecretname
// - spec.networking.tlsSecretName
// Note, most of the objects above are autogenerated and do not require any migration,
// but to handle the case when some were created manually or operator updated, the check is done here.
@ -119,12 +118,6 @@ func addPartOfCheLabeltoUserDefinedObjects(ctx *chetypes.DeployContext) error {
}
}
// Database credentials
chePostgresCredentialsSecret := utils.GetValue(ctx.CheCluster.Spec.Components.Database.CredentialsSecretName, constants.DefaultPostgresCredentialsSecret)
if err := addPartOfCheLabelToSecret(ctx, chePostgresCredentialsSecret); err != nil {
return err
}
// Legacy config map with additional CA certificates
if err := addPartOfCheLabelToConfigMap(ctx, constants.DefaultServerTrustStoreConfigMapName); err != nil {
return err

View File

@ -1,25 +0,0 @@
//
// Copyright (c) 2019-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 postgres
import (
"github.com/devfile/devworkspace-operator/pkg/infrastructure"
defaults "github.com/eclipse-che/che-operator/pkg/common/operator-defaults"
"github.com/eclipse-che/che-operator/pkg/common/test"
)
func init() {
test.EnableTestMode()
infrastructure.InitializeForTesting(infrastructure.OpenShiftv4)
defaults.InitializeForTesting("../../../config/manager/manager.yaml")
}

View File

@ -12,22 +12,21 @@
package postgres
import (
"strings"
chev2 "github.com/eclipse-che/che-operator/api/v2"
"github.com/eclipse-che/che-operator/pkg/common/chetypes"
"github.com/eclipse-che/che-operator/pkg/common/constants"
k8shelper "github.com/eclipse-che/che-operator/pkg/common/k8s-helper"
"github.com/eclipse-che/che-operator/pkg/common/test"
"github.com/eclipse-che/che-operator/pkg/common/utils"
"github.com/eclipse-che/che-operator/pkg/deploy"
"github.com/sirupsen/logrus"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
)
const (
defaultPostgresCredentialsSecret = "postgres-credentials"
defaultPostgresVolumeClaimName = "postgres-data"
postgresComponentName = "postgres"
backupServerComponentName = "backup-rest-server-deployment"
)
type PostgresReconciler struct {
deploy.Reconcilable
}
@ -37,38 +36,15 @@ func NewPostgresReconciler() *PostgresReconciler {
}
func (p *PostgresReconciler) Reconcile(ctx *chetypes.DeployContext) (reconcile.Result, bool, error) {
if ctx.CheCluster.Spec.Components.Database.ExternalDb {
return reconcile.Result{}, true, nil
}
// PostgreSQL component is not used anymore
_, _ = p.syncDeployment(ctx)
_, _ = p.syncPVC(ctx)
_, _ = p.syncCredentials(ctx)
_, _ = p.syncService(ctx)
_, _ = p.setDbVersion(ctx)
done, err := p.syncCredentials(ctx)
if !done {
return reconcile.Result{}, false, err
}
done, err = p.syncService(ctx)
if !done {
return reconcile.Result{}, false, err
}
done, err = p.syncPVC(ctx)
if !done {
return reconcile.Result{}, false, err
}
done, err = p.syncDeployment(ctx)
if !done {
return reconcile.Result{}, false, err
}
if ctx.CheCluster.Status.PostgresVersion == "" {
if !test.IsTestMode() { // ignore in tests
done, err := p.setDbVersion(ctx)
if !done {
return reconcile.Result{}, false, err
}
}
}
// Backup server component is not used anymore
_, _ = p.syncBackupDeployment(ctx)
return reconcile.Result{}, true, nil
}
@ -78,83 +54,30 @@ func (p *PostgresReconciler) Finalize(ctx *chetypes.DeployContext) bool {
}
func (p *PostgresReconciler) syncService(ctx *chetypes.DeployContext) (bool, error) {
return deploy.SyncServiceToCluster(ctx, constants.PostgresName, []string{constants.PostgresName}, []int32{5432}, constants.PostgresName)
return deploy.DeleteNamespacedObject(ctx, postgresComponentName, &corev1.Service{})
}
func (p *PostgresReconciler) syncPVC(ctx *chetypes.DeployContext) (bool, error) {
pvc := &chev2.PVC{
ClaimSize: constants.DefaultPostgresPvcClaimSize,
}
if ctx.CheCluster.Spec.Components.Database.Pvc != nil {
pvc.StorageClass = ctx.CheCluster.Spec.Components.Database.Pvc.StorageClass
if ctx.CheCluster.Spec.Components.Database.Pvc.ClaimSize != "" {
pvc.ClaimSize = ctx.CheCluster.Spec.Components.Database.Pvc.ClaimSize
}
}
done, err := deploy.SyncPVCToCluster(ctx, constants.DefaultPostgresVolumeClaimName, pvc, constants.PostgresName)
if !done {
if err == nil {
logrus.Infof("Waiting on pvc '%s' to be bound. Sometimes PVC can be bound only when the first consumer is created.", constants.DefaultPostgresVolumeClaimName)
}
}
return done, err
return deploy.DeleteNamespacedObject(ctx, defaultPostgresVolumeClaimName, &corev1.PersistentVolumeClaim{})
}
func (p *PostgresReconciler) syncDeployment(ctx *chetypes.DeployContext) (bool, error) {
clusterDeployment := &appsv1.Deployment{}
exists, err := deploy.GetNamespacedObject(ctx, constants.PostgresName, clusterDeployment)
if err != nil {
return false, err
}
if !exists {
clusterDeployment = nil
}
specDeployment, err := p.getDeploymentSpec(clusterDeployment, ctx)
if err != nil {
return false, err
}
return deploy.SyncDeploymentSpecToCluster(ctx, specDeployment, deploy.DefaultDeploymentDiffOpts)
return deploy.DeleteNamespacedObject(ctx, postgresComponentName, &appsv1.Deployment{})
}
func (p *PostgresReconciler) setDbVersion(ctx *chetypes.DeployContext) (bool, error) {
k8sHelper := k8shelper.New()
postgresVersion, err := k8sHelper.ExecIntoPod(
constants.PostgresName,
"postgres -V | awk '{print $NF}' | cut -d '.' -f1-2",
"get PostgreSQL version",
ctx.CheCluster.Namespace)
if err != nil {
return false, err
if ctx.CheCluster.Status.PostgresVersion != "" {
ctx.CheCluster.Status.PostgresVersion = ""
_ = deploy.UpdateCheCRStatus(ctx, "postgresVersion", ctx.CheCluster.Status.PostgresVersion)
}
postgresVersion = strings.TrimSpace(postgresVersion)
ctx.CheCluster.Status.PostgresVersion = postgresVersion
err = deploy.UpdateCheCRStatus(ctx, "postgresVersion", postgresVersion)
if err != nil {
return false, err
}
return true, nil
}
// Create secret with PostgreSQL credentials.
func (p *PostgresReconciler) syncCredentials(ctx *chetypes.DeployContext) (bool, error) {
postgresCredentialsSecretName := utils.GetValue(ctx.CheCluster.Spec.Components.Database.CredentialsSecretName, constants.DefaultPostgresCredentialsSecret)
exists, err := deploy.GetNamespacedObject(ctx, postgresCredentialsSecretName, &corev1.Secret{})
if err != nil {
return false, err
}
if !exists {
postgresUser := constants.DefaultPostgresUser
postgresPassword := utils.GeneratePassword(12)
return deploy.SyncSecretToCluster(ctx, postgresCredentialsSecretName, ctx.CheCluster.Namespace, map[string][]byte{"user": []byte(postgresUser), "password": []byte(postgresPassword)})
}
return true, nil
postgresCredentialsSecretName := utils.GetValue(ctx.CheCluster.Spec.Components.Database.CredentialsSecretName, defaultPostgresCredentialsSecret)
return deploy.DeleteNamespacedObject(ctx, postgresCredentialsSecretName, &corev1.Secret{})
}
func (p *PostgresReconciler) syncBackupDeployment(ctx *chetypes.DeployContext) (bool, error) {
return deploy.DeleteNamespacedObject(ctx, backupServerComponentName, &appsv1.Deployment{})
}

View File

@ -1,221 +0,0 @@
//
// Copyright (c) 2019-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 postgres
import (
"fmt"
"strings"
chev2 "github.com/eclipse-che/che-operator/api/v2"
"github.com/eclipse-che/che-operator/pkg/common/chetypes"
"github.com/eclipse-che/che-operator/pkg/common/constants"
defaults "github.com/eclipse-che/che-operator/pkg/common/operator-defaults"
"github.com/eclipse-che/che-operator/pkg/common/utils"
"github.com/eclipse-che/che-operator/pkg/deploy"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
)
const (
PostgresVersion9_6 = "9.6"
PostgresVersion13_3 = "13.3"
)
var (
postgresAdminPassword = utils.GeneratePassword(12)
)
func (p *PostgresReconciler) getDeploymentSpec(clusterDeployment *appsv1.Deployment, ctx *chetypes.DeployContext) (*appsv1.Deployment, error) {
terminationGracePeriodSeconds := int64(30)
labels, labelSelector := deploy.GetLabelsAndSelector(constants.PostgresName)
chePostgresDb := utils.GetValue(ctx.CheCluster.Spec.Components.Database.PostgresDb, constants.DefaultPostgresDb)
postgresImage, err := getPostgresImage(clusterDeployment, ctx.CheCluster)
if err != nil {
return nil, err
}
pullPolicy := corev1.PullPolicy(utils.GetPullPolicyFromDockerImage(postgresImage))
if clusterDeployment != nil {
clusterContainer := &clusterDeployment.Spec.Template.Spec.Containers[0]
value := utils.GetEnvByName("POSTGRESQL_ADMIN_PASSWORD", clusterContainer.Env)
if value != "" {
postgresAdminPassword = value
}
}
deployment := &appsv1.Deployment{
TypeMeta: metav1.TypeMeta{
Kind: "Deployment",
APIVersion: "apps/v1",
},
ObjectMeta: metav1.ObjectMeta{
Name: constants.PostgresName,
Namespace: ctx.CheCluster.Namespace,
Labels: labels,
},
Spec: appsv1.DeploymentSpec{
Selector: &metav1.LabelSelector{MatchLabels: labelSelector},
Strategy: appsv1.DeploymentStrategy{
Type: appsv1.DeploymentStrategyType("Recreate"),
},
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: labels,
},
Spec: corev1.PodSpec{
Volumes: []corev1.Volume{
{
Name: constants.DefaultPostgresVolumeClaimName,
VolumeSource: corev1.VolumeSource{
PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{
ClaimName: constants.DefaultPostgresVolumeClaimName,
},
},
},
},
Containers: []corev1.Container{
{
Name: constants.PostgresName,
Image: postgresImage,
ImagePullPolicy: pullPolicy,
Ports: []corev1.ContainerPort{
{
Name: constants.PostgresName,
ContainerPort: 5432,
Protocol: "TCP",
},
},
Resources: corev1.ResourceRequirements{
Requests: corev1.ResourceList{
corev1.ResourceMemory: resource.MustParse(constants.DefaultPostgresMemoryRequest),
corev1.ResourceCPU: resource.MustParse(constants.DefaultPostgresCpuRequest),
},
Limits: corev1.ResourceList{
corev1.ResourceMemory: resource.MustParse(constants.DefaultPostgresMemoryLimit),
corev1.ResourceCPU: resource.MustParse(constants.DefaultPostgresCpuLimit),
},
},
VolumeMounts: []corev1.VolumeMount{
{
Name: constants.DefaultPostgresVolumeClaimName,
MountPath: "/var/lib/pgsql/data",
},
},
ReadinessProbe: &corev1.Probe{
Handler: corev1.Handler{
Exec: &corev1.ExecAction{
Command: []string{
"/bin/sh",
"-i",
"-c",
"psql -h 127.0.0.1 -U $POSTGRESQL_USER -q -d " + chePostgresDb + " -c 'SELECT 1'",
},
},
},
InitialDelaySeconds: 15,
FailureThreshold: 10,
SuccessThreshold: 1,
PeriodSeconds: 10,
TimeoutSeconds: 5,
},
LivenessProbe: &corev1.Probe{
Handler: corev1.Handler{
TCPSocket: &corev1.TCPSocketAction{
Port: intstr.FromInt(5432),
},
},
InitialDelaySeconds: 30,
FailureThreshold: 10,
SuccessThreshold: 1,
PeriodSeconds: 10,
TimeoutSeconds: 5,
},
Env: []corev1.EnvVar{
{
Name: "POSTGRESQL_DATABASE",
Value: chePostgresDb,
},
{
Name: "POSTGRESQL_ADMIN_PASSWORD",
Value: postgresAdminPassword,
},
}},
},
TerminationGracePeriodSeconds: &terminationGracePeriodSeconds,
RestartPolicy: "Always",
},
},
},
}
container := &deployment.Spec.Template.Spec.Containers[0]
chePostgresCredentialsSecret := utils.GetValue(ctx.CheCluster.Spec.Components.Database.CredentialsSecretName, constants.DefaultPostgresCredentialsSecret)
container.Env = append(container.Env,
corev1.EnvVar{
Name: "POSTGRESQL_USER",
ValueFrom: &corev1.EnvVarSource{
SecretKeyRef: &corev1.SecretKeySelector{
Key: "user",
LocalObjectReference: corev1.LocalObjectReference{
Name: chePostgresCredentialsSecret,
},
},
},
}, corev1.EnvVar{
Name: "POSTGRESQL_PASSWORD",
ValueFrom: &corev1.EnvVarSource{
SecretKeyRef: &corev1.SecretKeySelector{
Key: "password",
LocalObjectReference: corev1.LocalObjectReference{
Name: chePostgresCredentialsSecret,
},
},
},
})
deploy.EnsurePodSecurityStandards(deployment, 26, 26)
deploy.CustomizeDeployment(deployment, ctx.CheCluster.Spec.Components.Database.Deployment)
return deployment, nil
}
func getPostgresImage(clusterDeployment *appsv1.Deployment, cheCluster *chev2.CheCluster) (string, error) {
if cheCluster.Spec.Components.Database.Deployment != nil &&
len(cheCluster.Spec.Components.Database.Deployment.Containers) > 0 &&
cheCluster.Spec.Components.Database.Deployment.Containers[0].Image != "" {
// use image explicitly set in a CR
return cheCluster.Spec.Components.Database.Deployment.Containers[0].Image, nil
} else if cheCluster.Status.PostgresVersion == PostgresVersion9_6 {
return defaults.GetPostgresImage(cheCluster), nil
} else if strings.HasPrefix(cheCluster.Status.PostgresVersion, "13.") {
return defaults.GetPostgres13Image(cheCluster), nil
} else if cheCluster.Status.PostgresVersion == "" {
if clusterDeployment == nil {
// Use PostgreSQL 13.3 for a new deployment if there is so.
// It allows to work in downstream until a new image is ready for production.
postgres13Image := defaults.GetPostgres13Image(cheCluster)
if postgres13Image != "" {
return postgres13Image, nil
} else {
return defaults.GetPostgresImage(cheCluster), nil
}
} else {
// Keep using current image
return clusterDeployment.Spec.Template.Spec.Containers[0].Image, nil
}
}
return "", fmt.Errorf("PostgreSQL image for '%s' version not found", cheCluster.Status.PostgresVersion)
}

View File

@ -1,60 +0,0 @@
//
// Copyright (c) 2019-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 postgres
import (
"fmt"
"github.com/eclipse-che/che-operator/pkg/common/chetypes"
"github.com/eclipse-che/che-operator/pkg/common/constants"
"github.com/eclipse-che/che-operator/pkg/common/utils"
"github.com/eclipse-che/che-operator/pkg/deploy"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
)
func GetWaitForPostgresInitContainer(deployContext *chetypes.DeployContext) (*corev1.Container, error) {
postgresDeployment := &appsv1.Deployment{}
exists, err := deploy.GetNamespacedObject(deployContext, constants.PostgresName, postgresDeployment)
if err != nil {
return nil, err
}
if !exists {
postgresDeployment = nil
}
postgresReadinessCheckerImage, err := getPostgresImage(postgresDeployment, deployContext.CheCluster)
if err != nil {
return nil, err
}
imagePullPolicy := corev1.PullPolicy(utils.GetPullPolicyFromDockerImage(postgresReadinessCheckerImage))
return &corev1.Container{
Name: "wait-for-postgres",
Image: postgresReadinessCheckerImage,
ImagePullPolicy: imagePullPolicy,
Command: []string{
"/bin/sh",
"-c",
getCheckPostgresReadinessScript(deployContext),
},
}, nil
}
func getCheckPostgresReadinessScript(deployContext *chetypes.DeployContext) string {
chePostgresHostName := utils.GetValue(deployContext.CheCluster.Spec.Components.Database.PostgresHostName, constants.DefaultPostgresHostName)
chePostgresPort := utils.GetValue(deployContext.CheCluster.Spec.Components.Database.PostgresPort, constants.DefaultPostgresPort)
return fmt.Sprintf(
"until pg_isready -h %s -p %s; do echo 'waiting for Postgres'; sleep 2; done;",
chePostgresHostName,
chePostgresPort)
}

View File

@ -1,294 +0,0 @@
//
// Copyright (c) 2019-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 postgres
import (
"fmt"
"os"
"k8s.io/apimachinery/pkg/api/resource"
"github.com/devfile/devworkspace-operator/pkg/infrastructure"
"github.com/eclipse-che/che-operator/pkg/common/constants"
defaults "github.com/eclipse-che/che-operator/pkg/common/operator-defaults"
"github.com/eclipse-che/che-operator/pkg/common/test"
"github.com/stretchr/testify/assert"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
chev2 "github.com/eclipse-che/che-operator/api/v2"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
"testing"
)
func TestDeploymentSpec(t *testing.T) {
type testCase struct {
name string
initObjects []runtime.Object
memoryLimit string
memoryRequest string
cpuLimit string
cpuRequest string
cheCluster *chev2.CheCluster
}
testCases := []testCase{
{
name: "Test default limits",
initObjects: []runtime.Object{},
memoryLimit: constants.DefaultPostgresMemoryLimit,
memoryRequest: constants.DefaultPostgresMemoryRequest,
cpuLimit: constants.DefaultPostgresCpuLimit,
cpuRequest: constants.DefaultPostgresCpuRequest,
cheCluster: &chev2.CheCluster{
ObjectMeta: metav1.ObjectMeta{
Namespace: "eclipse-che",
Name: "eclipse-che",
},
},
},
{
name: "Test custom limits",
initObjects: []runtime.Object{},
cpuLimit: "250m",
cpuRequest: "150m",
memoryLimit: "250Mi",
memoryRequest: "150Mi",
cheCluster: &chev2.CheCluster{
ObjectMeta: metav1.ObjectMeta{
Namespace: "eclipse-che",
Name: "eclipse-che",
},
Spec: chev2.CheClusterSpec{
Components: chev2.CheClusterComponents{
Database: chev2.Database{
Deployment: &chev2.Deployment{
Containers: []chev2.Container{
{
Name: constants.PostgresName,
Resources: &chev2.ResourceRequirements{
Requests: &chev2.ResourceList{
Memory: resource.MustParse("150Mi"),
Cpu: resource.MustParse("150m"),
},
Limits: &chev2.ResourceList{
Memory: resource.MustParse("250Mi"),
Cpu: resource.MustParse("250m"),
},
},
},
},
},
},
},
},
},
},
}
for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) {
logf.SetLogger(zap.New(zap.WriteTo(os.Stdout), zap.UseDevMode(true)))
ctx := test.GetDeployContext(testCase.cheCluster, []runtime.Object{})
postgres := NewPostgresReconciler()
deployment, err := postgres.getDeploymentSpec(nil, ctx)
assert.Nil(t, err)
test.CompareResources(deployment,
test.TestExpectedResources{
MemoryLimit: testCase.memoryLimit,
MemoryRequest: testCase.memoryRequest,
CpuRequest: testCase.cpuRequest,
CpuLimit: testCase.cpuLimit,
},
t)
test.ValidateSecurityContext(deployment, t)
})
}
}
func TestPostgresReconcile(t *testing.T) {
infrastructure.InitializeForTesting(infrastructure.OpenShiftv4)
ctx := test.GetDeployContext(nil, []runtime.Object{})
postgres := NewPostgresReconciler()
_, done, err := postgres.Reconcile(ctx)
assert.True(t, done)
assert.Nil(t, err)
assert.True(t, test.IsObjectExists(ctx.ClusterAPI.Client, types.NamespacedName{Name: "postgres", Namespace: "eclipse-che"}, &corev1.Service{}))
assert.True(t, test.IsObjectExists(ctx.ClusterAPI.Client, types.NamespacedName{Name: "postgres-data", Namespace: "eclipse-che"}, &corev1.PersistentVolumeClaim{}))
assert.True(t, test.IsObjectExists(ctx.ClusterAPI.Client, types.NamespacedName{Name: "postgres", Namespace: "eclipse-che"}, &appsv1.Deployment{}))
assert.True(t, test.IsObjectExists(ctx.ClusterAPI.Client, types.NamespacedName{Name: "postgres-credentials", Namespace: "eclipse-che"}, &corev1.Secret{}))
}
func TestGetPostgresImage(t *testing.T) {
type testCase struct {
name string
cheCluster *chev2.CheCluster
postgresDeployment *appsv1.Deployment
expectedPostgresImage string
expectedError bool
}
testCases := []testCase{
{
cheCluster: &chev2.CheCluster{
ObjectMeta: metav1.ObjectMeta{
Namespace: "eclipse-che",
},
},
expectedPostgresImage: defaults.GetPostgres13Image(&chev2.CheCluster{}),
},
{
cheCluster: &chev2.CheCluster{
ObjectMeta: metav1.ObjectMeta{
Namespace: "eclipse-che",
},
Status: chev2.CheClusterStatus{
PostgresVersion: "13.3",
},
},
expectedPostgresImage: defaults.GetPostgres13Image(&chev2.CheCluster{}),
},
{
cheCluster: &chev2.CheCluster{
ObjectMeta: metav1.ObjectMeta{
Namespace: "eclipse-che",
},
Status: chev2.CheClusterStatus{
PostgresVersion: "13.5",
},
},
expectedPostgresImage: defaults.GetPostgres13Image(&chev2.CheCluster{}),
},
{
cheCluster: &chev2.CheCluster{
ObjectMeta: metav1.ObjectMeta{
Namespace: "eclipse-che",
},
Status: chev2.CheClusterStatus{
PostgresVersion: "9.6",
},
},
expectedPostgresImage: defaults.GetPostgresImage(&chev2.CheCluster{}),
},
{
cheCluster: &chev2.CheCluster{
ObjectMeta: metav1.ObjectMeta{
Namespace: "eclipse-che",
},
Spec: chev2.CheClusterSpec{
Components: chev2.CheClusterComponents{
Database: chev2.Database{
Deployment: &chev2.Deployment{
Containers: []chev2.Container{
chev2.Container{
Image: "custom_postgre_image",
},
},
},
},
},
},
Status: chev2.CheClusterStatus{
PostgresVersion: "<some_version>",
},
},
expectedPostgresImage: "custom_postgre_image",
},
{
cheCluster: &chev2.CheCluster{
ObjectMeta: metav1.ObjectMeta{
Namespace: "eclipse-che",
},
Status: chev2.CheClusterStatus{
PostgresVersion: "<unrecognized_version>",
},
},
expectedError: true,
},
{
cheCluster: &chev2.CheCluster{
ObjectMeta: metav1.ObjectMeta{
Namespace: "eclipse-che",
},
Spec: chev2.CheClusterSpec{
Components: chev2.CheClusterComponents{
Database: chev2.Database{},
},
},
},
postgresDeployment: &appsv1.Deployment{
Spec: appsv1.DeploymentSpec{
Template: corev1.PodTemplateSpec{
Spec: corev1.PodSpec{
Containers: []corev1.Container{
{
Image: "current_postgres_image",
},
},
},
},
},
},
expectedPostgresImage: "current_postgres_image",
},
{
cheCluster: &chev2.CheCluster{
ObjectMeta: metav1.ObjectMeta{
Namespace: "eclipse-che",
},
Status: chev2.CheClusterStatus{
PostgresVersion: "13.3",
},
},
postgresDeployment: &appsv1.Deployment{
Spec: appsv1.DeploymentSpec{
Template: corev1.PodTemplateSpec{
Spec: corev1.PodSpec{
Containers: []corev1.Container{
{
Image: "current_postgres_image",
},
},
},
},
},
},
expectedPostgresImage: defaults.GetPostgres13Image(&chev2.CheCluster{}),
},
}
for i, testCase := range testCases {
actualPostgreImage, err := getPostgresImage(testCase.postgresDeployment, testCase.cheCluster)
t.Run(fmt.Sprintf("Test #%d", i), func(t *testing.T) {
if testCase.expectedError {
assert.NotNil(t, err, "Error expected")
} else {
assert.Nil(t, err, "Unexpected error occurred %v", err)
assert.Equal(t, testCase.expectedPostgresImage, actualPostgreImage, "A wrong PostgreSQL image")
}
})
}
}

View File

@ -61,9 +61,6 @@ type CheConfigMap struct {
WorkspacePvcStorageClassName string `json:"CHE_INFRA_KUBERNETES_PVC_STORAGE__CLASS__NAME"`
TlsSupport string `json:"CHE_INFRA_OPENSHIFT_TLS__ENABLED"`
K8STrustCerts string `json:"CHE_INFRA_KUBERNETES_TRUST__CERTS"`
DatabaseURL string `json:"CHE_JDBC_URL,omitempty"`
DbUserName string `json:"CHE_JDBC_USERNAME,omitempty"`
DbPassword string `json:"CHE_JDBC_PASSWORD,omitempty"`
CheLogLevel string `json:"CHE_LOG_LEVEL"`
IdentityProviderUrl string `json:"CHE_OIDC_AUTH__SERVER__URL,omitempty"`
IdentityProviderInternalURL string `json:"CHE_OIDC_AUTH__INTERNAL__SERVER__URL,omitempty"`
@ -133,9 +130,6 @@ func (s *CheServerReconciler) getCheConfigMapData(ctx *chetypes.DeployContext) (
}
}
chePostgresHostName := utils.GetValue(ctx.CheCluster.Spec.Components.Database.PostgresHostName, constants.DefaultPostgresHostName)
chePostgresPort := utils.GetValue(ctx.CheCluster.Spec.Components.Database.PostgresPort, constants.DefaultPostgresPort)
chePostgresDb := utils.GetValue(ctx.CheCluster.Spec.Components.Database.PostgresDb, constants.DefaultPostgresDb)
ingressClass := utils.GetValue(ctx.CheCluster.Spec.Networking.Annotations["kubernetes.io/ingress.class"], constants.DefaultIngressClass)
// grab first the devfile registry url which is deployed by operator
@ -242,7 +236,6 @@ func (s *CheServerReconciler) getCheConfigMapData(ctx *chetypes.DeployContext) (
}
data.IdentityProviderUrl = identityProviderURL
data.DatabaseURL = "jdbc:postgresql://" + chePostgresHostName + ":" + chePostgresPort + "/" + chePostgresDb
out, err := json.Marshal(data)
if err != nil {

View File

@ -17,7 +17,6 @@ import (
defaults "github.com/eclipse-che/che-operator/pkg/common/operator-defaults"
"github.com/eclipse-che/che-operator/pkg/common/utils"
"github.com/eclipse-che/che-operator/pkg/deploy"
"github.com/eclipse-che/che-operator/pkg/deploy/postgres"
"github.com/eclipse-che/che-operator/pkg/deploy/tls"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
@ -230,30 +229,6 @@ func (s CheServerReconciler) getDeploymentSpec(ctx *chetypes.DeployContext) (*ap
container := &deployment.Spec.Template.Spec.Containers[0]
chePostgresCredentialsSecret := utils.GetValue(ctx.CheCluster.Spec.Components.Database.CredentialsSecretName, constants.DefaultPostgresCredentialsSecret)
container.Env = append(container.Env,
corev1.EnvVar{
Name: "CHE_JDBC_USERNAME",
ValueFrom: &corev1.EnvVarSource{
SecretKeyRef: &corev1.SecretKeySelector{
Key: "user",
LocalObjectReference: corev1.LocalObjectReference{
Name: chePostgresCredentialsSecret,
},
},
},
}, corev1.EnvVar{
Name: "CHE_JDBC_PASSWORD",
ValueFrom: &corev1.EnvVarSource{
SecretKeyRef: &corev1.SecretKeySelector{
Key: "password",
LocalObjectReference: corev1.LocalObjectReference{
Name: chePostgresCredentialsSecret,
},
},
},
})
// configure probes if debug isn't set
if ctx.CheCluster.Spec.Components.CheServer.Debug == nil || !*ctx.CheCluster.Spec.Components.CheServer.Debug {
container.ReadinessProbe = &corev1.Probe{
@ -295,16 +270,6 @@ func (s CheServerReconciler) getDeploymentSpec(ctx *chetypes.DeployContext) (*ap
}
}
if defaults.IsComponentReadinessInitContainersConfigured() {
if !ctx.CheCluster.Spec.Components.Database.ExternalDb {
waitForPostgresInitContainer, err := postgres.GetWaitForPostgresInitContainer(ctx)
if err != nil {
return nil, err
}
deployment.Spec.Template.Spec.InitContainers = append(deployment.Spec.Template.Spec.InitContainers, *waitForPostgresInitContainer)
}
}
deploy.EnsurePodSecurityStandards(deployment, constants.DefaultSecurityContextRunAsUser, constants.DefaultSecurityContextFsGroup)
deploy.CustomizeDeployment(deployment, ctx.CheCluster.Spec.Components.CheServer.Deployment)