From e3b6c28dbf1b7a293f74b02bcd878546a7a8e496 Mon Sep 17 00:00:00 2001 From: tchughesiv Date: Mon, 29 Jul 2019 14:09:12 -0500 Subject: [PATCH 1/2] [KIECLOUD-281] Change operator to use versioned config dirs Signed-off-by: tchughesiv --- config/{ => 7.4.0}/common.yaml | 10 +- config/{ => 7.4.0}/dbs/external.yaml | 0 config/{ => 7.4.0}/dbs/h2.yaml | 0 config/{ => 7.4.0}/dbs/mysql.yaml | 0 config/{ => 7.4.0}/dbs/postgresql.yaml | 0 .../{ => 7.4.0}/envs/rhdm-authoring-ha.yaml | 0 config/{ => 7.4.0}/envs/rhdm-authoring.yaml | 0 .../envs/rhdm-production-immutable.yaml | 0 config/7.4.0/envs/rhdm-trial.yaml | 113 +++ .../{ => 7.4.0}/envs/rhpam-authoring-ha.yaml | 0 config/{ => 7.4.0}/envs/rhpam-authoring.yaml | 0 .../envs/rhpam-production-immutable.yaml | 0 config/{ => 7.4.0}/envs/rhpam-production.yaml | 0 config/7.4.0/envs/rhpam-trial.yaml | 113 +++ config/7.4.0/jms/activemq-jms-config.yaml | 226 +++++ config/7.4.1/common.yaml | 791 ++++++++++++++++++ config/7.4.1/dbs/external.yaml | 60 ++ config/7.4.1/dbs/h2.yaml | 78 ++ config/7.4.1/dbs/mysql.yaml | 166 ++++ config/7.4.1/dbs/postgresql.yaml | 166 ++++ config/7.4.1/envs/rhdm-authoring-ha.yaml | 609 ++++++++++++++ config/7.4.1/envs/rhdm-authoring.yaml | 53 ++ .../7.4.1/envs/rhdm-production-immutable.yaml | 92 ++ config/{ => 7.4.1}/envs/rhdm-trial.yaml | 0 config/7.4.1/envs/rhpam-authoring-ha.yaml | 611 ++++++++++++++ config/7.4.1/envs/rhpam-authoring.yaml | 36 + .../envs/rhpam-production-immutable.yaml | 91 ++ config/7.4.1/envs/rhpam-production.yaml | 47 ++ config/{ => 7.4.1}/envs/rhpam-trial.yaml | 0 .../{ => 7.4.1}/jms/activemq-jms-config.yaml | 0 pkg/apis/app/v1/kieapp_types.go | 12 + pkg/apis/app/v1/zz_generated.deepcopy.go | 16 + pkg/controller/kieapp/constants/constants.go | 59 +- pkg/controller/kieapp/defaults/defaults.go | 76 +- .../kieapp/defaults/defaults_test.go | 145 ++-- pkg/controller/kieapp/defaults/merge_test.go | 2 +- pkg/controller/kieapp/kieapp_controller.go | 16 +- .../kieapp/kieapp_controller_test.go | 12 +- 38 files changed, 3501 insertions(+), 99 deletions(-) rename config/{ => 7.4.0}/common.yaml (98%) rename config/{ => 7.4.0}/dbs/external.yaml (100%) rename config/{ => 7.4.0}/dbs/h2.yaml (100%) rename config/{ => 7.4.0}/dbs/mysql.yaml (100%) rename config/{ => 7.4.0}/dbs/postgresql.yaml (100%) rename config/{ => 7.4.0}/envs/rhdm-authoring-ha.yaml (100%) rename config/{ => 7.4.0}/envs/rhdm-authoring.yaml (100%) rename config/{ => 7.4.0}/envs/rhdm-production-immutable.yaml (100%) create mode 100644 config/7.4.0/envs/rhdm-trial.yaml rename config/{ => 7.4.0}/envs/rhpam-authoring-ha.yaml (100%) rename config/{ => 7.4.0}/envs/rhpam-authoring.yaml (100%) rename config/{ => 7.4.0}/envs/rhpam-production-immutable.yaml (100%) rename config/{ => 7.4.0}/envs/rhpam-production.yaml (100%) create mode 100644 config/7.4.0/envs/rhpam-trial.yaml create mode 100644 config/7.4.0/jms/activemq-jms-config.yaml create mode 100644 config/7.4.1/common.yaml create mode 100644 config/7.4.1/dbs/external.yaml create mode 100644 config/7.4.1/dbs/h2.yaml create mode 100644 config/7.4.1/dbs/mysql.yaml create mode 100644 config/7.4.1/dbs/postgresql.yaml create mode 100644 config/7.4.1/envs/rhdm-authoring-ha.yaml create mode 100644 config/7.4.1/envs/rhdm-authoring.yaml create mode 100644 config/7.4.1/envs/rhdm-production-immutable.yaml rename config/{ => 7.4.1}/envs/rhdm-trial.yaml (100%) create mode 100644 config/7.4.1/envs/rhpam-authoring-ha.yaml create mode 100644 config/7.4.1/envs/rhpam-authoring.yaml create mode 100644 config/7.4.1/envs/rhpam-production-immutable.yaml create mode 100644 config/7.4.1/envs/rhpam-production.yaml rename config/{ => 7.4.1}/envs/rhpam-trial.yaml (100%) rename config/{ => 7.4.1}/jms/activemq-jms-config.yaml (100%) diff --git a/config/common.yaml b/config/7.4.0/common.yaml similarity index 98% rename from config/common.yaml rename to config/7.4.0/common.yaml index 24d7ac380..0f4f36b5c 100644 --- a/config/common.yaml +++ b/config/7.4.0/common.yaml @@ -18,7 +18,7 @@ console: from: kind: ImageStreamTag namespace: openshift - name: "[[.Constants.Product]][[.Version]]-[[.Console.ImageName]]-openshift:[[.ImageTag]]" + name: "[[.Constants.Product]][[.Constants.Major]][[.Constants.Minor]]-[[.Console.ImageName]]-openshift:[[.ImageTag]]" - type: ConfigChange replicas: [[.Console.Replicas]] selector: @@ -36,7 +36,7 @@ console: terminationGracePeriodSeconds: 60 containers: - name: "[[.ApplicationName]]-[[.Console.Name]]" - image: "[[.Constants.Product]][[.Version]]-[[.Console.ImageName]]-openshift" + image: "[[.Constants.Product]][[.Constants.Major]][[.Constants.Minor]]-[[.Console.ImageName]]-openshift" imagePullPolicy: Always resources: limits: @@ -310,7 +310,7 @@ smartRouter: from: kind: ImageStreamTag namespace: "openshift" - name: "[[.Constants.Product]][[.Version]]-smartrouter-openshift:[[.ImageTag]]" + name: "[[.Constants.Product]][[.Constants.Major]][[.Constants.Minor]]-smartrouter-openshift:[[.ImageTag]]" - type: ConfigChange replicas: [[.SmartRouter.Replicas]] selector: @@ -328,7 +328,7 @@ smartRouter: terminationGracePeriodSeconds: 60 containers: - name: "[[.ApplicationName]]-smartrouter" - image: "[[.Constants.Product]][[.Version]]-smartrouter-openshift" + image: "[[.Constants.Product]][[.Constants.Major]][[.Constants.Minor]]-smartrouter-openshift" imagePullPolicy: Always resources: limits: @@ -476,7 +476,7 @@ servers: terminationGracePeriodSeconds: 90 containers: - name: "[[.KieName]]" - image: "[[$.Constants.Product]][[$.Version]]-kieserver-openshift" + image: "[[$.Constants.Product]][[$.Constants.Major]][[$.Constants.Minor]]-kieserver-openshift" imagePullPolicy: Always lifecycle: postStart: diff --git a/config/dbs/external.yaml b/config/7.4.0/dbs/external.yaml similarity index 100% rename from config/dbs/external.yaml rename to config/7.4.0/dbs/external.yaml diff --git a/config/dbs/h2.yaml b/config/7.4.0/dbs/h2.yaml similarity index 100% rename from config/dbs/h2.yaml rename to config/7.4.0/dbs/h2.yaml diff --git a/config/dbs/mysql.yaml b/config/7.4.0/dbs/mysql.yaml similarity index 100% rename from config/dbs/mysql.yaml rename to config/7.4.0/dbs/mysql.yaml diff --git a/config/dbs/postgresql.yaml b/config/7.4.0/dbs/postgresql.yaml similarity index 100% rename from config/dbs/postgresql.yaml rename to config/7.4.0/dbs/postgresql.yaml diff --git a/config/envs/rhdm-authoring-ha.yaml b/config/7.4.0/envs/rhdm-authoring-ha.yaml similarity index 100% rename from config/envs/rhdm-authoring-ha.yaml rename to config/7.4.0/envs/rhdm-authoring-ha.yaml diff --git a/config/envs/rhdm-authoring.yaml b/config/7.4.0/envs/rhdm-authoring.yaml similarity index 100% rename from config/envs/rhdm-authoring.yaml rename to config/7.4.0/envs/rhdm-authoring.yaml diff --git a/config/envs/rhdm-production-immutable.yaml b/config/7.4.0/envs/rhdm-production-immutable.yaml similarity index 100% rename from config/envs/rhdm-production-immutable.yaml rename to config/7.4.0/envs/rhdm-production-immutable.yaml diff --git a/config/7.4.0/envs/rhdm-trial.yaml b/config/7.4.0/envs/rhdm-trial.yaml new file mode 100644 index 000000000..d54acf712 --- /dev/null +++ b/config/7.4.0/envs/rhdm-trial.yaml @@ -0,0 +1,113 @@ +console: + deploymentConfigs: + - metadata: + name: "[[.ApplicationName]]-[[.Console.Name]]" + spec: + template: + spec: + containers: + - name: "[[.ApplicationName]]-[[.Console.Name]]" + ports: + - name: git-ssh + containerPort: 8001 + protocol: TCP + volumes: + - name: "[[.ApplicationName]]-[[.Console.Name]]-pvol" + emptyDir: {} + persistentVolumeClaims: + - metadata: + name: "[[.ApplicationName]]-[[.Console.Name]]-claim" + annotations: + delete: "true" + services: + - metadata: + name: "[[.ApplicationName]]-[[.Console.Name]]" + spec: + ports: + - name: git-ssh + port: 8001 + targetPort: 8001 + - metadata: + name: "[[.ApplicationName]]-[[.Console.Name]]-ping" + annotations: + delete: "true" + routes: + - id: "[[.ApplicationName]]-[[.Console.Name]]-http" + metadata: + name: "[[.ApplicationName]]-[[.Console.Name]]-http" + labels: + app: "[[.ApplicationName]]" + application: "[[.ApplicationName]]" + service: "[[.ApplicationName]]-[[.Console.Name]]" + annotations: + description: Route for Business Central's http service. + haproxy.router.openshift.io/timeout: 60s + spec: + to: + name: "[[.ApplicationName]]-[[.Console.Name]]" + port: + targetPort: http +## KIE Servers BEGIN +servers: + ## RANGE BEGINS + #[[ range $index, $Map := .Servers ]] + - deploymentConfigs: + ## KIE server deployment config BEGIN + - metadata: + name: "[[.KieName]]" + spec: + template: + metadata: + name: "[[.KieName]]" + spec: + containers: + - name: "[[.KieName]]" + env: + - name: JGROUPS_PING_PROTOCOL + - name: OPENSHIFT_DNS_PING_SERVICE_NAME + - name: OPENSHIFT_DNS_PING_SERVICE_PORT + - name: FILTERS + value: "AC_ALLOW_ORIGIN,AC_ALLOW_METHODS,AC_ALLOW_HEADERS,AC_ALLOW_CREDENTIALS,AC_MAX_AGE" + - name: AC_ALLOW_ORIGIN_FILTER_RESPONSE_HEADER_NAME + value: "Access-Control-Allow-Origin" + - name: AC_ALLOW_ORIGIN_FILTER_RESPONSE_HEADER_VALUE + value: "*" + - name: AC_ALLOW_METHODS_FILTER_RESPONSE_HEADER_NAME + value: "Access-Control-Allow-Methods" + - name: AC_ALLOW_METHODS_FILTER_RESPONSE_HEADER_VALUE + value: "GET, POST, OPTIONS, PUT" + - name: AC_ALLOW_HEADERS_FILTER_RESPONSE_HEADER_NAME + value: "Access-Control-Allow-Headers" + - name: AC_ALLOW_HEADERS_FILTER_RESPONSE_HEADER_VALUE + value: "Accept, Authorization, Content-Type, X-Requested-With" + - name: AC_ALLOW_CREDENTIALS_FILTER_RESPONSE_HEADER_NAME + value: "Access-Control-Allow-Credentials" + - name: AC_ALLOW_CREDENTIALS_FILTER_RESPONSE_HEADER_VALUE + value: "true" + - name: AC_MAX_AGE_FILTER_RESPONSE_HEADER_NAME + value: "Access-Control-Max-Age" + - name: AC_MAX_AGE_FILTER_RESPONSE_HEADER_VALUE + value: "1" + ## KIE server deployment config END + ## KIE server route BEGIN + routes: + - id: "[[.KieName]]-http" + metadata: + name: "[[.KieName]]-http" + labels: + app: "[[$.ApplicationName]]" + application: "[[$.ApplicationName]]" + service: "[[.KieName]]" + annotations: + description: Route for KIE server's http service. + haproxy.router.openshift.io/balance: source + haproxy.router.openshift.io/timeout: 60s + spec: + to: + name: "[[.KieName]]" + port: + targetPort: http + ## KIE server route END +#[[end]] +## RANGE ends +## KIE Servers END diff --git a/config/envs/rhpam-authoring-ha.yaml b/config/7.4.0/envs/rhpam-authoring-ha.yaml similarity index 100% rename from config/envs/rhpam-authoring-ha.yaml rename to config/7.4.0/envs/rhpam-authoring-ha.yaml diff --git a/config/envs/rhpam-authoring.yaml b/config/7.4.0/envs/rhpam-authoring.yaml similarity index 100% rename from config/envs/rhpam-authoring.yaml rename to config/7.4.0/envs/rhpam-authoring.yaml diff --git a/config/envs/rhpam-production-immutable.yaml b/config/7.4.0/envs/rhpam-production-immutable.yaml similarity index 100% rename from config/envs/rhpam-production-immutable.yaml rename to config/7.4.0/envs/rhpam-production-immutable.yaml diff --git a/config/envs/rhpam-production.yaml b/config/7.4.0/envs/rhpam-production.yaml similarity index 100% rename from config/envs/rhpam-production.yaml rename to config/7.4.0/envs/rhpam-production.yaml diff --git a/config/7.4.0/envs/rhpam-trial.yaml b/config/7.4.0/envs/rhpam-trial.yaml new file mode 100644 index 000000000..d54acf712 --- /dev/null +++ b/config/7.4.0/envs/rhpam-trial.yaml @@ -0,0 +1,113 @@ +console: + deploymentConfigs: + - metadata: + name: "[[.ApplicationName]]-[[.Console.Name]]" + spec: + template: + spec: + containers: + - name: "[[.ApplicationName]]-[[.Console.Name]]" + ports: + - name: git-ssh + containerPort: 8001 + protocol: TCP + volumes: + - name: "[[.ApplicationName]]-[[.Console.Name]]-pvol" + emptyDir: {} + persistentVolumeClaims: + - metadata: + name: "[[.ApplicationName]]-[[.Console.Name]]-claim" + annotations: + delete: "true" + services: + - metadata: + name: "[[.ApplicationName]]-[[.Console.Name]]" + spec: + ports: + - name: git-ssh + port: 8001 + targetPort: 8001 + - metadata: + name: "[[.ApplicationName]]-[[.Console.Name]]-ping" + annotations: + delete: "true" + routes: + - id: "[[.ApplicationName]]-[[.Console.Name]]-http" + metadata: + name: "[[.ApplicationName]]-[[.Console.Name]]-http" + labels: + app: "[[.ApplicationName]]" + application: "[[.ApplicationName]]" + service: "[[.ApplicationName]]-[[.Console.Name]]" + annotations: + description: Route for Business Central's http service. + haproxy.router.openshift.io/timeout: 60s + spec: + to: + name: "[[.ApplicationName]]-[[.Console.Name]]" + port: + targetPort: http +## KIE Servers BEGIN +servers: + ## RANGE BEGINS + #[[ range $index, $Map := .Servers ]] + - deploymentConfigs: + ## KIE server deployment config BEGIN + - metadata: + name: "[[.KieName]]" + spec: + template: + metadata: + name: "[[.KieName]]" + spec: + containers: + - name: "[[.KieName]]" + env: + - name: JGROUPS_PING_PROTOCOL + - name: OPENSHIFT_DNS_PING_SERVICE_NAME + - name: OPENSHIFT_DNS_PING_SERVICE_PORT + - name: FILTERS + value: "AC_ALLOW_ORIGIN,AC_ALLOW_METHODS,AC_ALLOW_HEADERS,AC_ALLOW_CREDENTIALS,AC_MAX_AGE" + - name: AC_ALLOW_ORIGIN_FILTER_RESPONSE_HEADER_NAME + value: "Access-Control-Allow-Origin" + - name: AC_ALLOW_ORIGIN_FILTER_RESPONSE_HEADER_VALUE + value: "*" + - name: AC_ALLOW_METHODS_FILTER_RESPONSE_HEADER_NAME + value: "Access-Control-Allow-Methods" + - name: AC_ALLOW_METHODS_FILTER_RESPONSE_HEADER_VALUE + value: "GET, POST, OPTIONS, PUT" + - name: AC_ALLOW_HEADERS_FILTER_RESPONSE_HEADER_NAME + value: "Access-Control-Allow-Headers" + - name: AC_ALLOW_HEADERS_FILTER_RESPONSE_HEADER_VALUE + value: "Accept, Authorization, Content-Type, X-Requested-With" + - name: AC_ALLOW_CREDENTIALS_FILTER_RESPONSE_HEADER_NAME + value: "Access-Control-Allow-Credentials" + - name: AC_ALLOW_CREDENTIALS_FILTER_RESPONSE_HEADER_VALUE + value: "true" + - name: AC_MAX_AGE_FILTER_RESPONSE_HEADER_NAME + value: "Access-Control-Max-Age" + - name: AC_MAX_AGE_FILTER_RESPONSE_HEADER_VALUE + value: "1" + ## KIE server deployment config END + ## KIE server route BEGIN + routes: + - id: "[[.KieName]]-http" + metadata: + name: "[[.KieName]]-http" + labels: + app: "[[$.ApplicationName]]" + application: "[[$.ApplicationName]]" + service: "[[.KieName]]" + annotations: + description: Route for KIE server's http service. + haproxy.router.openshift.io/balance: source + haproxy.router.openshift.io/timeout: 60s + spec: + to: + name: "[[.KieName]]" + port: + targetPort: http + ## KIE server route END +#[[end]] +## RANGE ends +## KIE Servers END diff --git a/config/7.4.0/jms/activemq-jms-config.yaml b/config/7.4.0/jms/activemq-jms-config.yaml new file mode 100644 index 000000000..d6e8a29fd --- /dev/null +++ b/config/7.4.0/jms/activemq-jms-config.yaml @@ -0,0 +1,226 @@ +## KIE Servers BEGIN +servers: +## RANGE BEGINS +#[[ range $index, $Map := .Servers ]] +## KIE server deployment config BEGIN + - deploymentConfigs: + - metadata: + name: "[[.KieName]]" + spec: + template: + spec: + containers: + - name: "[[.KieName]]" + env: + # JMS config BEGIN + - name: KIE_SERVER_JMS_QUEUE_REQUEST + value: "[[.Jms.KieServerJmsQueueRequest]]" + - name: KIE_SERVER_JMS_QUEUE_RESPONSE + value: "[[.Jms.KieServerJmsQueueResponse]]" + - name: KIE_SERVER_JMS_QUEUE_EXECUTOR + value: "[[.Jms.KieServerJmsQueueExecutor]]" + - name: KIE_SERVER_JMS_ENABLE_SIGNAL + value: "[[.Jms.KieServerJmsEnableSignal]]" + # [[ if .Jms.KieServerJmsEnableSignal]] + - name: KIE_SERVER_JMS_QUEUE_SIGNAL + value: "[[.Jms.KieServerJmsQueueSignal]]" + # [[end]] + - name: KIE_SERVER_JMS_ENABLE_AUDIT + value: "[[.Jms.KieServerJmsEnableAudit]]" + # [[ if .Jms.KieServerJmsEnableAudit]] + - name: KIE_SERVER_JMS_QUEUE_AUDIT + value: "[[.Jms.KieServerJmsQueueAudit]]" + # [[end]] + - name: KIE_SERVER_JMS_AUDIT_TRANSACTED + value: "[[.Jms.KieServerJmsAuditTransacted]]" + - name: MQ_SERVICE_PREFIX_MAPPING + value: "[[.KieName]]-amq7=AMQ" + - name: AMQ_USERNAME + value: "[[.Jms.KieServerJmsUsername]]" + - name: AMQ_PASSWORD + value: "[[.Jms.KieServerJmsPassword]]" + - name: AMQ_PROTOCOL + value: "tcp" + - name: AMQ_QUEUES + value: "[[.Jms.KieServerJmsAMQQueues]]" + # JMS config END + ## KIE server deployment config END + ## AMQ deployment BEGIN + - metadata: + name: "[[.KieName]]-amq" + labels: + app: "[[$.ApplicationName]]" + application: "[[$.ApplicationName]]" + service: "[[.KieName]]" + annotations: + template.alpha.openshift.io/wait-for-ready: "true" + spec: + strategy: + type: Recreate + triggers: + - type: ImageChange + imageChangeParams: + automatic: true + containerNames: + - "[[.KieName]]-amq" + from: + kind: ImageStreamTag + name: "[[$.Constants.BrokerImage]]:[[$.Constants.BrokerImageTag]]" + namespace: "openshift" + - type: ConfigChange + replicas: 1 + selector: + deploymentConfig: "[[.KieName]]-amq" + template: + metadata: + name: "[[.KieName]]-amq" + labels: + app: "[[$.ApplicationName]]" + application: "[[$.ApplicationName]]" + deploymentConfig: "[[.KieName]]-amq" + service: "[[.KieName]]-amq" + spec: + terminationGracePeriodSeconds: 60 + containers: + - name: "[[.KieName]]-amq" + image: "[[$.Constants.BrokerImage]]" + imagePullPolicy: Always + readinessProbe: + exec: + command: + - "/bin/bash" + - "-c" + - "/opt/amq/bin/readinessProbe.sh" + ports: + - containerPort: 8161 + name: console-jolokia + protocol: TCP + - containerPort: 5672 + name: amq-amqp + protocol: TCP + - containerPort: 1883 + name: amq-mqtt + protocol: TCP + - containerPort: 61613 + name: amq-stomp + protocol: TCP + - containerPort: 61616 + name: amq-tcp + protocol: TCP + env: + - name: AMQ_USER + value: "[[.Jms.KieServerJmsUsername]]" + - name: AMQ_PASSWORD + value: "[[.Jms.KieServerJmsPassword]]" + # maybe turn it in a parameter and defaults to admin if empty? + - name: AMQ_ROLE + value: "admin" + - name: AMQ_NAME + value: "broker" + - name: AMQ_TRANSPORTS + value: "openwire" + - name: AMQ_QUEUES + value: "[[.Jms.KieServerJmsAMQQueues]]" + - name: AMQ_REQUIRE_LOGIN + value: "false" + - name: AMQ_ANYCAST_PREFIX + - name: AMQ_MULTICAST_PREFIX + ## AMQ deployment END + services: + - spec: + ports: + - name: "amq-jolokia" + port: 8161 + targetPort: 8161 + selector: + deploymentConfig: "[[.KieName]]-amq" + metadata: + name: "[[.KieName]]-amq-jolokia" + labels: + app: "[[$.ApplicationName]]" + application: "[[$.ApplicationName]]" + service: "[[.KieName]]-amq" + annotations: + description: "The broker's console and Jolokia port." + - spec: + ports: + - name: "amp-amqp" + port: 5672 + targetPort: 5672 + selector: + deploymentConfig: "[[.KieName]]-amq" + metadata: + name: "[[.KieName]]-amq-amqp" + labels: + app: "[[$.ApplicationName]]" + application: "[[$.ApplicationName]]" + service: "[[.KieName]]-amq" + annotations: + description: "The broker's AMQP port." + - spec: + ports: + - name: "amq-mqtt" + port: 1883 + targetPort: 1883 + selector: + deploymentConfig: "[[.KieName]]-amq" + metadata: + name: "[[.KieName]]-amq-mqtt" + labels: + app: "[[$.ApplicationName]]" + application: "[[$.ApplicationName]]" + service: "[[.KieName]]-amq" + annotations: + description: "The broker's MQTT port." + - spec: + ports: + - name: "amp-stomp" + port: 61613 + targetPort: 61613 + selector: + deploymentConfig: "[[.KieName]]-amq" + metadata: + name: "[[.KieName]]-amq-stomp" + labels: + app: "[[$.ApplicationName]]" + application: "[[$.ApplicationName]]" + service: "[[.KieName]]-amq" + annotations: + description: "The broker's STOMP port." + - spec: + ports: + - name: "amq-tcp" + port: 61616 + targetPort: 61616 + selector: + deploymentConfig: "[[.KieName]]-amq" + metadata: + name: "[[.KieName]]-amq-tcp" + labels: + app: "[[$.ApplicationName]]" + application: "[[$.ApplicationName]]" + service: "[[.KieName]]-amq" + annotations: + description: The broker's OpenWire port. + service.alpha.openshift.io/dependencies: '[{"name": "[[.KieName]]-amq-amqp", + "kind": "Service"},{"name": "[[.KieName]]-amq-mqtt", "kind": "Service"},{"name": + "[[.KieName]]-amq-stomp", "kind": "Service"}]' + + routes: + - id: "[[.KieName]]-amq-jolokia-console" + metadata: + name: amq-jolokia-console + labels: + app: "[[$.ApplicationName]]" + application: "[[$.ApplicationName]]" + service: "[[.KieName]]-amq" + annotations: + description: "Route for AMQ Jolokia Service" + spec: + to: + kind: "Service" + name: "[[.KieName]]-amq-jolokia" +#[[end]] +## RANGE ends +## KIE Servers END + diff --git a/config/7.4.1/common.yaml b/config/7.4.1/common.yaml new file mode 100644 index 000000000..0f4f36b5c --- /dev/null +++ b/config/7.4.1/common.yaml @@ -0,0 +1,791 @@ +console: + deploymentConfigs: + - metadata: + name: "[[.ApplicationName]]-[[.Console.Name]]" + labels: + app: "[[.ApplicationName]]" + application: "[[.ApplicationName]]" + service: "[[.ApplicationName]]-[[.Console.Name]]" + spec: + strategy: + type: Recreate + triggers: + - type: ImageChange + imageChangeParams: + automatic: true + containerNames: + - "[[.ApplicationName]]-[[.Console.Name]]" + from: + kind: ImageStreamTag + namespace: openshift + name: "[[.Constants.Product]][[.Constants.Major]][[.Constants.Minor]]-[[.Console.ImageName]]-openshift:[[.ImageTag]]" + - type: ConfigChange + replicas: [[.Console.Replicas]] + selector: + deploymentConfig: "[[.ApplicationName]]-[[.Console.Name]]" + template: + metadata: + name: "[[.ApplicationName]]-[[.Console.Name]]" + labels: + deploymentConfig: "[[.ApplicationName]]-[[.Console.Name]]" + app: "[[.ApplicationName]]" + application: "[[.ApplicationName]]" + service: "[[.ApplicationName]]-[[.Console.Name]]" + spec: + serviceAccountName: "[[.ApplicationName]]-[[.Constants.Product]]svc" + terminationGracePeriodSeconds: 60 + containers: + - name: "[[.ApplicationName]]-[[.Console.Name]]" + image: "[[.Constants.Product]][[.Constants.Major]][[.Constants.Minor]]-[[.Console.ImageName]]-openshift" + imagePullPolicy: Always + resources: + limits: + memory: 2Gi + livenessProbe: + httpGet: + path: /rest/healthy + port: 8080 + scheme: HTTP + initialDelaySeconds: 180 + timeoutSeconds: 2 + periodSeconds: 15 + readinessProbe: + httpGet: + path: /rest/ready + port: 8080 + scheme: HTTP + initialDelaySeconds: 60 + timeoutSeconds: 2 + periodSeconds: 30 + failureThreshold: 6 + ports: + - name: jolokia + containerPort: 8778 + protocol: TCP + - name: http + containerPort: 8080 + protocol: TCP + - name: https + containerPort: 8443 + protocol: TCP + - name: ping + containerPort: 8888 + protocol: TCP + env: + - name: KIE_ADMIN_USER + value: "[[.AdminUser]]" + - name: KIE_ADMIN_PWD + value: "[[.AdminPassword]]" + - name: KIE_MAVEN_USER + value: mavenUser + - name: KIE_MAVEN_PWD + value: "[[.MavenPassword]]" + - name: KIE_SERVER_CONTROLLER_USER + value: controllerUser + - name: KIE_SERVER_CONTROLLER_PWD + value: "[[.ControllerPassword]]" + - name: KIE_SERVER_USER + value: executionUser + - name: KIE_SERVER_PWD + value: "[[.ServerPassword]]" + - name: KIE_MBEANS + value: enabled + ## OpenShift Enhancement BEGIN + - name: KIE_SERVER_CONTROLLER_OPENSHIFT_GLOBAL_DISCOVERY_ENABLED + value: "true" + - name: KIE_SERVER_CONTROLLER_OPENSHIFT_PREFER_KIESERVER_SERVICE + value: "true" + - name: KIE_SERVER_CONTROLLER_TEMPLATE_CACHE_TTL + value: "60000" + - name: KIE_WORKBENCH_CONTROLLER_OPENSHIFT_ENABLED + value: "true" + ## OpenShift Enhancement END + - name: HTTPS_KEYSTORE_DIR + value: "/etc/businesscentral-secret-volume" + - name: HTTPS_KEYSTORE + value: "keystore.jks" + - name: HTTPS_NAME + value: "jboss" + - name: HTTPS_PASSWORD + value: "[[.KeyStorePassword]]" + - name: WORKBENCH_ROUTE_NAME + value: "[[.ApplicationName]]-[[.Console.Name]]" + - name: JGROUPS_PING_PROTOCOL + value: "openshift.DNS_PING" + - name: OPENSHIFT_DNS_PING_SERVICE_NAME + value: "[[.ApplicationName]]-[[.Console.Name]]-ping" + - name: OPENSHIFT_DNS_PING_SERVICE_PORT + value: "8888" + # Auth config BEGIN + ## SSO config BEGIN + #[[if .Auth.SSO.URL]] + - name: SSO_OPENIDCONNECT_DEPLOYMENTS + value: ROOT.war + - name: SSO_URL + value: "[[.Auth.SSO.URL]]" + - name: SSO_REALM + value: "[[.Auth.SSO.Realm]]" + - name: SSO_USERNAME + value: "[[.Auth.SSO.AdminUser]]" + - name: SSO_PASSWORD + value: "[[.Auth.SSO.AdminPassword]]" + - name: SSO_DISABLE_SSL_CERTIFICATE_VALIDATION + value: "[[.Auth.SSO.DisableSSLCertValidation]]" + - name: SSO_PRINCIPAL_ATTRIBUTE + value: "[[.Auth.SSO.PrincipalAttribute]]" + - name: SSO_SECRET + value: "[[.Console.SSOAuthClient.Secret]]" + - name: SSO_CLIENT + value: "[[.Console.SSOAuthClient.Name]]" + - name: HOSTNAME_HTTP + value: "[[.Console.SSOAuthClient.HostnameHTTP]]" + - name: HOSTNAME_HTTPS + value: "[[.Console.SSOAuthClient.HostnameHTTPS]]" + #[[end]] + ## SSO config END + ## LDAP config BEGIN + #[[if .Auth.LDAP.URL]] + - name: AUTH_LDAP_URL + value: "[[.Auth.LDAP.URL]]" + - name: AUTH_LDAP_BIND_DN + value: "[[.Auth.LDAP.BindDN]]" + - name: AUTH_LDAP_BIND_CREDENTIAL + value: "[[.Auth.LDAP.BindCredential]]" + - name: AUTH_LDAP_JAAS_SECURITY_DOMAIN + value: "[[.Auth.LDAP.JAASSecurityDomain]]" + - name: AUTH_LDAP_BASE_CTX_DN + value: "[[.Auth.LDAP.BaseCtxDN]]" + - name: AUTH_LDAP_BASE_FILTER + value: "[[.Auth.LDAP.BaseFilter]]" + - name: AUTH_LDAP_SEARCH_SCOPE + value: "[[.Auth.LDAP.SearchScope]]" + - name: AUTH_LDAP_SEARCH_TIME_LIMIT + value: "[[.Auth.LDAP.SearchTimeLimit]]" + - name: AUTH_LDAP_DISTINGUISHED_NAME_ATTRIBUTE + value: "[[.Auth.LDAP.DistinguishedNameAttribute]]" + - name: AUTH_LDAP_PARSE_USERNAME + value: "[[.Auth.LDAP.ParseUsername]]" + - name: AUTH_LDAP_USERNAME_BEGIN_STRING + value: "[[.Auth.LDAP.UsernameBeginString]]" + - name: AUTH_LDAP_USERNAME_END_STRING + value: "[[.Auth.LDAP.UsernameEndString]]" + - name: AUTH_LDAP_ROLE_ATTRIBUTE_ID + value: "[[.Auth.LDAP.RoleAttributeID]]" + - name: AUTH_LDAP_ROLES_CTX_DN + value: "[[.Auth.LDAP.RolesCtxDN]]" + - name: AUTH_LDAP_ROLE_FILTER + value: "[[.Auth.LDAP.RoleFilter]]" + - name: AUTH_LDAP_ROLE_RECURSION + value: "[[.Auth.LDAP.RoleRecursion]]" + - name: AUTH_LDAP_DEFAULT_ROLE + value: "[[.Auth.LDAP.DefaultRole]]" + - name: AUTH_LDAP_ROLE_NAME_ATTRIBUTE_ID + value: "[[.Auth.LDAP.RoleNameAttributeID]]" + - name: AUTH_LDAP_PARSE_ROLE_NAME_FROM_DN + value: "[[.Auth.LDAP.ParseRoleNameFromDN]]" + - name: AUTH_LDAP_ROLE_ATTRIBUTE_IS_DN + value: "[[.Auth.LDAP.RoleAttributeIsDN]]" + - name: AUTH_LDAP_REFERRAL_USER_ATTRIBUTE_ID_TO_CHECK + value: "[[.Auth.LDAP.ReferralUserAttributeIDToCheck]]" + #[[end]] + ## LDAP config END + ## RoleMapping config BEGIN + #[[if .Auth.RoleMapper.RolesProperties]] + - name: AUTH_ROLE_MAPPER_ROLES_PROPERTIES + value: "[[.Auth.RoleMapper.RolesProperties]]" + - name: AUTH_ROLE_MAPPER_REPLACE_ROLE + value: "[[.Auth.RoleMapper.ReplaceRole]]" + #[[end]] + ## RoleMapping config END + # Auth config END + volumeMounts: + - name: "[[.ApplicationName]]-[[.Console.Name]]-[[.Constants.KeystoreVolumeSuffix]]" + mountPath: "/etc/businesscentral-secret-volume" + readOnly: true + - name: "[[.ApplicationName]]-[[.Console.Name]]-pvol" + mountPath: "/opt/kie/data" + volumes: + - name: "[[.ApplicationName]]-[[.Console.Name]]-[[.Constants.KeystoreVolumeSuffix]]" + secret: + secretName: "[[.Console.KeystoreSecret]]" + - name: "[[.ApplicationName]]-[[.Console.Name]]-pvol" + persistentVolumeClaim: + claimName: "[[.ApplicationName]]-[[.Console.Name]]-claim" + persistentVolumeClaims: + - metadata: + name: "[[.ApplicationName]]-[[.Console.Name]]-claim" + spec: + accessModes: + - ReadWriteMany + resources: + requests: + storage: "64Mi" + services: + - spec: + ports: + - name: http + port: 8080 + targetPort: 8080 + - name: https + port: 8443 + targetPort: 8443 + selector: + deploymentConfig: "[[.ApplicationName]]-[[.Console.Name]]" + metadata: + name: "[[.ApplicationName]]-[[.Console.Name]]" + labels: + app: "[[.ApplicationName]]" + application: "[[.ApplicationName]]" + service: "[[.ApplicationName]]-[[.Console.Name]]" + annotations: + description: All the Business Central web server's ports. + - spec: + clusterIP: "None" + ports: + - name: "ping" + port: 8888 + targetPort: 8888 + selector: + deploymentConfig: "[[.ApplicationName]]-[[.Console.Name]]" + metadata: + name: "[[.ApplicationName]]-[[.Console.Name]]-ping" + labels: + app: "[[.ApplicationName]]" + application: "[[.ApplicationName]]" + service: "[[.ApplicationName]]-[[.Console.Name]]" + annotations: + service.alpha.kubernetes.io/tolerate-unready-endpoints: "true" + description: "The JGroups ping port for clustering." + routes: + - id: "[[.ApplicationName]]-[[.Console.Name]]-https" + metadata: + name: "[[.ApplicationName]]-[[.Console.Name]]" + labels: + app: "[[.ApplicationName]]" + application: "[[.ApplicationName]]" + service: "[[.ApplicationName]]-[[.Console.Name]]" + annotations: + description: Route for Business Central's https service. + haproxy.router.openshift.io/timeout: 60s + spec: + host: "" + to: + name: "[[.ApplicationName]]-[[.Console.Name]]" + port: + targetPort: https + tls: + insecureEdgeTerminationPolicy: Redirect + termination: passthrough +## KIE smartrouter BEGIN +smartRouter: + persistentVolumeClaims: + - metadata: + name: "[[.ApplicationName]]-smartrouter-claim" + labels: + app: "[[.ApplicationName]]" + application: "[[.ApplicationName]]" + service: "[[.ApplicationName]]-smartrouter" + spec: + accessModes: + - ReadWriteMany + resources: + requests: + storage: "64Mi" + deploymentConfigs: + - metadata: + name: "[[.ApplicationName]]-smartrouter" + labels: + app: "[[.ApplicationName]]" + application: "[[.ApplicationName]]" + service: "[[.ApplicationName]]-smartrouter" + spec: + strategy: + type: Recreate + triggers: + - type: ImageChange + imageChangeParams: + automatic: true + containerNames: + - "[[.ApplicationName]]-smartrouter" + from: + kind: ImageStreamTag + namespace: "openshift" + name: "[[.Constants.Product]][[.Constants.Major]][[.Constants.Minor]]-smartrouter-openshift:[[.ImageTag]]" + - type: ConfigChange + replicas: [[.SmartRouter.Replicas]] + selector: + deploymentConfig: "[[.ApplicationName]]-smartrouter" + template: + metadata: + name: "[[.ApplicationName]]-smartrouter" + labels: + app: "[[.ApplicationName]]" + application: "[[.ApplicationName]]" + deploymentConfig: "[[.ApplicationName]]-smartrouter" + service: "[[.ApplicationName]]-smartrouter" + spec: + serviceAccountName: "[[$.ApplicationName]]-[[$.Constants.Product]]svc" + terminationGracePeriodSeconds: 60 + containers: + - name: "[[.ApplicationName]]-smartrouter" + image: "[[.Constants.Product]][[.Constants.Major]][[.Constants.Minor]]-smartrouter-openshift" + imagePullPolicy: Always + resources: + limits: + memory: "512Mi" + ports: + - name: http + containerPort: 9000 + protocol: TCP + env: + - name: KIE_SERVER_ROUTER_HOST + valueFrom: + fieldRef: + fieldPath: status.podIP + - name: KIE_SERVER_ROUTER_PORT + value: "9000" + - name: KIE_SERVER_ROUTER_PORT_TLS + value: "9443" + - name: KIE_SERVER_ROUTER_ID + value: "kie-server-router" + - name: KIE_SERVER_ROUTER_NAME + value: "KIE Server Router" + - name: KIE_SERVER_ROUTER_PROTOCOL + value: "[[.SmartRouter.Protocol]]" + #[[if .SmartRouter.UseExternalRoute]] + - name: KIE_SERVER_ROUTER_ROUTE_NAME + value: "[[$.ApplicationName]]-smartrouter" + #[[end]] + - name: KIE_SERVER_ROUTER_SERVICE + value: "[[.ApplicationName]]-smartrouter" + - name: KIE_SERVER_ROUTER_TLS_KEYSTORE_KEYALIAS + value: "jboss" + - name: KIE_SERVER_ROUTER_TLS_KEYSTORE_PASSWORD + value: "[[.KeyStorePassword]]" + - name: KIE_SERVER_ROUTER_TLS_KEYSTORE + value: "/etc/smartrouter-secret-volume/keystore.jks" + - name: KIE_SERVER_CONTROLLER_USER + value: controllerUser + - name: KIE_SERVER_CONTROLLER_PWD + value: "[[.ControllerPassword]]" + - name: KIE_SERVER_CONTROLLER_SERVICE + value: "[[.ApplicationName]]-[[.Console.Name]]" + - name: KIE_SERVER_CONTROLLER_PROTOCOL + value: "http" + - name: KIE_SERVER_ROUTER_REPO + value: "/opt/[[.Constants.Product]]-smartrouter/data" + - name: KIE_SERVER_ROUTER_CONFIG_WATCHER_ENABLED + value: "true" + volumeMounts: + - name: "[[.ApplicationName]]-smartrouter" + mountPath: "/opt/[[.Constants.Product]]-smartrouter/data" + - name: smartrouter-[[.Constants.KeystoreVolumeSuffix]] + mountPath: "/etc/smartrouter-secret-volume" + readOnly: true + volumes: + - name: "[[.ApplicationName]]-smartrouter" + persistentVolumeClaim: + claimName: "[[.ApplicationName]]-smartrouter-claim" + - name: smartrouter-[[.Constants.KeystoreVolumeSuffix]] + secret: + secretName: "[[.SmartRouter.KeystoreSecret]]" + services: + - spec: + ports: + - name: http + port: 9000 + targetPort: 9000 + - name: https + port: 9443 + targetPort: 9443 + selector: + deploymentConfig: "[[.ApplicationName]]-smartrouter" + metadata: + name: "[[.ApplicationName]]-smartrouter" + labels: + app: "[[.ApplicationName]]" + application: "[[.ApplicationName]]" + service: "[[.ApplicationName]]-smartrouter" + annotations: + description: The smart router server http and https ports. + routes: + - id: "[[.ApplicationName]]-smartrouter-https" + metadata: + name: "[[.ApplicationName]]-smartrouter" + labels: + app: "[[.ApplicationName]]" + application: "[[.ApplicationName]]" + service: "[[.ApplicationName]]-smartrouter" + annotations: + description: Route for Smart Router's https service. + spec: + host: "" + to: + name: "[[.ApplicationName]]-smartrouter" + port: + targetPort: https + tls: + insecureEdgeTerminationPolicy: Redirect + termination: passthrough +## KIE smartrouter END +## KIE Servers BEGIN +servers: + ## RANGE BEGINS + #[[ range $index, $Map := .Servers ]] + ## KIE server deployment config BEGIN + - deploymentConfigs: + - metadata: + name: "[[.KieName]]" + labels: + app: "[[$.ApplicationName]]" + application: "[[$.ApplicationName]]" + service: "[[.KieName]]" + services.server.kie.org/kie-server-id: "[[.KieServerID]]" + spec: + revisionHistoryLimit: 10 + strategy: + rollingParams: + maxSurge: 100% + maxUnavailable: 0 + type: Rolling + triggers: + - type: ImageChange + imageChangeParams: + automatic: true + containerNames: + - "[[.KieName]]" + from: + kind: "[[.From.Kind]]" + namespace: "[[.From.Namespace]]" + name: "[[.From.Name]]" + - type: ConfigChange + replicas: [[.Replicas]] + selector: + deploymentConfig: "[[.KieName]]" + template: + metadata: + name: "[[.KieName]]" + labels: + app: "[[$.ApplicationName]]" + application: "[[$.ApplicationName]]" + service: "[[.KieName]]" + deploymentConfig: "[[.KieName]]" + services.server.kie.org/kie-server-id: "[[.KieServerID]]" + spec: + serviceAccountName: "[[$.ApplicationName]]-[[$.Constants.Product]]svc" + terminationGracePeriodSeconds: 90 + containers: + - name: "[[.KieName]]" + image: "[[$.Constants.Product]][[$.Constants.Major]][[$.Constants.Minor]]-kieserver-openshift" + imagePullPolicy: Always + lifecycle: + postStart: + exec: + command: + - /bin/sh + - /opt/eap/bin/launch/jboss-kie-kieserver-hooks.sh + preStop: + exec: + command: + - /bin/sh + - /opt/eap/bin/launch/jboss-kie-kieserver-hooks.sh + env: + - name: WORKBENCH_SERVICE_NAME + value: "[[$.ApplicationName]]-[[$.Console.Name]]" + - name: KIE_ADMIN_USER + value: "[[$.AdminUser]]" + - name: KIE_ADMIN_PWD + value: "[[$.AdminPassword]]" + - name: KIE_SERVER_STARTUP_STRATEGY + value: "OpenShiftStartupStrategy" + - name: KIE_SERVER_USER + value: executionUser + - name: KIE_SERVER_PWD + value: "[[$.ServerPassword]]" + - name: DROOLS_SERVER_FILTER_CLASSES + value: "true" + - name: KIE_SERVER_CONTROLLER_USER + value: controllerUser + - name: KIE_SERVER_CONTROLLER_PWD + value: "[[$.ControllerPassword]]" + - name: KIE_SERVER_CONTROLLER_SERVICE + value: "[[$.ApplicationName]]-[[$.Console.Name]]" + - name: KIE_SERVER_CONTROLLER_PROTOCOL + value: ws + - name: KIE_SERVER_MODE + value: DEVELOPMENT + - name: KIE_MBEANS + value: enabled + - name: KIE_SERVER_HOST + valueFrom: + fieldRef: + fieldPath: status.podIP + - name: KIE_SERVER_ID + valueFrom: + fieldRef: + fieldPath: metadata.labels['services.server.kie.org/kie-server-id'] + - name: KIE_SERVER_ROUTE_NAME + value: "[[.KieName]]" + - name: "[[$.Constants.MavenRepo]]_MAVEN_REPO_USERNAME" + value: mavenUser + - name: "[[$.Constants.MavenRepo]]_MAVEN_REPO_PASSWORD" + value: "[[$.MavenPassword]]" + - name: "[[$.Constants.MavenRepo]]_MAVEN_REPO_SERVICE" + value: "[[$.ApplicationName]]-[[$.Console.Name]]" + - name: MAVEN_REPOS + value: "[[$.Constants.MavenRepo]],EXTERNAL" + - name: "[[$.Constants.MavenRepo]]_MAVEN_REPO_PATH" + value: /maven2/ + - name: KIE_SERVER_BYPASS_AUTH_USER + value: "false" + - name: HTTPS_KEYSTORE_DIR + value: "/etc/kieserver-secret-volume" + - name: HTTPS_KEYSTORE + value: "keystore.jks" + - name: HTTPS_NAME + value: "jboss" + - name: HTTPS_PASSWORD + value: "[[$.KeyStorePassword]]" + - name: JGROUPS_PING_PROTOCOL + value: "openshift.DNS_PING" + - name: OPENSHIFT_DNS_PING_SERVICE_NAME + value: "[[.KieName]]-ping" + - name: OPENSHIFT_DNS_PING_SERVICE_PORT + value: "8888" + # Auth config BEGIN + ## SSO config BEGIN + #[[if $.Auth.SSO.URL]] + - name: SSO_OPENIDCONNECT_DEPLOYMENTS + value: ROOT.war + - name: SSO_URL + value: "[[$.Auth.SSO.URL]]" + - name: SSO_REALM + value: "[[$.Auth.SSO.Realm]]" + - name: SSO_USERNAME + value: "[[$.Auth.SSO.AdminUser]]" + - name: SSO_PASSWORD + value: "[[$.Auth.SSO.AdminPassword]]" + - name: SSO_DISABLE_SSL_CERTIFICATE_VALIDATION + value: "[[$.Auth.SSO.DisableSSLCertValidation]]" + - name: SSO_PRINCIPAL_ATTRIBUTE + value: "[[$.Auth.SSO.PrincipalAttribute]]" + - name: SSO_SECRET + value: "[[.SSOAuthClient.Secret]]" + - name: SSO_CLIENT + value: "[[.SSOAuthClient.Name]]" + - name: HOSTNAME_HTTP + value: "[[.SSOAuthClient.HostnameHTTP]]" + - name: HOSTNAME_HTTPS + value: "[[.SSOAuthClient.HostnameHTTPS]]" + #[[end]] + ## SSO config END + ## LDAP config BEGIN + #[[if $.Auth.LDAP.URL]] + - name: AUTH_LDAP_URL + value: "[[$.Auth.LDAP.URL]]" + - name: AUTH_LDAP_BIND_DN + value: "[[$.Auth.LDAP.BindDN]]" + - name: AUTH_LDAP_BIND_CREDENTIAL + value: "[[$.Auth.LDAP.BindCredential]]" + - name: AUTH_LDAP_JAAS_SECURITY_DOMAIN + value: "[[$.Auth.LDAP.JAASSecurityDomain]]" + - name: AUTH_LDAP_BASE_CTX_DN + value: "[[$.Auth.LDAP.BaseCtxDN]]" + - name: AUTH_LDAP_BASE_FILTER + value: "[[$.Auth.LDAP.BaseFilter]]" + - name: AUTH_LDAP_SEARCH_SCOPE + value: "[[$.Auth.LDAP.SearchScope]]" + - name: AUTH_LDAP_SEARCH_TIME_LIMIT + value: "[[$.Auth.LDAP.SearchTimeLimit]]" + - name: AUTH_LDAP_DISTINGUISHED_NAME_ATTRIBUTE + value: "[[$.Auth.LDAP.DistinguishedNameAttribute]]" + - name: AUTH_LDAP_PARSE_USERNAME + value: "[[$.Auth.LDAP.ParseUsername]]" + - name: AUTH_LDAP_USERNAME_BEGIN_STRING + value: "[[$.Auth.LDAP.UsernameBeginString]]" + - name: AUTH_LDAP_USERNAME_END_STRING + value: "[[$.Auth.LDAP.UsernameEndString]]" + - name: AUTH_LDAP_ROLE_ATTRIBUTE_ID + value: "[[$.Auth.LDAP.RoleAttributeID]]" + - name: AUTH_LDAP_ROLES_CTX_DN + value: "[[$.Auth.LDAP.RolesCtxDN]]" + - name: AUTH_LDAP_ROLE_FILTER + value: "[[$.Auth.LDAP.RoleFilter]]" + - name: AUTH_LDAP_ROLE_RECURSION + value: "[[$.Auth.LDAP.RoleRecursion]]" + - name: AUTH_LDAP_DEFAULT_ROLE + value: "[[$.Auth.LDAP.DefaultRole]]" + - name: AUTH_LDAP_ROLE_NAME_ATTRIBUTE_ID + value: "[[$.Auth.LDAP.RoleNameAttributeID]]" + - name: AUTH_LDAP_PARSE_ROLE_NAME_FROM_DN + value: "[[$.Auth.LDAP.ParseRoleNameFromDN]]" + - name: AUTH_LDAP_ROLE_ATTRIBUTE_IS_DN + value: "[[$.Auth.LDAP.RoleAttributeIsDN]]" + - name: AUTH_LDAP_REFERRAL_USER_ATTRIBUTE_ID_TO_CHECK + value: "[[$.Auth.LDAP.ReferralUserAttributeIDToCheck]]" + #[[end]] + ## LDAP config END + ## RoleMapping config BEGIN + #[[if $.Auth.RoleMapper.RolesProperties]] + - name: AUTH_ROLE_MAPPER_ROLES_PROPERTIES + value: "[[$.Auth.RoleMapper.RolesProperties]]" + - name: AUTH_ROLE_MAPPER_REPLACE_ROLE + value: "[[$.Auth.RoleMapper.ReplaceRole]]" + #[[end]] + ## RoleMapping config END + # Auth config END + - name: KIE_SERVER_ROUTER_SERVICE + value: "[[$.ApplicationName]]-smartrouter" + #[[ if eq .SmartRouter.Protocol "https" ]] + - name: KIE_SERVER_ROUTER_PORT + value: "9443" + #[[ else ]] + - name: KIE_SERVER_ROUTER_PORT + value: "9000" + #[[ end ]] + - name: KIE_SERVER_ROUTER_PROTOCOL + value: "[[.SmartRouter.Protocol]]" + resources: + limits: + memory: 1Gi + livenessProbe: + httpGet: + path: /services/rest/server/healthcheck + port: 8080 + scheme: HTTP + initialDelaySeconds: 180 + timeoutSeconds: 2 + periodSeconds: 15 + failureThreshold: 3 + readinessProbe: + httpGet: + path: /services/rest/server/readycheck + port: 8080 + scheme: HTTP + initialDelaySeconds: 60 + timeoutSeconds: 2 + periodSeconds: 30 + failureThreshold: 6 + ports: + - name: jolokia + containerPort: 8778 + protocol: TCP + - name: http + containerPort: 8080 + protocol: TCP + - name: https + containerPort: 8443 + protocol: TCP + - name: ping + containerPort: 8888 + protocol: TCP + volumeMounts: + - mountPath: /etc/kieserver-secret-volume + name: kieserver-[[$.Constants.KeystoreVolumeSuffix]] + readOnly: true + volumes: + - name: kieserver-[[$.Constants.KeystoreVolumeSuffix]] + secret: + secretName: "[[.KeystoreSecret]]" + ## KIE server deployment config END + ## KIE server services BEGIN + services: + - spec: + ports: + - name: http + port: 8080 + targetPort: 8080 + - name: https + port: 8443 + targetPort: 8443 + selector: + deploymentConfig: "[[.KieName]]" + sessionAffinity: ClientIP + sessionAffinityConfig: + clientIP: + timeoutSeconds: 3600 + metadata: + name: "[[.KieName]]" + labels: + app: "[[$.ApplicationName]]" + application: "[[$.ApplicationName]]" + service: "[[.KieName]]" + annotations: + description: All the KIE server web server's ports. (KIE server) + - spec: + clusterIP: "None" + ports: + - name: "ping" + port: 8888 + targetPort: 8888 + selector: + deploymentConfig: "[[.KieName]]" + metadata: + name: "[[.KieName]]-ping" + labels: + app: "[[$.ApplicationName]]" + application: "[[$.ApplicationName]]" + service: "[[.KieName]]" + annotations: + service.alpha.kubernetes.io/tolerate-unready-endpoints: "true" + description: "The JGroups ping port for clustering." + ## KIE server services END + ## KIE server routes BEGIN + routes: + - id: "[[.KieName]]-https" + metadata: + name: "[[.KieName]]" + labels: + app: "[[$.ApplicationName]]" + application: "[[$.ApplicationName]]" + service: "[[.KieName]]" + annotations: + description: Route for KIE server's https service. + haproxy.router.openshift.io/timeout: 60s + spec: + to: + name: "[[.KieName]]" + port: + targetPort: https + tls: + insecureEdgeTerminationPolicy: Redirect + termination: passthrough + ## KIE server routes END +#[[end]] +## RANGE ends +## KIE Servers END + +## Other required resources BEGIN +others: + - roles: + - metadata: + name: "[[.ApplicationName]]-[[.Constants.Product]]svc-edit" + rules: + - apiGroups: + - "" + - app.kiegroup.org + - apps.openshift.io + - image.openshift.io + - route.openshift.io + resources: + - "*" + verbs: + - "*" + + serviceAccounts: + - metadata: + name: "[[.ApplicationName]]-[[.Constants.Product]]svc" + labels: + app: "[[.ApplicationName]]" + application: "[[.ApplicationName]]" + + rolebindings: + - metadata: + name: "[[.ApplicationName]]-[[.Constants.Product]]svc-edit" + subjects: + - kind: ServiceAccount + name: "[[.ApplicationName]]-[[.Constants.Product]]svc" + roleRef: + kind: Role + name: "[[.ApplicationName]]-[[.Constants.Product]]svc-edit" +# Other required resources END diff --git a/config/7.4.1/dbs/external.yaml b/config/7.4.1/dbs/external.yaml new file mode 100644 index 000000000..746371e3c --- /dev/null +++ b/config/7.4.1/dbs/external.yaml @@ -0,0 +1,60 @@ +## KIE Servers BEGIN +servers: + ## RANGE BEGINS + #[[ range $index, $Map := .Servers ]] + ## KIE server deployment config BEGIN + - deploymentConfigs: + - metadata: + name: "[[.KieName]]" + spec: + template: + spec: + containers: + - name: "[[.KieName]]" + env: + ## ExternalDB settings BEGIN + - name: KIE_SERVER_PERSISTENCE_DIALECT + value: "[[.Database.ExternalConfig.Dialect]]" + - name: DATASOURCES + value: "RHPAM" + - name: RHPAM_DATABASE + value: "[[.Database.ExternalConfig.Name]]" + - name: RHPAM_SERVICE_HOST + value: "[[.Database.ExternalConfig.Host]]" + - name: RHPAM_SERVICE_PORT + value: "[[.Database.ExternalConfig.Port]]" + - name: RHPAM_JNDI + value: "java:/jboss/datasources/rhpam" + - name: RHPAM_DRIVER + value: "[[.Database.ExternalConfig.Driver]]" + - name: RHPAM_USERNAME + value: "[[.Database.ExternalConfig.Username]]" + - name: RHPAM_PASSWORD + value: "[[.Database.ExternalConfig.Password]]" + - name: RHPAM_NONXA + value: "[[.Database.ExternalConfig.NonXA]]" + - name: RHPAM_URL + value: "[[.Database.ExternalConfig.JdbcURL]]" + - name: RHPAM_XA_CONNECTION_PROPERTY_URL + value: "[[.Database.ExternalConfig.JdbcURL]]" + - name: RHPAM_MIN_POOL_SIZE + value: "[[.Database.ExternalConfig.MinPoolSize]]" + - name: RHPAM_MAX_POOL_SIZE + value: "[[.Database.ExternalConfig.MaxPoolSize]]" + - name: RHPAM_CONNECTION_CHECKER + value: "[[.Database.ExternalConfig.ConnectionChecker]]" + - name: RHPAM_EXCEPTION_SORTER + value: "[[.Database.ExternalConfig.ExceptionSorter]]" + - name: RHPAM_BACKGROUND_VALIDATION + value: "[[.Database.ExternalConfig.BackgroundValidation]]" + - name: RHPAM_VALIDATION_MILLIS + value: "[[.Database.ExternalConfig.BackgroundValidationMillis]]" + - name: RHPAM_JTA + value: "true" + - name: TIMER_SERVICE_DATA_STORE_REFRESH_INTERVAL + value: "10000" + ## ExternalDB settings END + ## KIE server deployment config END + #[[end]] + ## RANGE ends + ## KIE Servers END diff --git a/config/7.4.1/dbs/h2.yaml b/config/7.4.1/dbs/h2.yaml new file mode 100644 index 000000000..a33ac9344 --- /dev/null +++ b/config/7.4.1/dbs/h2.yaml @@ -0,0 +1,78 @@ +## KIE Servers BEGIN +servers: + ## RANGE BEGINS + #[[ range $index, $Map := .Servers ]] + - deploymentConfigs: + ## KIE server deployment config BEGIN + - metadata: + name: "[[.KieName]]" + spec: + template: + metadata: + name: "[[.KieName]]" + spec: + containers: + - name: "[[.KieName]]" + env: + ## H2 driver settings BEGIN + - name: DATASOURCES + value: "RHPAM" + - name: RHPAM_DATABASE + value: "rhpam7" + - name: RHPAM_JNDI + value: "java:/jboss/datasources/rhpam" + - name: RHPAM_JTA + value: "true" + - name: RHPAM_DRIVER + value: "h2" + - name: KIE_SERVER_PERSISTENCE_DIALECT + value: "org.hibernate.dialect.H2Dialect" + - name: RHPAM_USERNAME + value: "rhpam" + - name: RHPAM_PASSWORD + value: "[[$.DBPassword]]" + - name: RHPAM_SERVICE_HOST + value: "dummy_ignored" + - name: RHPAM_SERVICE_PORT + value: "12345" + - name: KIE_SERVER_PERSISTENCE_DS + value: "java:/jboss/datasources/rhpam" + - name: RHPAM_NONXA + value: "false" + - name: RHPAM_XA_CONNECTION_PROPERTY_URL + value: "jdbc:h2:/opt/kie/data/h2/rhpam;AUTO_SERVER=TRUE" + ## H2 driver settings END + volumeMounts: + - name: "[[.KieName]]-kie-[[$.Constants.DatabaseVolumeSuffix]]" + mountPath: "/opt/kie/data" + ## [[ if ne .Database.Size "" ]] + volumes: + ## H2 volume settings BEGIN + - name: "[[.KieName]]-kie-[[$.Constants.DatabaseVolumeSuffix]]" + persistentVolumeClaim: + claimName: "[[.KieName]]-kie-claim" + ## KIE server deployment config END + persistentVolumeClaims: + ## H2 persistent volume claim BEGIN + - metadata: + name: "[[.KieName]]-kie-claim" + labels: + app: "[[$.ApplicationName]]" + application: "[[$.ApplicationName]]" + service: "[[.KieName]]" + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: "[[.Database.Size]]" + ## H2 persistent volume claim END + ## [[ else ]] + volumes: + ## H2 volume settings BEGIN + - name: "[[.KieName]]-kie-[[$.Constants.DatabaseVolumeSuffix]]" + emptyDir: {} +## [[ end ]] +#[[end]] +## RANGE ends +## KIE Servers END diff --git a/config/7.4.1/dbs/mysql.yaml b/config/7.4.1/dbs/mysql.yaml new file mode 100644 index 000000000..d94b0fe94 --- /dev/null +++ b/config/7.4.1/dbs/mysql.yaml @@ -0,0 +1,166 @@ +## KIE Servers BEGIN +servers: + ## RANGE BEGINS + #[[ range $index, $Map := .Servers ]] + ## KIE server deployment config BEGIN + - deploymentConfigs: + - metadata: + name: "[[.KieName]]" + spec: + template: + spec: + initContainers: + - command: + [ + "sh", + "-c", + "until nslookup [[.KieName]]-mysql && nc -vz [[.KieName]]-mysql 3306; do echo waiting for [[.KieName]]-mysql; sleep 2; done;", + ] + image: busybox + imagePullPolicy: IfNotPresent + name: "[[.KieName]]-mysql-init" + terminationMessagePolicy: FallbackToLogsOnError + containers: + - name: "[[.KieName]]" + env: + ## MySQL driver settings BEGIN + - name: DATASOURCES + value: "RHPAM" + - name: RHPAM_DATABASE + value: "rhpam7" + - name: RHPAM_JNDI + value: "java:/jboss/datasources/rhpam" + - name: RHPAM_JTA + value: "true" + - name: KIE_SERVER_PERSISTENCE_DS + value: "java:/jboss/datasources/rhpam" + - name: RHPAM_DRIVER + value: "mariadb" + - name: KIE_SERVER_PERSISTENCE_DIALECT + value: "org.hibernate.dialect.MySQL57Dialect" + - name: RHPAM_USERNAME + value: "rhpam" + - name: RHPAM_PASSWORD + value: "[[$.DBPassword]]" + - name: RHPAM_SERVICE_HOST + value: "[[.KieName]]-mysql" + - name: RHPAM_SERVICE_PORT + value: "3306" + - name: RHPAM_CONNECTION_CHECKER + value: "org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker" + - name: RHPAM_EXCEPTION_SORTER + value: "org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLExceptionSorter" + - name: TIMER_SERVICE_DATA_STORE_REFRESH_INTERVAL + value: "60000" + ## MySQL driver settings END + ## KIE server deployment config END + ## MySQL deployment BEGIN + - metadata: + name: "[[.KieName]]-mysql" + labels: + app: "[[$.ApplicationName]]" + application: "[[$.ApplicationName]]" + service: "[[.KieName]]-mysql" + spec: + strategy: + type: Recreate + triggers: + - type: ImageChange + imageChangeParams: + automatic: true + containerNames: + - "[[.KieName]]-mysql" + from: + kind: ImageStreamTag + namespace: "openshift" + name: "mysql:5.7" + - type: ConfigChange + replicas: 1 + selector: + deploymentConfig: "[[.KieName]]-mysql" + template: + metadata: + name: "[[.KieName]]-mysql" + labels: + deploymentConfig: "[[.KieName]]-mysql" + app: "[[$.ApplicationName]]" + application: "[[$.ApplicationName]]" + service: "[[.KieName]]-mysql" + spec: + terminationGracePeriodSeconds: 60 + containers: + - name: "[[.KieName]]-mysql" + image: mysql + imagePullPolicy: Always + livenessProbe: + tcpSocket: + port: 3306 + initialDelaySeconds: 30 + timeoutSeconds: 1 + readinessProbe: + exec: + command: + - "/bin/sh" + - "-i" + - "-c" + - "MYSQL_PWD=$MYSQL_PASSWORD mysql -h 127.0.0.1 -u $MYSQL_USER -D $MYSQL_DATABASE -e 'SELECT 1'" + port: 3306 + initialDelaySeconds: 5 + timeoutSeconds: 1 + ports: + - containerPort: 3306 + protocol: TCP + env: + - name: MYSQL_USER + value: "rhpam" + - name: MYSQL_PASSWORD + value: "[[$.DBPassword]]" + - name: MYSQL_DATABASE + value: "rhpam7" + volumeMounts: + - mountPath: "/var/lib/mysql/data" + name: "[[.KieName]]-mysql-[[$.Constants.DatabaseVolumeSuffix]]" + ## [[ if ne .Database.Size "" ]] + volumes: + - name: "[[.KieName]]-mysql-[[$.Constants.DatabaseVolumeSuffix]]" + persistentVolumeClaim: + claimName: "[[.KieName]]-mysql-claim" + ## MySQL persistent volume claim BEGIN + persistentVolumeClaims: + - metadata: + name: "[[.KieName]]-mysql-claim" + labels: + app: "[[$.ApplicationName]]" + application: "[[$.ApplicationName]]" + service: "[[.KieName]]-mysql" + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: "[[.Database.Size]]" + ## MySQL persistent volume claim END + ## [[ else ]] + volumes: + - name: "[[.KieName]]-mysql-[[$.Constants.DatabaseVolumeSuffix]]" + emptyDir: {} + ## [[ end ]] + ## MySQL deployment END + services: + - spec: + ports: + - port: 3306 + targetPort: 3306 + selector: + deploymentConfig: "[[.KieName]]-mysql" + metadata: + name: "[[.KieName]]-mysql" + labels: + app: "[[$.ApplicationName]]" + application: "[[$.ApplicationName]]" + service: "[[.KieName]]-mysql" + annotations: + description: The MySQL server's port. + #[[end]] + ## RANGE ends +## KIE Servers END diff --git a/config/7.4.1/dbs/postgresql.yaml b/config/7.4.1/dbs/postgresql.yaml new file mode 100644 index 000000000..4d933d200 --- /dev/null +++ b/config/7.4.1/dbs/postgresql.yaml @@ -0,0 +1,166 @@ +## KIE Servers BEGIN +servers: + ## RANGE BEGINS + #[[ range $index, $Map := .Servers ]] + ## KIE server deployment config BEGIN + - deploymentConfigs: + - metadata: + name: "[[.KieName]]" + spec: + template: + spec: + initContainers: + - command: + [ + "sh", + "-c", + "until nslookup [[.KieName]]-postgresql && nc -vz [[.KieName]]-postgresql 5432; do echo waiting for [[.KieName]]-postgresql; sleep 2; done;", + ] + image: busybox + imagePullPolicy: IfNotPresent + name: "[[.KieName]]-postgresql-init" + terminationMessagePolicy: FallbackToLogsOnError + containers: + - name: "[[.KieName]]" + env: + ## PostgreSQL driver settings BEGIN + - name: DATASOURCES + value: "RHPAM" + - name: RHPAM_DATABASE + value: "rhpam7" + - name: RHPAM_JNDI + value: "java:/jboss/datasources/rhpam" + - name: RHPAM_JTA + value: "true" + - name: KIE_SERVER_PERSISTENCE_DS + value: "java:/jboss/datasources/rhpam" + - name: RHPAM_DRIVER + value: "postgresql" + - name: KIE_SERVER_PERSISTENCE_DIALECT + value: "org.hibernate.dialect.PostgreSQLDialect" + - name: RHPAM_USERNAME + value: "rhpam" + - name: RHPAM_PASSWORD + value: "[[$.DBPassword]]" + - name: RHPAM_SERVICE_HOST + value: "[[.KieName]]-postgresql" + - name: RHPAM_SERVICE_PORT + value: "5432" + - name: RHPAM_CONNECTION_CHECKER + value: "org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLValidConnectionChecker" + - name: RHPAM_EXCEPTION_SORTER + value: "org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLExceptionSorter" + - name: TIMER_SERVICE_DATA_STORE_REFRESH_INTERVAL + value: "30000" + ## PostgreSQL driver settings END + ## KIE server deployment config END + ## PostgreSQL deployment config BEGIN + - metadata: + name: "[[.KieName]]-postgresql" + labels: + app: "[[$.ApplicationName]]" + application: "[[$.ApplicationName]]" + service: "[[.KieName]]-postgresql" + spec: + strategy: + type: Recreate + triggers: + - type: ImageChange + imageChangeParams: + automatic: true + containerNames: + - "[[.KieName]]-postgresql" + from: + kind: ImageStreamTag + namespace: "openshift" + name: "postgresql:10" + - type: ConfigChange + replicas: 1 + selector: + deploymentConfig: "[[.KieName]]-postgresql" + template: + metadata: + name: "[[.KieName]]-postgresql" + labels: + deploymentConfig: "[[.KieName]]-postgresql" + app: "[[$.ApplicationName]]" + application: "[[$.ApplicationName]]" + service: "[[.KieName]]-postgresql" + spec: + containers: + - name: "[[.KieName]]-postgresql" + image: postgresql + imagePullPolicy: IfNotPresent + livenessProbe: + exec: + command: + - "/usr/libexec/check-container" + - "--live" + initialDelaySeconds: 120 + timeoutSeconds: 10 + readinessProbe: + exec: + command: + - "/usr/libexec/check-container" + initialDelaySeconds: 5 + timeoutSeconds: 1 + ports: + - containerPort: 5432 + protocol: TCP + env: + - name: POSTGRESQL_USER + value: "rhpam" + - name: POSTGRESQL_PASSWORD + value: "[[$.DBPassword]]" + - name: POSTGRESQL_DATABASE + value: "rhpam7" + - name: POSTGRESQL_MAX_PREPARED_TRANSACTIONS + value: "100" + volumeMounts: + - mountPath: "/var/lib/pgsql/data" + name: "[[.KieName]]-postgresql-[[$.Constants.DatabaseVolumeSuffix]]" + ## [[ if ne .Database.Size "" ]] + volumes: + - name: "[[.KieName]]-postgresql-[[$.Constants.DatabaseVolumeSuffix]]" + persistentVolumeClaim: + claimName: "[[.KieName]]-postgresql-claim" + ## PostgreSQL deployment config END + ## PostgreSQL persistent volume claim BEGIN + persistentVolumeClaims: + - metadata: + name: "[[.KieName]]-postgresql-claim" + labels: + app: "[[$.ApplicationName]]" + application: "[[$.ApplicationName]]" + service: "[[.KieName]]-postgresql" + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: "[[.Database.Size]]" + ## PostgreSQL persistent volume claim END + ## [[ else ]] + volumes: + - name: "[[.KieName]]-postgresql-[[$.Constants.DatabaseVolumeSuffix]]" + emptyDir: {} + ## [[ end ]] + services: + ## PostgreSQL service BEGIN + - metadata: + annotations: + description: The database server's port. + labels: + application: prod + service: "[[.KieName]]-postgresql" + name: "[[.KieName]]-postgresql" + spec: + ports: + - port: 5432 + targetPort: 5432 + selector: + deploymentConfig: "[[.KieName]]-postgresql" + ## PostgreSQL service END + #[[end]] + ## RANGE ends + ## KIE Servers END diff --git a/config/7.4.1/envs/rhdm-authoring-ha.yaml b/config/7.4.1/envs/rhdm-authoring-ha.yaml new file mode 100644 index 000000000..bdc05735e --- /dev/null +++ b/config/7.4.1/envs/rhdm-authoring-ha.yaml @@ -0,0 +1,609 @@ +console: + persistentVolumeClaims: + - metadata: + name: "[[.ApplicationName]]-[[.Console.Name]]-claim" + labels: + app: "[[.ApplicationName]]" + application: "[[.ApplicationName]]" + spec: + accessModes: + - ReadWriteMany + resources: + requests: + storage: 1Gi + + deploymentConfigs: + - metadata: + name: "[[.ApplicationName]]-[[.Console.Name]]" + spec: + template: + metadata: + name: "[[.ApplicationName]]-[[.Console.Name]]" + spec: + containers: + - name: "[[.ApplicationName]]-[[.Console.Name]]" + volumeMounts: + - name: "[[.ApplicationName]]-[[.Console.Name]]-pvol" + mountPath: "/opt/kie/data" + ports: + - name: git-ssh + containerPort: 8001 + protocol: TCP + env: + - name: APPFORMER_INFINISPAN_SERVICE_NAME + value: "[[.ApplicationName]]-datagrid" + - name: APPFORMER_INFINISPAN_PORT + value: "11222" + - name: APPFORMER_JMS_BROKER_ADDRESS + value: "[[.ApplicationName]]-amq-tcp" + - name: APPFORMER_JMS_BROKER_PORT + value: "61616" + - name: APPFORMER_JMS_BROKER_USER + value: "jmsBrokerUser" + - name: APPFORMER_JMS_BROKER_PASSWORD + value: "[[.AMQClusterPassword]]" + volumes: + - name: "[[.ApplicationName]]-[[.Console.Name]]-pvol" + persistentVolumeClaim: + claimName: "[[.ApplicationName]]-[[.Console.Name]]-claim" + + services: + - spec: + ports: + - name: git-ssh + port: 8001 + targetPort: 8001 + metadata: + name: "[[.ApplicationName]]-[[.Console.Name]]" + +# ES/AMQ BEGIN +others: + - roles: + - metadata: + name: "[[.ApplicationName]]-amq-role" + labels: + app: "[[.ApplicationName]]" + application: "[[.ApplicationName]]" + rules: + - apiGroups: + - "" + resources: + - endpoints + verbs: + - create + - delete + - deletecollection + - get + - list + - patch + - update + - watch + - apiGroups: + - "" + resources: + - namespaces + verbs: + - get + - list + + - metadata: + name: "[[.ApplicationName]]-amq-scaledown-controller-role" + labels: + app: "[[.ApplicationName]]" + application: "[[.ApplicationName]]" + rules: + - apiGroups: + - apps + resources: + - statefulsets + verbs: + - get + - list + - watch + - apiGroups: + - "" + resources: + - pods + verbs: + - get + - list + - watch + - create + - delete + - patch + - update + - apiGroups: + - "" + resources: + - persistentvolumeclaims + verbs: + - get + - list + - watch + - delete + - apiGroups: + - "" + resources: + - events + verbs: + - get + - list + - watch + + rolebindings: + - metadata: + name: "[[.ApplicationName]]-amq-scaledown-controller-openshift-rb" + labels: + app: "[[.ApplicationName]]" + application: "[[.ApplicationName]]" + subjects: + - kind: ServiceAccount + name: "[[.ApplicationName]]-amq-scaledown-controller-sa" + roleRef: + kind: Role + name: "[[.ApplicationName]]-amq-scaledown-controller-role" + apiGroup: rbac.authorization.k8s.io + + - metadata: + name: "[[.ApplicationName]]-amq-rb" + labels: + app: "[[.ApplicationName]]" + application: "[[.ApplicationName]]" + subjects: + - kind: ServiceAccount + name: "[[.ApplicationName]]-amq-sa" + roleRef: + kind: Role + name: "[[.ApplicationName]]-amq-role" + apiGroup: rbac.authorization.k8s.io + + serviceaccounts: + - metadata: + labels: + app: "[[.ApplicationName]]" + application: "[[.ApplicationName]]" + name: "[[.ApplicationName]]-amq-sa" + + - metadata: + labels: + app: "[[.ApplicationName]]" + application: "[[.ApplicationName]]" + name: "[[.ApplicationName]]-amq-scaledown-controller-sa" + + deploymentConfigs: + - metadata: + labels: + app: "[[.ApplicationName]]" + application: "[[.ApplicationName]]" + service: "[[.ApplicationName]]-amq-scaledown-controller" + name: "[[.ApplicationName]]-amq-scaledown-controller" + annotations: + deployment.kubernetes.io/revision: "1" + template.alpha.openshift.io/wait-for-ready: "true" + spec: + replicas: 1 + selector: + deploymentConfig: "[[.ApplicationName]]-amq-scaledown-controller" + strategy: + rollingParams: + maxSurge: 0 + type: Rolling + template: + metadata: + labels: + app: "[[.ApplicationName]]" + application: "[[.ApplicationName]]" + deploymentConfig: "[[.ApplicationName]]-amq-scaledown-controller" + name: "[[.ApplicationName]]-amq-scaledown-controller" + spec: + serviceAccountName: "[[.ApplicationName]]-amq-scaledown-controller-sa" + containers: + - args: + - --localOnly + - --v + - "3" + image: "amq-broker-72-scaledown-controller-openshift" + imagePullPolicy: IfNotPresent + name: "[[.ApplicationName]]-amq" + terminationGracePeriodSeconds: 30 + triggers: + - imageChangeParams: + automatic: true + containerNames: + - "[[.ApplicationName]]-amq" + from: + kind: ImageStreamTag + namespace: "openshift" + name: "amq-broker-72-scaledown-controller-openshift:1.0" + type: ImageChange + - type: ConfigChange + + statefulsets: + - metadata: + name: "[[.ApplicationName]]-datagrid" + labels: + app: "[[.ApplicationName]]" + application: "[[.ApplicationName]]" + service: "[[.ApplicationName]]-datagrid" + spec: + podManagementPolicy: OrderedReady + replicas: 1 + selector: + matchLabels: + deploymentConfig: "[[.ApplicationName]]-datagrid" + serviceName: "[[.ApplicationName]]-datagrid" + strategy: + rollingParams: + intervalSeconds: 20 + maxSurge: 1 + maxUnavailable: 1 + timeoutSeconds: 1200 + updatePeriodSeconds: 20 + type: Rolling + template: + metadata: + labels: + app: "[[.ApplicationName]]" + application: "[[.ApplicationName]]" + deploymentConfig: "[[.ApplicationName]]-datagrid" + name: "[[.ApplicationName]]-datagrid" + spec: + containers: + - env: + - name: SERVICE_NAME + value: "[[.ApplicationName]]-datagrid" + - name: SERVICE_PROFILE + value: "[[.ApplicationName]]-datagrid" + - name: JGROUPS_PING_PROTOCOL + value: openshift.DNS_PING + - name: OPENSHIFT_DNS_PING_SERVICE_NAME + value: "[[.ApplicationName]]-datagrid-ping" + - name: INFINISPAN_CONNECTORS + value: "hotrod" + image: "registry.redhat.io/jboss-datagrid-7/[[$.Constants.DatagridImage]]:[[$.Constants.DatagridImageTag]]" + imagePullPolicy: IfNotPresent + name: "[[.ApplicationName]]-datagrid" + ports: + - containerPort: 8888 + name: ping + protocol: TCP + - containerPort: 11222 + name: hotrod + protocol: TCP + livenessProbe: + exec: + command: + - /opt/datagrid/bin/livenessProbe.sh + failureThreshold: 5 + initialDelaySeconds: 15 + periodSeconds: 20 + successThreshold: 1 + timeoutSeconds: 10 + readinessProbe: + exec: + command: + - /opt/datagrid/bin/readinessProbe.sh + failureThreshold: 5 + initialDelaySeconds: 17 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 10 + resources: + limits: + memory: "512Mi" + requests: + cpu: "0.5" + memory: "512Mi" + volumeMounts: + - mountPath: /opt/datagrid/standalone/data + name: srv-data + - mountPath: /var/run/secrets/java.io/keystores + name: datagrid-keystore-volume + - mountPath: /var/run/secrets/openshift.io/serviceaccount + name: datagrid-service-certs + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + securityContext: {} + terminationGracePeriodSeconds: 60 + volumes: + - empty-dir: {} + name: datagrid-keystore-volume + - name: datagrid-service-certs + secret: + secretName: datagrid-service-certs + triggers: + - type: ConfigChange + volumeClaimTemplates: + - metadata: + name: srv-data + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 1Gi + + - metadata: + annotations: + alpha.image.policy.openshift.io/resolve-names: "*" + statefulsets.kubernetes.io/drainer-pod-template: | + { + "metadata": { + "labels": { + "app": "[[.ApplicationName]]", + "application": "[[.ApplicationName]]" + }, + "name": "[[.ApplicationName]]-amq-drainer-pod" + }, + "spec": { + "serviceAccount": "[[.ApplicationName]]-amq-sa", + "serviceAccountName": "[[.ApplicationName]]-amq-sa", + "terminationGracePeriodSeconds": 5, + "containers": [ + { + "env": [ + { + "name": "AMQ_EXTRA_ARGS", + "value": "--no-autotune" + }, + { + "name": "AMQ_USER", + "value": "jmsBrokerUser" + }, + { + "name": "AMQ_PASSWORD", + "value": "[[.AMQPassword]]" + }, + { + "name": "AMQ_ROLE", + "value": "admin" + }, + { + "name": "AMQ_NAME", + "value": "broker" + }, + { + "name": "AMQ_TRANSPORTS", + "value": "openwire" + }, + { + "name": "AMQ_QUEUES", + "value": "" + }, + { + "name": "AMQ_GLOBAL_MAX_SIZE", + "value": "100 gb" + }, + { + "name": "AMQ_ALLOW_ANONYMOUS", + "value": "" + }, + { + "name": "AMQ_DATA_DIR", + "value": "/opt/amq/data" + }, + { + "name": "AMQ_DATA_DIR_LOGGING", + "value": "true" + }, + { + "name": "AMQ_CLUSTERED", + "value": "true" + }, + { + "name": "AMQ_REPLICAS", + "value": "2" + }, + { + "name": "AMQ_CLUSTER_USER", + "value": "jmsBrokerUser" + }, + { + "name": "AMQ_CLUSTER_PASSWORD", + "value": "[[.AMQClusterPassword]]" + }, + { + "name": "POD_NAMESPACE", + "valueFrom": { + "fieldRef": { + "fieldPath": "metadata.namespace" + } + } + }, + { + "name": "OPENSHIFT_DNS_PING_SERVICE_PORT", + "value": "8888" + } + ], + "image": "registry.redhat.io/amq-broker-7/[[$.Constants.BrokerImage]]:[[$.Constants.BrokerImageTag]]", + "name": "[[.ApplicationName]]-amq", + "command": ["/bin/sh", "-c", "echo \"Starting the drainer\" ; /opt/amq/bin/drain.sh; echo \"Drain completed! Exit code $?\""], + "volumeMounts": [ + { + "name": "[[.ApplicationName]]-amq-pvol", + "mountPath": "/opt/amq/data" + } + ] + } + ] + } + } + generation: 3 + labels: + app: "[[.ApplicationName]]" + application: "[[.ApplicationName]]" + name: "[[.ApplicationName]]-amq" + spec: + podManagementPolicy: OrderedReady + replicas: 2 + revisionHistoryLimit: 10 + selector: + matchLabels: + app: "[[.ApplicationName]]" + serviceName: "[[.ApplicationName]]-amq-tcp" + template: + metadata: + labels: + app: "[[.ApplicationName]]" + application: "[[.ApplicationName]]" + deploymentConfig: "[[.ApplicationName]]-amq" + name: "[[.ApplicationName]]-amq" + spec: + containers: + - env: + - name: AMQ_USER + value: "jmsBrokerUser" + - name: AMQ_PASSWORD + value: "[[.AMQPassword]]" + - name: AMQ_ROLE + value: admin + - name: AMQ_NAME + value: broker + - name: AMQ_TRANSPORTS + value: "openwire" + - name: AMQ_GLOBAL_MAX_SIZE + value: "100 gb" + - name: AMQ_REQUIRE_LOGIN + - name: AMQ_DATA_DIR + value: /opt/amq/data + - name: AMQ_DATA_DIR_LOGGING + value: "true" + - name: AMQ_CLUSTERED + value: "true" + - name: AMQ_REPLICAS + value: "0" + - name: AMQ_CLUSTER_USER + value: "jmsBrokerUser" + - name: AMQ_CLUSTER_PASSWORD + value: "[[.AMQClusterPassword]]" + - name: OPENSHIFT_DNS_PING_SERVICE_NAME + value: "[[.ApplicationName]]-amq-ping" + - name: AMQ_EXTRA_ARGS + - name: AMQ_ANYCAST_PREFIX + - name: AMQ_MULTICAST_PREFIX + - name: POD_NAMESPACE + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.namespace + image: "registry.redhat.io/amq-broker-7/[[$.Constants.BrokerImage]]:[[$.Constants.BrokerImageTag]]" + imagePullPolicy: IfNotPresent + name: broker-amq + ports: + - containerPort: 8161 + name: jolokia + protocol: TCP + - containerPort: 5672 + name: amqp + protocol: TCP + - containerPort: 1883 + name: mqtt + protocol: TCP + - containerPort: 61613 + name: stomp + protocol: TCP + - containerPort: 61616 + name: artemis + protocol: TCP + readinessProbe: + exec: + command: + - /bin/bash + - -c + - /opt/amq/bin/readinessProbe.sh + failureThreshold: 3 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 1 + resources: {} + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + volumeMounts: + - mountPath: /opt/amq/data + name: "[[.ApplicationName]]-amq-pvol" + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + securityContext: {} + terminationGracePeriodSeconds: 60 + updateStrategy: + type: OnDelete + volumeClaimTemplates: + - metadata: + name: "[[.ApplicationName]]-amq-pvol" + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 1Gi + + services: + - spec: + clusterIP: None + ports: + - port: 61616 + targetPort: 61616 + selector: + deploymentConfig: "[[.ApplicationName]]-amq" + metadata: + name: "[[.ApplicationName]]-amq-tcp" + labels: + app: "[[.ApplicationName]]" + application: "[[.ApplicationName]]" + service: "[[.ApplicationName]]-amq" + annotations: + description: The broker's OpenWire port. + + - spec: + clusterIP: None + ports: + - port: 8888 + protocol: TCP + targetPort: 8888 + selector: + deploymentConfig: "[[.ApplicationName]]-amq" + metadata: + name: "[[.ApplicationName]]-amq-ping" + annotations: + description: The JGroups ping port for clustering. + service.alpha.kubernetes.io/tolerate-unready-endpoints: "true" + labels: + app: "[[.ApplicationName]]" + application: "[[.ApplicationName]]" + + - spec: + clusterIP: None + ports: + - name: ping + port: 8888 + protocol: TCP + targetPort: 8888 + selector: + deploymentConfig: "[[.ApplicationName]]-datagrid" + metadata: + name: "[[.ApplicationName]]-datagrid-ping" + labels: + application: "[[.ApplicationName]]" + annotations: + description: "The JGroups ping port for clustering." + service.alpha.kubernetes.io/tolerate-unready-endpoints: "true" + + - spec: + ports: + - name: hotrod + port: 11222 + protocol: TCP + targetPort: 11222 + selector: + deploymentConfig: "[[.ApplicationName]]-datagrid" + metadata: + name: "[[.ApplicationName]]-datagrid" + labels: + application: "[[.ApplicationName]]" + annotations: + description: Provides a service for accessing the application over Hot Rod protocol. + service.alpha.openshift.io/serving-cert-secret-name: datagrid-service-certs + ## ES/AMQ END + diff --git a/config/7.4.1/envs/rhdm-authoring.yaml b/config/7.4.1/envs/rhdm-authoring.yaml new file mode 100644 index 000000000..e53276d2f --- /dev/null +++ b/config/7.4.1/envs/rhdm-authoring.yaml @@ -0,0 +1,53 @@ +console: + deploymentConfigs: + - metadata: + name: "[[.ApplicationName]]-[[.Console.Name]]" + spec: + template: + metadata: + name: "[[.ApplicationName]]-[[.Console.Name]]" + spec: + containers: + - name: "[[.ApplicationName]]-[[.Console.Name]]" + env: + - name: MAVEN_MIRROR_URL + value: "" + - name: MAVEN_REPO_ID + value: "" + - name: MAVEN_REPO_URL + value: "" + - name: MAVEN_REPO_USERNAME + value: "" + - name: MAVEN_REPO_PASSWORD + value: "" + - name: JGROUPS_PING_PROTOCOL + value: "" + - name: OPENSHIFT_DNS_PING_SERVICE_NAME + value: "" + - name: OPENSHIFT_DNS_PING_SERVICE_PORT + value: "" + ports: + - name: git-ssh + containerPort: 8001 + protocol: TCP + persistentVolumeClaims: + - metadata: + name: "[[.ApplicationName]]-[[.Console.Name]]-claim" + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 1Gi + services: + - metadata: + name: "[[.ApplicationName]]-[[.Console.Name]]" + spec: + ports: + - name: git-ssh + port: 8001 + targetPort: 8001 + - metadata: + name: "[[.ApplicationName]]-[[.Console.Name]]-ping" + annotations: + delete: "true" diff --git a/config/7.4.1/envs/rhdm-production-immutable.yaml b/config/7.4.1/envs/rhdm-production-immutable.yaml new file mode 100644 index 000000000..8c9bae3eb --- /dev/null +++ b/config/7.4.1/envs/rhdm-production-immutable.yaml @@ -0,0 +1,92 @@ +console: + omit: true +## KIE Servers BEGIN +servers: + ## RANGE BEGINS + #[[ range $index, $Map := .Servers ]] + ## KIE server deployment config BEGIN + - deploymentConfigs: + - metadata: + name: "[[.KieName]]" + labels: + app: "[[$.ApplicationName]]" + application: "[[$.ApplicationName]]" + service: "[[.KieName]]" + spec: + template: + spec: + containers: + - name: "[[.KieName]]" + image: "[[.KieName]]" + env: + - name: KIE_SERVER_CONTAINER_DEPLOYMENT + value: "[[.Build.KieServerContainerDeployment]]" + - name: KIE_SERVER_MGMT_DISABLED + value: "true" + - name: "[[$.Constants.MavenRepo]]_MAVEN_REPO_USERNAME" + value: "" + - name: "[[$.Constants.MavenRepo]]_MAVEN_REPO_PASSWORD" + value: "" + - name: "[[$.Constants.MavenRepo]]_MAVEN_REPO_SERVICE" + value: "" + - name: MAVEN_REPOS + value: "EXTERNAL" + + ## KIE server deployment config END + ## KIE server build config BEGIN + #[[if .Build.KieServerContainerDeployment]] + imageStreams: + - metadata: + name: "[[.KieName]]" + labels: + app: "[[$.ApplicationName]]" + application: "[[$.ApplicationName]]" + service: "[[.KieName]]" + buildConfigs: + - metadata: + name: "[[.KieName]]" + labels: + app: "[[$.ApplicationName]]" + application: "[[$.ApplicationName]]" + service: "[[.KieName]]" + spec: + source: + type: Git + git: + uri: "[[.Build.GitSource.URI]]" + ref: "[[.Build.GitSource.Reference]]" + contextDir: "[[.Build.GitSource.ContextDir]]" + strategy: + type: Source + sourceStrategy: + env: + - name: KIE_SERVER_CONTAINER_DEPLOYMENT + value: "[[.Build.KieServerContainerDeployment]]" + - name: MAVEN_MIRROR_URL + value: "[[.Build.MavenMirrorURL]]" + - name: ARTIFACT_DIR + value: "[[.Build.ArtifactDir]]" + forcePull: true + from: + kind: "[[.Build.From.Kind]]" + namespace: "[[.Build.From.Namespace]]" + name: "[[.Build.From.Name]]" + output: + to: + kind: ImageStreamTag + name: "[[.KieName]]:latest" + triggers: + - type: GitHub + github: + secret: "[[.Build.GitHubWebhookSecret]]" + - type: Generic + generic: + secret: "[[.Build.GenericWebhookSecret]]" + - type: ImageChange + imageChange: {} + - type: ConfigChange + #[[end]] + ## KIE server build config END +#[[end]] +## RANGE ends +## KIE Servers END diff --git a/config/envs/rhdm-trial.yaml b/config/7.4.1/envs/rhdm-trial.yaml similarity index 100% rename from config/envs/rhdm-trial.yaml rename to config/7.4.1/envs/rhdm-trial.yaml diff --git a/config/7.4.1/envs/rhpam-authoring-ha.yaml b/config/7.4.1/envs/rhpam-authoring-ha.yaml new file mode 100644 index 000000000..0ca7ec99c --- /dev/null +++ b/config/7.4.1/envs/rhpam-authoring-ha.yaml @@ -0,0 +1,611 @@ +console: + persistentVolumeClaims: + - metadata: + name: "[[.ApplicationName]]-[[.Console.Name]]-claim" + labels: + app: "[[.ApplicationName]]" + application: "[[.ApplicationName]]" + spec: + accessModes: + - ReadWriteMany + resources: + requests: + storage: 1Gi + + deploymentConfigs: + - metadata: + name: "[[.ApplicationName]]-[[.Console.Name]]" + spec: + template: + metadata: + name: "[[.ApplicationName]]-[[.Console.Name]]" + spec: + containers: + - name: "[[.ApplicationName]]-[[.Console.Name]]" + volumeMounts: + - name: "[[.ApplicationName]]-[[.Console.Name]]-pvol" + mountPath: "/opt/kie/data" + ports: + - name: git-ssh + containerPort: 8001 + protocol: TCP + env: + - name: APPFORMER_INFINISPAN_SERVICE_NAME + value: "[[.ApplicationName]]-datagrid" + - name: APPFORMER_INFINISPAN_PORT + value: "11222" + - name: APPFORMER_JMS_BROKER_ADDRESS + value: "[[.ApplicationName]]-amq-tcp" + - name: APPFORMER_JMS_BROKER_PORT + value: "61616" + - name: APPFORMER_JMS_BROKER_USER + value: "jmsBrokerUser" + - name: APPFORMER_JMS_BROKER_PASSWORD + value: "[[.AMQClusterPassword]]" + volumes: + - name: "[[.ApplicationName]]-[[.Console.Name]]-pvol" + persistentVolumeClaim: + claimName: "[[.ApplicationName]]-[[.Console.Name]]-claim" + + services: + - spec: + ports: + - name: git-ssh + port: 8001 + targetPort: 8001 + metadata: + name: "[[.ApplicationName]]-[[.Console.Name]]" + +# ES/AMQ BEGIN +others: + - roles: + - metadata: + name: "[[.ApplicationName]]-amq-role" + labels: + app: "[[.ApplicationName]]" + application: "[[.ApplicationName]]" + rules: + - apiGroups: + - "" + resources: + - endpoints + verbs: + - create + - delete + - deletecollection + - get + - list + - patch + - update + - watch + - apiGroups: + - "" + resources: + - namespaces + verbs: + - get + - list + + - metadata: + name: "[[.ApplicationName]]-amq-scaledown-controller-role" + labels: + app: "[[.ApplicationName]]" + application: "[[.ApplicationName]]" + rules: + - apiGroups: + - apps + resources: + - statefulsets + verbs: + - get + - list + - watch + - apiGroups: + - "" + resources: + - pods + verbs: + - get + - list + - watch + - create + - delete + - patch + - update + - apiGroups: + - "" + resources: + - persistentvolumeclaims + verbs: + - get + - list + - watch + - delete + - apiGroups: + - "" + resources: + - events + verbs: + - get + - list + - watch + + rolebindings: + - metadata: + name: "[[.ApplicationName]]-amq-scaledown-controller-openshift-rb" + labels: + app: "[[.ApplicationName]]" + application: "[[.ApplicationName]]" + subjects: + - kind: ServiceAccount + name: "[[.ApplicationName]]-amq-scaledown-controller-sa" + roleRef: + kind: Role + name: "[[.ApplicationName]]-amq-scaledown-controller-role" + apiGroup: rbac.authorization.k8s.io + + - metadata: + name: "[[.ApplicationName]]-amq-rb" + labels: + app: "[[.ApplicationName]]" + application: "[[.ApplicationName]]" + subjects: + - kind: ServiceAccount + name: "[[.ApplicationName]]-amq-sa" + roleRef: + kind: Role + name: "[[.ApplicationName]]-amq-role" + apiGroup: rbac.authorization.k8s.io + + serviceaccounts: + - metadata: + labels: + app: "[[.ApplicationName]]" + application: "[[.ApplicationName]]" + name: "[[.ApplicationName]]-amq-sa" + + - metadata: + labels: + app: "[[.ApplicationName]]" + application: "[[.ApplicationName]]" + name: "[[.ApplicationName]]-amq-scaledown-controller-sa" + + deploymentConfigs: + - metadata: + labels: + app: "[[.ApplicationName]]" + application: "[[.ApplicationName]]" + service: "[[.ApplicationName]]-amq-scaledown-controller" + name: "[[.ApplicationName]]-amq-scaledown-controller" + annotations: + deployment.kubernetes.io/revision: "1" + template.alpha.openshift.io/wait-for-ready: "true" + spec: + replicas: 1 + selector: + deploymentConfig: "[[.ApplicationName]]-amq-scaledown-controller" + strategy: + rollingParams: + maxSurge: 0 + type: Rolling + template: + metadata: + labels: + app: "[[.ApplicationName]]" + application: "[[.ApplicationName]]" + deploymentConfig: "[[.ApplicationName]]-amq-scaledown-controller" + name: "[[.ApplicationName]]-amq-scaledown-controller" + spec: + serviceAccountName: "[[.ApplicationName]]-amq-scaledown-controller-sa" + containers: + - args: + - --localOnly + - --v + - "3" + image: "amq-broker-72-scaledown-controller-openshift" + imagePullPolicy: IfNotPresent + name: "[[.ApplicationName]]-amq" + terminationGracePeriodSeconds: 30 + triggers: + - imageChangeParams: + automatic: true + containerNames: + - "[[.ApplicationName]]-amq" + from: + kind: ImageStreamTag + namespace: "openshift" + name: "amq-broker-72-scaledown-controller-openshift:1.0" + type: ImageChange + - type: ConfigChange + + statefulsets: + - metadata: + name: "[[.ApplicationName]]-datagrid" + labels: + app: "[[.ApplicationName]]" + application: "[[.ApplicationName]]" + service: "[[.ApplicationName]]-datagrid" + spec: + podManagementPolicy: OrderedReady + replicas: 1 + selector: + matchLabels: + deploymentConfig: "[[.ApplicationName]]-datagrid" + serviceName: "[[.ApplicationName]]-datagrid" + strategy: + rollingParams: + intervalSeconds: 20 + maxSurge: 1 + maxUnavailable: 1 + timeoutSeconds: 1200 + updatePeriodSeconds: 20 + type: Rolling + template: + metadata: + labels: + app: "[[.ApplicationName]]" + application: "[[.ApplicationName]]" + deploymentConfig: "[[.ApplicationName]]-datagrid" + name: "[[.ApplicationName]]-datagrid" + spec: + containers: + - env: + - name: SERVICE_NAME + value: "[[.ApplicationName]]-datagrid" + - name: SERVICE_PROFILE + value: "[[.ApplicationName]]-datagrid" + - name: JGROUPS_PING_PROTOCOL + value: openshift.DNS_PING + - name: OPENSHIFT_DNS_PING_SERVICE_NAME + value: "[[.ApplicationName]]-datagrid-ping" + - name: INFINISPAN_CONNECTORS + value: "hotrod" + image: "registry.redhat.io/jboss-datagrid-7/[[$.Constants.DatagridImage]]:[[$.Constants.DatagridImageTag]]" + imagePullPolicy: IfNotPresent + name: "[[.ApplicationName]]-datagrid" + ports: + - containerPort: 8888 + name: ping + protocol: TCP + - containerPort: 11222 + name: hotrod + protocol: TCP + livenessProbe: + exec: + command: + - /opt/datagrid/bin/livenessProbe.sh + failureThreshold: 5 + initialDelaySeconds: 15 + periodSeconds: 20 + successThreshold: 1 + timeoutSeconds: 10 + readinessProbe: + exec: + command: + - /opt/datagrid/bin/readinessProbe.sh + failureThreshold: 5 + initialDelaySeconds: 17 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 10 + resources: + limits: + memory: "512Mi" + requests: + cpu: "0.5" + memory: "512Mi" + volumeMounts: + - mountPath: /opt/datagrid/standalone/data + name: srv-data + - mountPath: /var/run/secrets/java.io/keystores + name: datagrid-keystore-volume + - mountPath: /var/run/secrets/openshift.io/serviceaccount + name: datagrid-service-certs + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + securityContext: {} + terminationGracePeriodSeconds: 60 + volumes: + - empty-dir: {} + name: datagrid-keystore-volume + - name: datagrid-service-certs + secret: + secretName: datagrid-service-certs + triggers: + - type: ConfigChange + volumeClaimTemplates: + - metadata: + name: srv-data + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 1Gi + - metadata: + annotations: + alpha.image.policy.openshift.io/resolve-names: "*" + statefulsets.kubernetes.io/drainer-pod-template: | + { + "metadata": { + "labels": { + "app": "[[.ApplicationName]]", + "application": "[[.ApplicationName]]" + }, + "name": "[[.ApplicationName]]-amq-drainer-pod" + }, + "spec": { + "serviceAccount": "[[.ApplicationName]]-amq-sa", + "serviceAccountName": "[[.ApplicationName]]-amq-sa", + "terminationGracePeriodSeconds": 5, + "containers": [ + { + "env": [ + { + "name": "AMQ_EXTRA_ARGS", + "value": "--no-autotune" + }, + { + "name": "AMQ_USER", + "value": "jmsBrokerUser" + }, + { + "name": "AMQ_PASSWORD", + "value": "[[.AMQPassword]]" + }, + { + "name": "AMQ_ROLE", + "value": "admin" + }, + { + "name": "AMQ_NAME", + "value": "broker" + }, + { + "name": "AMQ_TRANSPORTS", + "value": "openwire" + }, + { + "name": "AMQ_QUEUES", + "value": "" + }, + { + "name": "AMQ_GLOBAL_MAX_SIZE", + "value": "100 gb" + }, + { + "name": "AMQ_ALLOW_ANONYMOUS", + "value": "" + }, + { + "name": "AMQ_DATA_DIR", + "value": "/opt/amq/data" + }, + { + "name": "AMQ_DATA_DIR_LOGGING", + "value": "true" + }, + { + "name": "AMQ_CLUSTERED", + "value": "true" + }, + { + "name": "AMQ_REPLICAS", + "value": "2" + }, + { + "name": "AMQ_CLUSTER_USER", + "value": "jmsBrokerUser" + }, + { + "name": "AMQ_CLUSTER_PASSWORD", + "value": "[[.AMQClusterPassword]]" + }, + { + "name": "POD_NAMESPACE", + "valueFrom": { + "fieldRef": { + "fieldPath": "metadata.namespace" + } + } + }, + { + "name": "OPENSHIFT_DNS_PING_SERVICE_PORT", + "value": "8888" + } + ], + "image": "registry.redhat.io/amq-broker-7/[[$.Constants.BrokerImage]]:[[$.Constants.BrokerImageTag]]", + "name": "[[.ApplicationName]]-amq", + "command": ["/bin/sh", "-c", "echo \"Starting the drainer\" ; /opt/amq/bin/drain.sh; echo \"Drain completed! Exit code $?\""], + "volumeMounts": [ + { + "name": "[[.ApplicationName]]-amq-pvol", + "mountPath": "/opt/amq/data" + } + ] + } + ] + } + } + creationTimestamp: null + generation: 3 + labels: + app: "[[.ApplicationName]]" + application: "[[.ApplicationName]]" + name: "[[.ApplicationName]]-amq" + spec: + podManagementPolicy: OrderedReady + replicas: 2 + revisionHistoryLimit: 10 + selector: + matchLabels: + app: "[[.ApplicationName]]" + serviceName: "[[.ApplicationName]]-amq-tcp" + template: + metadata: + creationTimestamp: null + labels: + app: "[[.ApplicationName]]" + application: "[[.ApplicationName]]" + deploymentConfig: "[[.ApplicationName]]-amq" + name: "[[.ApplicationName]]-amq" + spec: + containers: + - env: + - name: AMQ_USER + value: "jmsBrokerUser" + - name: AMQ_PASSWORD + value: "[[.AMQPassword]]" + - name: AMQ_ROLE + value: admin + - name: AMQ_NAME + value: broker + - name: AMQ_TRANSPORTS + value: "openwire" + - name: AMQ_GLOBAL_MAX_SIZE + value: "100 gb" + - name: AMQ_REQUIRE_LOGIN + - name: AMQ_DATA_DIR + value: /opt/amq/data + - name: AMQ_DATA_DIR_LOGGING + value: "true" + - name: AMQ_CLUSTERED + value: "true" + - name: AMQ_REPLICAS + value: "0" + - name: AMQ_CLUSTER_USER + value: "jmsBrokerUser" + - name: AMQ_CLUSTER_PASSWORD + value: "[[.AMQClusterPassword]]" + - name: OPENSHIFT_DNS_PING_SERVICE_NAME + value: "[[.ApplicationName]]-amq-ping" + - name: AMQ_EXTRA_ARGS + - name: AMQ_ANYCAST_PREFIX + - name: AMQ_MULTICAST_PREFIX + - name: POD_NAMESPACE + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.namespace + image: "registry.redhat.io/amq-broker-7/[[$.Constants.BrokerImage]]:[[$.Constants.BrokerImageTag]]" + imagePullPolicy: IfNotPresent + name: broker-amq + ports: + - containerPort: 8161 + name: jolokia + protocol: TCP + - containerPort: 5672 + name: amqp + protocol: TCP + - containerPort: 1883 + name: mqtt + protocol: TCP + - containerPort: 61613 + name: stomp + protocol: TCP + - containerPort: 61616 + name: artemis + protocol: TCP + readinessProbe: + exec: + command: + - /bin/bash + - -c + - /opt/amq/bin/readinessProbe.sh + failureThreshold: 3 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 1 + resources: {} + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + volumeMounts: + - mountPath: /opt/amq/data + name: "[[.ApplicationName]]-amq-pvol" + dnsPolicy: ClusterFirst + restartPolicy: Always + schedulerName: default-scheduler + securityContext: {} + terminationGracePeriodSeconds: 60 + updateStrategy: + type: OnDelete + volumeClaimTemplates: + - metadata: + creationTimestamp: null + name: "[[.ApplicationName]]-amq-pvol" + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 1Gi + + services: + - spec: + clusterIP: None + ports: + - port: 61616 + targetPort: 61616 + selector: + deploymentConfig: "[[.ApplicationName]]-amq" + metadata: + name: "[[.ApplicationName]]-amq-tcp" + labels: + app: "[[.ApplicationName]]" + application: "[[.ApplicationName]]" + service: "[[.ApplicationName]]-amq" + annotations: + description: The broker's OpenWire port. + + - spec: + clusterIP: None + ports: + - port: 8888 + protocol: TCP + targetPort: 8888 + selector: + deploymentConfig: "[[.ApplicationName]]-amq" + metadata: + name: "[[.ApplicationName]]-amq-ping" + annotations: + description: The JGroups ping port for clustering. + service.alpha.kubernetes.io/tolerate-unready-endpoints: "true" + labels: + app: "[[.ApplicationName]]" + application: "[[.ApplicationName]]" + + - spec: + clusterIP: None + ports: + - name: ping + port: 8888 + protocol: TCP + targetPort: 8888 + selector: + deploymentConfig: "[[.ApplicationName]]-datagrid" + metadata: + name: "[[.ApplicationName]]-datagrid-ping" + labels: + application: "[[.ApplicationName]]" + annotations: + description: "The JGroups ping port for clustering." + service.alpha.kubernetes.io/tolerate-unready-endpoints: "true" + + - spec: + ports: + - name: hotrod + port: 11222 + protocol: TCP + targetPort: 11222 + selector: + deploymentConfig: "[[.ApplicationName]]-datagrid" + metadata: + name: "[[.ApplicationName]]-datagrid" + labels: + application: "[[.ApplicationName]]" + annotations: + description: Provides a service for accessing the application over Hot Rod protocol. + service.alpha.openshift.io/serving-cert-secret-name: datagrid-service-certs +## ES/AMQ END + diff --git a/config/7.4.1/envs/rhpam-authoring.yaml b/config/7.4.1/envs/rhpam-authoring.yaml new file mode 100644 index 000000000..896b65c56 --- /dev/null +++ b/config/7.4.1/envs/rhpam-authoring.yaml @@ -0,0 +1,36 @@ +console: + deploymentConfigs: + - metadata: + name: "[[.ApplicationName]]-[[.Console.Name]]" + spec: + template: + metadata: + name: "[[.ApplicationName]]-[[.Console.Name]]" + spec: + containers: + - name: "[[.ApplicationName]]-[[.Console.Name]]" + ports: + - name: git-ssh + containerPort: 8001 + protocol: TCP + persistentVolumeClaims: + - metadata: + name: "[[.ApplicationName]]-[[.Console.Name]]-claim" + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 1Gi + services: + - metadata: + name: "[[.ApplicationName]]-[[.Console.Name]]" + spec: + ports: + - name: git-ssh + port: 8001 + targetPort: 8001 + - metadata: + name: "[[.ApplicationName]]-[[.Console.Name]]-ping" + annotations: + delete: "true" diff --git a/config/7.4.1/envs/rhpam-production-immutable.yaml b/config/7.4.1/envs/rhpam-production-immutable.yaml new file mode 100644 index 000000000..f91b2d236 --- /dev/null +++ b/config/7.4.1/envs/rhpam-production-immutable.yaml @@ -0,0 +1,91 @@ +## KIE Servers BEGIN +servers: + ## RANGE BEGINS + #[[ range $index, $Map := .Servers ]] + ## KIE server deployment config BEGIN + - deploymentConfigs: + - metadata: + name: "[[.KieName]]" + labels: + app: "[[$.ApplicationName]]" + application: "[[$.ApplicationName]]" + service: "[[.KieName]]" + spec: + template: + spec: + containers: + - name: "[[.KieName]]" + image: "[[.KieName]]" + env: + - name: KIE_SERVER_CONTAINER_DEPLOYMENT + value: "[[.Build.KieServerContainerDeployment]]" + - name: KIE_SERVER_MGMT_DISABLED + value: "true" + - name: "[[$.Constants.MavenRepo]]_MAVEN_REPO_USERNAME" + value: "" + - name: "[[$.Constants.MavenRepo]]_MAVEN_REPO_PASSWORD" + value: "" + - name: "[[$.Constants.MavenRepo]]_MAVEN_REPO_SERVICE" + value: "" + - name: MAVEN_REPOS + value: "EXTERNAL" + - name: KIE_SERVER_ROUTER_PROTOCOL + value: "http" + ## KIE server deployment config END + ## KIE server build config BEGIN + #[[if .Build.KieServerContainerDeployment]] + imageStreams: + - metadata: + name: "[[.KieName]]" + labels: + app: "[[$.ApplicationName]]" + application: "[[$.ApplicationName]]" + service: "[[.KieName]]" + buildConfigs: + - metadata: + name: "[[.KieName]]" + labels: + app: "[[$.ApplicationName]]" + application: "[[$.ApplicationName]]" + service: "[[.KieName]]" + spec: + source: + type: Git + git: + uri: "[[.Build.GitSource.URI]]" + ref: "[[.Build.GitSource.Reference]]" + contextDir: "[[.Build.GitSource.ContextDir]]" + strategy: + type: Source + sourceStrategy: + env: + - name: KIE_SERVER_CONTAINER_DEPLOYMENT + value: "[[.Build.KieServerContainerDeployment]]" + - name: MAVEN_MIRROR_URL + value: "[[.Build.MavenMirrorURL]]" + - name: ARTIFACT_DIR + value: "[[.Build.ArtifactDir]]" + forcePull: true + from: + kind: "[[.Build.From.Kind]]" + namespace: "[[.Build.From.Namespace]]" + name: "[[.Build.From.Name]]" + output: + to: + kind: ImageStreamTag + name: "[[.KieName]]:latest" + triggers: + - type: GitHub + github: + secret: "[[.Build.GitHubWebhookSecret]]" + - type: Generic + generic: + secret: "[[.Build.GenericWebhookSecret]]" + - type: ImageChange + imageChange: {} + - type: ConfigChange + #[[end]] + ## KIE server build config END +#[[end]] +## RANGE ends +## KIE Servers END diff --git a/config/7.4.1/envs/rhpam-production.yaml b/config/7.4.1/envs/rhpam-production.yaml new file mode 100644 index 000000000..5af629c5f --- /dev/null +++ b/config/7.4.1/envs/rhpam-production.yaml @@ -0,0 +1,47 @@ +console: + deploymentConfigs: + - metadata: + name: "[[.ApplicationName]]-[[.Console.Name]]" + spec: + containers: + - name: "[[.ApplicationName]]-[[.Console.Name]]" + env: + - name: MAVEN_REPO_URL + value: "" + - name: MAVEN_REPO_USERNAME + value: "" + - name: MAVEN_REPO_PASSWORD + value: "" + +## KIE Servers BEGIN +servers: + ## RANGE BEGINS + #[[ range $index, $Map := .Servers ]] + ## KIE server deployment config BEGIN + - deploymentConfigs: + - metadata: + name: "[[.KieName]]" + labels: + app: "[[$.ApplicationName]]" + application: "[[$.ApplicationName]]" + service: "[[.KieName]]" + spec: + template: + spec: + containers: + - name: "[[.KieName]]" + env: + - name: EXTERNAL_MAVEN_REPO_ID + value: "" + - name: EXTERNAL_MAVEN_REPO_URL + value: "" + - name: EXTERNAL_MAVEN_REPO_USERNAME + value: "" + - name: EXTERNAL_MAVEN_REPO_PASSWORD + value: "" + - name: KIE_SERVER_MODE + value: PRODUCTION + ## KIE server deployment config END + #[[end]] + ## RANGE ends + ## KIE Servers END diff --git a/config/envs/rhpam-trial.yaml b/config/7.4.1/envs/rhpam-trial.yaml similarity index 100% rename from config/envs/rhpam-trial.yaml rename to config/7.4.1/envs/rhpam-trial.yaml diff --git a/config/jms/activemq-jms-config.yaml b/config/7.4.1/jms/activemq-jms-config.yaml similarity index 100% rename from config/jms/activemq-jms-config.yaml rename to config/7.4.1/jms/activemq-jms-config.yaml diff --git a/pkg/apis/app/v1/kieapp_types.go b/pkg/apis/app/v1/kieapp_types.go index edd937d9b..b3f0c7a64 100644 --- a/pkg/apis/app/v1/kieapp_types.go +++ b/pkg/apis/app/v1/kieapp_types.go @@ -348,6 +348,9 @@ type EnvTemplate struct { // TemplateConstants constant values that are used within the different configuration templates type TemplateConstants struct { Product string `json:"product,omitempty"` + Major string `json:"major,omitempty"` + Minor string `json:"minor,omitempty"` + Patch string `json:"patch,omitempty"` MavenRepo string `json:"mavenRepo,omitempty"` KeystoreVolumeSuffix string `json:"keystoreVolumeSuffix"` DatabaseVolumeSuffix string `json:"databaseVolumeSuffix"` @@ -428,6 +431,15 @@ type CommonConfig struct { MavenPassword string `json:"mavenPassword,omitempty"` } +// VersionConfigs ... +type VersionConfigs struct { + ImageStreamTag string `json:"imageStreamTag,omitempty"` + BrokerImage string `json:"brokerImage,omitempty"` + BrokerImageTag string `json:"brokerImageTag,omitempty"` + DatagridImage string `json:"datagridImage,omitempty"` + DatagridImageTag string `json:"datagridImageTag,omitempty"` +} + // AuthTemplate Authentication definition used in the template type AuthTemplate struct { SSO SSOAuthConfig `json:"sso,omitempty"` diff --git a/pkg/apis/app/v1/zz_generated.deepcopy.go b/pkg/apis/app/v1/zz_generated.deepcopy.go index 9a339257d..31cca183c 100644 --- a/pkg/apis/app/v1/zz_generated.deepcopy.go +++ b/pkg/apis/app/v1/zz_generated.deepcopy.go @@ -879,6 +879,22 @@ func (in *TemplateConstants) DeepCopy() *TemplateConstants { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VersionConfigs) DeepCopyInto(out *VersionConfigs) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VersionConfigs. +func (in *VersionConfigs) DeepCopy() *VersionConfigs { + if in == nil { + return nil + } + out := new(VersionConfigs) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *WebhookSecret) DeepCopyInto(out *WebhookSecret) { *out = *in diff --git a/pkg/controller/kieapp/constants/constants.go b/pkg/controller/kieapp/constants/constants.go index a69f3c424..e5cb5e3e2 100644 --- a/pkg/controller/kieapp/constants/constants.go +++ b/pkg/controller/kieapp/constants/constants.go @@ -5,6 +5,18 @@ import ( corev1 "k8s.io/api/core/v1" ) +const ( + // CurrentVersion version supported + CurrentVersion = "7.4.1" + // PastMinorVersion version supported + PastMinorVersion = "7.4.0" + // PastPatchVersion version supported + PastPatchVersion = "7.4.1" +) + +// SupportedVersions - product versions this operator supports +var SupportedVersions = []string{CurrentVersion, PastMinorVersion, PastPatchVersion} + const ( // RhpamPrefix RHPAM prefix RhpamPrefix = "rhpam" @@ -16,18 +28,6 @@ const ( ImageRegistry = "registry.redhat.io" // ImageStreamNamespace default namespace for the ImageStreams ImageStreamNamespace = "openshift" - // ProductVersion default version - ProductVersion = "7.4" - // ImageStreamTag default tag name for the ImageStreams - ImageStreamTag = "1.1" - // BrokerImage AMQ Broker Image Name - BrokerImage = "amq-broker-73-openshift" - // BrokerImageTag AMQ Broker Image Tag - BrokerImageTag = "7.3" - // DatagridImage JBoss Datagrid Image Name - DatagridImage = "datagrid73-openshift" - // DatagridImageTag JBoss Datagrid Image Tag - DatagridImageTag = "1.1" // ConfigMapPrefix prefix to use for the configmaps ConfigMapPrefix = "kieconfigs" // KieServerCMLabel the label to modify when replicas is set to 0 @@ -63,10 +63,37 @@ const ( ConsoleLinkName = "Installer" // ConsoleDescription is how the link will be described in an installed CSV within the marketplace ConsoleDescription = "**To use the guided installer to provision an environment, open the Installer link, in the links section on the left side of this page.**" - // Default SmartRouter protocol + // SmartRouterProtocol - default SmartRouter protocol SmartRouterProtocol = "http" ) +// VersionConstants ... +var VersionConstants = map[string]*v1.VersionConfigs{ + CurrentVersion: { + ImageStreamTag: "1.1", + BrokerImage: "amq-broker-73-openshift", + BrokerImageTag: "7.3", + DatagridImage: "datagrid73-openshift", + DatagridImageTag: "1.1", + }, + PastMinorVersion: { + ImageStreamTag: "1.0", + BrokerImage: "amq-broker-73-openshift", + BrokerImageTag: "7.3", + DatagridImage: "datagrid73-openshift", + DatagridImageTag: "1.1", + }, + /* + PastPatchVersion: { + ImageStreamTag: "1.1", + BrokerImage: "amq-broker-73-openshift", + BrokerImageTag: "7.3", + DatagridImage: "datagrid73-openshift", + DatagridImageTag: "1.1", + }, + */ +} + var rhpamAppConstants = v1.AppConstants{Product: RhpamPrefix, Prefix: "rhpamcentr", ImageName: "businesscentral", MavenRepo: "RHPAMCENTR"} var rhpamMonitorAppConstants = v1.AppConstants{Product: RhpamPrefix, Prefix: "rhpamcentrmon", ImageName: "businesscentral-monitoring", MavenRepo: "RHPAMCENTR"} var rhdmAppConstants = v1.AppConstants{Product: RhdmPrefix, Prefix: "rhdmcentr", ImageName: "decisioncentral", MavenRepo: "RHDMCENTR"} @@ -116,17 +143,15 @@ var EnvironmentConstants = map[v1.EnvironmentType]*v1.EnvironmentConstants{ var TemplateConstants = v1.TemplateConstants{ KeystoreVolumeSuffix: KeystoreVolumeSuffix, DatabaseVolumeSuffix: DatabaseVolumeSuffix, - BrokerImage: BrokerImage, - BrokerImageTag: BrokerImageTag, - DatagridImage: DatagridImage, - DatagridImageTag: DatagridImageTag, } +// DebugTrue - used to enable debug logs in objects var DebugTrue = corev1.EnvVar{ Name: "DEBUG", Value: "true", } +// DebugFalse - used to disable debug logs in objects var DebugFalse = corev1.EnvVar{ Name: "DEBUG", Value: "false", diff --git a/pkg/controller/kieapp/defaults/defaults.go b/pkg/controller/kieapp/defaults/defaults.go index 2e62ac0d0..49568534e 100644 --- a/pkg/controller/kieapp/defaults/defaults.go +++ b/pkg/controller/kieapp/defaults/defaults.go @@ -8,7 +8,6 @@ import ( "fmt" "html/template" "os" - "regexp" "strings" "github.com/ghodss/yaml" @@ -37,7 +36,7 @@ func GetEnvironment(cr *v1.KieApp, service v1.PlatformService) (v1.Environment, return v1.Environment{}, err } var common v1.Environment - yamlBytes, err := loadYaml(service, "common.yaml", cr.Namespace, envTemplate) + yamlBytes, err := loadYaml(service, "common.yaml", cr.Spec.CommonConfig.Version, cr.Namespace, envTemplate) if err != nil { return v1.Environment{}, err } @@ -46,7 +45,7 @@ func GetEnvironment(cr *v1.KieApp, service v1.PlatformService) (v1.Environment, return v1.Environment{}, err } var env v1.Environment - yamlBytes, err = loadYaml(service, fmt.Sprintf("envs/%s.yaml", cr.Spec.Environment), cr.Namespace, envTemplate) + yamlBytes, err = loadYaml(service, fmt.Sprintf("envs/%s.yaml", cr.Spec.Environment), cr.Spec.CommonConfig.Version, cr.Namespace, envTemplate) if err != nil { return v1.Environment{}, err } @@ -97,7 +96,7 @@ func mergeDB(service v1.PlatformService, cr *v1.KieApp, env v1.Environment, envT } dbType := kieServerSet.Database.Type if _, loadedDB := dbEnvs[dbType]; !loadedDB { - yamlBytes, err := loadYaml(service, fmt.Sprintf("dbs/%s.yaml", dbType), cr.Namespace, envTemplate) + yamlBytes, err := loadYaml(service, fmt.Sprintf("dbs/%s.yaml", dbType), cr.Spec.CommonConfig.Version, cr.Namespace, envTemplate) if err != nil { return v1.Environment{}, err } @@ -124,7 +123,7 @@ func mergeJms(service v1.PlatformService, cr *v1.KieApp, env v1.Environment, env isJmsEnabled := kieServerSet.Jms.EnableIntegration if isJmsEnabled { - yamlBytes, err := loadYaml(service, fmt.Sprintf("jms/activemq-jms-config.yaml"), cr.Namespace, envTemplate) + yamlBytes, err := loadYaml(service, fmt.Sprintf("jms/activemq-jms-config.yaml"), cr.Spec.CommonConfig.Version, cr.Namespace, envTemplate) if err != nil { return v1.Environment{}, err } @@ -156,13 +155,18 @@ func findCustomObjectByName(template v1.CustomObject, objects []v1.CustomObject) func getEnvTemplate(cr *v1.KieApp) (v1.EnvTemplate, error) { setAppConstants(&cr.Spec.CommonConfig) - + if !checkVersion(cr.Spec.CommonConfig.Version) { + return v1.EnvTemplate{}, fmt.Errorf("Product version %s is not supported by this Operator, %s", cr.Spec.CommonConfig.Version, version.Version) + } // set default values for go template where not provided if cr.Spec.Upgrades.Patch == nil { defaultPatchFlag := true cr.Spec.Upgrades.Patch = &defaultPatchFlag } config := &cr.Spec.CommonConfig + if len(config.ImageTag) == 0 { + config.ImageTag = constants.VersionConstants[config.Version].ImageStreamTag + } if config.ApplicationName == "" { config.ApplicationName = cr.Name } @@ -178,7 +182,7 @@ func getEnvTemplate(cr *v1.KieApp) (v1.EnvTemplate, error) { Console: getConsoleTemplate(cr), Servers: serversConfig, SmartRouter: getSmartRouterTemplate(cr), - Constants: *getTemplateConstants(cr.Spec.Environment), + Constants: *getTemplateConstants(cr.Spec.Environment, cr.Spec.CommonConfig.Version), } if err := configureAuth(cr, &envTemplate); err != nil { log.Error("unable to setup authentication: ", err) @@ -188,12 +192,19 @@ func getEnvTemplate(cr *v1.KieApp) (v1.EnvTemplate, error) { return envTemplate, nil } -func getTemplateConstants(env v1.EnvironmentType) *v1.TemplateConstants { +func getTemplateConstants(env v1.EnvironmentType, productVersion string) *v1.TemplateConstants { c := constants.TemplateConstants.DeepCopy() + c.Major, c.Minor, c.Patch = MajorMinorPatch(productVersion) if envConstants, found := constants.EnvironmentConstants[env]; found { c.Product = envConstants.App.Product c.MavenRepo = envConstants.App.MavenRepo } + if versionConstants, found := constants.VersionConstants[productVersion]; found { + c.BrokerImage = versionConstants.BrokerImage + c.BrokerImageTag = versionConstants.BrokerImageTag + c.DatagridImage = versionConstants.DatagridImage + c.DatagridImageTag = versionConstants.DatagridImageTag + } return c } @@ -495,7 +506,7 @@ func getDefaultKieServerImage(product string, config *v1.CommonConfig, from *cor if from != nil { return *from } - imageName := fmt.Sprintf("%s%s-kieserver-openshift:%s", product, config.Version, config.ImageTag) + imageName := fmt.Sprintf("%s%s-kieserver-openshift:%s", product, getMinorImageVersion(config.Version), config.ImageTag) return corev1.ObjectReference{ Kind: "ImageStreamTag", Name: imageName, @@ -616,9 +627,13 @@ func getWebhookSecret(webhookType v1.WebhookType, webhooks []v1.WebhookSecret) s } // important to parse template first with this function, before unmarshalling into object -func loadYaml(service v1.PlatformService, filename, namespace string, env v1.EnvTemplate) ([]byte, error) { +func loadYaml(service v1.PlatformService, filename, productVersion, namespace string, env v1.EnvTemplate) ([]byte, error) { if _, _, useEmbedded := UseEmbeddedFiles(service); useEmbedded { box := packr.New("config", "../../../../config") + if !box.HasDir(productVersion) { + return nil, fmt.Errorf("Product version %s configs are not available in this Operator, %s", productVersion, version.Version) + } + filename = strings.Join([]string{productVersion, filename}, "/") if box.Has(filename) { yamlString, err := box.FindString(filename) if err != nil { @@ -669,10 +684,14 @@ func convertToConfigMapName(filename string) (configMapName, file string) { // ConfigMapsFromFile reads the files under the config folder and creates // configmaps in the given namespace. It sets OwnerRef to operator deployment. -func ConfigMapsFromFile(myDep *appsv1.Deployment, ns string, scheme *runtime.Scheme) []corev1.ConfigMap { +func ConfigMapsFromFile(myDep *appsv1.Deployment, ns, productVersion string, scheme *runtime.Scheme) []corev1.ConfigMap { box := packr.New("config", "../../../../config") + if !box.HasDir(productVersion) { + log.Errorf("Product version %s configs are not available in this Operator, %s", productVersion, version.Version) + } cmList := map[string][]map[string]string{} for _, filename := range box.List() { + filename := strings.Join([]string{productVersion, filename}, "/") s, err := box.FindString(filename) if err != nil { log.Error("Error finding file with packr. ", err) @@ -727,17 +746,42 @@ func UseEmbeddedFiles(service v1.PlatformService) (opName string, depNameSpace s // setAppConstants sets the application-related constants to use in the template processing func setAppConstants(common *v1.CommonConfig) { if len(common.Version) == 0 { - pattern := regexp.MustCompile("[0-9]+") - common.Version = strings.Join(pattern.FindAllString(constants.ProductVersion, -1), "") - } - if len(common.ImageTag) == 0 { - common.ImageTag = constants.ImageStreamTag + common.Version = constants.CurrentVersion + } else if common.Version == "74" { + common.Version = "7.4.1" } if len(common.AdminUser) == 0 { common.AdminUser = constants.DefaultAdminUser } } +// getMinorImageVersion ... +func getMinorImageVersion(productVersion string) string { + major, minor, _ := MajorMinorPatch(productVersion) + return fmt.Sprintf("%s%s", major, minor) +} + +// MajorMinorPatch ... +func MajorMinorPatch(productVersion string) (major, minor, patch string) { + version := strings.Split(productVersion, ".") + for len(version) < 3 { + version = append(version, "0") + } + return version[0], version[1], version[2] +} + +// checkVersion ... +func checkVersion(productVersion string) bool { + versionCheck := make(map[string]bool) + for _, v := range constants.SupportedVersions { + versionCheck[v] = true + } + if versionCheck[productVersion] { + return true + } + return false +} + // Pint returns a pointer to an integer func Pint(i int) *int { return &i diff --git a/pkg/controller/kieapp/defaults/defaults_test.go b/pkg/controller/kieapp/defaults/defaults_test.go index 8bf20403d..dbb546813 100644 --- a/pkg/controller/kieapp/defaults/defaults_test.go +++ b/pkg/controller/kieapp/defaults/defaults_test.go @@ -4,7 +4,6 @@ import ( "context" "fmt" "os" - "regexp" "strings" "testing" @@ -13,6 +12,7 @@ import ( v1 "github.com/kiegroup/kie-cloud-operator/pkg/apis/app/v1" "github.com/kiegroup/kie-cloud-operator/pkg/controller/kieapp/constants" "github.com/kiegroup/kie-cloud-operator/pkg/controller/kieapp/test" + "github.com/kiegroup/kie-cloud-operator/version" appsv1 "github.com/openshift/api/apps/v1" buildv1 "github.com/openshift/api/build/v1" "github.com/stretchr/testify/assert" @@ -43,7 +43,7 @@ func TestLoadUnknownEnvironment(t *testing.T) { } _, err := GetEnvironment(cr, test.MockService()) - assert.Equal(t, fmt.Sprintf("envs/%s.yaml does not exist, '%s' KieApp not deployed", cr.Spec.Environment, cr.Name), err.Error()) + assert.Equal(t, fmt.Sprintf("%s/envs/%s.yaml does not exist, '%s' KieApp not deployed", cr.Spec.CommonConfig.Version, cr.Spec.Environment, cr.Name), err.Error()) } func TestInaccessibleConfigMap(t *testing.T) { @@ -73,7 +73,7 @@ func TestInaccessibleConfigMap(t *testing.T) { return client.Get(ctx, key, obj) } _, err := GetEnvironment(cr, mockService) - assert.Equal(t, fmt.Sprintf("envs/%s.yaml does not exist, '%s' KieApp not deployed", cr.Spec.Environment, cr.Name), err.Error()) + assert.Equal(t, fmt.Sprintf("%s/envs/%s.yaml does not exist, '%s' KieApp not deployed", cr.Spec.CommonConfig.Version, cr.Spec.Environment, cr.Name), err.Error()) } func TestMultipleServerDeployment(t *testing.T) { @@ -135,7 +135,7 @@ func TestRHPAMTrialEnvironment(t *testing.T) { assert.False(t, hasPort(pingService, 8888), "The ping service should listen on port 8888") assert.Equal(t, fmt.Sprintf("%s-kieserver-%d", cr.Spec.CommonConfig.ApplicationName, len(env.Servers)), env.Servers[len(env.Servers)-1].DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Name, "the container name should have incremented") assert.Equal(t, "test-rhpamcentr", env.Console.DeploymentConfigs[0].ObjectMeta.Name) - assert.Equal(t, fmt.Sprintf("rhpam%s-businesscentral-openshift", cr.Spec.CommonConfig.Version), env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Image) + assert.Equal(t, fmt.Sprintf("rhpam%s-businesscentral-openshift", getMinorImageVersion(cr.Spec.CommonConfig.Version)), env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Image) assert.Equal(t, getLivenessReadiness("/rest/ready"), env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].ReadinessProbe.HTTPGet) assert.Equal(t, getLivenessReadiness("/rest/healthy"), env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].LivenessProbe.HTTPGet) } @@ -168,7 +168,7 @@ func TestRHDMTrialEnvironment(t *testing.T) { assert.False(t, hasPort(pingService, 8888), "The ping service should not listen on port 8888") assert.Equal(t, fmt.Sprintf("%s-kieserver-%d", cr.Spec.CommonConfig.ApplicationName, len(env.Servers)), env.Servers[len(env.Servers)-1].DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Name, "the container name should have incremented") assert.Equal(t, "test-rhdmcentr", env.Console.DeploymentConfigs[0].ObjectMeta.Name) - assert.Equal(t, fmt.Sprintf("rhdm%s-decisioncentral-openshift", cr.Spec.CommonConfig.Version), env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Image) + assert.Equal(t, fmt.Sprintf("rhdm%s-decisioncentral-openshift", getMinorImageVersion(cr.Spec.CommonConfig.Version)), env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Image) assert.Equal(t, getLivenessReadiness("/rest/ready"), env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].ReadinessProbe.HTTPGet) assert.Equal(t, getLivenessReadiness("/rest/healthy"), env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].LivenessProbe.HTTPGet) @@ -188,7 +188,7 @@ func TestRhpamcentrMonitoringEnvironment(t *testing.T) { assert.Nil(t, err, "Error getting prod environment") assert.Equal(t, "test-rhpamcentrmon", env.Console.DeploymentConfigs[0].ObjectMeta.Name) - assert.Equal(t, fmt.Sprintf("rhpam%s-businesscentral-monitoring-openshift", cr.Spec.CommonConfig.Version), env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Image) + assert.Equal(t, fmt.Sprintf("rhpam%s-businesscentral-monitoring-openshift", getMinorImageVersion(cr.Spec.CommonConfig.Version)), env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Image) pingService := getService(env.Console.Services, "test-rhpamcentrmon-ping") assert.Len(t, pingService.Spec.Ports, 1, "The ping service should have only one port") @@ -214,10 +214,10 @@ func TestRhdmAuthoringHAEnvironment(t *testing.T) { assert.Equal(t, "test-rhdmcentr", env.Console.DeploymentConfigs[0].ObjectMeta.Name) assert.Equal(t, "test-datagrid", env.Others[0].StatefulSets[0].ObjectMeta.Name) assert.Equal(t, "test-amq", env.Others[0].StatefulSets[1].ObjectMeta.Name) - assert.Equal(t, fmt.Sprintf("registry.redhat.io/jboss-datagrid-7/%s:%s", constants.DatagridImage, constants.DatagridImageTag), env.Others[0].StatefulSets[0].Spec.Template.Spec.Containers[0].Image) - assert.Equal(t, fmt.Sprintf("registry.redhat.io/amq-broker-7/%s:%s", constants.BrokerImage, constants.BrokerImageTag), env.Others[0].StatefulSets[1].Spec.Template.Spec.Containers[0].Image) + assert.Equal(t, fmt.Sprintf("registry.redhat.io/jboss-datagrid-7/%s:%s", constants.VersionConstants[cr.Spec.CommonConfig.Version].DatagridImage, constants.VersionConstants[cr.Spec.CommonConfig.Version].DatagridImageTag), env.Others[0].StatefulSets[0].Spec.Template.Spec.Containers[0].Image) + assert.Equal(t, fmt.Sprintf("registry.redhat.io/amq-broker-7/%s:%s", constants.VersionConstants[cr.Spec.CommonConfig.Version].BrokerImage, constants.VersionConstants[cr.Spec.CommonConfig.Version].BrokerImageTag), env.Others[0].StatefulSets[1].Spec.Template.Spec.Containers[0].Image) assert.Equal(t, "test-amq-scaledown-controller", env.Others[0].DeploymentConfigs[0].ObjectMeta.Name) - assert.Equal(t, fmt.Sprintf("rhdm%s-decisioncentral-openshift", cr.Spec.CommonConfig.Version), env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Image) + assert.Equal(t, fmt.Sprintf("rhdm%s-decisioncentral-openshift", getMinorImageVersion(cr.Spec.CommonConfig.Version)), env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Image) for i := 0; i < len(env.Servers); i++ { assert.Equal(t, "DEVELOPMENT", getEnvVariable(env.Servers[i].DeploymentConfigs[0].Spec.Template.Spec.Containers[0], "KIE_SERVER_MODE")) } @@ -243,10 +243,10 @@ func TestRhpamAuthoringHAEnvironment(t *testing.T) { assert.Equal(t, "test-rhpamcentr", env.Console.DeploymentConfigs[0].ObjectMeta.Name) assert.Equal(t, "test-datagrid", env.Others[0].StatefulSets[0].ObjectMeta.Name) assert.Equal(t, "test-amq", env.Others[0].StatefulSets[1].ObjectMeta.Name) - assert.Equal(t, fmt.Sprintf("registry.redhat.io/jboss-datagrid-7/%s:%s", constants.DatagridImage, constants.DatagridImageTag), env.Others[0].StatefulSets[0].Spec.Template.Spec.Containers[0].Image) - assert.Equal(t, fmt.Sprintf("registry.redhat.io/amq-broker-7/%s:%s", constants.BrokerImage, constants.BrokerImageTag), env.Others[0].StatefulSets[1].Spec.Template.Spec.Containers[0].Image) + assert.Equal(t, fmt.Sprintf("registry.redhat.io/jboss-datagrid-7/%s:%s", constants.VersionConstants[cr.Spec.CommonConfig.Version].DatagridImage, constants.VersionConstants[cr.Spec.CommonConfig.Version].DatagridImageTag), env.Others[0].StatefulSets[0].Spec.Template.Spec.Containers[0].Image) + assert.Equal(t, fmt.Sprintf("registry.redhat.io/amq-broker-7/%s:%s", constants.VersionConstants[cr.Spec.CommonConfig.Version].BrokerImage, constants.VersionConstants[cr.Spec.CommonConfig.Version].BrokerImageTag), env.Others[0].StatefulSets[1].Spec.Template.Spec.Containers[0].Image) assert.Equal(t, "test-amq-scaledown-controller", env.Others[0].DeploymentConfigs[0].ObjectMeta.Name) - assert.Equal(t, fmt.Sprintf("rhpam%s-businesscentral-openshift", cr.Spec.CommonConfig.Version), env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Image) + assert.Equal(t, fmt.Sprintf("rhpam%s-businesscentral-openshift", getMinorImageVersion(cr.Spec.CommonConfig.Version)), env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Image) amqClusterPassword := getEnvVariable(env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0], "APPFORMER_JMS_BROKER_PASSWORD") assert.Equal(t, "cluster", amqClusterPassword, "Expected provided password to take effect, but found %v", amqClusterPassword) amqPassword := getEnvVariable(env.Others[0].StatefulSets[1].Spec.Template.Spec.Containers[0], "AMQ_PASSWORD") @@ -277,7 +277,7 @@ func TestRhdmProdImmutableEnvironment(t *testing.T) { assert.Equal(t, "", getEnvVariable(env.Servers[0].DeploymentConfigs[0].Spec.Template.Spec.Containers[0], "KIE_SERVER_ROUTER_PORT"), "Variable should not exist") assert.Equal(t, "", getEnvVariable(env.Servers[0].DeploymentConfigs[0].Spec.Template.Spec.Containers[0], "KIE_SERVER_ROUTER_PROTOCOL"), "Variable should not exist") assert.Equal(t, "test-rhdmcentr", env.Console.DeploymentConfigs[0].ObjectMeta.Name) - assert.Equal(t, fmt.Sprintf("rhdm%s-decisioncentral-openshift", cr.Spec.CommonConfig.Version), env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Image) + assert.Equal(t, fmt.Sprintf("rhdm%s-decisioncentral-openshift", getMinorImageVersion(cr.Spec.CommonConfig.Version)), env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Image) } func TestRhpamProdwSmartRouter(t *testing.T) { @@ -302,7 +302,7 @@ func TestRhpamProdwSmartRouter(t *testing.T) { assert.Equal(t, "", getEnvVariable(env.SmartRouter.DeploymentConfigs[0].Spec.Template.Spec.Containers[0], "KIE_SERVER_ROUTER_ROUTE_NAME"), "Variable should exist") assert.Equal(t, "test-rhpamcentrmon", env.Console.DeploymentConfigs[0].ObjectMeta.Name) assert.Equal(t, "test-smartrouter", env.SmartRouter.DeploymentConfigs[0].ObjectMeta.Name) - assert.Equal(t, fmt.Sprintf("rhpam%s-businesscentral-monitoring-openshift", cr.Spec.CommonConfig.Version), env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Image) + assert.Equal(t, fmt.Sprintf("rhpam%s-businesscentral-monitoring-openshift", getMinorImageVersion(cr.Spec.CommonConfig.Version)), env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Image) } func TestRhpamProdSmartRouterWithSSL(t *testing.T) { @@ -330,7 +330,7 @@ func TestRhpamProdSmartRouterWithSSL(t *testing.T) { assert.Equal(t, "test-rhpamcentrmon", env.Console.DeploymentConfigs[0].ObjectMeta.Name) assert.Equal(t, "test-smartrouter", env.SmartRouter.DeploymentConfigs[0].ObjectMeta.Name) assert.Equal(t, "test-smartrouter", getEnvVariable(env.SmartRouter.DeploymentConfigs[0].Spec.Template.Spec.Containers[0], "KIE_SERVER_ROUTER_ROUTE_NAME"), "Variable should exist") - assert.Equal(t, fmt.Sprintf("rhpam%s-businesscentral-monitoring-openshift", cr.Spec.CommonConfig.Version), env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Image) + assert.Equal(t, fmt.Sprintf("rhpam%s-businesscentral-monitoring-openshift", getMinorImageVersion(cr.Spec.CommonConfig.Version)), env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Image) } func TestRhdmProdImmutableJMSEnvironment(t *testing.T) { @@ -369,7 +369,7 @@ func TestRhdmProdImmutableJMSEnvironment(t *testing.T) { testAMQEnvs(t, env.Servers[0].DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Env, env.Servers[0].DeploymentConfigs[1].Spec.Template.Spec.Containers[0].Env) - assert.Equal(t, fmt.Sprintf("rhdm%s-decisioncentral-openshift", cr.Spec.CommonConfig.Version), env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Image) + assert.Equal(t, fmt.Sprintf("rhdm%s-decisioncentral-openshift", getMinorImageVersion(cr.Spec.CommonConfig.Version)), env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Image) } func TestRhpamProdImmutableEnvironment(t *testing.T) { @@ -387,7 +387,7 @@ func TestRhpamProdImmutableEnvironment(t *testing.T) { assert.True(t, env.SmartRouter.Omit, "SmarterRouter should be omitted") assert.Equal(t, "test-rhpamcentrmon", env.Console.DeploymentConfigs[0].ObjectMeta.Name) - assert.Equal(t, fmt.Sprintf("rhpam%s-businesscentral-monitoring-openshift", cr.Spec.CommonConfig.Version), env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Image) + assert.Equal(t, fmt.Sprintf("rhpam%s-businesscentral-monitoring-openshift", getMinorImageVersion(cr.Spec.CommonConfig.Version)), env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Image) } func TestRhpamProdImmutableJMSEnvironment(t *testing.T) { @@ -427,7 +427,7 @@ func TestRhpamProdImmutableJMSEnvironment(t *testing.T) { testAMQEnvs(t, env.Servers[0].DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Env, env.Servers[0].DeploymentConfigs[2].Spec.Template.Spec.Containers[0].Env) - assert.Equal(t, fmt.Sprintf("rhpam%s-businesscentral-monitoring-openshift", cr.Spec.CommonConfig.Version), env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Image) + assert.Equal(t, fmt.Sprintf("rhpam%s-businesscentral-monitoring-openshift", getMinorImageVersion(cr.Spec.CommonConfig.Version)), env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Image) } @@ -472,7 +472,7 @@ func TestRhpamProdImmutableJMSEnvironmentExecutorDisabled(t *testing.T) { assert.Equal(t, "queue/CUSTOM.KIE.SERVER.SIGNAL", getEnvVariable(env.Servers[0].DeploymentConfigs[0].Spec.Template.Spec.Containers[0], "KIE_SERVER_JMS_QUEUE_SIGNAL"), "Variable should exist") assert.Equal(t, "queue/KIE.SERVER.REQUEST, queue/KIE.SERVER.RESPONSE, queue/CUSTOM.KIE.SERVER.SIGNAL, queue/CUSTOM.KIE.SERVER.AUDIT", getEnvVariable(env.Servers[0].DeploymentConfigs[0].Spec.Template.Spec.Containers[0], "AMQ_QUEUES"), "Variable should exist") - assert.Equal(t, fmt.Sprintf("rhpam%s-businesscentral-monitoring-openshift", cr.Spec.CommonConfig.Version), env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Image) + assert.Equal(t, fmt.Sprintf("rhpam%s-businesscentral-monitoring-openshift", getMinorImageVersion(cr.Spec.CommonConfig.Version)), env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Image) } @@ -727,8 +727,7 @@ func TestConstructConsoleObject(t *testing.T) { env = ConsolidateObjects(env, cr) assert.Equal(t, fmt.Sprintf("%s-rhpamcentr", name), env.Console.DeploymentConfigs[0].Name) assert.Equal(t, int32(1), env.Console.DeploymentConfigs[0].Spec.Replicas) - re := regexp.MustCompile("[0-9]+") - assert.Equal(t, fmt.Sprintf("rhpam%s-businesscentral-openshift:%s", strings.Join(re.FindAllString(constants.ProductVersion, -1), ""), constants.ImageStreamTag), env.Console.DeploymentConfigs[0].Spec.Triggers[0].ImageChangeParams.From.Name) + assert.Equal(t, fmt.Sprintf("rhpam%s-businesscentral-openshift:%s", getMinorImageVersion(cr.Spec.CommonConfig.Version), cr.Spec.CommonConfig.ImageTag), env.Console.DeploymentConfigs[0].Spec.Triggers[0].ImageChangeParams.From.Name) for i := range sampleEnv { assert.Contains(t, env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Env, sampleEnv[i], "Environment merge not functional. Expecting: %v", sampleEnv[i]) } @@ -744,8 +743,7 @@ func TestConstructSmartRouterObject(t *testing.T) { assert.Equal(t, fmt.Sprintf("%s-smartrouter", name), env.SmartRouter.DeploymentConfigs[0].Name) assert.Equal(t, int32(1), env.SmartRouter.DeploymentConfigs[0].Spec.Replicas) - re := regexp.MustCompile("[0-9]+") - assert.Equal(t, fmt.Sprintf("rhpam%s-smartrouter-openshift:%s", strings.Join(re.FindAllString(constants.ProductVersion, -1), ""), constants.ImageStreamTag), env.SmartRouter.DeploymentConfigs[0].Spec.Triggers[0].ImageChangeParams.From.Name) + assert.Equal(t, fmt.Sprintf("rhpam%s-smartrouter-openshift:%s", getMinorImageVersion(cr.Spec.CommonConfig.Version), cr.Spec.CommonConfig.ImageTag), env.SmartRouter.DeploymentConfigs[0].Spec.Triggers[0].ImageChangeParams.From.Name) for i := range sampleEnv { assert.Contains(t, env.SmartRouter.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Env, sampleEnv[i], "Environment merge not functional. Expecting: %v", sampleEnv[i]) } @@ -761,8 +759,7 @@ func TestConstructServerObject(t *testing.T) { env = ConsolidateObjects(env, cr) assert.Equal(t, fmt.Sprintf("%s-kieserver", name), env.Servers[0].DeploymentConfigs[0].Name) assert.Equal(t, int32(1), env.Servers[0].DeploymentConfigs[0].Spec.Replicas) - re := regexp.MustCompile("[0-9]+") - assert.Equal(t, fmt.Sprintf("rhpam%s-kieserver-openshift:%s", strings.Join(re.FindAllString(constants.ProductVersion, -1), ""), constants.ImageStreamTag), env.Servers[0].DeploymentConfigs[0].Spec.Triggers[0].ImageChangeParams.From.Name) + assert.Equal(t, fmt.Sprintf("rhpam%s-kieserver-openshift:%s", getMinorImageVersion(cr.Spec.CommonConfig.Version), cr.Spec.CommonConfig.ImageTag), env.Servers[0].DeploymentConfigs[0].Spec.Triggers[0].ImageChangeParams.From.Name) for i := range sampleEnv { assert.Contains(t, env.Servers[0].DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Env, sampleEnv[i], "Environment merge not functional. Expecting: %v", sampleEnv[i]) } @@ -779,8 +776,7 @@ func TestConstructServerObject(t *testing.T) { } else { assert.Equal(t, fmt.Sprintf("%s-kieserver-%d", name, i+1), s.DeploymentConfigs[0].Name) } - re := regexp.MustCompile("[0-9]+") - assert.Equal(t, fmt.Sprintf("rhpam%s-kieserver-openshift:%s", strings.Join(re.FindAllString(constants.ProductVersion, -1), ""), constants.ImageStreamTag), env.Servers[i].DeploymentConfigs[0].Spec.Triggers[0].ImageChangeParams.From.Name) + assert.Equal(t, fmt.Sprintf("rhpam%s-kieserver-openshift:%s", getMinorImageVersion(cr.Spec.CommonConfig.Version), cr.Spec.CommonConfig.ImageTag), env.Servers[i].DeploymentConfigs[0].Spec.Triggers[0].ImageChangeParams.From.Name) for i := range sampleEnv { assert.Contains(t, s.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Env, sampleEnv[i], "Environment merge not functional. Expecting: %v", sampleEnv[i]) } @@ -809,8 +805,7 @@ func TestSetReplicas(t *testing.T) { } else { assert.Equal(t, fmt.Sprintf("%s-kieserver-%d", name, i+1), s.DeploymentConfigs[0].Name) } - re := regexp.MustCompile("[0-9]+") - assert.Equal(t, fmt.Sprintf("rhpam%s-kieserver-openshift:%s", strings.Join(re.FindAllString(constants.ProductVersion, -1), ""), constants.ImageStreamTag), env.Servers[i].DeploymentConfigs[0].Spec.Triggers[0].ImageChangeParams.From.Name) + assert.Equal(t, fmt.Sprintf("rhpam%s-kieserver-openshift:%s", getMinorImageVersion(cr.Spec.CommonConfig.Version), cr.Spec.CommonConfig.ImageTag), env.Servers[i].DeploymentConfigs[0].Spec.Triggers[0].ImageChangeParams.From.Name) assert.Equal(t, *replicas, s.DeploymentConfigs[0].Spec.Replicas) for i := range sampleEnv { assert.Contains(t, s.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Env, sampleEnv[i], "Environment merge not functional. Expecting: %v", sampleEnv[i]) @@ -847,7 +842,7 @@ func TestUnknownEnvironmentObjects(t *testing.T) { } env, err := GetEnvironment(cr, test.MockService()) - assert.Equal(t, fmt.Sprintf("envs/%s.yaml does not exist, '%s' KieApp not deployed", cr.Spec.Environment, cr.Name), err.Error()) + assert.Equal(t, fmt.Sprintf("%s/envs/%s.yaml does not exist, '%s' KieApp not deployed", cr.Spec.CommonConfig.Version, cr.Spec.Environment, cr.Name), err.Error()) env = ConsolidateObjects(env, cr) assert.NotNil(t, err) @@ -903,9 +898,7 @@ func TestTrialServerEnv(t *testing.T) { assert.Equal(t, deployments, len(env.Servers)) assert.Equal(t, fmt.Sprintf("%s-kieserver-%d", cr.Spec.CommonConfig.ApplicationName, deployments), env.Servers[deployments-1].DeploymentConfigs[0].Name) - pattern := regexp.MustCompile("[0-9]+") - expectedISTagName := fmt.Sprintf("rhpam%s-kieserver-openshift:%s", strings.Join(pattern.FindAllString(constants.ProductVersion, -1), ""), constants.ImageStreamTag) - assert.Equal(t, expectedISTagName, env.Servers[0].DeploymentConfigs[0].Spec.Triggers[0].ImageChangeParams.From.Name) + assert.Equal(t, fmt.Sprintf("rhpam%s-kieserver-openshift:%s", getMinorImageVersion(cr.Spec.CommonConfig.Version), cr.Spec.CommonConfig.ImageTag), env.Servers[0].DeploymentConfigs[0].Spec.Triggers[0].ImageChangeParams.From.Name) assert.Contains(t, env.Servers[deployments-1].DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Env, envReplace, "Environment overriding not functional") assert.Contains(t, env.Servers[deployments-1].DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Env, envAddition, "Environment additions not functional") assert.Contains(t, env.Servers[deployments-1].DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Env, corev1.EnvVar{ @@ -967,11 +960,9 @@ func TestTrialServersEnv(t *testing.T) { env = ConsolidateObjects(env, cr) assert.Len(t, env.Servers, 4) - pattern := regexp.MustCompile("[0-9]+") - expectedISTagName := fmt.Sprintf("rhpam%s-kieserver-openshift:%s", strings.Join(pattern.FindAllString(constants.ProductVersion, -1), ""), constants.ImageStreamTag) for index := 0; index < 1; index++ { s := env.Servers[index] - assert.Equal(t, expectedISTagName, s.DeploymentConfigs[0].Spec.Triggers[0].ImageChangeParams.From.Name) + assert.Equal(t, fmt.Sprintf("rhpam%s-kieserver-openshift:%s", getMinorImageVersion(cr.Spec.CommonConfig.Version), cr.Spec.CommonConfig.ImageTag), s.DeploymentConfigs[0].Spec.Triggers[0].ImageChangeParams.From.Name) assert.Equal(t, cr.Spec.Objects.Servers[0].Name, s.DeploymentConfigs[0].Name) assert.Contains(t, s.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Env, envReplace, "Environment overriding not functional") assert.Contains(t, s.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Env, envAddition, "Environment additions not functional") @@ -1028,8 +1019,7 @@ func TestTrialConsoleEnv(t *testing.T) { env = ConsolidateObjects(env, cr) assert.Equal(t, fmt.Sprintf("%s-rhdmcentr", cr.Spec.CommonConfig.ApplicationName), env.Console.DeploymentConfigs[0].Name) - re := regexp.MustCompile("[0-9]+") - assert.Equal(t, fmt.Sprintf("rhdm%s-decisioncentral-openshift:%s", strings.Join(re.FindAllString(constants.ProductVersion, -1), ""), constants.ImageStreamTag), env.Console.DeploymentConfigs[0].Spec.Triggers[0].ImageChangeParams.From.Name) + assert.Equal(t, fmt.Sprintf("rhdm%s-decisioncentral-openshift:%s", getMinorImageVersion(cr.Spec.CommonConfig.Version), cr.Spec.CommonConfig.ImageTag), env.Console.DeploymentConfigs[0].Spec.Triggers[0].ImageChangeParams.From.Name) adminUser := getEnvVariable(env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0], "KIE_ADMIN_USER") assert.Equal(t, constants.DefaultAdminUser, adminUser, "AdminUser default not being set correctly") assert.Contains(t, env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Env, envReplace, "Environment overriding not functional") @@ -1604,7 +1594,7 @@ func TestMultipleBuildConfigurations(t *testing.T) { assert.Equal(t, "", env.Servers[0].BuildConfigs[0].Spec.Strategy.SourceStrategy.From.Namespace) assert.Equal(t, "ImageStreamTag", env.Servers[1].BuildConfigs[0].Spec.Strategy.SourceStrategy.From.Kind) - imgName := fmt.Sprintf("rhdm%v-kieserver-openshift:%v", cr.Spec.CommonConfig.Version, cr.Spec.CommonConfig.ImageTag) + imgName := fmt.Sprintf("rhdm%v-kieserver-openshift:%v", getMinorImageVersion(cr.Spec.CommonConfig.Version), cr.Spec.CommonConfig.ImageTag) assert.Equal(t, imgName, env.Servers[1].BuildConfigs[0].Spec.Strategy.SourceStrategy.From.Name) assert.Equal(t, "openshift", env.Servers[1].BuildConfigs[0].Spec.Strategy.SourceStrategy.From.Namespace) } @@ -1704,7 +1694,7 @@ func TestDatabaseExternal(t *testing.T) { assert.Nil(t, err, "Error getting prod environment") assert.Equal(t, "test-rhpamcentrmon", env.Console.DeploymentConfigs[0].ObjectMeta.Name) - assert.Equal(t, fmt.Sprintf("rhpam%s-businesscentral-monitoring-openshift", cr.Spec.CommonConfig.Version), env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Image) + assert.Equal(t, fmt.Sprintf("rhpam%s-businesscentral-monitoring-openshift", getMinorImageVersion(cr.Spec.CommonConfig.Version)), env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Image) for i := 0; i < deployments; i++ { idx := "" if i > 0 { @@ -1768,7 +1758,7 @@ func TestDatabaseH2(t *testing.T) { assert.Nil(t, err, "Error getting prod environment") assert.Equal(t, "test-rhpamcentrmon", env.Console.DeploymentConfigs[0].ObjectMeta.Name) - assert.Equal(t, fmt.Sprintf("rhpam%s-businesscentral-monitoring-openshift", cr.Spec.CommonConfig.Version), env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Image) + assert.Equal(t, fmt.Sprintf("rhpam%s-businesscentral-monitoring-openshift", getMinorImageVersion(cr.Spec.CommonConfig.Version)), env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Image) for i := 0; i < deployments; i++ { idx := "" if i > 0 { @@ -1790,6 +1780,65 @@ func TestDatabaseH2(t *testing.T) { } } +func TestDefaultVersioning(t *testing.T) { + cr := &v1.KieApp{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test", + }, + Spec: v1.KieAppSpec{ + Environment: v1.RhpamProduction, + }, + } + env, err := GetEnvironment(cr, test.MockService()) + assert.Nil(t, err, "Error getting prod environment") + assert.Equal(t, "test-rhpamcentrmon", env.Console.DeploymentConfigs[0].ObjectMeta.Name) + assert.Equal(t, constants.CurrentVersion, cr.Spec.CommonConfig.Version) + assert.True(t, checkVersion(cr.Spec.CommonConfig.Version)) + assert.Equal(t, fmt.Sprintf("rhpam%s-businesscentral-monitoring-openshift", getMinorImageVersion(constants.CurrentVersion)), env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Image) +} + +func TestOldConfigVersioning(t *testing.T) { + cr := &v1.KieApp{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test", + }, + Spec: v1.KieAppSpec{ + Environment: v1.RhpamProduction, + CommonConfig: v1.CommonConfig{Version: "74"}, + }, + } + env, err := GetEnvironment(cr, test.MockService()) + assert.Nil(t, err, "Error getting prod environment") + assert.Equal(t, "test-rhpamcentrmon", env.Console.DeploymentConfigs[0].ObjectMeta.Name) + assert.Equal(t, "7.4.1", cr.Spec.CommonConfig.Version) + major, minor, patch := MajorMinorPatch(cr.Spec.CommonConfig.Version) + assert.Equal(t, "7", major) + assert.Equal(t, "4", minor) + assert.Equal(t, "1", patch) + assert.Equal(t, fmt.Sprintf("rhpam%s-businesscentral-monitoring-openshift", getMinorImageVersion(cr.Spec.CommonConfig.Version)), env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Image) +} + +func TestConfigVersioning(t *testing.T) { + cr := &v1.KieApp{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test", + }, + Spec: v1.KieAppSpec{ + Environment: v1.RhpamProduction, + CommonConfig: v1.CommonConfig{Version: "6.3.1"}, + }, + } + _, err := GetEnvironment(cr, test.MockService()) + assert.Error(t, err, "Incompatible product versions should throw an error") + assert.Equal(t, fmt.Sprintf("Product version %s is not supported by this Operator, %s", cr.Spec.CommonConfig.Version, version.Version), err.Error()) + assert.Equal(t, "6.3.1", cr.Spec.CommonConfig.Version) + major, minor, patch := MajorMinorPatch(cr.Spec.CommonConfig.Version) + assert.Equal(t, "6", major) + assert.Equal(t, "3", minor) + assert.Equal(t, "1", patch) + assert.False(t, checkVersion(cr.Spec.CommonConfig.Version)) +} + func TestDatabaseH2Ephemeral(t *testing.T) { deployments := 2 cr := &v1.KieApp{ @@ -1815,7 +1864,7 @@ func TestDatabaseH2Ephemeral(t *testing.T) { assert.Nil(t, err, "Error getting trial environment") assert.Equal(t, "test-rhpamcentr", env.Console.DeploymentConfigs[0].ObjectMeta.Name) - assert.Equal(t, fmt.Sprintf("rhpam%s-businesscentral-openshift", cr.Spec.CommonConfig.Version), env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Image) + assert.Equal(t, fmt.Sprintf("rhpam%s-businesscentral-openshift", getMinorImageVersion(cr.Spec.CommonConfig.Version)), env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Image) for i := 0; i < deployments; i++ { idx := "" if i > 0 { @@ -1861,7 +1910,7 @@ func TestDatabaseMySQL(t *testing.T) { assert.Nil(t, err, "Error getting prod environment") assert.Equal(t, "test-rhpamcentrmon", env.Console.DeploymentConfigs[0].ObjectMeta.Name) - assert.Equal(t, fmt.Sprintf("rhpam%s-businesscentral-monitoring-openshift", cr.Spec.CommonConfig.Version), env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Image) + assert.Equal(t, fmt.Sprintf("rhpam%s-businesscentral-monitoring-openshift", getMinorImageVersion(cr.Spec.CommonConfig.Version)), env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Image) for i := 0; i < deployments; i++ { idx := "" if i > 0 { @@ -1914,7 +1963,7 @@ func TestDatabaseMySQLDefaultSize(t *testing.T) { assert.Nil(t, err, "Error getting prod environment") assert.Equal(t, "test-rhpamcentrmon", env.Console.DeploymentConfigs[0].ObjectMeta.Name) - assert.Equal(t, fmt.Sprintf("rhpam%s-businesscentral-monitoring-openshift", cr.Spec.CommonConfig.Version), env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Image) + assert.Equal(t, fmt.Sprintf("rhpam%s-businesscentral-monitoring-openshift", getMinorImageVersion(cr.Spec.CommonConfig.Version)), env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Image) for i := 0; i < deployments; i++ { idx := "" if i > 0 { @@ -1976,7 +2025,7 @@ func TestDatabaseMySQLTrialEphemeral(t *testing.T) { assert.Nil(t, err, "Error getting trial environment") assert.Equal(t, "test-rhpamcentr", env.Console.DeploymentConfigs[0].ObjectMeta.Name) - assert.Equal(t, fmt.Sprintf("rhpam%s-businesscentral-openshift", cr.Spec.CommonConfig.Version), env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Image) + assert.Equal(t, fmt.Sprintf("rhpam%s-businesscentral-openshift", getMinorImageVersion(cr.Spec.CommonConfig.Version)), env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Image) for i := 0; i < deployments; i++ { idx := "" if i > 0 { @@ -2027,7 +2076,7 @@ func TestDatabasePostgresql(t *testing.T) { assert.Nil(t, err, "Error getting prod environment") assert.Equal(t, "test-rhpamcentrmon", env.Console.DeploymentConfigs[0].ObjectMeta.Name) - assert.Equal(t, fmt.Sprintf("rhpam%s-businesscentral-monitoring-openshift", cr.Spec.CommonConfig.Version), env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Image) + assert.Equal(t, fmt.Sprintf("rhpam%s-businesscentral-monitoring-openshift", getMinorImageVersion(cr.Spec.CommonConfig.Version)), env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Image) for i := 0; i < deployments; i++ { idx := "" if i > 0 { @@ -2080,7 +2129,7 @@ func TestDatabasePostgresqlDefaultSize(t *testing.T) { assert.Nil(t, err, "Error getting prod environment") assert.Equal(t, "test-rhpamcentrmon", env.Console.DeploymentConfigs[0].ObjectMeta.Name) - assert.Equal(t, fmt.Sprintf("rhpam%s-businesscentral-monitoring-openshift", cr.Spec.CommonConfig.Version), env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Image) + assert.Equal(t, fmt.Sprintf("rhpam%s-businesscentral-monitoring-openshift", getMinorImageVersion(cr.Spec.CommonConfig.Version)), env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Image) for i := 0; i < deployments; i++ { idx := "" if i > 0 { @@ -2142,7 +2191,7 @@ func TestDatabasePostgresqlTrialEphemeral(t *testing.T) { assert.Nil(t, err, "Error getting trial environment") assert.Equal(t, "test-rhpamcentr", env.Console.DeploymentConfigs[0].ObjectMeta.Name) - assert.Equal(t, fmt.Sprintf("rhpam%s-businesscentral-openshift", cr.Spec.CommonConfig.Version), env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Image) + assert.Equal(t, fmt.Sprintf("rhpam%s-businesscentral-openshift", getMinorImageVersion(cr.Spec.CommonConfig.Version)), env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Image) for i := 0; i < deployments; i++ { idx := "" if i > 0 { diff --git a/pkg/controller/kieapp/defaults/merge_test.go b/pkg/controller/kieapp/defaults/merge_test.go index 4510e3bf4..7e701765d 100644 --- a/pkg/controller/kieapp/defaults/merge_test.go +++ b/pkg/controller/kieapp/defaults/merge_test.go @@ -486,7 +486,7 @@ func getParsedTemplateFromCR(cr *v1.KieApp, filename string, object interface{}) log.Error("Error getting environment template", err) } - yamlBytes, err := loadYaml(test.MockService(), filename, cr.Namespace, envTemplate) + yamlBytes, err := loadYaml(test.MockService(), filename, cr.Spec.CommonConfig.Version, cr.Namespace, envTemplate) if err != nil { return err } diff --git a/pkg/controller/kieapp/kieapp_controller.go b/pkg/controller/kieapp/kieapp_controller.go index accbb5dd9..3e642df4f 100644 --- a/pkg/controller/kieapp/kieapp_controller.go +++ b/pkg/controller/kieapp/kieapp_controller.go @@ -50,7 +50,11 @@ func (reconciler *Reconciler) Reconcile(request reconcile.Request) (reconcile.Re err := reconciler.Service.Get(context.TODO(), types.NamespacedName{Namespace: depNameSpace, Name: opName}, myDep) if err == nil { // Reconcile ConfigMaps - reconciler.CreateConfigMaps(myDep) + // NOTES FOR FUTURE DEV + // started creating as versioned configs + // if versioned one already exists, reconcile?? + // if not, but prior version exists, check deltas and apply as new versioned config + reconciler.CreateConfigMaps(myDep, constants.CurrentVersion) if shouldDeployConsole() { deployConsole(reconciler, myDep) } @@ -293,9 +297,9 @@ func (reconciler *Reconciler) createLocalImageTag(tagRefName string, cr *v1.KieA } product := defaults.GetProduct(cr.Spec.Environment) tagName := fmt.Sprintf("%s:%s", result[0], result[1]) - version := []byte(cr.Spec.CommonConfig.Version) imageName := tagName - regContext := fmt.Sprintf("%s-%s", product, string(version[0])) + major, _, _ := defaults.MajorMinorPatch(cr.Spec.CommonConfig.Version) + regContext := fmt.Sprintf("%s-%s", product, major) // default registry settings registry := &v1.KieAppRegistry{ @@ -753,9 +757,9 @@ func (reconciler *Reconciler) GetRouteHost(route routev1.Route, cr *v1.KieApp) s return found.Spec.Host } -// CreateConfigMaps generates & creates necessary ConfigMaps from embedded files -func (reconciler *Reconciler) CreateConfigMaps(myDep *appsv1.Deployment) { - configMaps := defaults.ConfigMapsFromFile(myDep, myDep.Namespace, reconciler.Service.GetScheme()) +// CreateConfigMaps generates & creates necessary versioned ConfigMaps from embedded product files +func (reconciler *Reconciler) CreateConfigMaps(myDep *appsv1.Deployment, productVersion string) { + configMaps := defaults.ConfigMapsFromFile(myDep, myDep.Namespace, productVersion, reconciler.Service.GetScheme()) for _, configMap := range configMaps { var testDir bool result := strings.Split(configMap.Name, "-") diff --git a/pkg/controller/kieapp/kieapp_controller_test.go b/pkg/controller/kieapp/kieapp_controller_test.go index 9e8b23728..63990e9d9 100644 --- a/pkg/controller/kieapp/kieapp_controller_test.go +++ b/pkg/controller/kieapp/kieapp_controller_test.go @@ -218,13 +218,13 @@ func TestCreateTagVersionImageStreams(t *testing.T) { Service: mockSvc, } - err = reconciler.createLocalImageTag(fmt.Sprintf("%s:%s", constants.DatagridImage, constants.DatagridImageTag), cr) + err = reconciler.createLocalImageTag(fmt.Sprintf("%s:%s", constants.VersionConstants[cr.Spec.CommonConfig.Version].DatagridImage, constants.VersionConstants[cr.Spec.CommonConfig.Version].DatagridImageTag), cr) assert.Nil(t, err) - isTag, err := isTagMock.Get(fmt.Sprintf("test-ns/%s:%s", constants.DatagridImage, constants.DatagridImageTag), metav1.GetOptions{}) + isTag, err := isTagMock.Get(fmt.Sprintf("test-ns/%s:%s", constants.VersionConstants[cr.Spec.CommonConfig.Version].DatagridImage, constants.VersionConstants[cr.Spec.CommonConfig.Version].DatagridImageTag), metav1.GetOptions{}) assert.Nil(t, err) assert.NotNil(t, isTag) - assert.Equal(t, fmt.Sprintf("%s/jboss-datagrid-7/%s:%s", constants.ImageRegistry, constants.DatagridImage, constants.DatagridImageTag), isTag.Tag.From.Name) + assert.Equal(t, fmt.Sprintf("%s/jboss-datagrid-7/%s:%s", constants.ImageRegistry, constants.VersionConstants[cr.Spec.CommonConfig.Version].DatagridImage, constants.VersionConstants[cr.Spec.CommonConfig.Version].DatagridImageTag), isTag.Tag.From.Name) } func TestCreateImageStreamsLatest(t *testing.T) { @@ -245,14 +245,14 @@ func TestCreateImageStreamsLatest(t *testing.T) { Service: mockSvc, } - err = reconciler.createLocalImageTag(fmt.Sprintf("%s", constants.DatagridImage), cr) + err = reconciler.createLocalImageTag(fmt.Sprintf("%s", constants.VersionConstants[cr.Spec.CommonConfig.Version].DatagridImage), cr) assert.Nil(t, err) - isTag, err := isTagMock.Get(fmt.Sprintf("test-ns/%s:latest", constants.DatagridImage), metav1.GetOptions{}) + isTag, err := isTagMock.Get(fmt.Sprintf("test-ns/%s:latest", constants.VersionConstants[cr.Spec.CommonConfig.Version].DatagridImage), metav1.GetOptions{}) assert.Nil(t, err) fmt.Print(isTag) assert.NotNil(t, isTag) - assert.Equal(t, fmt.Sprintf("%s/jboss-datagrid-7/%s:latest", constants.ImageRegistry, constants.DatagridImage), isTag.Tag.From.Name) + assert.Equal(t, fmt.Sprintf("%s/jboss-datagrid-7/%s:latest", constants.ImageRegistry, constants.VersionConstants[cr.Spec.CommonConfig.Version].DatagridImage), isTag.Tag.From.Name) } func TestStatusDeploymentsProgression(t *testing.T) { From 4ff03feb94a0d08b1eb962f6deacd49ff1d19489 Mon Sep 17 00:00:00 2001 From: tchughesiv Date: Tue, 30 Jul 2019 09:52:52 -0500 Subject: [PATCH 2/2] [KIECLOUD-284] Change patch upgrade default to false Signed-off-by: tchughesiv --- pkg/controller/kieapp/defaults/defaults.go | 4 -- .../kieapp/defaults/defaults_test.go | 46 ++++++++++++------- .../kieapp/kieapp_controller_test.go | 16 +++---- 3 files changed, 38 insertions(+), 28 deletions(-) diff --git a/pkg/controller/kieapp/defaults/defaults.go b/pkg/controller/kieapp/defaults/defaults.go index 49568534e..1e9bb2ace 100644 --- a/pkg/controller/kieapp/defaults/defaults.go +++ b/pkg/controller/kieapp/defaults/defaults.go @@ -159,10 +159,6 @@ func getEnvTemplate(cr *v1.KieApp) (v1.EnvTemplate, error) { return v1.EnvTemplate{}, fmt.Errorf("Product version %s is not supported by this Operator, %s", cr.Spec.CommonConfig.Version, version.Version) } // set default values for go template where not provided - if cr.Spec.Upgrades.Patch == nil { - defaultPatchFlag := true - cr.Spec.Upgrades.Patch = &defaultPatchFlag - } config := &cr.Spec.CommonConfig if len(config.ImageTag) == 0 { config.ImageTag = constants.VersionConstants[config.Version].ImageStreamTag diff --git a/pkg/controller/kieapp/defaults/defaults_test.go b/pkg/controller/kieapp/defaults/defaults_test.go index dbb546813..dbf80e416 100644 --- a/pkg/controller/kieapp/defaults/defaults_test.go +++ b/pkg/controller/kieapp/defaults/defaults_test.go @@ -871,7 +871,7 @@ func TestTrialServerEnv(t *testing.T) { Name: name, }, Spec: v1.KieAppSpec{ - Environment: "rhpam-trial", + Environment: v1.RhpamTrial, Objects: v1.KieAppObjects{ Servers: []v1.KieServerSet{ { @@ -928,7 +928,7 @@ func TestTrialServersEnv(t *testing.T) { Name: name, }, Spec: v1.KieAppSpec{ - Environment: "rhpam-trial", + Environment: v1.RhpamTrial, Objects: v1.KieAppObjects{ Servers: []v1.KieServerSet{ { @@ -995,7 +995,7 @@ func TestTrialConsoleEnv(t *testing.T) { Name: name, }, Spec: v1.KieAppSpec{ - Environment: "rhdm-trial", + Environment: v1.RhdmTrial, CommonConfig: v1.CommonConfig{ ApplicationName: "trial", }, @@ -1033,12 +1033,10 @@ func TestTrialConsoleEnv(t *testing.T) { func TestKieAppDefaults(t *testing.T) { cr := &v1.KieApp{ ObjectMeta: metav1.ObjectMeta{ - Name: "test", - Namespace: "test-ns", + Name: "test", }, Spec: v1.KieAppSpec{ - Environment: "rhpam-trial", - Objects: v1.KieAppObjects{}, + Environment: v1.RhpamTrial, }, } _, err := GetEnvironment(cr, test.MockService()) @@ -1047,17 +1045,33 @@ func TestKieAppDefaults(t *testing.T) { assert.NotContains(t, cr.Spec.Objects.Console.Env, corev1.EnvVar{ Name: "empty", }) - assert.True(t, *cr.Spec.Upgrades.Patch, "Spec.Upgrades.Patch should be true by default") + assert.Nil(t, cr.Spec.Upgrades.Patch, "Spec.Upgrades.Patch should be empty by default") assert.False(t, cr.Spec.Upgrades.Minor, "Spec.Upgrades.Minor should be false by default") } +func TestUpgradesTrue(t *testing.T) { + patch := true + cr := &v1.KieApp{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test", + }, + Spec: v1.KieAppSpec{ + Environment: v1.RhpamTrial, + Upgrades: v1.KieAppUpgrades{Patch: &patch}, + }, + } + _, err := GetEnvironment(cr, test.MockService()) + assert.Nil(t, err) + assert.True(t, *cr.Spec.Upgrades.Patch, "Spec.Upgrades.Patch should be true") +} + func TestMergeTrialAndCommonConfig(t *testing.T) { cr := &v1.KieApp{ ObjectMeta: metav1.ObjectMeta{ Name: "test", }, Spec: v1.KieAppSpec{ - Environment: "rhpam-trial", + Environment: v1.RhpamTrial, }, } env, err := GetEnvironment(cr, test.MockService()) @@ -1105,7 +1119,7 @@ func TestServerConflict(t *testing.T) { Name: name, }, Spec: v1.KieAppSpec{ - Environment: "rhpam-trial", + Environment: v1.RhpamTrial, Objects: v1.KieAppObjects{ Servers: []v1.KieServerSet{ {Name: duplicate, Deployments: Pint(deployments)}, @@ -1128,7 +1142,7 @@ func TestServerConflictGenerated(t *testing.T) { Name: name, }, Spec: v1.KieAppSpec{ - Environment: "rhpam-trial", + Environment: v1.RhpamTrial, Objects: v1.KieAppObjects{ Servers: []v1.KieServerSet{ {Name: duplicate}, @@ -1151,7 +1165,7 @@ func TestServersDefaultNameDeployments(t *testing.T) { Name: name, }, Spec: v1.KieAppSpec{ - Environment: "rhpam-trial", + Environment: v1.RhpamTrial, Objects: v1.KieAppObjects{ Servers: []v1.KieServerSet{ {Deployments: Pint(deployments)}, @@ -1179,7 +1193,7 @@ func TestServersDefaultNameArray(t *testing.T) { Name: name, }, Spec: v1.KieAppSpec{ - Environment: "rhpam-trial", + Environment: v1.RhpamTrial, Objects: v1.KieAppObjects{ Servers: []v1.KieServerSet{ {}, {}, {}, @@ -1212,7 +1226,7 @@ func TestServersDefaultNameMixed(t *testing.T) { Name: name, }, Spec: v1.KieAppSpec{ - Environment: "rhpam-trial", + Environment: v1.RhpamTrial, Objects: v1.KieAppObjects{ Servers: []v1.KieServerSet{ {Deployments: Pint(deployments0)}, @@ -1252,7 +1266,7 @@ func TestImageRegistry(t *testing.T) { Name: "test", }, Spec: v1.KieAppSpec{ - Environment: "rhpam-trial", + Environment: v1.RhpamTrial, }, } _, err := GetEnvironment(cr, test.MockService()) @@ -1267,7 +1281,7 @@ func TestImageRegistry(t *testing.T) { Name: "test", }, Spec: v1.KieAppSpec{ - Environment: "rhpam-trial", + Environment: v1.RhpamTrial, ImageRegistry: &v1.KieAppRegistry{ Registry: registry2, }, diff --git a/pkg/controller/kieapp/kieapp_controller_test.go b/pkg/controller/kieapp/kieapp_controller_test.go index 63990e9d9..fa10be5c4 100644 --- a/pkg/controller/kieapp/kieapp_controller_test.go +++ b/pkg/controller/kieapp/kieapp_controller_test.go @@ -25,7 +25,7 @@ func TestGenerateSecret(t *testing.T) { Name: "test", }, Spec: v1.KieAppSpec{ - Environment: "rhpam-trial", + Environment: v1.RhpamTrial, Objects: v1.KieAppObjects{ Servers: []v1.KieServerSet{ {Deployments: defaults.Pint(3)}, @@ -67,7 +67,7 @@ func TestSpecifySecret(t *testing.T) { Name: "test", }, Spec: v1.KieAppSpec{ - Environment: "rhpam-trial", + Environment: v1.RhpamTrial, Objects: v1.KieAppObjects{ Console: v1.SecuredKieAppObject{ KieAppObject: v1.KieAppObject{ @@ -130,7 +130,7 @@ func TestConsoleHost(t *testing.T) { Name: "test", }, Spec: v1.KieAppSpec{ - Environment: "rhdm-trial", + Environment: v1.RhdmTrial, }, } @@ -153,7 +153,7 @@ func TestCreateRhpamImageStreams(t *testing.T) { Namespace: "test-ns", }, Spec: v1.KieAppSpec{ - Environment: "rhpam-trial", + Environment: v1.RhpamTrial, }, } mockSvc := test.MockService() @@ -180,7 +180,7 @@ func TestCreateRhdmImageStreams(t *testing.T) { Namespace: "test-ns", }, Spec: v1.KieAppSpec{ - Environment: "rhdm-trial", + Environment: v1.RhdmTrial, }, } mockSvc := test.MockService() @@ -207,7 +207,7 @@ func TestCreateTagVersionImageStreams(t *testing.T) { Namespace: "test-ns", }, Spec: v1.KieAppSpec{ - Environment: "rhdm-trial", + Environment: v1.RhdmTrial, }, } mockSvc := test.MockService() @@ -234,7 +234,7 @@ func TestCreateImageStreamsLatest(t *testing.T) { Namespace: "test-ns", }, Spec: v1.KieAppSpec{ - Environment: "rhdm-trial", + Environment: v1.RhdmTrial, }, } mockSvc := test.MockService() @@ -259,7 +259,7 @@ func TestStatusDeploymentsProgression(t *testing.T) { crNamespacedName := getNamespacedName("namespace", "cr") cr := getInstance(crNamespacedName) cr.Spec = v1.KieAppSpec{ - Environment: "rhpam-trial", + Environment: v1.RhpamTrial, } service := test.MockService() err := service.Create(context.TODO(), cr)