Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG-591266: add deployment name and rename tier-based objects. #242

Merged
merged 16 commits into from
Apr 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion charts/pega/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,35 @@ docker:
imagePullPolicy: "Always"
```

## Deployment Name (Optional)

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:
deployment:
name: app1-dev
```
will result in:
```
>kubectl get pods -n test
NAME READY STATUS RESTARTS AGE
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
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
```
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 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

Expand Down
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -17,7 +18,7 @@ spec:
app: constellation
spec:
imagePullSecrets:
- name: {{ template "pegaRegistrySecret" }}
- name: {{ template "pegaRegistrySecret" $ }}
containers:
- name: constellation
imagePullPolicy: {{ .Values.imagePullPolicy }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,5 @@ spec:
# Volume used to mount secret files.
{{- include "pegaCredentialVolumeTemplate" . | indent 6 }}
imagePullSecrets:
- name: {{ template "pegaRegistrySecret" }}
- name: {{ template "pegaRegistrySecret" $ }}
{{ end }}
8 changes: 6 additions & 2 deletions charts/pega/charts/installer/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -54,6 +56,8 @@
{{- end }}

{{- define "waitForRollingUpdates" -}}
{{- $deploymentName := printf "%s-" (include "installerDeploymentName" $) -}}
{{- $deploymentNameRegex := printf "%s- " (include "installerDeploymentName" $) -}}
pega-talba marked this conversation as resolved.
Show resolved Hide resolved
{{- $rolloutCommand := "" }}
{{- $kindName := "" }}
{{- $lastIndex := sub (len .Values.global.tier) 1 }}
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -79,6 +79,6 @@ spec:
{{- end }}
restartPolicy: Never
imagePullSecrets:
- name: {{ template "pegaRegistrySecret" }}
- name: {{ template "pegaRegistrySecret" .root }}
---
{{- end -}}
42 changes: 33 additions & 9 deletions charts/pega/charts/pegasearch/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -1,13 +1,37 @@
{{- define "searchName" -}}
pega-search
{{- 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 "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, 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" $) -}}
{{- if or (ne $searchURL $defaultSearchURL) $.Values.externalSearchService -}}
true
{{- else -}}
false
{{- end -}}
{{- end }}
{{- end -}}
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ spec:
- name: esstorage
mountPath: /usr/share/elasticsearch/data
imagePullSecrets:
- name: {{ template "pegaRegistrySecret" }}
- name: {{ template "pegaRegistrySecret" $}}
volumeClaimTemplates:
- metadata:
name: esstorage
Expand Down
5 changes: 3 additions & 2 deletions charts/pega/charts/pegasearch/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ 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.
misterdorito marked this conversation as resolved.
Show resolved Hide resolved
# If externalURL is set to a value different from the name of the k8s service defined in pega-search-service.yaml,
# 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).
Expand Down
35 changes: 30 additions & 5 deletions charts/pega/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -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 -}}

Expand Down Expand Up @@ -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" -}}
Expand Down Expand Up @@ -239,7 +255,16 @@ 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}}

{{- define "deploymentName" }}{{ $deploymentNamePrefix := "pega" }}{{ if (.Values.global.deployment) }}{{ if (.Values.global.deployment.name) }}{{ $deploymentNamePrefix = .Values.global.deployment.name }}{{ end }}{{ end }}{{ $deploymentNamePrefix }}{{- end }}


{{- define "pegaSearchURL" -}}
{{- $d1 := dict "overrideURL" $.Values.pegasearch.externalURL }}
{{- $d2 := merge $ $d1 }}
{{- template "searchURL" $d2 }}
{{- end -}}
2 changes: 1 addition & 1 deletion charts/pega/templates/_pega-config.tpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- define "pega.config" -}}
{{ template "pega.config.inner" dict "root" .root "node" .dep "name" (printf "pega-%s" .dep.name) "mode" (include "deployConfig" .root) "custom" .dep.custom }}
{{ template "pega.config.inner" dict "root" .root "node" .dep "name" .name "mode" (include "deployConfig" .root) "custom" .dep.custom }}
{{- end -}}


Expand Down
2 changes: 1 addition & 1 deletion charts/pega/templates/_pega-credentials-secret.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
kind: Secret
apiVersion: v1
metadata:
name: {{ template "pegaCredentialsSecret" }}
name: {{ template "pegaCredentialsSecret" $ }}
namespace: {{ .Release.Namespace }}
data:
# Base64 encoded username for connecting to the Pega DB
Expand Down
6 changes: 3 additions & 3 deletions charts/pega/templates/_pega-deployment.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -252,7 +252,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:
Expand Down
2 changes: 1 addition & 1 deletion charts/pega/templates/_pega-registry-secret.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
kind: Secret
apiVersion: v1
metadata:
name: {{ template "pegaRegistrySecret" }}
name: {{ template "pegaRegistrySecret" $ }}
namespace: {{ .Release.Namespace }}
data:
.dockerconfigjson: {{ template "imagePullSecret" . }}
Expand Down
6 changes: 3 additions & 3 deletions charts/pega/templates/pega-environment-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
kind: ConfigMap
apiVersion: v1
metadata:
name: {{ template "pegaEnvironmentConfig" }}
name: {{ template "pegaEnvironmentConfig" $ }}
namespace: {{ .Release.Namespace }}
data:
# Database Type for installation
Expand Down Expand Up @@ -40,10 +40,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" . }}"
Expand Down
4 changes: 3 additions & 1 deletion charts/pega/templates/pega-gke-backend-config.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{{ $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 "pega-%s" $dep.name) }}
{{ template "pega.gke.backendConfig" dict "root" $ "node" $dep "name" (printf "%s-%s" $depName $dep.name) }}
{{ end }}
{{ end }}
{{ end }}
Expand Down
3 changes: 2 additions & 1 deletion charts/pega/templates/pega-tier-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{{ $depName := printf "%s" (include "deploymentName" $) }}
{{ if (eq (include "performDeployment" $) "true") }}
{{ range $index, $dep := .Values.global.tier}}
{{ template "pega.config" dict "root" $ "dep" $dep }}
{{ template "pega.config" dict "root" $ "dep" $dep "name" (printf "%s-%s" $depName $dep.name)}}
{{ end }}
{{ end }}
5 changes: 4 additions & 1 deletion charts/pega/templates/pega-tier-deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{{ $depName := printf "%s" (include "deploymentName" $) }}

{{ $kindName := "" }}
{{ $apiVer := "" }}
{{ range $index, $dep := .Values.global.tier}}
Expand All @@ -9,6 +11,7 @@
{{ $apiVer = "apps/v1" }}
{{ end }}


{{ $containerWaitList := list }}
{{ if (eq (include "performOnlyDeployment" $) "true") }}
{{ if not $.Values.pegasearch.externalSearchService }}
Expand All @@ -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" $depName $dep.name) "tierName" $dep.name "kind" $kindName "apiVersion" $apiVer "nodeType" $dep.nodeType "initContainers" $containerWaitList "custom" $dep.custom }}
{{- end }}
{{ end }}
4 changes: 3 additions & 1 deletion charts/pega/templates/pega-tier-hpa.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{{ $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 "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" $depName $dep.name)) "deploymentName" (printf "%s-%s" $depName $dep.name) "hpa" $dep.hpa }}
{{ end }}
{{ end }}
{{ end }}
12 changes: 7 additions & 5 deletions charts/pega/templates/pega-tier-ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
{{ $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 "pega-%s" $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 "pega-%s" $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 "pega-%s" $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 "pega-%s" $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 "pega-%s" $dep.name) }}
{{ template "pega.k8s.ingress" dict "root" $ "node" $dep "name" (printf "%s-%s" $depName $dep.name) }}
{{- end -}}
{{- end -}}
{{- end -}}
Loading