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

Added configurability of hazelcast/clusteringservice name #814

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
893f37f
Added configuration to change the name of the hazelcast deployment
alemax22 Sep 29, 2024
49eb1c8
Fixed templating for hazelcast deployment of version previous to Pega…
alemax22 Sep 29, 2024
cc68b38
Created Unit Test for new functionality
alemax22 Sep 29, 2024
9aa9ed5
Updated documentation
alemax22 Sep 29, 2024
9b6a19f
Merge branch 'master' into feature/clustering-service-name
Saurabh-16 Oct 1, 2024
79b43e7
Merge branch 'pegasystems:master' into feature/clustering-service-name
alemax22 Oct 9, 2024
6d19265
Merge branch 'pegasystems:master' into feature/clustering-service-name
alemax22 Oct 20, 2024
1a3058d
Merge branch 'pegasystems:master' into feature/clustering-service-name
alemax22 Oct 23, 2024
be6fc42
Fixed merge conflicts
alemax22 Nov 1, 2024
3727435
Removed with space
alemax22 Nov 1, 2024
2b7bfc9
Added . in front of path for values.yaml file in README of addons
alemax22 Nov 2, 2024
21e7d75
Merge branch 'pegasystems:master' into feature/clustering-service-name
alemax22 Nov 6, 2024
f27236f
Merge branch 'pegasystems:master' into feature/clustering-service-name
alemax22 Nov 7, 2024
a91f404
Merge branch 'master' into feature/clustering-service-name
alemax22 Nov 7, 2024
fada57e
Merge branch 'master' into feature/clustering-service-name
alemax22 Nov 11, 2024
74d3270
Merge branch 'master' into feature/clustering-service-name
alemax22 Nov 14, 2024
3b92ee0
Merge branch 'master' into feature/clustering-service-name
alemax22 Nov 26, 2024
acc46d1
Merged with master
alemax22 Dec 9, 2024
e32dda9
Merge branch 'master' into feature/clustering-service-name
alemax22 Dec 23, 2024
de21c64
Merge branch 'master' into feature/clustering-service-name
alemax22 Dec 26, 2024
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
3 changes: 3 additions & 0 deletions charts/pega/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1258,6 +1258,7 @@ here: [Additional Parameters](charts/hazelcast/README.md)

Parameter | Description | Default value
--- |--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| ---
`hazelcast.deployment.name` | Name used for the hazelcast deployment. | `pega-hazelcast`
`hazelcast.image` | Reference the `platform/clustering-service` Docker image that you downloaded and pushed to your Docker registry that your deployment can access. | `YOUR_HAZELCAST_IMAGE:TAG`
`hazelcast.clusteringServiceImage` | Reference the `platform/clustering-service` Docker image that you downloaded and pushed to your Docker registry that your deployment can access. | `YOUR_CLUSTERING_SERVICE_IMAGE:TAG`
`hazelcast.enabled` | Set to `true` if client-server deployment of Pega Platform is required; otherwise leave set to `false`. Note: To avoid an installation failure, you must set this value to `false` for Pega platform deployments using versions before 8.6. | `true`
Expand All @@ -1275,6 +1276,8 @@ Parameter | Description
#### Example
```yaml
hazelcast:
deployment:
name: "pega-hazelcast"
image: "YOUR_HAZELCAST_IMAGE:TAG"
clusteringServiceImage: "YOUR_CLUSTERING_SERVICE_IMAGE:TAG"
enabled: true
Expand Down
2 changes: 2 additions & 0 deletions charts/pega/charts/hazelcast/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ Name | Description
#### Example

```yaml
deployment:
name: pega-hazelcast
image: "YOUR_HAZELCAST_IMAGE:TAG"
clusteringServiceImage: "YOUR_CLUSTERING_SERVICE_IMAGE:TAG"
imagePullPolicy: "Always"
Expand Down
9 changes: 5 additions & 4 deletions charts/pega/charts/hazelcast/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{{- define "hazelcastName" -}} pega-hazelcast {{- end -}}
{{- define "hazelcastEnvironmentConfig" -}} pega-hz-env-config {{- end -}}
{{- define "hazelcastDeploymentName" }}{{ $hazelcastDeploymentName := .defaultname }}{{ if (.root.deployment) }}{{ if (.root.deployment.name) }}{{ $hazelcastDeploymentName = .root.deployment.name }}{{ end }}{{ end }}{{ $hazelcastDeploymentName }}{{- end -}}

{{- define "clusteringServiceName" -}} clusteringservice {{- end -}}
{{- define "clusteringServiceEnvironmentConfig" -}} clusteringservice-env-config {{- end -}}
{{- define "hazelcastName" -}}{{ include "hazelcastDeploymentName" (dict "root" .Values "defaultname" "pega-hazelcast" )}}{{- end -}}
{{- define "hazelcastEnvironmentConfig" -}}{{include "hazelcastName" .}}-env-config {{- end -}}

{{- define "clusteringServiceName" -}}{{ include "hazelcastDeploymentName" (dict "root" .Values "defaultname" "clusteringservice" )}}{{- end -}}
{{- define "clusteringServiceEnvironmentConfig" -}}{{include "clusteringServiceName" .}}-env-config {{- end -}}

{{- define "isHazelcastEnabled" }}
{{- if .Values.enabled -}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ spec:
{{- end }}
envFrom:
- configMapRef:
name: {{ template "clusteringServiceEnvironmentConfig" }}
name: {{ template "clusteringServiceEnvironmentConfig" .}}
{{- if .Values.containerSecurityContext }}
securityContext:
{{ toYaml .Values.containerSecurityContext | indent 10 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
kind: ConfigMap
apiVersion: v1
metadata:
name: {{ template "clusteringServiceEnvironmentConfig" }}
name: {{ template "clusteringServiceEnvironmentConfig" . }}
namespace: {{ .Release.Namespace }}
data:
# Key Value pairs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ spec:
mountPath: "/opt/hazelcast/secrets"
envFrom:
- configMapRef:
name: {{ template "hazelcastEnvironmentConfig" }}
name: {{ template "hazelcastEnvironmentConfig" . }}
resources:
requests:
cpu: "{{ .Values.resources.requests.cpu }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
kind: ConfigMap
apiVersion: v1
metadata:
name: {{ template "hazelcastEnvironmentConfig" }}
name: {{ template "hazelcastEnvironmentConfig" .}}
namespace: {{ .Release.Namespace }}
data:
# Key Value pairs
NAMESPACE: {{ .Release.Namespace }}
JAVA_OPTS: {{ .Values.server.java_opts | quote }}
SERVICE_NAME: {{ template "hazelcastName" }}-service
SERVICE_NAME: {{ template "hazelcastName" .}}-service
MIN_CLUSTER_SIZE: {{ .Values.replicas | quote }}
{{- if .Values.server.jmx_enabled }}
JMX_ENABLED: {{ .Values.server.jmx_enabled | quote }}
Expand Down
3 changes: 3 additions & 0 deletions charts/pega/charts/hazelcast/values.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
---
image: "YOUR_HAZELCAST_IMAGE:TAG"
# Change the name of the hazelcast deployment
# deployment:
# name: "pega-hazelcast"
clusteringServiceImage: "YOUR_CLUSTERING_SERVICE_IMAGE:TAG"
imagePullPolicy: "Always"
# Enter the number of initial members in Hazelcast cluster.
Expand Down
5 changes: 3 additions & 2 deletions charts/pega/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -484,10 +484,11 @@ servicePort: use-annotation
{{- end -}}

{{- define "hzServiceName" -}}
{{- $hzDict := dict "Values" .Values.hazelcast -}}
{{- if and (not .Values.hazelcast.enabled) .Values.hazelcast.clusteringServiceEnabled -}}
{{ template "clusteringServiceName" }}
{{ template "clusteringServiceName" $hzDict }}
{{- else -}}
{{ template "hazelcastName" }}
{{ template "hazelcastName" $hzDict }}
{{- end -}}
{{- end -}}

Expand Down
41 changes: 41 additions & 0 deletions terratest/src/test/pega/clustering-service-deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,47 @@ func VerifyClusteringServiceDeployment(t *testing.T, yamlContent string, ssl boo
}
}

func TestClusteringServiceDeploymentName(t *testing.T) {
var supportedVendors = []string{"k8s", "openshift", "eks", "gke", "aks", "pks"}
var supportedOperations = []string{"deploy", "install-deploy"}

helmChartPath, err := filepath.Abs(PegaHelmChartPath)
require.NoError(t, err)

for _, vendor := range supportedVendors {

for _, operation := range supportedOperations {

fmt.Println(vendor + "-" + operation)

var options = &helm.Options{
SetValues: map[string]string{
"global.provider": vendor,
"global.actions.execute": operation,
"hazelcast.clusteringServiceEnabled": "true",
"hazelcast.deployment.name": "clusteringservice-test",
},
}

yamlContent := RenderTemplate(t, options, helmChartPath, []string{"charts/hazelcast/templates/clustering-service-deployment.yaml"})
VerifyClusteringServiceDeploymentName(t, yamlContent)

}
}
}

func VerifyClusteringServiceDeploymentName(t *testing.T, yamlContent string) {
var statefulsetObj appsv1beta2.StatefulSet
statefulSlice := strings.Split(yamlContent, "---")
for index, statefulInfo := range statefulSlice {
if index >= 1 {
UnmarshalK8SYaml(t, statefulInfo, &statefulsetObj)
require.Equal(t, statefulsetObj.Name, "clusteringservice-test")
require.Equal(t, statefulsetObj.Spec.ServiceName, "clusteringservice-test-service")
}
}
}

func TestClusteringServiceDeploymentSecurityContext(t *testing.T) {
var supportedVendors = []string{"k8s", "openshift", "eks", "gke", "aks", "pks"}
var supportedOperations = []string{"deploy", "install-deploy"}
Expand Down
73 changes: 56 additions & 17 deletions terratest/src/test/pega/clustering-service-service_test.go
Original file line number Diff line number Diff line change
@@ -1,42 +1,40 @@
package pega

import (
"fmt"
"path/filepath"
"strings"
"testing"

"github.com/gruntwork-io/terratest/modules/helm"
"github.com/stretchr/testify/require"
k8score "k8s.io/api/core/v1"
intstr "k8s.io/apimachinery/pkg/util/intstr"
"path/filepath"
"strings"
"testing"
"fmt"
)



func TestClusteringService(t *testing.T){
var supportedVendors = []string{"k8s","openshift","eks","gke","aks","pks"}
var supportedOperations = []string{"deploy","install-deploy"}
func TestClusteringService(t *testing.T) {
var supportedVendors = []string{"k8s", "openshift", "eks", "gke", "aks", "pks"}
var supportedOperations = []string{"deploy", "install-deploy"}

helmChartPath, err := filepath.Abs(PegaHelmChartPath)
require.NoError(t, err)

for _, vendor := range supportedVendors {

for _,vendor := range supportedVendors{

for _,operation := range supportedOperations{
for _, operation := range supportedOperations {

fmt.Println(vendor + "-" + operation)

var options = &helm.Options{
SetValues: map[string]string{
"global.provider": vendor,
"global.actions.execute": operation,
"hazelcast.clusteringServiceEnabled": "true",
"global.provider": vendor,
"global.actions.execute": operation,
"hazelcast.clusteringServiceEnabled": "true",
},
}

yamlContent := RenderTemplate(t, options, helmChartPath, []string{"charts/hazelcast/templates/clustering-service-service.yaml"})
VerifyClusteringService(t,yamlContent,options)
VerifyClusteringService(t, yamlContent, options)
}
}
}
Expand All @@ -55,4 +53,45 @@ func VerifyClusteringService(t *testing.T, yamlContent string, options *helm.Opt
require.Equal(t, intstr.FromInt(5701), clusteringServiceObj.Spec.Ports[0].TargetPort)
}
}
}
}

func TestClusteringServiceName(t *testing.T) {
var supportedVendors = []string{"k8s", "openshift", "eks", "gke", "aks", "pks"}
var supportedOperations = []string{"deploy", "install-deploy"}

helmChartPath, err := filepath.Abs(PegaHelmChartPath)
require.NoError(t, err)

for _, vendor := range supportedVendors {

for _, operation := range supportedOperations {

fmt.Println(vendor + "-" + operation)

var options = &helm.Options{
SetValues: map[string]string{
"global.provider": vendor,
"global.actions.execute": operation,
"hazelcast.clusteringServiceEnabled": "true",
"hazelcast.deployment.name": "clustering-test",
},
}

yamlContent := RenderTemplate(t, options, helmChartPath, []string{"charts/hazelcast/templates/clustering-service-service.yaml"})
VerifyClusteringServiceName(t, yamlContent, options)
}
}
}

func VerifyClusteringServiceName(t *testing.T, yamlContent string, options *helm.Options) {
var clusteringServiceObj k8score.Service
serviceSlice := strings.Split(yamlContent, "---")
for index, serviceInfo := range serviceSlice {
if index >= 1 {
UnmarshalK8SYaml(t, serviceInfo, &clusteringServiceObj)
require.Equal(t, "clustering-test-service", clusteringServiceObj.Name)
require.Equal(t, "Hazelcast", clusteringServiceObj.Spec.Selector["component"])
require.Equal(t, "clustering-test", clusteringServiceObj.Spec.Selector["app"])
}
}
}
41 changes: 41 additions & 0 deletions terratest/src/test/pega/pega-hz-deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,47 @@ func VerifyHazelcastDeployment(t *testing.T, yamlContent string) {
}
}

func TestHazelcastDeploymentName(t *testing.T) {
var supportedVendors = []string{"k8s", "openshift", "eks", "gke", "aks", "pks"}
var supportedOperations = []string{"deploy", "install-deploy"}

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,
"hazelcast.enabled": "true",
"hazelcast.deployment.name": "hz-test",
},
}

yamlContent := RenderTemplate(t, options, helmChartPath, []string{"charts/hazelcast/templates/pega-hz-deployment.yaml"})
VerifyHazelcastDeploymentName(t, yamlContent)

}
}
}

func VerifyHazelcastDeploymentName(t *testing.T, yamlContent string) {
var statefulsetObj appsv1beta2.StatefulSet
statefulSlice := strings.Split(yamlContent, "---")
for index, statefulInfo := range statefulSlice {
if index >= 1 {
UnmarshalK8SYaml(t, statefulInfo, &statefulsetObj)
require.Equal(t, statefulsetObj.Name, "hz-test")
require.Equal(t, statefulsetObj.Spec.ServiceName, "hz-test-service")
statefulsetSpec := statefulsetObj.Spec.Template.Spec
require.Equal(t, statefulsetSpec.Volumes[1].Projected.Sources[0].Secret.Name, "pega-hz-secret")
}
}
}

func TestHazelcastDeploymentWithPodAffinity(t *testing.T) {
var supportedVendors = []string{"k8s", "openshift", "eks", "gke", "aks", "pks"}
var supportedOperations = []string{"deploy", "install-deploy"}
Expand Down
Loading