From e48342932bb03973761334da64beef71a5aa9c99 Mon Sep 17 00:00:00 2001 From: misterdorito Date: Wed, 27 Jan 2021 17:39:58 -0500 Subject: [PATCH 01/14] BUG-591266: add environment name and rename tier-based objects. --- charts/pega/templates/_helpers.tpl | 2 ++ charts/pega/templates/pega-gke-backend-config.yaml | 4 +++- charts/pega/templates/pega-tier-config.yaml | 4 +++- charts/pega/templates/pega-tier-deployment.yaml | 5 ++++- charts/pega/templates/pega-tier-hpa.yaml | 4 +++- charts/pega/templates/pega-tier-ingress.yaml | 12 +++++++----- charts/pega/templates/pega-tier-service.yaml | 4 +++- 7 files changed, 25 insertions(+), 10 deletions(-) diff --git a/charts/pega/templates/_helpers.tpl b/charts/pega/templates/_helpers.tpl index c0b9ae81b..de2bbba40 100644 --- a/charts/pega/templates/_helpers.tpl +++ b/charts/pega/templates/_helpers.tpl @@ -243,3 +243,5 @@ true # Used to specify permissions on files within the volume. defaultMode: 420 {{- end}} + +{{- define "environmentName" }}{{ $environmentNamePrefix := "pega-" }}{{ if (.Values.global.environment) }}{{ if (.Values.global.environment.name) }}{{ $environmentNamePrefix = .Values.global.environment.name }}{{ end }}{{ end }}{{ $environmentNamePrefix }}{{- end }} diff --git a/charts/pega/templates/pega-gke-backend-config.yaml b/charts/pega/templates/pega-gke-backend-config.yaml index 080e273c3..5ea8dc472 100644 --- a/charts/pega/templates/pega-gke-backend-config.yaml +++ b/charts/pega/templates/pega-gke-backend-config.yaml @@ -1,8 +1,10 @@ +{{ $envName := printf "%s" (include "environmentName" $) }} + {{ if (eq (include "performDeployment" $) "true") }} {{- if (eq .Values.global.provider "gke") }} {{ range $index, $dep := .Values.global.tier }} {{ if ($dep.ingress) }} -{{ template "pega.gke.backendConfig" dict "root" $ "node" $dep "name" (printf "pega-%s" $dep.name) }} +{{ template "pega.gke.backendConfig" dict "root" $ "node" $dep "name" (printf "%s%s" $envName $dep.name) }} {{ end }} {{ end }} {{ end }} diff --git a/charts/pega/templates/pega-tier-config.yaml b/charts/pega/templates/pega-tier-config.yaml index 4cf0e033b..756e65954 100644 --- a/charts/pega/templates/pega-tier-config.yaml +++ b/charts/pega/templates/pega-tier-config.yaml @@ -1,5 +1,7 @@ +{{ $envName := printf "%s" (include "environmentName" $) }} + {{ if (eq (include "performDeployment" $) "true") }} {{ range $index, $dep := .Values.global.tier}} -{{ template "pega.config" dict "root" $ "node" $dep "name" (printf "pega-%s" $dep.name) "mode" (include "deployConfig" $) "custom" $dep.custom }} +{{ template "pega.config" dict "root" $ "node" $dep "name" (printf "%s%s" $envName $dep.name) "mode" (include "deployConfig" $) "custom" $dep.custom }} {{ end }} {{ end }} \ No newline at end of file diff --git a/charts/pega/templates/pega-tier-deployment.yaml b/charts/pega/templates/pega-tier-deployment.yaml index 6e0d326c9..96b3d3eed 100644 --- a/charts/pega/templates/pega-tier-deployment.yaml +++ b/charts/pega/templates/pega-tier-deployment.yaml @@ -1,3 +1,5 @@ +{{ $envName := printf "%s" (include "environmentName" $) }} + {{ $kindName := "" }} {{ $apiVer := "" }} {{ range $index, $dep := .Values.global.tier}} @@ -9,6 +11,7 @@ {{ $apiVer = "apps/v1" }} {{ end }} + {{ $containerWaitList := list }} {{ if (eq (include "performOnlyDeployment" $) "true") }} {{ if not $.Values.pegasearch.externalSearchService }} @@ -34,6 +37,6 @@ {{ end }} {{- if or (eq (include "performOnlyDeployment" $) "true") (eq (include "performInstallAndDeployment" $) "true") (eq (include "performUpgradeAndDeployment" $) "true") }} -{{ template "pega.deployment" dict "root" $ "node" $dep "name" (printf "pega-%s" $dep.name) "tierName" $dep.name "kind" $kindName "apiVersion" $apiVer "nodeType" $dep.nodeType "initContainers" $containerWaitList "custom" $dep.custom }} +{{ template "pega.deployment" dict "root" $ "node" $dep "name" (printf "%s%s" $envName $dep.name) "tierName" $dep.name "kind" $kindName "apiVersion" $apiVer "nodeType" $dep.nodeType "initContainers" $containerWaitList "custom" $dep.custom }} {{- end }} {{ end }} diff --git a/charts/pega/templates/pega-tier-hpa.yaml b/charts/pega/templates/pega-tier-hpa.yaml index 343755407..48af938f7 100644 --- a/charts/pega/templates/pega-tier-hpa.yaml +++ b/charts/pega/templates/pega-tier-hpa.yaml @@ -1,7 +1,9 @@ +{{ $envName := printf "%s" (include "environmentName" $) }} + {{ if (eq (include "performDeployment" $) "true") }} {{ range $dep := .Values.global.tier }} {{ if ($dep.hpa) }} -{{ template "pega.hpa" dict "root" $ "name" (printf "%s-hpa" (printf "pega-%s" $dep.name)) "deploymentName" (printf "pega-%s" $dep.name) "hpa" $dep.hpa }} +{{ template "pega.hpa" dict "root" $ "name" (printf "%s-hpa" (printf "%s%s" $envName $dep.name)) "deploymentName" (printf "%s%s" $envName $dep.name) "hpa" $dep.hpa }} {{ end }} {{ end }} {{ end }} \ No newline at end of file diff --git a/charts/pega/templates/pega-tier-ingress.yaml b/charts/pega/templates/pega-tier-ingress.yaml index ba6e9853b..06d4567ad 100644 --- a/charts/pega/templates/pega-tier-ingress.yaml +++ b/charts/pega/templates/pega-tier-ingress.yaml @@ -1,15 +1,17 @@ +{{ $envName := printf "%s" (include "environmentName" $) }} + {{- range $index, $dep := .Values.global.tier }} {{ if and (eq (include "performDeployment" $ ) "true") ($dep.service) }} {{- if eq $.Values.global.provider "openshift" -}} -{{ template "pega.openshift.ingress" dict "root" $ "node" $dep "name" (printf "pega-%s" $dep.name) }} +{{ template "pega.openshift.ingress" dict "root" $ "node" $dep "name" (printf "%s%s" $envName $dep.name) }} {{- else if and (eq $.Values.global.provider "eks") -}} -{{ template "pega.eks.ingress" dict "root" $ "node" $dep "name" (printf "pega-%s" $dep.name) }} +{{ template "pega.eks.ingress" dict "root" $ "node" $dep "name" (printf "%s%s" $envName $dep.name) }} {{- else if and (eq $.Values.global.provider "gke") -}} -{{ template "pega.gke.ingress" dict "root" $ "node" $dep "name" (printf "pega-%s" $dep.name) }} +{{ template "pega.gke.ingress" dict "root" $ "node" $dep "name" (printf "%s%s" $envName $dep.name) }} {{- else if and (eq $.Values.global.provider "aks") -}} -{{ template "pega.aks.ingress" dict "root" $ "node" $dep "name" (printf "pega-%s" $dep.name) }} +{{ template "pega.aks.ingress" dict "root" $ "node" $dep "name" (printf "%s%s" $envName $dep.name) }} {{- else -}} -{{ template "pega.k8s.ingress" dict "root" $ "node" $dep "name" (printf "pega-%s" $dep.name) }} +{{ template "pega.k8s.ingress" dict "root" $ "node" $dep "name" (printf "%s%s" $envName $dep.name) }} {{- end -}} {{- end -}} {{- end -}} \ No newline at end of file diff --git a/charts/pega/templates/pega-tier-service.yaml b/charts/pega/templates/pega-tier-service.yaml index 56480349e..9e67a84f5 100644 --- a/charts/pega/templates/pega-tier-service.yaml +++ b/charts/pega/templates/pega-tier-service.yaml @@ -1,7 +1,9 @@ +{{ $envName := printf "%s" (include "environmentName" $) }} + {{ if (eq (include "performDeployment" $) "true") }} {{ range $index, $dep := .Values.global.tier }} {{ if ($dep.service) }} -{{ template "pega.service" dict "root" $ "node" $dep "name" (printf "pega-%s" $dep.name) }} +{{ template "pega.service" dict "root" $ "node" $dep "name" (printf "%s%s" $envName $dep.name) }} {{ end }} {{ end }} {{ end }} \ No newline at end of file From a0cf421f266e6805c57b2a65ba0d64c9610f28c4 Mon Sep 17 00:00:00 2001 From: David Dority <57111997+misterdorito@users.noreply.github.com> Date: Thu, 28 Jan 2021 09:58:55 -0500 Subject: [PATCH 02/14] Update README.md Updated doc with info on how to leverage environment name. --- charts/pega/README.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/charts/pega/README.md b/charts/pega/README.md index c44accc28..b57b788e4 100644 --- a/charts/pega/README.md +++ b/charts/pega/README.md @@ -130,6 +130,30 @@ docker: imagePullPolicy: "Always" ``` +## Environment Name (Optional) + +Set the environment name to help differentiate this deployment from others. The provided name will be used as a prefix to the various Pega tiers (and the k8s objects created on their behalf). The environment name must consist of a DNS friendly name as it will be incorporated into the names of k8s objects. For example: +```yaml +global: + environment: + name: app1-dev- +``` +will result in: +``` +>kubectl get pods -n test +NAME READY STATUS RESTARTS AGE +pega-search-0 1/1 Running 0 24m +app1-dev-batch-86584dcd6b-dsvdd 1/1 Running 0 24m +app1-dev-batch-86584dcd6b-lfwjg 1/1 Running 0 7m31s +app1-dev-stream-0 1/1 Running 0 24m +app1-dev-stream-1 1/1 Running 0 18m +app1-dev-web-788cfb8cc4-6c5nz 1/1 Running 0 8m57s +app1-dev-web-788cfb8cc4-gcltx 1/1 Running 0 24m +``` +(pega-search-0 is not renamed as it not a Pega tier as it doesn't host a Pega node.) + +The default value is "pega-" if it is unset. + ## Tiers of a Pega deployment Pega supports deployment using a multi-tier architecture to separate processing and functions. Isolating processing in its own tier also allows for unique deployment configuration such as its own prconfig, resource allocations, or scaling characteristics. Use the `tier` section in the helm chart to specify which tiers you wish to deploy and their logical tasks. From 977675c279e2df498b0c3a038ba063f488f0e7a1 Mon Sep 17 00:00:00 2001 From: misterdorito Date: Tue, 16 Feb 2021 16:55:16 -0500 Subject: [PATCH 03/14] BUG-591266: Rename embedded search tier as well as other deployed artifacts. --- .../charts/pegasearch/templates/_helpers.tpl | 34 +++++++++++++++--- .../templates/pega-search-deployment.yaml | 2 +- charts/pega/charts/pegasearch/values.yaml | 3 +- charts/pega/templates/_helpers.tpl | 35 ++++++++++++++++--- .../templates/_pega-credentials-secret.tpl | 2 +- charts/pega/templates/_pega-deployment.tpl | 4 +-- .../pega/templates/_pega-registry-secret.tpl | 2 +- .../templates/pega-environment-config.yaml | 6 ++-- .../templates/pega-gke-backend-config.yaml | 4 +-- charts/pega/templates/pega-tier-config.yaml | 4 +-- .../pega/templates/pega-tier-deployment.yaml | 4 +-- charts/pega/templates/pega-tier-hpa.yaml | 4 +-- charts/pega/templates/pega-tier-ingress.yaml | 12 +++---- charts/pega/templates/pega-tier-service.yaml | 4 +-- charts/pega/values-large.yaml | 4 +++ charts/pega/values.yaml | 4 +++ 16 files changed, 93 insertions(+), 35 deletions(-) diff --git a/charts/pega/charts/pegasearch/templates/_helpers.tpl b/charts/pega/charts/pegasearch/templates/_helpers.tpl index c0dd49240..f998e2cb2 100644 --- a/charts/pega/charts/pegasearch/templates/_helpers.tpl +++ b/charts/pega/charts/pegasearch/templates/_helpers.tpl @@ -1,13 +1,37 @@ -{{- define "searchName" -}} -pega-search +{{- define "searchDeploymentName" }}{{ $deploymentNamePrefix := "pega" }}{{ if (.Values.global.deployment) }}{{ if (.Values.global.deployment.name) }}{{ $deploymentNamePrefix = .Values.global.deployment.name }}{{ end }}{{ end }}{{ $deploymentNamePrefix }}{{- end }} + +{{- define "searchName" -}}{{ $depName := printf "%s" (include "searchDeploymentName" $) }}{{- printf "%s" $depName -}}-search{{- end -}} + +{{- define "defaultSearchURL" }}http://{{ template "searchName" $}}{{- end }} + +{{- define "searchURL" -}} +{{ $override := get $ "overrideURL" -}} +{{- $searchURLOverride := $.Values.externalURL -}} +{{- if not (empty $override) -}} +{{- $searchURLOverride = $override -}} {{- end -}} +{{- $defaultSearchURL := printf "%s" (include "defaultSearchURL" $) -}} +{{- $deploymentName := printf "%s" (include "searchDeploymentName" $) -}} +{{- if not (empty $searchURLOverride) -}} +{{- if and (ne $deploymentName "pega") (eq $searchURLOverride "http://pega-search") -}} +{{- $defaultSearchURL -}} +{{- else -}} +{{- $searchURLOverride -}} +{{- end -}} +{{- else -}} +{{- $defaultSearchURL -}} +{{- end -}} +{{- end -}} + {{- /* From the perspective of the Pega Infinity nodes, the search instances are always external when deployed via these charts, but this check determines if search is being deployed externally from the perspective of the charts as a whole, such as when the backing search service is being used.*/ -}} -{{- define "isExternalSearch" }} - {{- if or (and (.Values.externalURL) (ne .Values.externalURL "http://pega-search")) .Values.externalSearchService -}} +{{- define "isExternalSearch" -}} + {{- $defaultSearchURL := printf "%s" (include "defaultSearchURL" $) -}} + {{- $searchURL := printf "%s" (include "searchURL" $) -}} + {{- if or (ne $searchURL $defaultSearchURL) $.Values.externalSearchService -}} true {{- else -}} false {{- end -}} -{{- end }} \ No newline at end of file +{{- end -}} \ No newline at end of file diff --git a/charts/pega/charts/pegasearch/templates/pega-search-deployment.yaml b/charts/pega/charts/pegasearch/templates/pega-search-deployment.yaml index b676d0c14..3732fad74 100644 --- a/charts/pega/charts/pegasearch/templates/pega-search-deployment.yaml +++ b/charts/pega/charts/pegasearch/templates/pega-search-deployment.yaml @@ -105,7 +105,7 @@ spec: - name: esstorage mountPath: /usr/share/elasticsearch/data imagePullSecrets: - - name: {{ template "pegaRegistrySecret" }} + - name: {{ template "pegaRegistrySecret" $}} volumeClaimTemplates: - metadata: name: esstorage diff --git a/charts/pega/charts/pegasearch/values.yaml b/charts/pega/charts/pegasearch/values.yaml index 5cebb3223..2780005eb 100644 --- a/charts/pega/charts/pegasearch/values.yaml +++ b/charts/pega/charts/pegasearch/values.yaml @@ -6,7 +6,8 @@ replicas: 1 # node is set to the minimum number of master-eligible nodes that must be visible in order to form a cluster. # Configure this value using the formula (n/2) + 1 where n is replica count or desired capacity. minimumMasterNodes: 1 -# If externalURL is set, no search nodes will be deployed automatically, and Pega will use this search node url. +# If externalURL is set to a value different from the name of the k8s service defined in pega-search-service.yaml, +# no search nodes will be deployed automatically, and Pega will use this search node url. externalURL: "http://pega-search" # Enter the docker image used to deploy Elasticsearch. This value will be ignored if using an external url. # Push the Elasticsearch image to your internal docker registry. This must be the same registry as the docker section above. diff --git a/charts/pega/templates/_helpers.tpl b/charts/pega/templates/_helpers.tpl index de2bbba40..a2cd32d10 100644 --- a/charts/pega/templates/_helpers.tpl +++ b/charts/pega/templates/_helpers.tpl @@ -1,8 +1,24 @@ -{{- define "pegaEnvironmentConfig" }}pega-environment-config{{- end }} + +{{- define "pegaEnvironmentConfig" }} +{{- $depName := printf "%s" (include "deploymentName" $) -}} +{{- $depName -}}-environment-config +{{- end }} + {{- define "pegaVolumeConfig" }}pega-volume-config{{- end }} + {{- define "pegaVolumeCredentials" }}pega-volume-credentials{{- end }} -{{- define "pegaCredentialsSecret" }}pega-credentials-secret{{- end }} -{{- define "pegaRegistrySecret" }}pega-registry-secret{{- end }} + +{{- define "pegaCredentialsSecret" }} +{{- $depName := printf "%s" (include "deploymentName" $) -}} +{{- $depName -}}-credentials-secret +{{- end }} + +{{- define "pegaRegistrySecret" }} +{{- $depName := printf "%s" (include "deploymentName" $) -}} +{{- $depName -}}-registry-secret +{{- end }} + + {{- define "deployConfig" -}}deploy-config{{- end -}} {{- define "pegaBackendConfig" -}}pega-backend-config{{- end -}} @@ -96,7 +112,7 @@ - name: wait-for-pegasearch image: busybox:1.31.0 # Init container for waiting for Elastic Search to initialize. The URL should point at your Elastic Search instance. - command: ['sh', '-c', 'until $(wget -q -S --spider --timeout=2 -O /dev/null {{ .Values.pegasearch.externalURL }}); do echo Waiting for search to become live...; sleep 10; done;'] + command: ['sh', '-c', 'until $(wget -q -S --spider --timeout=2 -O /dev/null {{ include "pegaSearchURL" $ }}); do echo Waiting for search to become live...; sleep 10; done;'] {{- end }} {{- define "waitForCassandra" -}} @@ -244,4 +260,13 @@ true defaultMode: 420 {{- end}} -{{- define "environmentName" }}{{ $environmentNamePrefix := "pega-" }}{{ if (.Values.global.environment) }}{{ if (.Values.global.environment.name) }}{{ $environmentNamePrefix = .Values.global.environment.name }}{{ end }}{{ end }}{{ $environmentNamePrefix }}{{- end }} +{{- define "deploymentName" }}{{ $deploymentNamePrefix := "pega" }}{{ if (.Values.global.deployment) }}{{ if (.Values.global.deployment.name) }}{{ $deploymentNamePrefix = .Values.global.deployment.name }}{{ end }}{{ end }}{{ $deploymentNamePrefix }}{{- end }} + +#As the pegasearch chart includes an externalURL value that is hardcoded to the name of the search service +#it poses certain challenges if we want to rename the search service from something other than 'pega-search' +#and still want to deploy pegasearch pods. +{{- define "pegaSearchURL" -}} +{{- $d1 := dict "overrideURL" $.Values.pegasearch.externalURL }} +{{- $d2 := merge $ $d1 }} +{{- template "searchURL" $d2 }} +{{- end -}} diff --git a/charts/pega/templates/_pega-credentials-secret.tpl b/charts/pega/templates/_pega-credentials-secret.tpl index 694c9eb79..8f7092473 100644 --- a/charts/pega/templates/_pega-credentials-secret.tpl +++ b/charts/pega/templates/_pega-credentials-secret.tpl @@ -2,7 +2,7 @@ kind: Secret apiVersion: v1 metadata: - name: {{ template "pegaCredentialsSecret" }} + name: {{ template "pegaCredentialsSecret" $ }} namespace: {{ .Release.Namespace }} data: # Base64 encdoded username for connecting to the Pega DB diff --git a/charts/pega/templates/_pega-deployment.tpl b/charts/pega/templates/_pega-deployment.tpl index 831f79f55..a865cedd8 100644 --- a/charts/pega/templates/_pega-deployment.tpl +++ b/charts/pega/templates/_pega-deployment.tpl @@ -140,7 +140,7 @@ spec: value: {{ .tierName }} envFrom: - configMapRef: - name: {{ template "pegaEnvironmentConfig" }} + name: {{ template "pegaEnvironmentConfig" .root }} resources: # Maximum CPU and Memory that the containers for {{ .name }} can use limits: @@ -213,7 +213,7 @@ spec: # Secret which is used to pull the image from the repository. This secret contains docker login details for the particular user. # If the image is in a protected registry, you must specify a secret to access it. imagePullSecrets: - - name: {{ template "pegaRegistrySecret" }} + - name: {{ template "pegaRegistrySecret" .root }} {{- if (.node.volumeClaimTemplate) }} volumeClaimTemplates: - metadata: diff --git a/charts/pega/templates/_pega-registry-secret.tpl b/charts/pega/templates/_pega-registry-secret.tpl index 5c9507225..bf72312a3 100644 --- a/charts/pega/templates/_pega-registry-secret.tpl +++ b/charts/pega/templates/_pega-registry-secret.tpl @@ -2,7 +2,7 @@ kind: Secret apiVersion: v1 metadata: - name: {{ template "pegaRegistrySecret" }} + name: {{ template "pegaRegistrySecret" $ }} namespace: {{ .Release.Namespace }} data: .dockerconfigjson: {{ template "imagePullSecret" . }} diff --git a/charts/pega/templates/pega-environment-config.yaml b/charts/pega/templates/pega-environment-config.yaml index 2295f694d..034850a43 100644 --- a/charts/pega/templates/pega-environment-config.yaml +++ b/charts/pega/templates/pega-environment-config.yaml @@ -3,7 +3,7 @@ kind: ConfigMap apiVersion: v1 metadata: - name: {{ template "pegaEnvironmentConfig" }} + name: {{ template "pegaEnvironmentConfig" $ }} namespace: {{ .Release.Namespace }} data: # Database Type for installation @@ -36,10 +36,10 @@ data: # Search deployment type so that the engine knows to connect to the search service PEGA_SEARCH_TYPE: "ExternalSearchService" # URL to connect to Search and Reporting service - SEARCH_AND_REPORTING_SERVICE_URL: {{ .Values.pegasearch.externalURL }} + SEARCH_AND_REPORTING_SERVICE_URL: {{ include "pegaSearchURL" $ }} {{- else }} # URL to connect to Elastic Search - PEGA_SEARCH_URL: {{ .Values.pegasearch.externalURL }} + PEGA_SEARCH_URL: {{ include "pegaSearchURL" $ }} {{- end }} # Whether to enable connecting to a cassandra cluster. "true" for enabled, "false for disabled" CASSANDRA_CLUSTER: "{{ include "cassandraEnabled" . }}" diff --git a/charts/pega/templates/pega-gke-backend-config.yaml b/charts/pega/templates/pega-gke-backend-config.yaml index 5ea8dc472..800fa46bd 100644 --- a/charts/pega/templates/pega-gke-backend-config.yaml +++ b/charts/pega/templates/pega-gke-backend-config.yaml @@ -1,10 +1,10 @@ -{{ $envName := printf "%s" (include "environmentName" $) }} +{{ $depName := printf "%s" (include "deploymentName" $) }} {{ if (eq (include "performDeployment" $) "true") }} {{- if (eq .Values.global.provider "gke") }} {{ range $index, $dep := .Values.global.tier }} {{ if ($dep.ingress) }} -{{ template "pega.gke.backendConfig" dict "root" $ "node" $dep "name" (printf "%s%s" $envName $dep.name) }} +{{ template "pega.gke.backendConfig" dict "root" $ "node" $dep "name" (printf "%s-%s" $depName $dep.name) }} {{ end }} {{ end }} {{ end }} diff --git a/charts/pega/templates/pega-tier-config.yaml b/charts/pega/templates/pega-tier-config.yaml index 756e65954..5896bd9a6 100644 --- a/charts/pega/templates/pega-tier-config.yaml +++ b/charts/pega/templates/pega-tier-config.yaml @@ -1,7 +1,7 @@ -{{ $envName := printf "%s" (include "environmentName" $) }} +{{ $depName := printf "%s" (include "deploymentName" $) }} {{ if (eq (include "performDeployment" $) "true") }} {{ range $index, $dep := .Values.global.tier}} -{{ template "pega.config" dict "root" $ "node" $dep "name" (printf "%s%s" $envName $dep.name) "mode" (include "deployConfig" $) "custom" $dep.custom }} +{{ template "pega.config" dict "root" $ "node" $dep "name" (printf "%s-%s" $depName $dep.name) "mode" (include "deployConfig" $) "custom" $dep.custom }} {{ end }} {{ end }} \ No newline at end of file diff --git a/charts/pega/templates/pega-tier-deployment.yaml b/charts/pega/templates/pega-tier-deployment.yaml index 96b3d3eed..5598e813e 100644 --- a/charts/pega/templates/pega-tier-deployment.yaml +++ b/charts/pega/templates/pega-tier-deployment.yaml @@ -1,4 +1,4 @@ -{{ $envName := printf "%s" (include "environmentName" $) }} +{{ $depName := printf "%s" (include "deploymentName" $) }} {{ $kindName := "" }} {{ $apiVer := "" }} @@ -37,6 +37,6 @@ {{ end }} {{- if or (eq (include "performOnlyDeployment" $) "true") (eq (include "performInstallAndDeployment" $) "true") (eq (include "performUpgradeAndDeployment" $) "true") }} -{{ template "pega.deployment" dict "root" $ "node" $dep "name" (printf "%s%s" $envName $dep.name) "tierName" $dep.name "kind" $kindName "apiVersion" $apiVer "nodeType" $dep.nodeType "initContainers" $containerWaitList "custom" $dep.custom }} +{{ template "pega.deployment" dict "root" $ "node" $dep "name" (printf "%s-%s" $depName $dep.name) "tierName" $dep.name "kind" $kindName "apiVersion" $apiVer "nodeType" $dep.nodeType "initContainers" $containerWaitList "custom" $dep.custom }} {{- end }} {{ end }} diff --git a/charts/pega/templates/pega-tier-hpa.yaml b/charts/pega/templates/pega-tier-hpa.yaml index 48af938f7..0c9874c4b 100644 --- a/charts/pega/templates/pega-tier-hpa.yaml +++ b/charts/pega/templates/pega-tier-hpa.yaml @@ -1,9 +1,9 @@ -{{ $envName := printf "%s" (include "environmentName" $) }} +{{ $depName := printf "%s" (include "deploymentName" $) }} {{ if (eq (include "performDeployment" $) "true") }} {{ range $dep := .Values.global.tier }} {{ if ($dep.hpa) }} -{{ template "pega.hpa" dict "root" $ "name" (printf "%s-hpa" (printf "%s%s" $envName $dep.name)) "deploymentName" (printf "%s%s" $envName $dep.name) "hpa" $dep.hpa }} +{{ template "pega.hpa" dict "root" $ "name" (printf "%s-hpa" (printf "%s-%s" $depName $dep.name)) "deploymentName" (printf "%s-%s" $depName $dep.name) "hpa" $dep.hpa }} {{ end }} {{ end }} {{ end }} \ No newline at end of file diff --git a/charts/pega/templates/pega-tier-ingress.yaml b/charts/pega/templates/pega-tier-ingress.yaml index 06d4567ad..10c3b33e4 100644 --- a/charts/pega/templates/pega-tier-ingress.yaml +++ b/charts/pega/templates/pega-tier-ingress.yaml @@ -1,17 +1,17 @@ -{{ $envName := printf "%s" (include "environmentName" $) }} +{{ $depName := printf "%s" (include "deploymentName" $) }} {{- range $index, $dep := .Values.global.tier }} {{ if and (eq (include "performDeployment" $ ) "true") ($dep.service) }} {{- if eq $.Values.global.provider "openshift" -}} -{{ template "pega.openshift.ingress" dict "root" $ "node" $dep "name" (printf "%s%s" $envName $dep.name) }} +{{ template "pega.openshift.ingress" dict "root" $ "node" $dep "name" (printf "%s-%s" $depName $dep.name) }} {{- else if and (eq $.Values.global.provider "eks") -}} -{{ template "pega.eks.ingress" dict "root" $ "node" $dep "name" (printf "%s%s" $envName $dep.name) }} +{{ template "pega.eks.ingress" dict "root" $ "node" $dep "name" (printf "%s-%s" $depName $dep.name) }} {{- else if and (eq $.Values.global.provider "gke") -}} -{{ template "pega.gke.ingress" dict "root" $ "node" $dep "name" (printf "%s%s" $envName $dep.name) }} +{{ template "pega.gke.ingress" dict "root" $ "node" $dep "name" (printf "%s-%s" $depName $dep.name) }} {{- else if and (eq $.Values.global.provider "aks") -}} -{{ template "pega.aks.ingress" dict "root" $ "node" $dep "name" (printf "%s%s" $envName $dep.name) }} +{{ template "pega.aks.ingress" dict "root" $ "node" $dep "name" (printf "%s-%s" $depName $dep.name) }} {{- else -}} -{{ template "pega.k8s.ingress" dict "root" $ "node" $dep "name" (printf "%s%s" $envName $dep.name) }} +{{ template "pega.k8s.ingress" dict "root" $ "node" $dep "name" (printf "%s-%s" $depName $dep.name) }} {{- end -}} {{- end -}} {{- end -}} \ No newline at end of file diff --git a/charts/pega/templates/pega-tier-service.yaml b/charts/pega/templates/pega-tier-service.yaml index 9e67a84f5..3011aa833 100644 --- a/charts/pega/templates/pega-tier-service.yaml +++ b/charts/pega/templates/pega-tier-service.yaml @@ -1,9 +1,9 @@ -{{ $envName := printf "%s" (include "environmentName" $) }} +{{ $depName := printf "%s" (include "deploymentName" $) }} {{ if (eq (include "performDeployment" $) "true") }} {{ range $index, $dep := .Values.global.tier }} {{ if ($dep.service) }} -{{ template "pega.service" dict "root" $ "node" $dep "name" (printf "%s%s" $envName $dep.name) }} +{{ template "pega.service" dict "root" $ "node" $dep "name" (printf "%s-%s" $depName $dep.name) }} {{ end }} {{ end }} {{ end }} \ No newline at end of file diff --git a/charts/pega/values-large.yaml b/charts/pega/values-large.yaml index c1fdaa804..8b95221d8 100644 --- a/charts/pega/values-large.yaml +++ b/charts/pega/values-large.yaml @@ -7,6 +7,10 @@ global: # Enter your Kubernetes provider. provider: "YOUR_KUBERNETES_PROVIDER" + deployment: + #The name specified will be used to prefix all of the Pega pods (replacing "pega"). + #name: "myapp-dev" + # Deploy Pega nodes actions: execute: "deploy" diff --git a/charts/pega/values.yaml b/charts/pega/values.yaml index efe773050..d7eb10ed9 100644 --- a/charts/pega/values.yaml +++ b/charts/pega/values.yaml @@ -6,6 +6,10 @@ global: # Enter your Kubernetes provider. provider: "YOUR_KUBERNETES_PROVIDER" + deployment: + #The name specified will be used to prefix all of the Pega pods (replacing "pega"). + #name: "myapp-dev" + # Deploy Pega nodes actions: execute: "deploy" From ce4fa3ae18b0ed7b8c32ecef3e7742e1a0173623 Mon Sep 17 00:00:00 2001 From: misterdorito Date: Tue, 16 Feb 2021 17:52:56 -0500 Subject: [PATCH 04/14] Updated subcharts and address pegaVolumeCredentials contests issue. --- .../pega/charts/constellation/templates/clln-deployment.yaml | 3 ++- charts/pega/charts/hazelcast/templates/pega-hz-deployment.yaml | 2 +- charts/pega/charts/pegasearch/values.yaml | 2 +- charts/pega/templates/_helpers.tpl | 2 +- charts/pega/templates/_pega-deployment.tpl | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/charts/pega/charts/constellation/templates/clln-deployment.yaml b/charts/pega/charts/constellation/templates/clln-deployment.yaml index 064f80621..b80a16f76 100644 --- a/charts/pega/charts/constellation/templates/clln-deployment.yaml +++ b/charts/pega/charts/constellation/templates/clln-deployment.yaml @@ -1,5 +1,6 @@ #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: @@ -17,7 +18,7 @@ spec: app: constellation spec: imagePullSecrets: - - name: {{ template "pegaRegistrySecret" }} + - name: {{ template "pegaRegistrySecret" $ }} containers: - name: constellation imagePullPolicy: {{ .Values.imagePullPolicy }} diff --git a/charts/pega/charts/hazelcast/templates/pega-hz-deployment.yaml b/charts/pega/charts/hazelcast/templates/pega-hz-deployment.yaml index 50f63c621..c36afbf70 100644 --- a/charts/pega/charts/hazelcast/templates/pega-hz-deployment.yaml +++ b/charts/pega/charts/hazelcast/templates/pega-hz-deployment.yaml @@ -61,5 +61,5 @@ spec: # Volume used to mount secret files. {{- include "pegaCredentialVolumeTemplate" . | indent 6 }} imagePullSecrets: - - name: {{ template "pegaRegistrySecret" }} + - name: {{ template "pegaRegistrySecret" $ }} {{ end }} \ No newline at end of file diff --git a/charts/pega/charts/pegasearch/values.yaml b/charts/pega/charts/pegasearch/values.yaml index 2780005eb..266b9dc53 100644 --- a/charts/pega/charts/pegasearch/values.yaml +++ b/charts/pega/charts/pegasearch/values.yaml @@ -7,7 +7,7 @@ replicas: 1 # Configure this value using the formula (n/2) + 1 where n is replica count or desired capacity. minimumMasterNodes: 1 # If externalURL is set to a value different from the name of the k8s service defined in pega-search-service.yaml, -# no search nodes will be deployed automatically, and Pega will use this search node url. +# no search nodes will be deployed automatically, and Pega will use this search node url. externalURL: "http://pega-search" # Enter the docker image used to deploy Elasticsearch. This value will be ignored if using an external url. # Push the Elasticsearch image to your internal docker registry. This must be the same registry as the docker section above. diff --git a/charts/pega/templates/_helpers.tpl b/charts/pega/templates/_helpers.tpl index a2cd32d10..5982aa97a 100644 --- a/charts/pega/templates/_helpers.tpl +++ b/charts/pega/templates/_helpers.tpl @@ -255,7 +255,7 @@ true - name: {{ template "pegaVolumeCredentials" }} secret: # This name will be referred in the volume mounts kind. - secretName: {{ template "pegaCredentialsSecret" }} + secretName: {{ template "pegaCredentialsSecret" $ }} # Used to specify permissions on files within the volume. defaultMode: 420 {{- end}} diff --git a/charts/pega/templates/_pega-deployment.tpl b/charts/pega/templates/_pega-deployment.tpl index a865cedd8..7fa4c56fc 100644 --- a/charts/pega/templates/_pega-deployment.tpl +++ b/charts/pega/templates/_pega-deployment.tpl @@ -57,7 +57,7 @@ spec: name: {{ .name }} # Used to specify permissions on files within the volume. defaultMode: 420 -{{- include "pegaCredentialVolumeTemplate" . | indent 6 }} +{{- include "pegaCredentialVolumeTemplate" .root | indent 6 }} {{- if .custom }} {{- if .custom.volumes }} # Additional custom volumes From a81c11b04ddaa644bb325eb5e729116b4ee0aaf1 Mon Sep 17 00:00:00 2001 From: misterdorito Date: Wed, 17 Feb 2021 08:58:55 -0500 Subject: [PATCH 05/14] BUG-591266: update install/upgrade jobs to accommodate renamed tiers. --- charts/pega/charts/installer/templates/_helpers.tpl | 8 ++++++-- .../charts/installer/templates/_pega-installer-job.tpl | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/charts/pega/charts/installer/templates/_helpers.tpl b/charts/pega/charts/installer/templates/_helpers.tpl index f6f75d6d7..e81771bda 100644 --- a/charts/pega/charts/installer/templates/_helpers.tpl +++ b/charts/pega/charts/installer/templates/_helpers.tpl @@ -10,6 +10,8 @@ {{- define "pegaUpgradeEnvironmentConfig" -}}pega-upgrade-environment-config{{- end -}} {{- define "pegaDistributionKitVolume" -}}pega-distribution-kit-volume{{- end -}} +{{- define "installerDeploymentName" }}{{ $deploymentNamePrefix := "pega" }}{{ if (.Values.global.deployment) }}{{ if (.Values.global.deployment.name) }}{{ $deploymentNamePrefix = .Values.global.deployment.name }}{{ end }}{{ end }}{{ $deploymentNamePrefix }}{{- end }} + {{- define "performInstall" }} {{- if or (eq .Values.global.actions.execute "install") (eq .Values.global.actions.execute "install-deploy") -}} true @@ -54,6 +56,8 @@ {{- end }} {{- define "waitForRollingUpdates" -}} +{{- $deploymentName := printf "%s-" (include "installerDeploymentName" $) -}} +{{- $deploymentNameRegex := printf "%s- " (include "installerDeploymentName" $) -}} {{- $rolloutCommand := "" }} {{- $kindName := "" }} {{- $lastIndex := sub (len .Values.global.tier) 1 }} @@ -64,14 +68,14 @@ {{- else -}} {{- $kindName = "deployment" }} {{- end }} -{{- $constructCommand := cat "kubectl rollout status" $kindName "/" "pega-" $dep.name "--namespace" $namespace }} +{{- $constructCommand := cat "kubectl rollout status" $kindName "/" $deploymentName $dep.name "--namespace" $namespace }} {{- if ne $index $lastIndex }} {{- $rolloutCommand = cat $rolloutCommand $constructCommand "&&" }} {{- else }} {{- $rolloutCommand = cat $rolloutCommand $constructCommand }} {{- end }} {{- $rolloutCommand = regexReplaceAllLiteral " / " $rolloutCommand "/" }} -{{- $rolloutCommand = regexReplaceAllLiteral "pega- " $rolloutCommand "pega-" }} +{{- $rolloutCommand = regexReplaceAllLiteral $deploymentNameRegex $rolloutCommand $deploymentName }} {{- end -}} - name: wait-for-rolling-updates image: dcasavant/k8s-wait-for diff --git a/charts/pega/charts/installer/templates/_pega-installer-job.tpl b/charts/pega/charts/installer/templates/_pega-installer-job.tpl index c7afc8cc0..a949969c9 100644 --- a/charts/pega/charts/installer/templates/_pega-installer-job.tpl +++ b/charts/pega/charts/installer/templates/_pega-installer-job.tpl @@ -30,7 +30,7 @@ spec: persistentVolumeClaim: claimName: {{ .root.Values.distributionKitVolumeClaimName }} {{- end }} -{{- include "pegaCredentialVolumeTemplate" . | indent 6 }} +{{- include "pegaCredentialVolumeTemplate" .root | indent 6 }} - name: {{ template "pegaVolumeInstall" }} configMap: # This name will be referred in the volume mounts kind. @@ -79,6 +79,6 @@ spec: {{- end }} restartPolicy: Never imagePullSecrets: - - name: {{ template "pegaRegistrySecret" }} + - name: {{ template "pegaRegistrySecret" .root }} --- {{- end -}} From 0c6c7377c1c238fda0471baf13021ac0c6e294dc Mon Sep 17 00:00:00 2001 From: David Dority <57111997+misterdorito@users.noreply.github.com> Date: Wed, 17 Feb 2021 09:21:16 -0500 Subject: [PATCH 06/14] Update README.md --- charts/pega/README.md | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/charts/pega/README.md b/charts/pega/README.md index b57b788e4..d02d88578 100644 --- a/charts/pega/README.md +++ b/charts/pega/README.md @@ -130,19 +130,23 @@ docker: imagePullPolicy: "Always" ``` -## Environment Name (Optional) +## Deployment Name (Optional) -Set the environment name to help differentiate this deployment from others. The provided name will be used as a prefix to the various Pega tiers (and the k8s objects created on their behalf). The environment name must consist of a DNS friendly name as it will be incorporated into the names of k8s objects. For example: +Specify a deployment name that is used to differentiate this deployment in your environment. This name will be prepended to the various Pega tiers and the associated k8s objects in your deployment. Your deployment name should be constrained to lowercase alphanumeric and '-' characters. + +This is meant as an alternative to renaming individual deployment tiers (see [Tiers of a Pega deployment](#tiers-of-a-pega-deployment)). + +For example: ```yaml global: - environment: - name: app1-dev- + deployment: + name: app1-dev ``` will result in: ``` >kubectl get pods -n test NAME READY STATUS RESTARTS AGE -pega-search-0 1/1 Running 0 24m +app1-dev-0 1/1 Running 0 24m app1-dev-batch-86584dcd6b-dsvdd 1/1 Running 0 24m app1-dev-batch-86584dcd6b-lfwjg 1/1 Running 0 7m31s app1-dev-stream-0 1/1 Running 0 24m @@ -150,9 +154,7 @@ app1-dev-stream-1 1/1 Running 0 18m app1-dev-web-788cfb8cc4-6c5nz 1/1 Running 0 8m57s app1-dev-web-788cfb8cc4-gcltx 1/1 Running 0 24m ``` -(pega-search-0 is not renamed as it not a Pega tier as it doesn't host a Pega node.) - -The default value is "pega-" if it is unset. +The default value is "pega" if it is unset. ## Tiers of a Pega deployment From cbe0596713d6f1ce29ee58e2502d9e36c5d60222 Mon Sep 17 00:00:00 2001 From: David Dority <57111997+misterdorito@users.noreply.github.com> Date: Wed, 17 Feb 2021 09:23:01 -0500 Subject: [PATCH 07/14] Updated tier rename example for renamed search tier --- charts/pega/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/pega/README.md b/charts/pega/README.md index d02d88578..416e32a18 100644 --- a/charts/pega/README.md +++ b/charts/pega/README.md @@ -146,7 +146,7 @@ will result in: ``` >kubectl get pods -n test NAME READY STATUS RESTARTS AGE -app1-dev-0 1/1 Running 0 24m +app1-dev-search-0 1/1 Running 0 24m app1-dev-batch-86584dcd6b-dsvdd 1/1 Running 0 24m app1-dev-batch-86584dcd6b-lfwjg 1/1 Running 0 7m31s app1-dev-stream-0 1/1 Running 0 24m From 60f3b3fd4a05f65fd06e876900177f9085fce6eb Mon Sep 17 00:00:00 2001 From: misterdorito Date: Wed, 17 Feb 2021 09:38:34 -0500 Subject: [PATCH 08/14] Fix comment spacing. --- charts/pega/values-large.yaml | 4 ++-- charts/pega/values.yaml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/charts/pega/values-large.yaml b/charts/pega/values-large.yaml index 8b95221d8..bb5de2595 100644 --- a/charts/pega/values-large.yaml +++ b/charts/pega/values-large.yaml @@ -8,8 +8,8 @@ global: provider: "YOUR_KUBERNETES_PROVIDER" deployment: - #The name specified will be used to prefix all of the Pega pods (replacing "pega"). - #name: "myapp-dev" + # The name specified will be used to prefix all of the Pega pods (replacing "pega"). + # name: "myapp-dev" # Deploy Pega nodes actions: diff --git a/charts/pega/values.yaml b/charts/pega/values.yaml index d7eb10ed9..58c03619f 100644 --- a/charts/pega/values.yaml +++ b/charts/pega/values.yaml @@ -7,8 +7,8 @@ global: provider: "YOUR_KUBERNETES_PROVIDER" deployment: - #The name specified will be used to prefix all of the Pega pods (replacing "pega"). - #name: "myapp-dev" + # The name specified will be used to prefix all of the Pega pods (replacing "pega"). + # name: "myapp-dev" # Deploy Pega nodes actions: From c5ff4c69339da5c3a53a6ec1b900169950ae30b1 Mon Sep 17 00:00:00 2001 From: David Dority <57111997+misterdorito@users.noreply.github.com> Date: Wed, 17 Feb 2021 10:04:29 -0500 Subject: [PATCH 09/14] Placate yaml linting rules --- charts/pega/values.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/charts/pega/values.yaml b/charts/pega/values.yaml index 58c03619f..dd718c134 100644 --- a/charts/pega/values.yaml +++ b/charts/pega/values.yaml @@ -7,9 +7,9 @@ global: provider: "YOUR_KUBERNETES_PROVIDER" deployment: - # The name specified will be used to prefix all of the Pega pods (replacing "pega"). - # name: "myapp-dev" - + # The name specified will be used to prefix all of the Pega pods (replacing "pega" with something like "app1-dev"). + name: "pega" + # Deploy Pega nodes actions: execute: "deploy" From 249c8702b75b69520cbd1e1cb967a667644920f0 Mon Sep 17 00:00:00 2001 From: David Dority <57111997+misterdorito@users.noreply.github.com> Date: Wed, 17 Feb 2021 10:05:36 -0500 Subject: [PATCH 10/14] Fixing whitespace --- charts/pega/values-large.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/charts/pega/values-large.yaml b/charts/pega/values-large.yaml index bb5de2595..339b6805b 100644 --- a/charts/pega/values-large.yaml +++ b/charts/pega/values-large.yaml @@ -8,9 +8,9 @@ global: provider: "YOUR_KUBERNETES_PROVIDER" deployment: - # The name specified will be used to prefix all of the Pega pods (replacing "pega"). - # name: "myapp-dev" - + # The name specified will be used to prefix all of the Pega pods (replacing "pega" with something like "app1-dev"). + name: "pega" + # Deploy Pega nodes actions: execute: "deploy" From f8790ccf1d0f4ebe9970f82295d4c11ed3c6bdb4 Mon Sep 17 00:00:00 2001 From: misterdorito Date: Wed, 24 Feb 2021 10:15:12 -0500 Subject: [PATCH 11/14] Update tests to account for tier renaming. --- .../test/pega/pega-credentials-secret_test.go | 26 ++++--- .../test/pega/pega-environment-config_test.go | 29 ++++--- .../test/pega/pega-gke-backend-config_test.go | 15 ++-- .../src/test/pega/pega-installer-job_test.go | 76 ++++++++++--------- .../test/pega/pega-registry-secret_test.go | 26 ++++--- .../test/pega/pega-search-deployment_test.go | 25 +++--- .../src/test/pega/pega-search-service_test.go | 25 +++--- .../pega-search-transport-service_test.go | 26 ++++--- .../src/test/pega/pega-tier-config_test.go | 35 ++++++--- .../pega-tier-deployment-with-c11n_test.go | 41 +++++----- .../pega-tier-deployment-with-hzcs_test.go | 29 +++---- .../test/pega/pega-tier-deployment_test.go | 57 +++++++------- terratest/src/test/pega/pega-tier-hpa_test.go | 30 ++++---- .../src/test/pega/pega-tier-ingress_test.go | 27 ++++--- .../src/test/pega/pega-tier-service_test.go | 29 ++++--- terratest/src/test/pega/renderer.go | 7 -- terratest/src/test/pega/utilities.go | 20 ++++- 17 files changed, 308 insertions(+), 215 deletions(-) diff --git a/terratest/src/test/pega/pega-credentials-secret_test.go b/terratest/src/test/pega/pega-credentials-secret_test.go index a04b67fe4..bf5cb250e 100644 --- a/terratest/src/test/pega/pega-credentials-secret_test.go +++ b/terratest/src/test/pega/pega-credentials-secret_test.go @@ -13,6 +13,7 @@ import ( func TestPegaCredentialsSecret(t *testing.T){ var supportedVendors = []string{"k8s","openshift","eks","gke","aks","pks"} var supportedOperations = []string{"install","install-deploy", "upgrade", "upgrade-deploy"} + var deploymentNames = []string{"pega","myapp-dev"} helmChartPath, err := filepath.Abs(PegaHelmChartPath) require.NoError(t, err) @@ -22,27 +23,32 @@ func TestPegaCredentialsSecret(t *testing.T){ for _,operation := range supportedOperations{ - fmt.Println(vendor + "-" + operation) + for _, depName := range deploymentNames { + fmt.Println(vendor + "-" + operation) - var options = &helm.Options{ - SetValues: map[string]string{ - "global.provider": vendor, - "global.actions.execute": operation, - }, - } + var options = &helm.Options{ + SetValues: map[string]string{ + "global.deployment.name": depName, + "global.provider": vendor, + "global.actions.execute": operation, + }, + } - yamlContent := RenderTemplate(t, options, helmChartPath, []string{"templates/pega-credentials-secret.yaml"}) - VerifyCredentialsSecret(t,yamlContent) + yamlContent := RenderTemplate(t, options, helmChartPath, []string{"templates/pega-credentials-secret.yaml"}) + VerifyCredentialsSecret(t, yamlContent, options) + } } } } -func VerifyCredentialsSecret(t *testing.T, yamlContent string) { +func VerifyCredentialsSecret(t *testing.T, yamlContent string, options *helm.Options) { var secretobj k8score.Secret UnmarshalK8SYaml(t, yamlContent, &secretobj) + + require.Equal(t, secretobj.ObjectMeta.Name, getObjName(options, "-credentials-secret")) secretData := secretobj.Data require.Equal(t, string(secretData["DB_USERNAME"]), "YOUR_JDBC_USERNAME") require.Equal(t, string(secretData["DB_PASSWORD"]), "YOUR_JDBC_PASSWORD") diff --git a/terratest/src/test/pega/pega-environment-config_test.go b/terratest/src/test/pega/pega-environment-config_test.go index 60c52e250..904ec1706 100644 --- a/terratest/src/test/pega/pega-environment-config_test.go +++ b/terratest/src/test/pega/pega-environment-config_test.go @@ -14,6 +14,7 @@ import ( func TestPegaEnvironmentConfig(t *testing.T){ var supportedVendors = []string{"k8s","openshift","eks","gke","aks","pks"} var supportedOperations = []string{"deploy","install-deploy","upgrade-deploy"} + var deploymentNames = []string{"pega","myapp-dev"} helmChartPath, err := filepath.Abs(PegaHelmChartPath) require.NoError(t, err) @@ -23,28 +24,32 @@ func TestPegaEnvironmentConfig(t *testing.T){ for _,operation := range supportedOperations{ - fmt.Println(vendor + "-" + operation) + for _, depName := range deploymentNames { - var options = &helm.Options{ - SetValues: map[string]string{ - "global.provider": vendor, - "global.actions.execute": operation, - }, - } + fmt.Println(vendor + "-" + operation + "-" +depName) - yamlContent := RenderTemplate(t, options, helmChartPath, []string{"templates/pega-environment-config.yaml"}) - VerifyEnvironmentConfig(t,yamlContent, options) + var options = &helm.Options{ + SetValues: map[string]string{ + "global.deployment.name": depName, + "global.provider": vendor, + "global.actions.execute": operation, + }, + } + yamlContent := RenderTemplate(t, options, helmChartPath, []string{"templates/pega-environment-config.yaml"}) + VerifyEnvironmentConfig(t,yamlContent, options) + } } } - - } func VerifyEnvironmentConfig(t *testing.T, yamlContent string, options *helm.Options) { var envConfigMap k8score.ConfigMap UnmarshalK8SYaml(t, yamlContent, &envConfigMap) + + require.Equal(t, envConfigMap.ObjectMeta.Name, getObjName(options, "-environment-config")) + envConfigData := envConfigMap.Data require.Equal(t, envConfigData["DB_TYPE"], "YOUR_DATABASE_TYPE") require.Equal(t, envConfigData["JDBC_URL"], "YOUR_JDBC_URL") @@ -58,7 +63,7 @@ func VerifyEnvironmentConfig(t *testing.T, yamlContent string, options *helm.Opt require.Equal(t, envConfigData["DATA_SCHEMA"], "YOUR_DATA_SCHEMA") require.Equal(t, envConfigData["CUSTOMERDATA_SCHEMA"], "") require.Equal(t, envConfigData["JDBC_CONNECTION_PROPERTIES"], "") - require.Equal(t, envConfigData["PEGA_SEARCH_URL"], "http://pega-search") + require.Equal(t, envConfigData["PEGA_SEARCH_URL"], "http://" + getObjName(options, "-search")) require.Equal(t, envConfigData["CASSANDRA_CLUSTER"], "true") require.Equal(t, envConfigData["CASSANDRA_NODES"], "pega-cassandra") require.Equal(t, envConfigData["CASSANDRA_PORT"], "9042") diff --git a/terratest/src/test/pega/pega-gke-backend-config_test.go b/terratest/src/test/pega/pega-gke-backend-config_test.go index 76eb7fde4..b0b4764ce 100644 --- a/terratest/src/test/pega/pega-gke-backend-config_test.go +++ b/terratest/src/test/pega/pega-gke-backend-config_test.go @@ -12,35 +12,40 @@ import ( func TestPegaGKEBackendConfig(t *testing.T) { var supportedOperations = []string{"deploy","install-deploy","upgrade-deploy"} + var deploymentNames = []string{"pega","myapp-dev"} helmChartPath, err := filepath.Abs(PegaHelmChartPath) require.NoError(t, err) for _,operation := range supportedOperations{ - var options = &helm.Options{ + for _, depName := range deploymentNames { + + var options = &helm.Options{ SetValues: map[string]string{ + "global.deployment.name": depName, "global.provider": "gke", "global.actions.execute": operation, }, } yamlContent := RenderTemplate(t, options, helmChartPath, []string{"templates/pega-gke-backend-config.yaml"}) - verifyBackendConfigs(t, yamlContent) + verifyBackendConfigs(t, yamlContent, options) } + } } -func verifyBackendConfigs(t *testing.T, yamlContent string) { +func verifyBackendConfigs(t *testing.T, yamlContent string, options *helm.Options) { var backendConfig v1beta1.BackendConfig backendConfigSlice := strings.Split(yamlContent, "---") for index, backendConfigStr := range backendConfigSlice { if index >= 1 && index <= 2 { UnmarshalK8SYaml(t, backendConfigStr, &backendConfig) if index == 1 { - verifyBackendConfig(t, &backendConfig, "pega-web", 8080) + verifyBackendConfig(t, &backendConfig, getObjName(options, "-web"), 8080) } else { // web and stream health check will happen on 8080 port - verifyBackendConfig(t, &backendConfig, "pega-stream", 8080) + verifyBackendConfig(t, &backendConfig, getObjName(options, "-stream"), 8080) } } } diff --git a/terratest/src/test/pega/pega-installer-job_test.go b/terratest/src/test/pega/pega-installer-job_test.go index 48d395011..2324d1624 100644 --- a/terratest/src/test/pega/pega-installer-job_test.go +++ b/terratest/src/test/pega/pega-installer-job_test.go @@ -24,46 +24,50 @@ func TestPegaInstallerJob(t *testing.T) { var supportedVendors = []string{"k8s", "openshift", "eks", "gke", "aks", "pks"} var supportedOperations = []string{"install", "install-deploy", "upgrade", "upgrade-deploy"} + var deploymentNames = []string{"pega","myapp-dev"} helmChartPath, err := filepath.Abs(PegaHelmChartPath) require.NoError(t, err) for _, vendor := range supportedVendors { for _, operation := range supportedOperations { - var options = &helm.Options{ - SetValues: map[string]string{ - "global.provider": vendor, - "global.actions.execute": operation, - }, - } - - yamlContent := RenderTemplate(t, options, helmChartPath, []string{"charts/installer/templates/pega-installer-job.yaml"}) - yamlSplit := strings.Split(yamlContent, "---") - - // If there are three slices, it means that it is a pega-upgrade-deploy job - if len(yamlSplit) == 4 { - var expectedJob pegaDbJob - for index, jobInfo := range yamlSplit { - if index >= 1 && index <= 3 { - if index == 1 { - expectedJob = pegaDbJob{"pega-pre-upgrade", []string{}, "pega-upgrade-environment-config"} - } else if index == 2 { - expectedJob = pegaDbJob{"pega-db-upgrade", []string{"wait-for-pre-dbupgrade"}, "pega-upgrade-environment-config"} - } else if index == 3 { - expectedJob = pegaDbJob{"pega-post-upgrade", []string{"wait-for-pegaupgrade", "wait-for-rolling-updates"}, "pega-upgrade-environment-config"} - } - - assertJob(t, jobInfo, expectedJob, options) - } - - } - } else { - if operation == "install" || operation == "install-deploy" { - assertJob(t, yamlSplit[1], pegaDbJob{"pega-db-install", []string{}, "pega-install-environment-config"}, options) - } else { - assertJob(t, yamlSplit[1], pegaDbJob{"pega-db-upgrade", []string{}, "pega-upgrade-environment-config"}, options) - } - } + for _, depName := range deploymentNames { + var options = &helm.Options{ + SetValues: map[string]string{ + "global.deployment.name": depName, + "global.provider": vendor, + "global.actions.execute": operation, + }, + } + + yamlContent := RenderTemplate(t, options, helmChartPath, []string{"charts/installer/templates/pega-installer-job.yaml"}) + yamlSplit := strings.Split(yamlContent, "---") + + // If there are three slices, it means that it is a pega-upgrade-deploy job + if len(yamlSplit) == 4 { + var expectedJob pegaDbJob + for index, jobInfo := range yamlSplit { + if index >= 1 && index <= 3 { + if index == 1 { + expectedJob = pegaDbJob{"pega-pre-upgrade", []string{}, "pega-upgrade-environment-config"} + } else if index == 2 { + expectedJob = pegaDbJob{"pega-db-upgrade", []string{"wait-for-pre-dbupgrade"}, "pega-upgrade-environment-config"} + } else if index == 3 { + expectedJob = pegaDbJob{"pega-post-upgrade", []string{"wait-for-pegaupgrade", "wait-for-rolling-updates"}, "pega-upgrade-environment-config"} + } + + assertJob(t, jobInfo, expectedJob, options) + } + + } + } else { + if operation == "install" || operation == "install-deploy" { + assertJob(t, yamlSplit[1], pegaDbJob{"pega-db-install", []string{}, "pega-install-environment-config"}, options) + } else { + assertJob(t, yamlSplit[1], pegaDbJob{"pega-db-upgrade", []string{}, "pega-upgrade-environment-config"}, options) + } + } + } } } } @@ -78,7 +82,7 @@ func assertJob(t *testing.T, jobYaml string, expectedJob pegaDbJob, options *hel var containerPort int32 = 8080 require.Equal(t, jobSpec.Volumes[0].Name, "pega-volume-credentials") - require.Equal(t, jobSpec.Volumes[0].VolumeSource.Secret.SecretName, "pega-credentials-secret") + require.Equal(t, jobSpec.Volumes[0].VolumeSource.Secret.SecretName, getObjName(options, "-credentials-secret")) require.Equal(t, jobSpec.Volumes[0].VolumeSource.Secret.DefaultMode, volDefaultModePointer) require.Equal(t, jobSpec.Volumes[1].Name, "pega-volume-installer") require.Equal(t, jobSpec.Volumes[1].VolumeSource.ConfigMap.LocalObjectReference.Name, "pega-installer-config") @@ -93,7 +97,7 @@ func assertJob(t *testing.T, jobYaml string, expectedJob pegaDbJob, options *hel require.Equal(t, jobContainers[0].VolumeMounts[1].MountPath, "/opt/pega/secrets") require.Equal(t, jobContainers[0].EnvFrom[0].ConfigMapRef.LocalObjectReference.Name, expectedJob.configMapName) - require.Equal(t, jobSpec.ImagePullSecrets[0].Name, "pega-registry-secret") + require.Equal(t, jobSpec.ImagePullSecrets[0].Name, getObjName(options, "-registry-secret")) require.Equal(t, jobSpec.RestartPolicy, k8score.RestartPolicy("Never")) diff --git a/terratest/src/test/pega/pega-registry-secret_test.go b/terratest/src/test/pega/pega-registry-secret_test.go index 0178d551a..ac47e5149 100644 --- a/terratest/src/test/pega/pega-registry-secret_test.go +++ b/terratest/src/test/pega/pega-registry-secret_test.go @@ -14,6 +14,7 @@ import ( func TestPegaRegistrySecret(t *testing.T){ var supportedVendors = []string{"k8s","openshift","eks","gke","aks","pks"} var supportedOperations = []string{"install","install-deploy", "upgrade", "upgrade-deploy"} + var deploymentNames = []string{"pega","myapp-dev"} helmChartPath, err := filepath.Abs(PegaHelmChartPath) require.NoError(t, err) @@ -23,17 +24,21 @@ func TestPegaRegistrySecret(t *testing.T){ for _,operation := range supportedOperations{ - fmt.Println(vendor + "-" + operation) + for _, depName := range deploymentNames { - var options = &helm.Options{ - SetValues: map[string]string{ - "global.provider": vendor, - "global.actions.execute": operation, - }, - } + fmt.Println(vendor + "-" + operation) - yamlContent := RenderTemplate(t, options, helmChartPath, []string{"templates/pega-registry-secret.yaml"}) - VerfiyRegistrySecret(t,yamlContent) + var options = &helm.Options{ + SetValues: map[string]string{ + "global.deployment.name": depName, + "global.provider": vendor, + "global.actions.execute": operation, + }, + } + + yamlContent := RenderTemplate(t, options, helmChartPath, []string{"templates/pega-registry-secret.yaml"}) + VerfiyRegistrySecret(t, yamlContent, options) + } } } @@ -41,9 +46,10 @@ func TestPegaRegistrySecret(t *testing.T){ } // VerfiyRegistrySecret - Verifies the registry secret deployed with the values as provided in default values.yaml -func VerfiyRegistrySecret(t *testing.T, yamlContent string) { +func VerfiyRegistrySecret(t *testing.T, yamlContent string, options *helm.Options) { var registrySecretObj k8score.Secret UnmarshalK8SYaml(t, yamlContent, ®istrySecretObj) + require.Equal(t, registrySecretObj.ObjectMeta.Name, getObjName(options, "-registry-secret")) reqgistrySecretData := registrySecretObj.Data require.Contains(t, string(reqgistrySecretData[".dockerconfigjson"]), "YOUR_DOCKER_REGISTRY") require.Contains(t, string(reqgistrySecretData[".dockerconfigjson"]), "WU9VUl9ET0NLRVJfUkVHSVNUUllfVVNFUk5BTUU6WU9VUl9ET0NLRVJfUkVHSVNUUllfUEFTU1dPUkQ=") diff --git a/terratest/src/test/pega/pega-search-deployment_test.go b/terratest/src/test/pega/pega-search-deployment_test.go index 8778c2dc2..0284404c9 100644 --- a/terratest/src/test/pega/pega-search-deployment_test.go +++ b/terratest/src/test/pega/pega-search-deployment_test.go @@ -14,6 +14,7 @@ import ( func TestPegaSearchDeployment(t *testing.T){ var supportedVendors = []string{"k8s","openshift","eks","gke","aks","pks"} var supportedOperations = []string{"deploy","install-deploy","upgrade-deploy"} + var deploymentNames = []string{"pega","myapp-dev"} helmChartPath, err := filepath.Abs(PegaHelmChartPath) require.NoError(t, err) @@ -23,29 +24,33 @@ func TestPegaSearchDeployment(t *testing.T){ for _,operation := range supportedOperations{ - var options = &helm.Options{ - SetValues: map[string]string{ - "global.provider": vendor, - "global.actions.execute": operation, - }, - } + for _, depName := range deploymentNames { - yamlContent := RenderTemplate(t, options, helmChartPath, []string{"charts/pegasearch/templates/pega-search-deployment.yaml"}) - VerifySearchDeployment(t,yamlContent) + var options = &helm.Options{ + SetValues: map[string]string{ + "global.deployment.name": depName, + "global.provider": vendor, + "global.actions.execute": operation, + }, + } + yamlContent := RenderTemplate(t, options, helmChartPath, []string{"charts/pegasearch/templates/pega-search-deployment.yaml"}) + VerifySearchDeployment(t, yamlContent, options) + } } } } -func VerifySearchDeployment(t *testing.T, yamlContent string) { +func VerifySearchDeployment(t *testing.T, yamlContent string, options *helm.Options) { var statefulsetObj appsv1beta2.StatefulSet UnmarshalK8SYaml(t, yamlContent, &statefulsetObj) + require.Equal(t, statefulsetObj.ObjectMeta.Name, getObjName(options, "-search")) require.Equal(t, *statefulsetObj.Spec.Replicas, int32(1)) require.Equal(t, statefulsetObj.Spec.VolumeClaimTemplates[0].Name, "esstorage") require.Equal(t, statefulsetObj.Spec.VolumeClaimTemplates[0].Spec.AccessModes[0], k8score.PersistentVolumeAccessMode("ReadWriteOnce")) - require.Equal(t, statefulsetObj.Spec.ServiceName, "pega-search") + require.Equal(t, statefulsetObj.Spec.ServiceName, getObjName(options, "-search")) statefulsetSpec := statefulsetObj.Spec.Template.Spec require.Equal(t, statefulsetSpec.Containers[0].VolumeMounts[0].Name, "esstorage") require.Equal(t, statefulsetSpec.Containers[0].VolumeMounts[0].MountPath, "/usr/share/elasticsearch/data") diff --git a/terratest/src/test/pega/pega-search-service_test.go b/terratest/src/test/pega/pega-search-service_test.go index fc77473b6..ad194e7a4 100644 --- a/terratest/src/test/pega/pega-search-service_test.go +++ b/terratest/src/test/pega/pega-search-service_test.go @@ -15,6 +15,7 @@ import ( func TestPegaSearchService(t *testing.T){ var supportedVendors = []string{"k8s","openshift","eks","gke","aks","pks"} var supportedOperations = []string{"deploy","install-deploy","upgrade-deploy"} + var deploymentNames = []string{"pega","myapp-dev"} helmChartPath, err := filepath.Abs(PegaHelmChartPath) require.NoError(t, err) @@ -24,18 +25,21 @@ func TestPegaSearchService(t *testing.T){ for _,operation := range supportedOperations{ - fmt.Println(vendor + "-" + operation) + for _, depName := range deploymentNames { - var options = &helm.Options{ - SetValues: map[string]string{ - "global.provider": vendor, - "global.actions.execute": operation, - }, - } + fmt.Println(vendor + "-" + operation) - yamlContent := RenderTemplate(t, options, helmChartPath, []string{"charts/pegasearch/templates/pega-search-service.yaml"}) - VerifySearchService(t,yamlContent, options) + var options = &helm.Options{ + SetValues: map[string]string{ + "global.deployment.name": depName, + "global.provider": vendor, + "global.actions.execute": operation, + }, + } + yamlContent := RenderTemplate(t, options, helmChartPath, []string{"charts/pegasearch/templates/pega-search-service.yaml"}) + VerifySearchService(t, yamlContent, options) + } } } @@ -45,8 +49,9 @@ func TestPegaSearchService(t *testing.T){ func VerifySearchService(t *testing.T, yamlContent string, options *helm.Options) { var searchServiceObj k8score.Service helm.UnmarshalK8SYaml(t, yamlContent, &searchServiceObj) + require.Equal(t, searchServiceObj.ObjectMeta.Name, getObjName(options, "-search")) require.Equal(t, searchServiceObj.Spec.Selector["component"], "Search") - require.Equal(t, searchServiceObj.Spec.Selector["app"], "pega-search") + require.Equal(t, searchServiceObj.Spec.Selector["app"], getObjName(options, "-search")) require.Equal(t, searchServiceObj.Spec.Ports[0].Name, "http") require.Equal(t, searchServiceObj.Spec.Ports[0].Port, int32(80)) require.Equal(t, searchServiceObj.Spec.Ports[0].TargetPort, intstr.FromInt(9200)) diff --git a/terratest/src/test/pega/pega-search-transport-service_test.go b/terratest/src/test/pega/pega-search-transport-service_test.go index 184207cd0..64adf36ae 100644 --- a/terratest/src/test/pega/pega-search-transport-service_test.go +++ b/terratest/src/test/pega/pega-search-transport-service_test.go @@ -15,6 +15,7 @@ import ( func TestPegaSearchTransportService(t *testing.T){ var supportedOperations = []string{"deploy","install-deploy","upgrade-deploy"} var supportedVendors = []string{"k8s", "openshift", "eks","gke","aks","pks"} + var deploymentNames = []string{"pega","myapp-dev"} helmChartPath, err := filepath.Abs(PegaHelmChartPath) require.NoError(t, err) @@ -24,18 +25,21 @@ func TestPegaSearchTransportService(t *testing.T){ for _,operation := range supportedOperations{ - fmt.Println(vendor + "-" + operation) + for _, depName := range deploymentNames { - var options = &helm.Options{ - SetValues: map[string]string{ - "global.provider": vendor, - "global.actions.execute": operation, - }, - } + fmt.Println(vendor + "-" + operation) - yamlContent := RenderTemplate(t, options, helmChartPath, []string{"charts/pegasearch/templates/pega-search-transport-service.yaml"}) - VerifySearchTransportService(t,yamlContent, options) + var options = &helm.Options{ + SetValues: map[string]string{ + "global.deployment.name": depName, + "global.provider": vendor, + "global.actions.execute": operation, + }, + } + yamlContent := RenderTemplate(t, options, helmChartPath, []string{"charts/pegasearch/templates/pega-search-transport-service.yaml"}) + VerifySearchTransportService(t, yamlContent, options) + } } } @@ -45,9 +49,9 @@ func TestPegaSearchTransportService(t *testing.T){ func VerifySearchTransportService(t *testing.T, yamlContent string, options *helm.Options) { var transportSearchServiceObj k8score.Service UnmarshalK8SYaml(t, yamlContent, &transportSearchServiceObj) - + require.Equal(t, transportSearchServiceObj.ObjectMeta.Name, getObjName(options, "-search-transport")) require.Equal(t, transportSearchServiceObj.Spec.Selector["component"], "Search") - require.Equal(t, transportSearchServiceObj.Spec.Selector["app"], "pega-search") + require.Equal(t, transportSearchServiceObj.Spec.Selector["app"], getObjName(options, "-search")) require.Equal(t, transportSearchServiceObj.Spec.ClusterIP, "None") require.Equal(t, transportSearchServiceObj.Spec.Ports[0].Name, "transport") require.Equal(t, transportSearchServiceObj.Spec.Ports[0].Port, int32(80)) diff --git a/terratest/src/test/pega/pega-tier-config_test.go b/terratest/src/test/pega/pega-tier-config_test.go index d59b1cff5..0097cc0a9 100644 --- a/terratest/src/test/pega/pega-tier-config_test.go +++ b/terratest/src/test/pega/pega-tier-config_test.go @@ -17,6 +17,7 @@ import( func TestPegaTierConfig(t *testing.T){ var supportedVendors = []string{"k8s","openshift","eks","gke","aks","pks"} var supportedOperations = []string{"deploy","install-deploy","upgrade-deploy"} + var deploymentNames = []string{"pega","myapp-dev"} helmChartPath, err := filepath.Abs(PegaHelmChartPath) require.NoError(t, err) @@ -26,18 +27,21 @@ func TestPegaTierConfig(t *testing.T){ for _,operation := range supportedOperations{ - fmt.Println(vendor + "-" + operation) + for _, depName := range deploymentNames { - var options = &helm.Options{ - SetValues: map[string]string{ - "global.provider": vendor, - "global.actions.execute": operation, - }, - } + fmt.Println(vendor + "-" + operation) - yamlContent := RenderTemplate(t, options, helmChartPath, []string{"templates/pega-tier-config.yaml"}) - VerifyTierConfg(t,yamlContent, options) + var options = &helm.Options{ + SetValues: map[string]string{ + "global.deployment.name": depName, + "global.provider": vendor, + "global.actions.execute": operation, + }, + } + yamlContent := RenderTemplate(t, options, helmChartPath, []string{"templates/pega-tier-config.yaml"}) + VerifyTierConfg(t,yamlContent, options) + } } } @@ -50,7 +54,20 @@ func VerifyTierConfg(t *testing.T, yamlContent string, options *helm.Options) { configSlice := strings.Split(yamlContent, "---") for index, configData := range configSlice { if index >= 1 && index <= 3 { + var tierName string + switch index { + case 1: + tierName = "-web" + case 2: + tierName = "-batch" + case 3: + tierName = "-stream" + } + UnmarshalK8SYaml(t, configData, &pegaConfigMap) + + require.Equal(t, pegaConfigMap.ObjectMeta.Name, getObjName(options, tierName)) + pegaConfigMapData := pegaConfigMap.Data compareConfigMapData(t, pegaConfigMapData["prconfig.xml"], "data/expectedInstallDeployPrconfig.xml") compareConfigMapData(t, pegaConfigMapData["context.xml.tmpl"], "data/expectedInstallDeployContext.xml") diff --git a/terratest/src/test/pega/pega-tier-deployment-with-c11n_test.go b/terratest/src/test/pega/pega-tier-deployment-with-c11n_test.go index 467299261..f423796b4 100644 --- a/terratest/src/test/pega/pega-tier-deployment-with-c11n_test.go +++ b/terratest/src/test/pega/pega-tier-deployment-with-c11n_test.go @@ -14,29 +14,32 @@ func TestConstellation(t *testing.T) { var supportedVendors = []string{"k8s"} var supportedOperations = []string{"deploy","install-deploy","upgrade-deploy"} + var deploymentNames = []string{"pega","myapp-dev"} - helmChartPath, err := filepath.Abs(PegaHelmChartPath) - require.NoError(t, err) + helmChartPath, err := filepath.Abs(PegaHelmChartPath) + require.NoError(t, err) for _, vendor := range supportedVendors { for _, operation := range supportedOperations { - var constellationOptions = &helm.Options{ - SetValues: map[string]string{ - "global.provider": vendor, - "global.actions.execute": operation, - "constellation.enabled": "true", - }, - } - deploymentYaml := RenderTemplate(t, constellationOptions, helmChartPath, []string{"templates/pega-tier-deployment.yaml"}) - yamlSplit := strings.Split(deploymentYaml, "---") - assertWeb(t,yamlSplit[1],constellationOptions) - assertBatch(t,yamlSplit[2],constellationOptions) - assertStream(t,yamlSplit[3],constellationOptions) - ingressYaml := RenderTemplate(t, constellationOptions, helmChartPath, []string{"templates/pega-tier-ingress.yaml"}) - assertPegaTierIngress(t, ingressYaml, constellationOptions) - - } - } + for _, depName := range deploymentNames { + var constellationOptions = &helm.Options{ + SetValues: map[string]string{ + "global.deployment.name": depName, + "global.provider": vendor, + "global.actions.execute": operation, + "constellation.enabled": "true", + }, + } + deploymentYaml := RenderTemplate(t, constellationOptions, helmChartPath, []string{"templates/pega-tier-deployment.yaml"}) + yamlSplit := strings.Split(deploymentYaml, "---") + assertWeb(t,yamlSplit[1],constellationOptions) + assertBatch(t,yamlSplit[2],constellationOptions) + assertStream(t,yamlSplit[3],constellationOptions) + ingressYaml := RenderTemplate(t, constellationOptions, helmChartPath, []string{"templates/pega-tier-ingress.yaml"}) + assertPegaTierIngress(t, ingressYaml, constellationOptions) + } + } + } } func assertPegaTierIngress(t *testing.T, ingressYaml string, options *helm.Options ) { diff --git a/terratest/src/test/pega/pega-tier-deployment-with-hzcs_test.go b/terratest/src/test/pega/pega-tier-deployment-with-hzcs_test.go index 48e9390da..1767e7471 100644 --- a/terratest/src/test/pega/pega-tier-deployment-with-hzcs_test.go +++ b/terratest/src/test/pega/pega-tier-deployment-with-hzcs_test.go @@ -12,25 +12,28 @@ func TestHazelcast(t *testing.T) { var supportedVendors = []string{"k8s","openshift","eks","gke","aks","pks"} var supportedOperations = []string{"deploy","install-deploy"} + var deploymentNames = []string{"pega","myapp-dev"} helmChartPath, err := filepath.Abs(PegaHelmChartPath) require.NoError(t, err) for _, vendor := range supportedVendors { for _, operation := range supportedOperations { - var hazelcastOptions = &helm.Options{ - SetValues: map[string]string{ - "global.provider": vendor, - "global.actions.execute": operation, - "hazelcast.enabled": "true", - }, - } - deploymentYaml := RenderTemplate(t, hazelcastOptions, helmChartPath, []string{"templates/pega-tier-deployment.yaml"}) - yamlSplit := strings.Split(deploymentYaml, "---") - assertWeb(t,yamlSplit[1],hazelcastOptions) - assertBatch(t,yamlSplit[2],hazelcastOptions) - assertStream(t,yamlSplit[3],hazelcastOptions) - + for _, depName := range deploymentNames { + var hazelcastOptions = &helm.Options{ + SetValues: map[string]string{ + "global.deployment.name": depName, + "global.provider": vendor, + "global.actions.execute": operation, + "hazelcast.enabled": "true", + }, + } + deploymentYaml := RenderTemplate(t, hazelcastOptions, helmChartPath, []string{"templates/pega-tier-deployment.yaml"}) + yamlSplit := strings.Split(deploymentYaml, "---") + assertWeb(t,yamlSplit[1],hazelcastOptions) + assertBatch(t,yamlSplit[2],hazelcastOptions) + assertStream(t,yamlSplit[3],hazelcastOptions) + } } } } \ No newline at end of file diff --git a/terratest/src/test/pega/pega-tier-deployment_test.go b/terratest/src/test/pega/pega-tier-deployment_test.go index a17602830..7cacc2496 100644 --- a/terratest/src/test/pega/pega-tier-deployment_test.go +++ b/terratest/src/test/pega/pega-tier-deployment_test.go @@ -19,6 +19,7 @@ var initContainers = []string{"wait-for-pegasearch", "wait-for-cassandra"} func TestPegaTierDeployment(t *testing.T){ var supportedVendors = []string{"k8s","openshift","eks","gke","aks","pks"} var supportedOperations = []string{"deploy","install-deploy","upgrade-deploy"} + var deploymentNames = []string{"pega","myapp-dev"} helmChartPath, err := filepath.Abs(PegaHelmChartPath) require.NoError(t, err) @@ -28,21 +29,25 @@ func TestPegaTierDeployment(t *testing.T){ for _,operation := range supportedOperations{ - fmt.Println(vendor + "-" + operation) + for _, depName := range deploymentNames { - var options = &helm.Options{ - SetValues: map[string]string{ - "global.provider": vendor, - "global.actions.execute": operation, - }, - } + fmt.Println(vendor + "-" + operation) - yamlContent := RenderTemplate(t, options, helmChartPath, []string{"templates/pega-tier-deployment.yaml"}) - yamlSplit := strings.Split(yamlContent, "---") - assertWeb(t,yamlSplit[1],options) - assertBatch(t,yamlSplit[2],options) - assertStream(t,yamlSplit[3],options) + var options = &helm.Options{ + SetValues: map[string]string{ + "global.provider": vendor, + "global.actions.execute": operation, + "global.deployment.name": depName, + }, + } + yamlContent := RenderTemplate(t, options, helmChartPath, []string{"templates/pega-tier-deployment.yaml"}) + yamlSplit := strings.Split(yamlContent, "---") + assertWeb(t,yamlSplit[1],options) + assertBatch(t,yamlSplit[2],options) + assertStream(t,yamlSplit[3],options) + + } } } } @@ -50,16 +55,17 @@ func TestPegaTierDeployment(t *testing.T){ func assertStream(t *testing.T, streamYaml string, options *helm.Options){ var statefulsetObj appsv1beta2.StatefulSet UnmarshalK8SYaml(t,streamYaml,&statefulsetObj) - VerifyPegaStatefulSet(t, &statefulsetObj, pegaDeployment{"pega-stream", initContainers, "Stream", "900"},options) + require.Equal(t, statefulsetObj.ObjectMeta.Name, getObjName(options, "-stream")) + VerifyPegaStatefulSet(t, &statefulsetObj, pegaDeployment{getObjName(options, "-stream"), initContainers, "Stream", "900"},options) } - func assertBatch(t *testing.T, batchYaml string, options *helm.Options){ var deploymentObj appsv1.Deployment UnmarshalK8SYaml(t,batchYaml,&deploymentObj) + require.Equal(t, deploymentObj.ObjectMeta.Name, getObjName(options, "-batch")) VerifyPegaDeployment(t, &deploymentObj, - pegaDeployment{"pega-batch", initContainers, "BackgroundProcessing,Search,Batch,RealTime,Custom1,Custom2,Custom3,Custom4,Custom5,BIX", ""}, + pegaDeployment{getObjName(options, "-batch"), initContainers, "BackgroundProcessing,Search,Batch,RealTime,Custom1,Custom2,Custom3,Custom4,Custom5,BIX", ""}, options) } @@ -67,18 +73,17 @@ func assertBatch(t *testing.T, batchYaml string, options *helm.Options){ func assertWeb(t *testing.T, webYaml string, options *helm.Options){ var deploymentObj appsv1.Deployment UnmarshalK8SYaml(t,webYaml,&deploymentObj) - VerifyPegaDeployment(t, &deploymentObj, pegaDeployment{"pega-web", initContainers, "WebUser", "900"}, options) - - + require.Equal(t, deploymentObj.ObjectMeta.Name, getObjName(options, "-web")) + VerifyPegaDeployment(t, &deploymentObj, pegaDeployment{getObjName(options, "-web"), initContainers, "WebUser", "900"}, options) } // VerifyPegaStatefulSet - Performs specific Pega statefulset assertions with the values as provided in default values.yaml func VerifyPegaStatefulSet(t *testing.T, statefulsetObj *appsv1beta2.StatefulSet, expectedStatefulset pegaDeployment, options *helm.Options) { - require.Equal(t, statefulsetObj.Spec.VolumeClaimTemplates[0].Name, "pega-stream") + require.Equal(t, statefulsetObj.Spec.VolumeClaimTemplates[0].Name, getObjName(options, "-stream")) require.Equal(t, statefulsetObj.Spec.VolumeClaimTemplates[0].Spec.AccessModes[0], k8score.PersistentVolumeAccessMode("ReadWriteOnce")) - require.Equal(t, statefulsetObj.Spec.ServiceName, "pega-stream") + require.Equal(t, statefulsetObj.Spec.ServiceName, getObjName(options, "-stream")) statefulsetSpec := statefulsetObj.Spec.Template.Spec - require.Equal(t, statefulsetSpec.Containers[0].VolumeMounts[1].Name, "pega-stream") + require.Equal(t, statefulsetSpec.Containers[0].VolumeMounts[1].Name, getObjName(options, "-stream")) require.Equal(t, statefulsetSpec.Containers[0].VolumeMounts[1].MountPath, "/opt/pega/kafkadata") require.Equal(t, statefulsetSpec.Containers[0].VolumeMounts[2].Name, "pega-volume-credentials") require.Equal(t, statefulsetSpec.Containers[0].VolumeMounts[2].MountPath, "/opt/pega/secrets") @@ -106,7 +111,7 @@ func VerifyDeployment(t *testing.T, pod *k8score.PodSpec, expectedSpec pegaDeplo require.Equal(t, expectedSpec.name, pod.Volumes[0].VolumeSource.ConfigMap.LocalObjectReference.Name) require.Equal(t, pod.Volumes[0].VolumeSource.ConfigMap.DefaultMode, volumeDefaultModePtr) require.Equal(t, pod.Volumes[1].Name, "pega-volume-credentials") - require.Equal(t, pod.Volumes[1].VolumeSource.Secret.SecretName, "pega-credentials-secret") + require.Equal(t, pod.Volumes[1].VolumeSource.Secret.SecretName, getObjName(options, "-credentials-secret")) require.Equal(t, pod.Volumes[1].VolumeSource.Secret.DefaultMode, volumeDefaultModePtr) actualInitContainers := pod.InitContainers @@ -128,7 +133,7 @@ func VerifyDeployment(t *testing.T, pod *k8score.PodSpec, expectedSpec pegaDeplo envIndex++ require.Equal(t, pod.Containers[0].Env[envIndex].Name, "PEGA_APP_CONTEXT_PATH") require.Equal(t, pod.Containers[0].Env[envIndex].Value, "prweb") - if expectedSpec.name == "pega-web" || expectedSpec.name == "pega-stream" { + if expectedSpec.name == getObjName(options, "-web") || expectedSpec.name == getObjName(options, "-stream") { envIndex++ require.Equal(t, pod.Containers[0].Env[envIndex].Name, "REQUESTOR_PASSIVATION_TIMEOUT") require.Equal(t, expectedSpec.passivationTimeout, pod.Containers[0].Env[envIndex].Value) @@ -150,7 +155,7 @@ func VerifyDeployment(t *testing.T, pod *k8score.PodSpec, expectedSpec pegaDeplo envIndex++ require.Equal(t, pod.Containers[0].Env[envIndex].Name, "MAX_HEAP") require.Equal(t, pod.Containers[0].Env[envIndex].Value, "7168m") - require.Equal(t, pod.Containers[0].EnvFrom[0].ConfigMapRef.LocalObjectReference.Name, "pega-environment-config") + require.Equal(t, pod.Containers[0].EnvFrom[0].ConfigMapRef.LocalObjectReference.Name, getObjName(options, "-environment-config")) require.Equal(t, "4", pod.Containers[0].Resources.Limits.Cpu().String()) require.Equal(t, "8Gi", pod.Containers[0].Resources.Limits.Memory().String()) require.Equal(t, "2", pod.Containers[0].Resources.Requests.Cpu().String()) @@ -177,14 +182,14 @@ func VerifyDeployment(t *testing.T, pod *k8score.PodSpec, expectedSpec pegaDeplo require.Equal(t, pod.Containers[0].ReadinessProbe.HTTPGet.Port, intstr.FromInt(8080)) require.Equal(t, pod.Containers[0].ReadinessProbe.HTTPGet.Scheme, k8score.URIScheme("HTTP")) - require.Equal(t, pod.ImagePullSecrets[0].Name, "pega-registry-secret") + require.Equal(t, pod.ImagePullSecrets[0].Name, getObjName(options, "-registry-secret")) require.Equal(t, pod.RestartPolicy, k8score.RestartPolicy("Always")) require.Equal(t, *pod.TerminationGracePeriodSeconds, int64(300)) require.Equal(t, pod.Containers[0].VolumeMounts[0].Name, "pega-volume-config") require.Equal(t, pod.Containers[0].VolumeMounts[0].MountPath, "/opt/pega/config") require.Equal(t, pod.Volumes[0].Name, "pega-volume-config") require.Equal(t, pod.Volumes[1].Name, "pega-volume-credentials") - require.Equal(t, pod.Volumes[1].Secret.SecretName, "pega-credentials-secret") + require.Equal(t, pod.Volumes[1].Secret.SecretName, getObjName(options, "-credentials-secret")) } diff --git a/terratest/src/test/pega/pega-tier-hpa_test.go b/terratest/src/test/pega/pega-tier-hpa_test.go index bde9ed4d2..5fdea3e3a 100644 --- a/terratest/src/test/pega/pega-tier-hpa_test.go +++ b/terratest/src/test/pega/pega-tier-hpa_test.go @@ -16,6 +16,7 @@ import ( func TestPegaTierHPA(t *testing.T){ var supportedVendors = []string{"k8s", "openshift", "eks","gke","aks","pks"} var supportedOperations = []string{"deploy","install-deploy","upgrade-deploy"} + var deploymentNames = []string{"pega","myapp-dev"} helmChartPath, err := filepath.Abs(PegaHelmChartPath) require.NoError(t, err) @@ -25,23 +26,25 @@ func TestPegaTierHPA(t *testing.T){ for _,operation := range supportedOperations{ - fmt.Println(vendor + "-" + operation) + for _, depName := range deploymentNames { - var options = &helm.Options{ - SetValues: map[string]string{ - "global.provider": vendor, - "global.actions.execute": operation, - }, - } + fmt.Println(vendor + "-" + operation) - yamlContent := RenderTemplate(t, options, helmChartPath, []string{"templates/pega-tier-hpa.yaml"}) - VerifyPegaHPAs(t,yamlContent, options) + var options = &helm.Options{ + SetValues: map[string]string{ + "global.deployment.name": depName, + "global.provider": vendor, + "global.actions.execute": operation, + }, + } + yamlContent := RenderTemplate(t, options, helmChartPath, []string{"templates/pega-tier-hpa.yaml"}) + VerifyPegaHPAs(t, yamlContent, options) + } } } - - } + // VerifyPegaHPAs - Splits the HPA object from the rendered template and asserts each HPA object func VerifyPegaHPAs(t *testing.T, yamlContent string, options *helm.Options) { var pegaHpaObj autoscaling.HorizontalPodAutoscaler @@ -50,9 +53,9 @@ func VerifyPegaHPAs(t *testing.T, yamlContent string, options *helm.Options) { if index >= 0 && index <= 1 { UnmarshalK8SYaml(t, hpaInfo, &pegaHpaObj) if index == 0 { - VerifyPegaHpa(t, &pegaHpaObj, hpa{"pega-web-hpa", "pega-web", "Deployment", "apps/v1"}) + VerifyPegaHpa(t, &pegaHpaObj, hpa{getObjName(options, "-web-hpa"), getObjName(options, "-web"), "Deployment", "apps/v1"}) } else { - VerifyPegaHpa(t, &pegaHpaObj, hpa{"pega-batch-hpa", "pega-batch", "Deployment", "apps/v1"}) + VerifyPegaHpa(t, &pegaHpaObj, hpa{getObjName(options, "-batch-hpa"), getObjName(options, "-batch"), "Deployment", "apps/v1"}) } } } @@ -60,6 +63,7 @@ func VerifyPegaHPAs(t *testing.T, yamlContent string, options *helm.Options) { // VerifyPegaHpa - Performs Pega HPA assertions with the values as provided in default values.yaml func VerifyPegaHpa(t *testing.T, hpaObj *autoscaling.HorizontalPodAutoscaler, expectedHpa hpa) { + //hpaObj.ObjectMeta.Name doesn't appear to get set require.Equal(t, hpaObj.Spec.ScaleTargetRef.Name, expectedHpa.targetRefName) require.Equal(t, hpaObj.Spec.ScaleTargetRef.Kind, expectedHpa.kind) require.Equal(t, hpaObj.Spec.ScaleTargetRef.APIVersion, expectedHpa.apiversion) diff --git a/terratest/src/test/pega/pega-tier-ingress_test.go b/terratest/src/test/pega/pega-tier-ingress_test.go index 82e335839..cdada9d31 100644 --- a/terratest/src/test/pega/pega-tier-ingress_test.go +++ b/terratest/src/test/pega/pega-tier-ingress_test.go @@ -16,6 +16,7 @@ import ( func TestPegaTierIngress(t *testing.T){ var supportedOperations = []string{"deploy","install-deploy","upgrade-deploy"} var supportedVendors = []string{"k8s","eks","gke","aks","pks"} + var deploymentNames = []string{"pega","myapp-dev"} helmChartPath, err := filepath.Abs(PegaHelmChartPath) require.NoError(t, err) @@ -25,18 +26,21 @@ func TestPegaTierIngress(t *testing.T){ for _,operation := range supportedOperations{ - fmt.Println(vendor + "-" + operation) + for _, depName := range deploymentNames { - var options = &helm.Options{ - SetValues: map[string]string{ - "global.provider": vendor, - "global.actions.execute": operation, - }, - } + fmt.Println(vendor + "-" + operation) - yamlContent := RenderTemplate(t, options, helmChartPath, []string{"templates/pega-tier-ingress.yaml"}) - VerifyPegaIngresses(t,yamlContent, options) + var options = &helm.Options{ + SetValues: map[string]string{ + "global.deployment.name": depName, + "global.provider": vendor, + "global.actions.execute": operation, + }, + } + yamlContent := RenderTemplate(t, options, helmChartPath, []string{"templates/pega-tier-ingress.yaml"}) + VerifyPegaIngresses(t, yamlContent, options) + } } } @@ -52,11 +56,11 @@ func VerifyPegaIngresses(t *testing.T, yamlContent string, options *helm.Options UnmarshalK8SYaml(t, ingressInfo, &pegaIngressObj) if index == 1 { VerifyPegaIngress(t, &pegaIngressObj, - pegaIngress{"pega-web", intstr.IntOrString{IntVal: 80}, 1020}, + pegaIngress{getObjName(options, "-web"), intstr.IntOrString{IntVal: 80}, 1020}, options) } else { VerifyPegaIngress(t, &pegaIngressObj, - pegaIngress{"pega-stream", intstr.IntOrString{IntVal: 7003}, 1020}, + pegaIngress{getObjName(options, "-stream"), intstr.IntOrString{IntVal: 7003}, 1020}, options) } @@ -65,6 +69,7 @@ func VerifyPegaIngresses(t *testing.T, yamlContent string, options *helm.Options } func VerifyPegaIngress(t *testing.T, ingressObj *k8sv1beta1.Ingress, expectedIngress pegaIngress, options *helm.Options) { + require.Equal(t, ingressObj.ObjectMeta.Name, expectedIngress.Name) provider := options.SetValues["global.provider"] if provider == "eks" { VerifyEKSIngress(t, ingressObj, expectedIngress) diff --git a/terratest/src/test/pega/pega-tier-service_test.go b/terratest/src/test/pega/pega-tier-service_test.go index cb5972fc8..ada4dab78 100644 --- a/terratest/src/test/pega/pega-tier-service_test.go +++ b/terratest/src/test/pega/pega-tier-service_test.go @@ -16,6 +16,7 @@ import ( func TestPegaTierService(t *testing.T){ var supportedVendors = []string{"k8s","openshift","eks","gke","aks","pks"} var supportedOperations = []string{"deploy","install-deploy","upgrade-deploy"} + var deploymentNames = []string{"pega","myapp-dev"} helmChartPath, err := filepath.Abs(PegaHelmChartPath) require.NoError(t, err) @@ -25,18 +26,21 @@ func TestPegaTierService(t *testing.T){ for _,operation := range supportedOperations{ - fmt.Println(vendor + "-" + operation) + for _, depName := range deploymentNames { - var options = &helm.Options{ - SetValues: map[string]string{ - "global.provider": vendor, - "global.actions.execute": operation, - }, - } + fmt.Println(vendor + "-" + operation) - yamlContent := RenderTemplate(t, options, helmChartPath, []string{"templates/pega-tier-service.yaml"}) - VerifyPegaServices(t,yamlContent, options) + var options = &helm.Options{ + SetValues: map[string]string{ + "global.deployment.name": depName, + "global.provider": vendor, + "global.actions.execute": operation, + }, + } + yamlContent := RenderTemplate(t, options, helmChartPath, []string{"templates/pega-tier-service.yaml"}) + VerifyPegaServices(t, yamlContent, options) + } } } @@ -49,10 +53,13 @@ func VerifyPegaServices(t *testing.T, yamlContent string, options *helm.Options) for index, serviceInfo := range serviceSlice { if index >= 1 && index <= 2 { UnmarshalK8SYaml(t, serviceInfo, &pegaServiceObj) + if index == 1 { - VerifyPegaService(t, &pegaServiceObj, pegaServices{"pega-web", int32(80), intstr.IntOrString{IntVal: 8080}}, options) + require.Equal(t, getObjName(options, "-web"), pegaServiceObj.ObjectMeta.Name) + VerifyPegaService(t, &pegaServiceObj, pegaServices{getObjName(options, "-web"), int32(80), intstr.IntOrString{IntVal: 8080}}, options) } else { - VerifyPegaService(t, &pegaServiceObj, pegaServices{"pega-stream", int32(7003), intstr.IntOrString{IntVal: 7003}}, options) + require.Equal(t, getObjName(options, "-stream"), pegaServiceObj.ObjectMeta.Name) + VerifyPegaService(t, &pegaServiceObj, pegaServices{getObjName(options, "-stream"), int32(7003), intstr.IntOrString{IntVal: 7003}}, options) } } } diff --git a/terratest/src/test/pega/renderer.go b/terratest/src/test/pega/renderer.go index e87231af7..99fc2a073 100644 --- a/terratest/src/test/pega/renderer.go +++ b/terratest/src/test/pega/renderer.go @@ -4,24 +4,17 @@ import ( "github.com/gruntwork-io/terratest/modules/helm" "testing" - ) func RenderTemplate(t *testing.T, options *helm.Options, helmChartPath string, templates []string, extraHelmArgs ...string) string{ - return helm.RenderTemplate(t, options, helmChartPath, PegaHelmRelease, templates, extraHelmArgs...) - } func RenderTemplateE(t *testing.T, options *helm.Options, helmChartPath string, templates []string) (string, error) { - return helm.RenderTemplateE(t, options, helmChartPath, PegaHelmRelease, templates) - } func UnmarshalK8SYaml(t *testing.T, yamlData string, destinationObj interface{}){ - helm.UnmarshalK8SYaml(t,yamlData,destinationObj) - } \ No newline at end of file diff --git a/terratest/src/test/pega/utilities.go b/terratest/src/test/pega/utilities.go index fe76a9f41..2449b8f56 100644 --- a/terratest/src/test/pega/utilities.go +++ b/terratest/src/test/pega/utilities.go @@ -43,6 +43,7 @@ func aksSpecificUpgraderDeployEnvs(t *testing.T, options *helm.Options, containe // VerifyInitContinerData - Verifies any possible initContainer that can occur in pega helm chart deployments func VerifyInitContinerData(t *testing.T, containers []k8score.Container, options *helm.Options) { + var depName = getDeploymentName(options) if len(containers) == 0 { println("no init containers") @@ -56,12 +57,14 @@ func VerifyInitContinerData(t *testing.T, containers []k8score.Container, option require.Equal(t, []string{"job", "pega-db-install"}, container.Args) } else if name == "wait-for-pegasearch" { require.Equal(t, "busybox:1.31.0", container.Image) - require.Equal(t, []string{"sh", "-c", "until $(wget -q -S --spider --timeout=2 -O /dev/null http://pega-search); do echo Waiting for search to become live...; sleep 10; done;"}, container.Command) + require.Equal(t, []string{"sh", "-c", "until $(wget -q -S --spider --timeout=2 -O /dev/null http://" + depName + "-search); do echo Waiting for search to become live...; sleep 10; done;"}, container.Command) } else if name == "wait-for-cassandra" { require.Equal(t, "cassandra:3.11.3", container.Image) + //todo: update with depName? require.Equal(t, []string{"sh", "-c", "until cqlsh -u \"dnode_ext\" -p \"dnode_ext\" -e \"describe cluster\" pega-cassandra 9042 ; do echo Waiting for cassandra to become live...; sleep 10; done;"}, container.Command) } else if name == "wait-for-cassandra" { require.Equal(t, "cassandra:3.11.3", container.Image) + //todo: update with depName? require.Equal(t, []string{"sh", "-c", "until cqlsh -u \"dnode_ext\" -p \"dnode_ext\" -e \"describe cluster\" pega-cassandra 9042 ; do echo Waiting for cassandra to become live...; sleep 10; done;"}, container.Command) } else if name == "wait-for-pegaupgrade" { require.Equal(t, "dcasavant/k8s-wait-for", container.Image) @@ -72,10 +75,23 @@ func VerifyInitContinerData(t *testing.T, containers []k8score.Container, option require.Equal(t, []string{"job", "pega-pre-upgrade"}, container.Args) } else if name == "wait-for-rolling-updates" { require.Equal(t, "dcasavant/k8s-wait-for", container.Image) - require.Equal(t, []string{"sh", "-c", " kubectl rollout status deployment/pega-web --namespace default && kubectl rollout status deployment/pega-batch --namespace default && kubectl rollout status statefulset/pega-stream --namespace default"}, container.Command) + require.Equal(t, []string{"sh", "-c", " kubectl rollout status deployment/" + depName + "-web --namespace default && kubectl rollout status deployment/" + depName + "-batch --namespace default && kubectl rollout status statefulset/" + depName + "-stream --namespace default"}, container.Command) } else { fmt.Println("invalid init containers found.. please check the list", name) t.Fail() } } } + + +func getDeploymentName(options *helm.Options) string { + var depName string = options.SetValues["global.deployment.name"] + if (depName == "") { + depName = "pega" + } + return depName +} + +func getObjName(options *helm.Options, suffix string) string { + return getDeploymentName(options) + suffix +} From 67102598aa65579ebf68c623df68db5386e6f1ac Mon Sep 17 00:00:00 2001 From: misterdorito Date: Wed, 21 Apr 2021 14:56:34 -0400 Subject: [PATCH 12/14] Remove todo/add comment --- terratest/src/test/pega/utilities.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/terratest/src/test/pega/utilities.go b/terratest/src/test/pega/utilities.go index 2449b8f56..0609df0bd 100644 --- a/terratest/src/test/pega/utilities.go +++ b/terratest/src/test/pega/utilities.go @@ -60,11 +60,11 @@ func VerifyInitContinerData(t *testing.T, containers []k8score.Container, option require.Equal(t, []string{"sh", "-c", "until $(wget -q -S --spider --timeout=2 -O /dev/null http://" + depName + "-search); do echo Waiting for search to become live...; sleep 10; done;"}, container.Command) } else if name == "wait-for-cassandra" { require.Equal(t, "cassandra:3.11.3", container.Image) - //todo: update with depName? + //The cassandra svc name below is derived from helm release name and not .Values.global.deploymentName like search svc require.Equal(t, []string{"sh", "-c", "until cqlsh -u \"dnode_ext\" -p \"dnode_ext\" -e \"describe cluster\" pega-cassandra 9042 ; do echo Waiting for cassandra to become live...; sleep 10; done;"}, container.Command) } else if name == "wait-for-cassandra" { require.Equal(t, "cassandra:3.11.3", container.Image) - //todo: update with depName? + //The cassandra svc name below is derived from helm release name and not .Values.global.deploymentName like search svc require.Equal(t, []string{"sh", "-c", "until cqlsh -u \"dnode_ext\" -p \"dnode_ext\" -e \"describe cluster\" pega-cassandra 9042 ; do echo Waiting for cassandra to become live...; sleep 10; done;"}, container.Command) } else if name == "wait-for-pegaupgrade" { require.Equal(t, "dcasavant/k8s-wait-for", container.Image) From 8173ecfd0f30ce441de6c88bc3d9b48ed8de417a Mon Sep 17 00:00:00 2001 From: misterdorito Date: Thu, 22 Apr 2021 13:44:08 -0400 Subject: [PATCH 13/14] Incorporated doc feedback. --- charts/pega/README.md | 2 +- charts/pega/charts/pegasearch/templates/_helpers.tpl | 8 ++++---- charts/pega/charts/pegasearch/values.yaml | 4 ++-- charts/pega/templates/_helpers.tpl | 4 +--- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/charts/pega/README.md b/charts/pega/README.md index 5fb8592b7..7bab956ff 100644 --- a/charts/pega/README.md +++ b/charts/pega/README.md @@ -161,7 +161,7 @@ The default value is "pega" if it is unset. ## Tiers of a Pega deployment -Pega supports deployment using a multi-tier architecture to separate processing and functions. Isolating processing in its own tier also allows for unique deployment configuration such as its own prconfig, resource allocations, or scaling characteristics. Use the `tier` section in the helm chart to specify which tiers you wish to deploy and their logical tasks. +Pega supports deployments that a multi-tier architecture model that separates application processing from k8s functions. Isolating processing in its own tier supports unique deployment configurations, including the Pega application prconfig, resource allocations, and scaling characteristics. Use the tier section in the helm chart to specify which tiers you wish to deploy the tier with nodes dedicated to the logical tasks of the tier. ### Tier examples diff --git a/charts/pega/charts/pegasearch/templates/_helpers.tpl b/charts/pega/charts/pegasearch/templates/_helpers.tpl index f998e2cb2..7b9e9f0d5 100644 --- a/charts/pega/charts/pegasearch/templates/_helpers.tpl +++ b/charts/pega/charts/pegasearch/templates/_helpers.tpl @@ -23,9 +23,9 @@ {{- end -}} {{- end -}} -{{- /* From the perspective of the Pega Infinity nodes, the search instances are always external when deployed via these charts, - but this check determines if search is being deployed externally from the perspective of the charts as a whole, such as - when the backing search service is being used.*/ -}} +{{- /* From the perspective of the Pega Infinity nodes, Pega deployments always assume that the search instances are external to the deployment when you use these charts; + however this check determines if search is deployed externally as defined in the backing search service configuration or if it is defined in the Pega-provided + Docker search image.*/ -}} {{- define "isExternalSearch" -}} {{- $defaultSearchURL := printf "%s" (include "defaultSearchURL" $) -}} {{- $searchURL := printf "%s" (include "searchURL" $) -}} @@ -34,4 +34,4 @@ {{- else -}} false {{- end -}} -{{- end -}} \ No newline at end of file +{{- end -}} diff --git a/charts/pega/charts/pegasearch/values.yaml b/charts/pega/charts/pegasearch/values.yaml index 266b9dc53..9fdbef4b8 100644 --- a/charts/pega/charts/pegasearch/values.yaml +++ b/charts/pega/charts/pegasearch/values.yaml @@ -7,10 +7,10 @@ replicas: 1 # Configure this value using the formula (n/2) + 1 where n is replica count or desired capacity. minimumMasterNodes: 1 # If externalURL is set to a value different from the name of the k8s service defined in pega-search-service.yaml, -# no search nodes will be deployed automatically, and Pega will use this search node url. +# no search nodes are deployed automatically, and Pega uses this search node url. externalURL: "http://pega-search" # Enter the docker image used to deploy Elasticsearch. This value will be ignored if using an external url. -# Push the Elasticsearch image to your internal docker registry. This must be the same registry as the docker section above. +# Push the Elasticsearch image to the same internal Docker registry that you specified in the Docker section above. image: "pegasystems/search" imagePullPolicy: "" # Enter the CPU limit for each search node (recommended 1). diff --git a/charts/pega/templates/_helpers.tpl b/charts/pega/templates/_helpers.tpl index 7967d2914..74008c8b7 100644 --- a/charts/pega/templates/_helpers.tpl +++ b/charts/pega/templates/_helpers.tpl @@ -262,9 +262,7 @@ true {{- define "deploymentName" }}{{ $deploymentNamePrefix := "pega" }}{{ if (.Values.global.deployment) }}{{ if (.Values.global.deployment.name) }}{{ $deploymentNamePrefix = .Values.global.deployment.name }}{{ end }}{{ end }}{{ $deploymentNamePrefix }}{{- end }} -#As the pegasearch chart includes an externalURL value that is hardcoded to the name of the search service -#it poses certain challenges if we want to rename the search service from something other than 'pega-search' -#and still want to deploy pegasearch pods. + {{- define "pegaSearchURL" -}} {{- $d1 := dict "overrideURL" $.Values.pegasearch.externalURL }} {{- $d2 := merge $ $d1 }} From 3d8aab21868658a207649fcca9eaebd747095a99 Mon Sep 17 00:00:00 2001 From: misterdorito Date: Thu, 22 Apr 2021 15:22:11 -0400 Subject: [PATCH 14/14] Final readme tweak. --- charts/pega/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/pega/README.md b/charts/pega/README.md index 7bab956ff..5e2a6b8b8 100644 --- a/charts/pega/README.md +++ b/charts/pega/README.md @@ -161,7 +161,7 @@ The default value is "pega" if it is unset. ## Tiers of a Pega deployment -Pega supports deployments that a multi-tier architecture model that separates application processing from k8s functions. Isolating processing in its own tier supports unique deployment configurations, including the Pega application prconfig, resource allocations, and scaling characteristics. Use the tier section in the helm chart to specify which tiers you wish to deploy the tier with nodes dedicated to the logical tasks of the tier. +Pega supports deployments using a multi-tier architecture model that separates application processing from k8s functions. Isolating processing in its own tier supports unique deployment configurations, including the Pega application prconfig, resource allocations, and scaling characteristics. Use the tier section in the helm chart to specify into which tiers you wish to deploy the tier with nodes dedicated to the logical tasks of the tier. ### Tier examples