Skip to content

Commit 8d68d1c

Browse files
Evan1ocontolocoeAPegaDavis
authored
BUG-737502 added infrastructure to give the user the option to change… (#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]>
1 parent 2d9f46b commit 8d68d1c

File tree

3 files changed

+53
-40
lines changed

3 files changed

+53
-40
lines changed

charts/pega/README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,14 +759,18 @@ The Helm charts also support an automated install or upgrade with a Kubernetes J
759759

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

762+
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.
763+
762764
Example:
763765

764766
```yaml
765767
installer:
766768
image: "YOUR_INSTALLER_IMAGE:TAG"
769+
imagePullPolicy: "PREFERRED_IMAGE_PULL_POLICY"
767770
adminPassword: "ADMIN_PASSWORD"
768771
```
769772

773+
770774
### Upgrades and patches
771775

772776
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.
@@ -782,7 +786,8 @@ Use the `installer` section of the values file with the appropriate parameters
782786
Parameter | Description | Default value
783787
--- | --- | ---
784788
`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`
785-
`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"`
789+
`imagePullPolicy` | Specify when to pull an image. | `IfNotPresent`
790+
`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"`
786791
`upgrade.upgradeType:` |Specify the type of process, applying a patch or upgrading. | See the next table for details.
787792
`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>
788793
`upgrade.targetRulesSchema:` |Specify the name of the schema you created the process creates for the new rules schema. | `""`

charts/pega/charts/installer/templates/_pega-installer-job.tpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ spec:
6868
containers:
6969
- name: {{ template "pegaDBInstallerContainer" }}
7070
image: {{ .root.Values.image }}
71+
{{- if .root.Values.imagePullPolicy }}
72+
imagePullPolicy: {{ .root.Values.imagePullPolicy }}
73+
{{- end }}
7174
ports:
7275
- containerPort: 8080
7376
resources:

terratest/src/test/pega/pega-installer-job_test.go

Lines changed: 44 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type pegaDbJob struct {
1515
name string
1616
initContainers []string
1717
configMapName string
18-
containerName string
18+
containerName string
1919
}
2020

2121
var volDefaultMode int32 = 420
@@ -26,56 +26,59 @@ func TestPegaInstallerJob(t *testing.T) {
2626
var supportedVendors = []string{"k8s", "openshift", "eks", "gke", "aks", "pks"}
2727
var supportedOperations = []string{"install", "install-deploy", "upgrade", "upgrade-deploy"}
2828
var deploymentNames = []string{"pega", "myapp-dev"}
29-
29+
var imagePullPolicy = []string{"", "IfNotPresent", "Always"}
3030
helmChartPath, err := filepath.Abs(PegaHelmChartPath)
3131
require.NoError(t, err)
3232

3333
for _, vendor := range supportedVendors {
3434
for _, operation := range supportedOperations {
3535
for _, depName := range deploymentNames {
36-
var options = &helm.Options{
37-
SetValues: map[string]string{
38-
"global.deployment.name": depName,
39-
"global.provider": vendor,
40-
"global.actions.execute": operation,
41-
"installer.upgrade.upgradeType": "zero-downtime",
42-
},
43-
}
44-
45-
yamlContent := RenderTemplate(t, options, helmChartPath, []string{"charts/installer/templates/pega-installer-job.yaml"})
46-
yamlSplit := strings.Split(yamlContent, "---")
47-
48-
// If there are three slices, it means that it is a pega-upgrade-deploy job
49-
if len(yamlSplit) == 4 {
50-
var expectedJob pegaDbJob
51-
for index, jobInfo := range yamlSplit {
52-
if index >= 1 && index <= 3 {
53-
if index == 1 {
54-
expectedJob = pegaDbJob{"pega-pre-upgrade", []string{}, "pega-upgrade-environment-config", "pega-installer"}
55-
} else if index == 2 {
56-
expectedJob = pegaDbJob{"pega-zdt-upgrade", []string{"wait-for-pre-dbupgrade"}, "pega-upgrade-environment-config", "pega-installer"}
57-
} else if index == 3 {
58-
expectedJob = pegaDbJob{"pega-post-upgrade", []string{"wait-for-pegaupgrade", "wait-for-rolling-updates"}, "pega-upgrade-environment-config", "pega-installer"}
36+
for _, pullPolicy := range imagePullPolicy {
37+
var options = &helm.Options{
38+
SetValues: map[string]string{
39+
"global.deployment.name": depName,
40+
"global.provider": vendor,
41+
"global.actions.execute": operation,
42+
"installer.imagePullPolicy": pullPolicy,
43+
"installer.upgrade.upgradeType": "zero-downtime",
44+
},
45+
}
46+
yamlContent := RenderTemplate(t, options, helmChartPath, []string{"charts/installer/templates/pega-installer-job.yaml"})
47+
yamlSplit := strings.Split(yamlContent, "---")
48+
49+
// If there are three slices, it means that it is a pega-upgrade-deploy job
50+
if len(yamlSplit) == 4 {
51+
var expectedJob pegaDbJob
52+
for index, jobInfo := range yamlSplit {
53+
if index >= 1 && index <= 3 {
54+
if index == 1 {
55+
expectedJob = pegaDbJob{"pega-pre-upgrade", []string{}, "pega-upgrade-environment-config", "pega-installer"}
56+
} else if index == 2 {
57+
expectedJob = pegaDbJob{"pega-zdt-upgrade", []string{"wait-for-pre-dbupgrade"}, "pega-upgrade-environment-config", "pega-installer"}
58+
} else if index == 3 {
59+
expectedJob = pegaDbJob{"pega-post-upgrade", []string{"wait-for-pegaupgrade", "wait-for-rolling-updates"}, "pega-upgrade-environment-config", "pega-installer"}
60+
}
61+
62+
assertJob(t, jobInfo, expectedJob, options, pullPolicy)
5963
}
6064

61-
assertJob(t, jobInfo, expectedJob, options)
6265
}
63-
64-
}
65-
} else {
66-
if operation == "install" || operation == "install-deploy" {
67-
assertJob(t, yamlSplit[1], pegaDbJob{"pega-db-install", []string{}, "pega-install-environment-config", "pega-installer"}, options)
6866
} else {
69-
assertJob(t, yamlSplit[1], pegaDbJob{"pega-pre-upgrade", []string{}, "pega-upgrade-environment-config", "pega-installer"}, options)
67+
if operation == "install" || operation == "install-deploy" {
68+
assertJob(t, yamlSplit[1], pegaDbJob{"pega-db-install", []string{}, "pega-install-environment-config", "pega-installer"}, options, pullPolicy)
69+
} else {
70+
assertJob(t, yamlSplit[1], pegaDbJob{"pega-pre-upgrade", []string{}, "pega-upgrade-environment-config", "pega-installer"}, options, pullPolicy)
71+
}
7072
}
73+
7174
}
75+
7276
}
7377
}
7478
}
7579
}
7680

77-
78-
func assertJob(t *testing.T, jobYaml string, expectedJob pegaDbJob, options *helm.Options) {
81+
func assertJob(t *testing.T, jobYaml string, expectedJob pegaDbJob, options *helm.Options, pullPolicy string) {
7982
var jobObj k8sbatch.Job
8083
UnmarshalK8SYaml(t, jobYaml, &jobObj)
8184

@@ -88,14 +91,16 @@ func assertJob(t *testing.T, jobYaml string, expectedJob pegaDbJob, options *hel
8891
require.Equal(t, jobSpec.Volumes[0].VolumeSource.Projected.Sources[0].Secret.Name, getObjName(options, "-credentials-secret"))
8992
require.Equal(t, jobSpec.Volumes[0].VolumeSource.Projected.DefaultMode, volDefaultModePointer)
9093
require.Equal(t, jobSpec.Volumes[1].Name, "pega-volume-installer")
91-
if(jobSpec.Volumes[1].VolumeSource.ConfigMap.LocalObjectReference.Name=="pega-install-config") {
92-
require.Equal(t, jobSpec.Volumes[1].VolumeSource.ConfigMap.LocalObjectReference.Name, "pega-install-config")
94+
if jobSpec.Volumes[1].VolumeSource.ConfigMap.LocalObjectReference.Name == "pega-install-config" {
95+
require.Equal(t, jobSpec.Volumes[1].VolumeSource.ConfigMap.LocalObjectReference.Name, "pega-install-config")
9396
}
94-
if(jobSpec.Volumes[1].VolumeSource.ConfigMap.LocalObjectReference.Name=="pega-upgrade-config") {
95-
require.Equal(t, jobSpec.Volumes[1].VolumeSource.ConfigMap.LocalObjectReference.Name, "pega-upgrade-config")
97+
if jobSpec.Volumes[1].VolumeSource.ConfigMap.LocalObjectReference.Name == "pega-upgrade-config" {
98+
require.Equal(t, jobSpec.Volumes[1].VolumeSource.ConfigMap.LocalObjectReference.Name, "pega-upgrade-config")
9699
}
97100
require.Equal(t, jobSpec.Volumes[1].VolumeSource.ConfigMap.DefaultMode, volDefaultModePointer)
98-
101+
102+
require.Equal(t, string(jobContainers[0].ImagePullPolicy), pullPolicy)
103+
99104
require.Equal(t, jobContainers[0].Name, expectedJob.containerName)
100105
require.Equal(t, "YOUR_INSTALLER_IMAGE:TAG", jobContainers[0].Image)
101106
require.Equal(t, jobContainers[0].Ports[0].ContainerPort, containerPort)

0 commit comments

Comments
 (0)