From 6fa57f4df5dd2398b1945d31348a3d31f2eed021 Mon Sep 17 00:00:00 2001 From: maracle6 <45719028+maracle6@users.noreply.github.com> Date: Mon, 23 Oct 2023 14:19:11 -0700 Subject: [PATCH] ISSUE-655 Add backingservices subchart for Constellation Messaging --- charts/backingservices/README.md | 3 +- .../charts/constellation-messaging/Chart.yaml | 6 ++ .../charts/constellation-messaging/README.md | 20 +++++++ .../templates/messaging-deployment.yaml | 32 +++++++++++ .../templates/messaging-ingress.yaml | 25 ++++++++ .../templates/messaging-service.yaml | 16 ++++++ .../constellation-messaging/values.yaml | 24 ++++++++ charts/backingservices/requirements.yaml | 2 + charts/backingservices/values.yaml | 6 ++ .../backingservices/constellation_test.go | 57 +++++++++++++++++++ 10 files changed, 190 insertions(+), 1 deletion(-) create mode 100644 charts/backingservices/charts/constellation-messaging/Chart.yaml create mode 100644 charts/backingservices/charts/constellation-messaging/README.md create mode 100644 charts/backingservices/charts/constellation-messaging/templates/messaging-deployment.yaml create mode 100644 charts/backingservices/charts/constellation-messaging/templates/messaging-ingress.yaml create mode 100644 charts/backingservices/charts/constellation-messaging/templates/messaging-service.yaml create mode 100644 charts/backingservices/charts/constellation-messaging/values.yaml diff --git a/charts/backingservices/README.md b/charts/backingservices/README.md index 32e184bcf..d43806584 100644 --- a/charts/backingservices/README.md +++ b/charts/backingservices/README.md @@ -5,4 +5,5 @@ You deploy dedicated services to support Pega Infinity as an independent microse The backingservices chart supports deployment of the following services. Each of these readme files provide a detailed description of possible configurations and their default values as applicable. * [Search and Reporting Service](./charts/srs/README.md) -* [Constellation Static Content](./charts/constellation/README.md) \ No newline at end of file +* [Constellation App Static Content](./charts/constellation/README.md) +* [Constellation Messaging](./charts/constellation-messaging/README.md) \ No newline at end of file diff --git a/charts/backingservices/charts/constellation-messaging/Chart.yaml b/charts/backingservices/charts/constellation-messaging/Chart.yaml new file mode 100644 index 000000000..e7aa2c3df --- /dev/null +++ b/charts/backingservices/charts/constellation-messaging/Chart.yaml @@ -0,0 +1,6 @@ +--- +apiVersion: v1 +name: constellation-messaging +version: 1.0.0 +description: Pega Constellation Messaging Service +appVersion: 8.8.0 diff --git a/charts/backingservices/charts/constellation-messaging/README.md b/charts/backingservices/charts/constellation-messaging/README.md new file mode 100644 index 000000000..d0cd009b5 --- /dev/null +++ b/charts/backingservices/charts/constellation-messaging/README.md @@ -0,0 +1,20 @@ +#Constellation Messaging Service + +The optional Messaging service acts as a middle man between information publishers and information subscribers; accepting simple http publish of information to forward to 1000's of websocket subscribers. The publishers are typically the Infinity case engine or 3rd party integration services, and the subscribers are UI components in browsers running Constellation UI. + +Once the service routing (with TLS) is set up, configure the Pega Infinity ConstellationMessageSvcHostPath DSS to your service URL (e.g. http://yourhostname.com/c11n-messaging). + +Only a single Messaging Service deployment is necessary to support an entire organization. Do not install the service in every namespace or for every application or project. + +Complete information on the design of the service including architecture, scalability, reliability, operations and troubleshooting is available at [https://documents.constellation.pega.io/messaging/introduction.html](https://documents.constellation.pega.io/messaging/introduction.html). + +### Configuration settings + +| Configuration | Usage | +|-----------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `enabled` | Enable the Messaging Service deployment as a backing service. Set this parameter to `true` to deploy the service. | +| `name` | Specify the name of your messaging service. Your deployment creates resources prefixed with this string. | +| `imagePullSecretNames` | List pre-existing secrets to be used for pulling docker images. | +| `pegaMessagingPort` | Defines the port used by the Service. | +| `pegaMessagingTargetPort` | Defines the port used by the Pod and Container. | +| `ingress` | Allows optional configuration of a domain name, ingressClass, and annotations. An ingress will be provisioned if a domain name is supplied. Due to the diversity of network configurations, ingress vendors, and TLS requirements it may be necessary to define your ingress separately from this chart. diff --git a/charts/backingservices/charts/constellation-messaging/templates/messaging-deployment.yaml b/charts/backingservices/charts/constellation-messaging/templates/messaging-deployment.yaml new file mode 100644 index 000000000..c5769e954 --- /dev/null +++ b/charts/backingservices/charts/constellation-messaging/templates/messaging-deployment.yaml @@ -0,0 +1,32 @@ +{{- if .Values.enabled }} +kind: Deployment +apiVersion: apps/v1 +metadata: + name: {{ .Values.name }} + labels: + app: {{ .Values.name }} +spec: + replicas: {{ .Values.replicas }} + selector: + matchLabels: + app: {{ .Values.name }} + template: + metadata: + labels: + app: {{ .Values.name }} + spec: + imagePullSecrets: + {{- range .Values.imagePullSecretNames }} + - name: {{ . }} + {{- end }} + containers: + - name: c11n-messaging + imagePullPolicy: {{ .Values.imagePullPolicy }} + image: {{ .Values.image }} + args: + - --max-semi-space-size=1024 + - port={{ .Values.pegaMessagingTargetPort }} + - path=/c11n-messaging + ports: + - containerPort: {{ .Values.pegaMessagingTargetPort }} +{{ end }} diff --git a/charts/backingservices/charts/constellation-messaging/templates/messaging-ingress.yaml b/charts/backingservices/charts/constellation-messaging/templates/messaging-ingress.yaml new file mode 100644 index 000000000..6cacefded --- /dev/null +++ b/charts/backingservices/charts/constellation-messaging/templates/messaging-ingress.yaml @@ -0,0 +1,25 @@ +{{- if and .Values.enabled .Values.ingress.domain }} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ .Values.name }} +{{- if .Values.ingress.annotations }} + annotations: +{{ toYaml .Values.ingress.annotations | indent 4 }} +{{- end }} +spec: +{{- if .Values.ingress.ingressClassName }} + ingressClassName: {{ .Values.ingress.ingressClassName }} +{{- end }} + rules: + - host: {{ .Values.ingress.domain }} + http: + paths: + - path: /c11n-messaging + pathType: Prefix + backend: + service: + name: {{ .Values.name }} + port: + number: {{ $.Values.pegaMessagingPort }} +{{ end }} diff --git a/charts/backingservices/charts/constellation-messaging/templates/messaging-service.yaml b/charts/backingservices/charts/constellation-messaging/templates/messaging-service.yaml new file mode 100644 index 000000000..a54f17a24 --- /dev/null +++ b/charts/backingservices/charts/constellation-messaging/templates/messaging-service.yaml @@ -0,0 +1,16 @@ +{{- if .Values.enabled }} +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.name }} + labels: + app: {{ .Values.name }} +spec: + type: NodePort + selector: + app: {{ .Values.name }} + ports: + - protocol: TCP + port: {{ .Values.pegaMessagingPort }} + targetPort: {{ .Values.pegaMessagingTargetPort }} +{{ end }} diff --git a/charts/backingservices/charts/constellation-messaging/values.yaml b/charts/backingservices/charts/constellation-messaging/values.yaml new file mode 100644 index 000000000..bda6acb74 --- /dev/null +++ b/charts/backingservices/charts/constellation-messaging/values.yaml @@ -0,0 +1,24 @@ +--- +enabled: false +name: YOUR_MESSAGING_SERVICE_DEPLOYMENT_NAME + +image: YOUR_MESSAGING_SERVICE_IMAGE:TAG +replicas: 1 + +# To avoid exposing Docker credentials, create a separate Docker config secret. +# Specify secret names as an array of comma-separated strings. For example: ["secret1", "secret2"] +imagePullSecretNames: [] +imagePullPolicy: Always + +pegaMessagingPort: 3000 +pegaMessagingTargetPort: 3000 + +serviceType: NodePort + +# An ingress will be provisioned if a hostname is defined, or omitted if the hostname is empty. +# ingressClassName and annotations are optional and will be included if defined. +# Due to the diverse requirements for ingresses and TLS configuration, it may be necessary to define the ingress separately from this chart. +ingress: + domain: + ingressClassName: + annotations: diff --git a/charts/backingservices/requirements.yaml b/charts/backingservices/requirements.yaml index 891dcd358..42598f265 100644 --- a/charts/backingservices/requirements.yaml +++ b/charts/backingservices/requirements.yaml @@ -10,5 +10,7 @@ dependencies: condition: srs.srsStorage.provisionInternalESCluster - name: constellation version: "1.0.0" +- name: constellation-messaging + version: "1.0.0" - name: srs version: "0.1.0" \ No newline at end of file diff --git a/charts/backingservices/values.yaml b/charts/backingservices/values.yaml index 502574921..715b36927 100644 --- a/charts/backingservices/values.yaml +++ b/charts/backingservices/values.yaml @@ -75,6 +75,12 @@ srs: constellation: enabled: false +constellation-messaging: + enabled: false + name: YOUR_MESSAGING_SERVICE_DEPLOYMENT_NAME + image: YOUR_MESSAGING_SERVICE_IMAGE:TAG + replicas: 1 + # This section specifies the configuration for deploying an internal elasticsearch cluster for use with SRS. # The configuration for rest of the values defined under 'elasticsearch' are to define the elasticsearch cluster # based on helm charts defined at https://github.com/elastic/helm-charts/tree/master/elasticsearch and may be modified diff --git a/terratest/src/test/backingservices/constellation_test.go b/terratest/src/test/backingservices/constellation_test.go index 09dfd97e7..97ae5de65 100644 --- a/terratest/src/test/backingservices/constellation_test.go +++ b/terratest/src/test/backingservices/constellation_test.go @@ -35,6 +35,48 @@ func Test_shouldContainConstellationResourcesWhenEnabled(t *testing.T) { } } +func Test_shouldContainConstellationMessagingWhenEnabled(t *testing.T) { + helmChartParser := NewHelmConfigParser( + NewHelmTest(t, helmChartRelativePath, map[string]string{ + "srs.enabled": "false", + "constellation-messaging.enabled": "true", + "constellation-messaging.name": "constellation-messaging", + "constellation-messaging.image": "messaging-image:1.0.0", + "constellation-messaging.replicas": "3", + "constellation-messaging.imagePullSecretNames": "{secret1, secret2}", + "constellation-messaging.ingress.domain": "test.com", + }), + ) + + for _, i := range constellationMessagingResources { + require.True(t, helmChartParser.Contains(SearchResourceOption{ + Name: i.Name, + Kind: i.Kind, + })) + } +} + +func Test_shouldNotContainConstellationMessagingWhenDisabled(t *testing.T) { + helmChartParser := NewHelmConfigParser( + NewHelmTest(t, helmChartRelativePath, map[string]string{ + "srs.enabled": "false", + "constellation-messaging.enabled": "false", + "constellation-messaging.name": "constellation-messaging", + "constellation-messaging.image": "messaging-image:1.0.0", + "constellation-messaging.replicas": "3", + "constellation-messaging.imagePullSecretNames": "{secret1, secret2}", + "constellation-messaging.ingress.domain": "test.com", + }), + ) + + for _, i := range constellationMessagingResources { + require.False(t, helmChartParser.Contains(SearchResourceOption{ + Name: i.Name, + Kind: i.Kind, + })) + } +} + var constellationResources = []SearchResourceOption{ { Name: "constellation", @@ -53,3 +95,18 @@ var constellationResources = []SearchResourceOption{ Kind: "Secret", }, } + +var constellationMessagingResources = []SearchResourceOption{ + { + Name: "constellation-messaging", + Kind: "Deployment", + }, + { + Name: "constellation-messaging", + Kind: "Service", + }, + { + Name: "constellation-messaging", + Kind: "Ingress", + }, +}