Skip to content

Commit

Permalink
BUG-737502 added infrastructure to give the user the option to change… (
Browse files Browse the repository at this point in the history
#437)

* BUG-737502 added infrastructure to give the user teh option to change imagePullPolicy and made note of that in the README

* fixed readme, and added terratest

* added a new line to distinguish the new test

* reworded a part of the readme

Co-authored-by: locoe <[email protected]>
Co-authored-by: Davis Walsh <[email protected]>
  • Loading branch information
3 people authored Jul 27, 2022
1 parent 2d9f46b commit 8d68d1c
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 40 deletions.
7 changes: 6 additions & 1 deletion charts/pega/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -759,14 +759,18 @@ The Helm charts also support an automated install or upgrade with a Kubernetes J

For installations of the Pega platform, you must specify the installer Docker image and an initial default password for the `[email protected]` user.

Along with this, you can configure the kubelet pull policy for the image. It is defaulted to `IfNotPresent`, meaning an image will be pulled if it is "not present". All possible options are `IfNotPresent`, `Always`, and `Never`. Always pulling an image ensures you always have the latest image at all times, even if the specific tag already exists on your machine.

Example:

```yaml
installer:
image: "YOUR_INSTALLER_IMAGE:TAG"
imagePullPolicy: "PREFERRED_IMAGE_PULL_POLICY"
adminPassword: "ADMIN_PASSWORD"
```


### Upgrades and patches

The Pega Helm charts support zero-downtime patch and upgrades processes which synchronize the required process steps to minimize downtime. With these zero-downtime processes, you and your customers can continue to access and use their applications in your environment with minimal disruption while you patch or upgrade your system.
Expand All @@ -782,7 +786,8 @@ Use the `installer` section of the values file with the appropriate parameters
Parameter | Description | Default value
--- | --- | ---
`image` | Reference the `platform/installer` Docker image that you downloaded and pushed to your Docker registry that your deployment can access. | `YOUR_INSTALLER_IMAGE:TAG`
`adminPassword` | Specify a temporary, initial password to log into teh Pega application. This will need to be changed at first login. The adminPassword value cannot start with "@". | `"ADMIN_PASSWORD"`
`imagePullPolicy` | Specify when to pull an image. | `IfNotPresent`
`adminPassword` | Specify a temporary, initial password to log into the Pega application. This will need to be changed at first login. The adminPassword value cannot start with "@". | `"ADMIN_PASSWORD"`
`upgrade.upgradeType:` |Specify the type of process, applying a patch or upgrading. | See the next table for details.
`upgrade.upgradeSteps:` |Specify the steps of a `custom` upgrade process that you want to complete. For `zero-downtime`, `out-of-place-rules`, `out-of-place-data`, or `in-place` upgrades, leave this parameter empty. | <ul>`enable_cluster_upgrade` `rules_migration` `rules_upgrade` `data_upgrade` `disable_cluster_upgrade`</ul>
`upgrade.targetRulesSchema:` |Specify the name of the schema you created the process creates for the new rules schema. | `""`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ spec:
containers:
- name: {{ template "pegaDBInstallerContainer" }}
image: {{ .root.Values.image }}
{{- if .root.Values.imagePullPolicy }}
imagePullPolicy: {{ .root.Values.imagePullPolicy }}
{{- end }}
ports:
- containerPort: 8080
resources:
Expand Down
83 changes: 44 additions & 39 deletions terratest/src/test/pega/pega-installer-job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type pegaDbJob struct {
name string
initContainers []string
configMapName string
containerName string
containerName string
}

var volDefaultMode int32 = 420
Expand All @@ -26,56 +26,59 @@ 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"}

var imagePullPolicy = []string{"", "IfNotPresent", "Always"}
helmChartPath, err := filepath.Abs(PegaHelmChartPath)
require.NoError(t, err)

for _, vendor := range supportedVendors {
for _, operation := range supportedOperations {
for _, depName := range deploymentNames {
var options = &helm.Options{
SetValues: map[string]string{
"global.deployment.name": depName,
"global.provider": vendor,
"global.actions.execute": operation,
"installer.upgrade.upgradeType": "zero-downtime",
},
}

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", "pega-installer"}
} else if index == 2 {
expectedJob = pegaDbJob{"pega-zdt-upgrade", []string{"wait-for-pre-dbupgrade"}, "pega-upgrade-environment-config", "pega-installer"}
} else if index == 3 {
expectedJob = pegaDbJob{"pega-post-upgrade", []string{"wait-for-pegaupgrade", "wait-for-rolling-updates"}, "pega-upgrade-environment-config", "pega-installer"}
for _, pullPolicy := range imagePullPolicy {
var options = &helm.Options{
SetValues: map[string]string{
"global.deployment.name": depName,
"global.provider": vendor,
"global.actions.execute": operation,
"installer.imagePullPolicy": pullPolicy,
"installer.upgrade.upgradeType": "zero-downtime",
},
}
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", "pega-installer"}
} else if index == 2 {
expectedJob = pegaDbJob{"pega-zdt-upgrade", []string{"wait-for-pre-dbupgrade"}, "pega-upgrade-environment-config", "pega-installer"}
} else if index == 3 {
expectedJob = pegaDbJob{"pega-post-upgrade", []string{"wait-for-pegaupgrade", "wait-for-rolling-updates"}, "pega-upgrade-environment-config", "pega-installer"}
}

assertJob(t, jobInfo, expectedJob, options, pullPolicy)
}

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", "pega-installer"}, options)
} else {
assertJob(t, yamlSplit[1], pegaDbJob{"pega-pre-upgrade", []string{}, "pega-upgrade-environment-config", "pega-installer"}, options)
if operation == "install" || operation == "install-deploy" {
assertJob(t, yamlSplit[1], pegaDbJob{"pega-db-install", []string{}, "pega-install-environment-config", "pega-installer"}, options, pullPolicy)
} else {
assertJob(t, yamlSplit[1], pegaDbJob{"pega-pre-upgrade", []string{}, "pega-upgrade-environment-config", "pega-installer"}, options, pullPolicy)
}
}

}

}
}
}
}


func assertJob(t *testing.T, jobYaml string, expectedJob pegaDbJob, options *helm.Options) {
func assertJob(t *testing.T, jobYaml string, expectedJob pegaDbJob, options *helm.Options, pullPolicy string) {
var jobObj k8sbatch.Job
UnmarshalK8SYaml(t, jobYaml, &jobObj)

Expand All @@ -88,14 +91,16 @@ func assertJob(t *testing.T, jobYaml string, expectedJob pegaDbJob, options *hel
require.Equal(t, jobSpec.Volumes[0].VolumeSource.Projected.Sources[0].Secret.Name, getObjName(options, "-credentials-secret"))
require.Equal(t, jobSpec.Volumes[0].VolumeSource.Projected.DefaultMode, volDefaultModePointer)
require.Equal(t, jobSpec.Volumes[1].Name, "pega-volume-installer")
if(jobSpec.Volumes[1].VolumeSource.ConfigMap.LocalObjectReference.Name=="pega-install-config") {
require.Equal(t, jobSpec.Volumes[1].VolumeSource.ConfigMap.LocalObjectReference.Name, "pega-install-config")
if jobSpec.Volumes[1].VolumeSource.ConfigMap.LocalObjectReference.Name == "pega-install-config" {
require.Equal(t, jobSpec.Volumes[1].VolumeSource.ConfigMap.LocalObjectReference.Name, "pega-install-config")
}
if(jobSpec.Volumes[1].VolumeSource.ConfigMap.LocalObjectReference.Name=="pega-upgrade-config") {
require.Equal(t, jobSpec.Volumes[1].VolumeSource.ConfigMap.LocalObjectReference.Name, "pega-upgrade-config")
if jobSpec.Volumes[1].VolumeSource.ConfigMap.LocalObjectReference.Name == "pega-upgrade-config" {
require.Equal(t, jobSpec.Volumes[1].VolumeSource.ConfigMap.LocalObjectReference.Name, "pega-upgrade-config")
}
require.Equal(t, jobSpec.Volumes[1].VolumeSource.ConfigMap.DefaultMode, volDefaultModePointer)


require.Equal(t, string(jobContainers[0].ImagePullPolicy), pullPolicy)

require.Equal(t, jobContainers[0].Name, expectedJob.containerName)
require.Equal(t, "YOUR_INSTALLER_IMAGE:TAG", jobContainers[0].Image)
require.Equal(t, jobContainers[0].Ports[0].ContainerPort, containerPort)
Expand Down

0 comments on commit 8d68d1c

Please sign in to comment.