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

Replaced deploymentName with deployment.name in SRS chart #835

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
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
8 changes: 5 additions & 3 deletions charts/backingservices/charts/srs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ To deploy Pega Platform with the SRS backing service, the SRS helm chart require
| Configuration | Usage |
|-----------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `enabled` | Enable the Search and Reporting Service deployment as a backing service. Set this parameter to `true` to use SRS. |
| `deploymentName` | Specify the name of your SRS cluster. Your deployment creates resources prefixed with this string. This is also the service name for the SRS. |
| `deploymentName` | Deprecated, use `deployment.name`. Specify the name of your SRS cluster. Your deployment creates resources prefixed with this string. This is also the service name for the SRS. |
| `deployment.name` | Specify the name of your SRS cluster. Your deployment creates resources prefixed with this string. This is also the service name for the SRS. |
| `srsRuntime` | Use this section to define specific resource configuration options like image, replica count, pod affinity, cpu and memory resource settings in the SRS. The default minimum required number of replicas is 2, but as a best practice, deploy 3 replicas to maintain high availability. |
| `busybox` | When provisioning an internally managed Elasticsearch cluster, you can customize the location and pull policy of the Alpine image used during the deployment process by specifying `busybox.image` and `busybox.imagePullPolicy`. |
| `elasticsearch` | Define the elasticsearch cluster configurations. The [Elasticsearch](https://github.com/helm/charts/tree/master/stable/elasticsearch/values.yaml) chart defines the values for Elasticsearch provisioning in the SRS cluster. For internally provisioned Elasticsearch the default version is set to `7.17.9`. Set the `elasticsearch.imageTag` parameter in values.yaml to `7.16.3` to use this supported version in the SRS cluster. |
Expand Down Expand Up @@ -171,8 +172,9 @@ srs:
# Set srs.enabled=true to enable SRS
enabled: true

# specify unique name for the deployment based on org app and/or srs applicable environment name. eg: acme-demo-dev-srs
deploymentName: "YOUR_SRS_DEPLOYMENT_NAME"
deployment:
# specify unique name for the deployment based on org app and/or srs applicable environment name. eg: acme-demo-dev-srs
name: "YOUR_SRS_DEPLOYMENT_NAME"

# Configure the location of the busybox image that is used during the deployment process of
# the internal Elasticsearch cluster
Expand Down
3 changes: 3 additions & 0 deletions charts/backingservices/charts/srs/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ App name
Create a default fully qualified deployment name. This is used to define the deployment resource name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
The key deploymentName is DEPRECATED use deployment.name instead.
*/}}
{{- define "srs.fullname" -}}
{{- if .Values.deploymentName }}
{{- .Values.deploymentName | trunc 63 | trimSuffix "-" }}
{{- else if and (.Values.deployment) (.Values.deployment.name)}}
{{- .Values.deployment.name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.deploymentName }}
{{- if contains $name .Release.Name }}
Expand Down
3 changes: 2 additions & 1 deletion charts/backingservices/charts/srs/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
enabled: true
deploymentName: pega-shared-srs
deployment:
name: pega-shared-srs

# srs-service configuration
srsRuntime:
Expand Down
5 changes: 3 additions & 2 deletions charts/backingservices/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ srs:
# Set srs.enabled=true to enable SRS
enabled: true

# specify unique name for the deployment based on org app and/or srs applicable environment name. eg: acme-demo-dev-srs
deploymentName: "YOUR_SRS_DEPLOYMENT_NAME"
deployment:
# specify unique name for the deployment based on org app and/or srs applicable environment name. eg: acme-demo-dev-srs
name: "YOUR_SRS_DEPLOYMENT_NAME"

# Configure the location of the busybox image that is used during the deployment process of
# the internal Elasticsearch cluster
Expand Down
48 changes: 45 additions & 3 deletions terratest/src/test/backingservices/srs-deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,52 @@ import (

func TestSRSDeployment(t *testing.T) {

helmChartParser := NewHelmConfigParser(
NewHelmTestFromTemplate(t, helmChartRelativePath, map[string]string{
"srs.enabled": "true",
"srs.deployment.name": "test-srs",
"global.imageCredentials.registry": "docker-registry.io",
"srs.srsRuntime.replicaCount": "1",
"srs.srsRuntime.srsImage": "platform-services/search-n-reporting-service:latest",
"srs.srsRuntime.env.AuthEnabled": "false",
"srs.srsRuntime.env.OAuthPublicKeyURL": "",
"srs.srsStorage.tls.enabled": "true",
"srs.srsStorage.basicAuthentication.enabled": "false",
},
[]string{"charts/srs/templates/srsservice_deployment.yaml"}),
)

var srsDeploymentObj appsv1.Deployment
helmChartParser.getResourceYAML(SearchResourceOption{
Name: "test-srs",
Kind: "Deployment",
}, &srsDeploymentObj)
VerifySRSDeployment(t, srsDeploymentObj,
srsDeployment{
"test-srs",
"srs-service",
int32(1),
"platform-services/search-n-reporting-service:latest",
"false",
"",
false,
podResources{"1300m", "2Gi", "650m", "2Gi"},
esDomain{
domain: "elasticsearch-master.default.svc",
port: "9200",
protocol: "https",
},
false,
})
}

func TestSRSDeploymentDeprecatedNameOverNewForBackwardCompatibility(t *testing.T) {

helmChartParser := NewHelmConfigParser(
NewHelmTestFromTemplate(t, helmChartRelativePath, map[string]string{
"srs.enabled": "true",
"srs.deploymentName": "test-srs",
"srs.deployment.name": "test-srs-new-key",
"global.imageCredentials.registry": "docker-registry.io",
"srs.srsRuntime.replicaCount": "1",
"srs.srsRuntime.srsImage": "platform-services/search-n-reporting-service:latest",
Expand Down Expand Up @@ -56,7 +98,7 @@ func TestSRSDeploymentVariables(t *testing.T) {
helmChartParser := NewHelmConfigParser(
NewHelmTestFromTemplate(t, helmChartRelativePath, map[string]string{
"srs.enabled": "true",
"srs.deploymentName": "test-srs-dev",
"srs.deployment.name": "test-srs-dev",
"global.imageCredentials.registry": "docker-registry.io",
"srs.srsRuntime.replicaCount": "3",
"srs.srsRuntime.srsImage": "platform-services/search-n-reporting-service:1.0.0",
Expand Down Expand Up @@ -109,7 +151,7 @@ func TestSRSDeploymentVariablesDefaultInternetEgress(t *testing.T) {
helmChartParser := NewHelmConfigParser(
NewHelmTestFromTemplate(t, helmChartRelativePath, map[string]string{
"srs.enabled": "true",
"srs.deploymentName": "test-srs-dev",
"srs.deployment.name": "test-srs-dev",
"global.imageCredentials.registry": "docker-registry.io",
"srs.srsRuntime.replicaCount": "3",
"srs.srsRuntime.srsImage": "platform-services/search-n-reporting-service:1.0.0",
Expand Down Expand Up @@ -161,7 +203,7 @@ func TestSRSDeploymentWithAffinity(t *testing.T) {
helmChartParser := NewHelmConfigParser(
NewHelmTestFromTemplate(t, helmChartRelativePath, map[string]string{
"srs.enabled": "true",
"srs.deploymentName": "test-srs",
"srs.deployment.name": "test-srs",
"global.imageCredentials.registry": "docker-registry.io",
"srs.srsRuntime.replicaCount": "1",
"srs.srsRuntime.srsImage": "platform-services/search-n-reporting-service:latest",
Expand Down
42 changes: 21 additions & 21 deletions terratest/src/test/backingservices/srs-networkpolicy_test.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
package backingservices

import (
"testing"

"github.com/stretchr/testify/require"
networkingv1 "k8s.io/api/networking/v1"
"testing"
)

func TestSRSServiceNetworkPolicy(t *testing.T){
func TestSRSServiceNetworkPolicy(t *testing.T) {

helmChartParser := NewHelmConfigParser(
NewHelmTestFromTemplate(t, helmChartRelativePath, map[string]string{
"srs.enabled": "true",
"srs.deploymentName": "test-srs",
"srs.enabled": "true",
"srs.deployment.name": "test-srs",
"srs.srsStorage.tls.enabled": "false",
},
[]string{"charts/srs/templates/srsservice_networkpolicy.yaml"}),
Expand All @@ -25,14 +26,14 @@ func TestSRSServiceNetworkPolicy(t *testing.T){
VerifySRSServiceNetworkPolicy(t, &networkPolicyObj, false)
}

func TestSRSServiceNetworkPolicyWithProvisionInternalESCluster(t *testing.T){
func TestSRSServiceNetworkPolicyWithProvisionInternalESCluster(t *testing.T) {

helmChartParser := NewHelmConfigParser(
NewHelmTestFromTemplate(t, helmChartRelativePath, map[string]string{
"srs.enabled": "true",
"srs.deploymentName": "test-srs",
"srs.srsStorage.tls.enabled": "false",
"srs.srsStorage.requireInternetAccess": "true",
"srs.enabled": "true",
"srs.deployment.name": "test-srs",
"srs.srsStorage.tls.enabled": "false",
"srs.srsStorage.requireInternetAccess": "true",
"srs.srsStorage.provisionInternalESCluster": "true",
},
[]string{"charts/srs/templates/srsservice_networkpolicy.yaml"}),
Expand All @@ -46,18 +47,18 @@ func TestSRSServiceNetworkPolicyWithProvisionInternalESCluster(t *testing.T){
VerifySRSServiceNetworkPolicy(t, &networkPolicyObj, false)
}

func TestSRSServiceNetworkPolicyWithProvisionInternalESClusterFalse(t *testing.T){
func TestSRSServiceNetworkPolicyWithProvisionInternalESClusterFalse(t *testing.T) {

helmChartParser := NewHelmConfigParser(
NewHelmTestFromTemplate(t, helmChartRelativePath, map[string]string{
"srs.enabled": "true",
"srs.deploymentName": "test-srs",
"srs.srsStorage.requireInternetAccess": "true",
"srs.srsStorage.provisionInternalESCluster": "false",
"srs.srsStorage.tls.enabled": "false",
"srs.srsStorage.domain": "es.acme.io",
"srs.srsStorage.port": "8008",
"srs.srsStorage.protocol": "https",
"srs.enabled": "true",
"srs.deployment.name": "test-srs",
"srs.srsStorage.requireInternetAccess": "true",
"srs.srsStorage.provisionInternalESCluster": "false",
"srs.srsStorage.tls.enabled": "false",
"srs.srsStorage.domain": "es.acme.io",
"srs.srsStorage.port": "8008",
"srs.srsStorage.protocol": "https",
"srs.srsStorage.basicAuthentication.enabled": "false",
},
[]string{"charts/srs/templates/srsservice_networkpolicy.yaml"}),
Expand All @@ -74,8 +75,7 @@ func TestSRSServiceNetworkPolicyWithProvisionInternalESClusterFalse(t *testing.T
func VerifySRSServiceNetworkPolicy(t *testing.T, networkPolicySvcObj *networkingv1.NetworkPolicy, internetEgress bool) {
require.Equal(t, "srs-service", networkPolicySvcObj.Spec.PodSelector.MatchLabels["app.kubernetes.io/name"])


require.ElementsMatch(t, []networkingv1.PolicyType{ "Ingress","Egress"}, networkPolicySvcObj.Spec.PolicyTypes)
require.ElementsMatch(t, []networkingv1.PolicyType{"Ingress", "Egress"}, networkPolicySvcObj.Spec.PolicyTypes)
// ingress
require.Equal(t, "0.0.0.0/0", networkPolicySvcObj.Spec.Ingress[0].From[0].IPBlock.CIDR)
require.Equal(t, int32(8080), networkPolicySvcObj.Spec.Ingress[0].Ports[0].Port.IntVal)
Expand All @@ -93,4 +93,4 @@ func VerifySRSServiceNetworkPolicy(t *testing.T, networkPolicySvcObj *networking
require.Equal(t, "", networkPolicySvcObj.Spec.PodSelector.MatchLabels["networking/allow-internet-egress"])
}

}
}
41 changes: 21 additions & 20 deletions terratest/src/test/backingservices/srs-pdb_test.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
package backingservices

import (
"testing"

"github.com/stretchr/testify/require"
"k8s.io/api/policy/v1beta1"
"testing"
)

func TestSRSServicePDB(t *testing.T){
func TestSRSServicePDB(t *testing.T) {

helmChartParser := NewHelmConfigParser(
NewHelmTestFromTemplate(t, helmChartRelativePath, map[string]string{
"srs.enabled": "true",
"srs.deploymentName": "test-srs",
"srs.enabled": "true",
"srs.deployment.name": "test-srs",
"srs.srsStorage.tls.enabled": "false",
},
[]string{"charts/srs/templates/srsservice_poddisruptionbudget.yaml"}),
Expand All @@ -25,13 +26,13 @@ func TestSRSServicePDB(t *testing.T){
VerifySRSServicePDB(t, &pdbObj)
}

func TestSRSServicePDBWithESInternetAccess(t *testing.T){
func TestSRSServicePDBWithESInternetAccess(t *testing.T) {

helmChartParser := NewHelmConfigParser(
NewHelmTestFromTemplate(t, helmChartRelativePath, map[string]string{
"srs.enabled": "true",
"srs.deploymentName": "test-srs",
"srs.srsStorage.tls.enabled": "false",
"srs.enabled": "true",
"srs.deployment.name": "test-srs",
"srs.srsStorage.tls.enabled": "false",
"srs.srsStorage.requireInternetAccess": "true",
},
[]string{"charts/srs/templates/srsservice_poddisruptionbudget.yaml"}),
Expand All @@ -45,18 +46,18 @@ func TestSRSServicePDBWithESInternetAccess(t *testing.T){
VerifySRSServicePDB(t, &pdbObj)
}

func TestSRSServicePDBWithESInternetAccessWithExternalES(t *testing.T){
func TestSRSServicePDBWithESInternetAccessWithExternalES(t *testing.T) {

helmChartParser := NewHelmConfigParser(
NewHelmTestFromTemplate(t, helmChartRelativePath, map[string]string{
"srs.enabled": "true",
"srs.deploymentName": "test-srs",
"srs.srsStorage.requireInternetAccess": "true",
"srs.srsStorage.tls.enabled": "false",
"srs.srsStorage.provisionInternalESCluster": "false",
"srs.srsStorage.domain": "es.acme.io",
"srs.srsStorage.port": "8008",
"srs.srsStorage.protocol": "https",
"srs.enabled": "true",
"srs.deployment.name": "test-srs",
"srs.srsStorage.requireInternetAccess": "true",
"srs.srsStorage.tls.enabled": "false",
"srs.srsStorage.provisionInternalESCluster": "false",
"srs.srsStorage.domain": "es.acme.io",
"srs.srsStorage.port": "8008",
"srs.srsStorage.protocol": "https",
"srs.srsStorage.basicAuthentication.enabled": "false",
},
[]string{"charts/srs/templates/srsservice_poddisruptionbudget.yaml"}),
Expand All @@ -71,11 +72,11 @@ func TestSRSServicePDBWithESInternetAccessWithExternalES(t *testing.T){
}

func VerifySRSServicePDB(t *testing.T, servicePDBObj *v1beta1.PodDisruptionBudget) {
require.Equal(t, "srs-service", servicePDBObj.Spec.Selector.MatchLabels["app.kubernetes.io/name"] )
require.Equal(t, "srs-service", servicePDBObj.Spec.Selector.MatchLabels["app.kubernetes.io/name"])
require.Equal(t, "", servicePDBObj.Spec.Selector.MatchLabels["networking/allow-internet-egress"])
}

func VerifySRSServicePDBWithEgressLabel(t *testing.T, servicePDBObj *v1beta1.PodDisruptionBudget) {
require.Equal(t, "srs-service", servicePDBObj.Spec.Selector.MatchLabels["app.kubernetes.io/name"] )
require.Equal(t, "srs-service", servicePDBObj.Spec.Selector.MatchLabels["app.kubernetes.io/name"])
require.Equal(t, "true", servicePDBObj.Spec.Selector.MatchLabels["networking/allow-internet-egress"])
}
}
Loading