Skip to content

Commit

Permalink
Initial Constellation integration (#97)
Browse files Browse the repository at this point in the history
* Add preliminary support for the constellation service.

Co-authored-by: Parmar <[email protected]>
Co-authored-by: anuds <[email protected]>
Co-authored-by: parmn <[email protected]>
Co-authored-by: casad <[email protected]>
  • Loading branch information
5 people authored Aug 20, 2020
1 parent 6524854 commit 7509c8d
Show file tree
Hide file tree
Showing 13 changed files with 183 additions and 13 deletions.
6 changes: 6 additions & 0 deletions charts/pega/charts/constellation/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
apiVersion: v1
name: constellation
version: 0.0.1
description: Pega constellation service
appVersion: 8.5.0
37 changes: 37 additions & 0 deletions charts/pega/charts/constellation/templates/clln-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#Deploy only when the constellation flag has been enabled in the values yaml.
{{ if and .Values.enabled (eq .Values.enabled true) }}
kind: Deployment
apiVersion: apps/v1
metadata:
name: constellation
labels:
app: constellation
spec:
replicas: 2
selector:
matchLabels:
app: constellation
template:
metadata:
labels:
app: constellation
spec:
imagePullSecrets:
- name: {{ template "pegaRegistrySecret" }}
containers:
- name: constellation
imagePullPolicy: {{ .Values.imagePullPolicy }}
image: {{ .Values.image }}
args:
- port=3000
- {{ .Values.logLevel }}
livenessProbe:
httpGet:
path: /c11n/api/v1/ping
readinessProbe:
initialDelaySeconds: 1
httpGet:
path: /c11n/api/v1/ping
ports:
- containerPort: 3000
{{ end }}
19 changes: 19 additions & 0 deletions charts/pega/charts/constellation/templates/clln-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#Deploy only when the constellation flag has been enabled in the values yaml.
{{ if and .Values.enabled (eq .Values.enabled true) }}
apiVersion: v1
kind: Service
metadata:
name: constellation
labels:
app: constellation
# component: constellation
spec:
selector:
app: constellation
# component: constellation
ports:
- protocol: TCP
port: 3000
targetPort: 3000
type: LoadBalancer
{{ end }}
7 changes: 7 additions & 0 deletions charts/pega/charts/constellation/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
# Parameters for constellation operation:
# Docker repos and tag for image
image: IMAGE_REPO_URL_HERE
# log level : error, warn, info, debug. use error for production
logLevel: info
enabled: false
4 changes: 4 additions & 0 deletions charts/pega/templates/_pega-deployment.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ spec:
- name: REQUESTOR_PASSIVATION_TIMEOUT
value: "{{ .node.requestor.passivationTimeSec }}"
{{- end }}
{{- if and .root.Values.constellation (eq .root.Values.constellation.enabled true) }}
- name: COSMOS_SETTINGS
value: "Pega-UIEngine/cosmosservicesURI=/c11n"
{{- end }}
{{- if .custom }}
{{- if .custom.env }}
# Additional custom env vars
Expand Down
12 changes: 9 additions & 3 deletions charts/pega/templates/_pega-eks-ingress.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,15 @@ spec:
# To access the below service, along with {{ .node.domain }}, alb http port also has to be provided in the URL.
- host: {{ template "domainName" dict "node" .node }}
http:
paths:
- backend:
serviceName: {{ .name }}
paths:
{{ if and .root.Values.constellation (eq .root.Values.constellation.enabled true) }}
- path: /c11n
backend:
serviceName: constellation
servicePort: 3000
{{ end }}
- backend:
serviceName: {{ .name }}
servicePort: {{ .node.service.port }}
---
{{- end }}
12 changes: 9 additions & 3 deletions charts/pega/templates/_pega-gke-ingress.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,15 @@ spec:
# To access the below service, along with {{ .node.domain }}, http/https port also has to be provided in the URL.
- host: {{ template "domainName" dict "node" .node }}
http:
paths:
- backend:
serviceName: {{ .name }}
paths:
{{ if and .root.Values.constellation (eq .root.Values.constellation.enabled true) }}
- path: /c11n
backend:
serviceName: constellation
servicePort: 3000
{{ end }}
- backend:
serviceName: {{ .name }}
servicePort: {{ .node.service.port }}
---
{{- end }}
12 changes: 9 additions & 3 deletions charts/pega/templates/_pega-k8s-ingress.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,15 @@ spec:
# To access the below service, along with {{ .node.domain }}, traefik http port also has to be provided in the URL.
- host: {{ template "domainName" dict "node" .node }}
http:
paths:
- backend:
serviceName: {{ .name }}
paths:
{{ if and .root.Values.constellation (eq .root.Values.constellation.enabled true) }}
- path: /c11n
backend:
serviceName: constellation
servicePort: 3000
{{ end }}
- backend:
serviceName: {{ .name }}
servicePort: {{ .node.service.port }}
---
{{- end }}
2 changes: 1 addition & 1 deletion charts/pega/values-large.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ global:
# For GKE to use static IP for load balancer, use kubernetes.io/ingress.global-static-ip-name: <global-static-ip-name>
ssl_annotation:


replicas: 1
javaOpts: ""

pegaDiagnosticUser: ""
pegaDiagnosticPassword: ""

Expand Down
1 change: 0 additions & 1 deletion charts/pega/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ global:

replicas: 1
javaOpts: ""

pegaDiagnosticUser: ""
pegaDiagnosticPassword: ""

Expand Down
4 changes: 2 additions & 2 deletions terratest/src/test/Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions terratest/src/test/pega/deploy_with_constellation_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package pega

import (
"path/filepath"
"testing"

"github.com/gruntwork-io/terratest/modules/helm"
"github.com/stretchr/testify/require"
)

// set action execute to install
var constellation_options = &helm.Options{
SetValues: map[string]string{
"global.provider": "k8s",
"global.actions.execute": "deploy",
"constellation.enabled": "true",
},
}

// TestPegaStandardTierDeployment - Test case to verify the standard pega tier deployment.
// Standard tier deployment includes web deployment, batch deployment, stream statefulset, search service, hpa, rolling update, web services, ingresses and config maps
func TestPegaStandardTierDeploymentWithConstellation(t *testing.T) {
t.Parallel()
// Path to the helm chart we will test
helmChartPath, err := filepath.Abs(PegaHelmChartPath)
require.NoError(t, err)

VerifyPegaStandardTierDeployment(t, helmChartPath, constellation_options, []string{"wait-for-pegasearch", "wait-for-cassandra"})
}
51 changes: 51 additions & 0 deletions terratest/src/test/pega/deployment_utility.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ func VerifyPegaStandardTierDeployment(t *testing.T, helmChartPath string, option
// Verify search service
VerifySearchService(t, helmChartPath, options)

if options.SetValues["constellation.enabled"] == "true" {
// Verify constellation service
VerifyConstellationService(t, helmChartPath, options)
}

// Verfiy Pega deployed services
SplitAndVerifyPegaServices(t, helmChartPath, options)

Expand Down Expand Up @@ -126,6 +131,17 @@ func VerifyDeployment(t *testing.T, pod *k8score.PodSpec, expectedSpec pegaDeplo
require.Equal(t, pod.Containers[0].Env[envIndex].Name, "REQUESTOR_PASSIVATION_TIMEOUT")
require.Equal(t, expectedSpec.passivationTimeout, pod.Containers[0].Env[envIndex].Value)
}
if options.SetValues["constellation.enabled"] == "true" && expectedSpec.name == "pega-web" {
envIndex++
require.Equal(t, pod.Containers[0].Env[envIndex].Name, "COSMOS_SETTINGS")
require.Equal(t, "Pega-UIEngine/cosmosservicesURI=/c11n", pod.Containers[0].Env[envIndex].Value)
}

if options.SetValues["constellation.enabled"] == "true" && expectedSpec.name != "pega-web" {
envIndex++
require.Equal(t, pod.Containers[0].Env[envIndex].Name, "COSMOS_SETTINGS")
require.Equal(t, "Pega-UIEngine/cosmosservicesURI=/c11n", pod.Containers[0].Env[envIndex].Value)
}
envIndex++
require.Equal(t, pod.Containers[0].Env[envIndex].Name, "JAVA_OPTS")
require.Equal(t, pod.Containers[0].Env[envIndex].Value, "")
Expand Down Expand Up @@ -279,6 +295,14 @@ func VerifyPegaIngress(t *testing.T, ingressObj *k8sv1beta1.Ingress, expectedIng
VerifyGKEIngress(t, ingressObj, expectedIngress)
} else if provider == "aks" {
VerifyAKSIngress(t, ingressObj, expectedIngress)
} else if provider != "eks" && options.SetValues["constellation.enabled"] == "false" {
VerifyK8SIngress(t, ingressObj, expectedIngress)
} else if provider != "aks" && options.SetValues["constellation.enabled"] == "false" {
VerifyAKSIngress(t, ingressObj, expectedIngress)
} else if provider != "gke" && options.SetValues["constellation.enabled"] == "false" {
VerifyGKEIngress(t, ingressObj, expectedIngress)
} else if options.SetValues["constellation.enabled"] == "true" {
VerifyK8SIngressWithConstellationEnabled(t, ingressObj, expectedIngress)
} else {
VerifyK8SIngress(t, ingressObj, expectedIngress)
}
Expand Down Expand Up @@ -323,6 +347,21 @@ func VerifyK8SIngress(t *testing.T, ingressObj *k8sv1beta1.Ingress, expectedIngr
require.Equal(t, expectedIngress.Port, ingressObj.Spec.Rules[0].HTTP.Paths[0].Backend.ServicePort)
}

// VerifyPegaIngressWithconstellationEnabled - Performs Pega Ingress assertions with the values as provided in default values.yaml when the constellation service is enabled.
func VerifyK8SIngressWithConstellationEnabled(t *testing.T, ingressObj *k8sv1beta1.Ingress, expectedIngress pegaIngress) {
if ingressObj.Spec.Rules[0].HTTP.Paths[0].Backend.ServiceName == "constellation" {
require.Equal(t, "traefik", ingressObj.Annotations["kubernetes.io/ingress.class"])
require.Equal(t, "/c11n", ingressObj.Spec.Rules[0].HTTP.Paths[0].Path)
require.Equal(t, "constellation", ingressObj.Spec.Rules[0].HTTP.Paths[0].Backend.ServiceName)
require.Equal(t, intstr.FromInt(3000), ingressObj.Spec.Rules[0].HTTP.Paths[0].Backend.ServicePort)
require.Equal(t, expectedIngress.Name, ingressObj.Spec.Rules[0].HTTP.Paths[1].Backend.ServiceName)
require.Equal(t, expectedIngress.Port, ingressObj.Spec.Rules[0].HTTP.Paths[1].Backend.ServicePort)
} else {
require.Equal(t, expectedIngress.Name, ingressObj.Spec.Rules[0].HTTP.Paths[0].Backend.ServiceName)
require.Equal(t, expectedIngress.Port, ingressObj.Spec.Rules[0].HTTP.Paths[0].Backend.ServicePort)
}
}

// VerifySearchService - Verifies search service deployment used by search pod with the values as provided in default values.yaml
func VerifySearchService(t *testing.T, helmChartPath string, options *helm.Options) {

Expand All @@ -336,6 +375,18 @@ func VerifySearchService(t *testing.T, helmChartPath string, options *helm.Optio
require.Equal(t, searchServiceObj.Spec.Ports[0].TargetPort, intstr.FromInt(9200))
}

// VerifyconstellationService - Verifies constellation service deployment used by constellation pod with the values as provided in default values.yaml
func VerifyConstellationService(t *testing.T, helmChartPath string, options *helm.Options) {

constellationService := helm.RenderTemplate(t, options, helmChartPath, []string{"charts/constellation/templates/clln-service.yaml"})
var constellationServiceObj k8score.Service
helm.UnmarshalK8SYaml(t, constellationService, &constellationServiceObj)
require.Equal(t, constellationServiceObj.Spec.Selector["app"], "constellation")
// require.Equal(t, constellationServiceObj.Spec.Ports[0].Protocol, "TCP")
require.Equal(t, constellationServiceObj.Spec.Ports[0].Port, int32(3000))
require.Equal(t, constellationServiceObj.Spec.Ports[0].TargetPort, intstr.FromInt(3000))
}

// VerifyEnvironmentConfig - Verifies the environment configuration used by the pods with the values as provided in default values.yaml
func VerifyEnvironmentConfig(t *testing.T, helmChartPath string, options *helm.Options) {

Expand Down

0 comments on commit 7509c8d

Please sign in to comment.