Skip to content

Commit ca0bfcb

Browse files
authored
Server certs support (#100)
* Added support to configure server certificates for TLS * Improved logic to set and log pod active labels as part of readiness check * Updated names and file locations for readiness check related files to align with long-term broker file system strategy * Renamed internal script setup-config-sync to startup-broker * Added more default exposed ports, unified port names * Added automation coverage for TLS configuration * Fixed reference to Helm hub * Updated chart version to 2.4 Closes issues #87, #92, #94, #98
1 parent 29c4db4 commit ca0bfcb

10 files changed

+438
-297
lines changed

.github/workflows/build-test.yml

+11-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: build
22

3-
# Controls when the action will run.
3+
# Controls when the action will run.
44
on:
55
# pull_request:
66

@@ -53,7 +53,10 @@ jobs:
5353
run: |
5454
REPO=$(echo ${{ secrets.BROKER_DOCKER_IMAGE_REF }} | cut -d ":" -f 1)
5555
TAG=$(echo ${{ secrets.BROKER_DOCKER_IMAGE_REF }} | cut -d ":" -f 2)
56-
helm install my-release pubsubplus --set solace.size=dev,solace.redundancy=true,solace.usernameAdminPassword=admin,image.repository=$REPO,image.tag=$TAG
56+
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout tls.key -out tls.crt -subj "/CN=*"
57+
kubectl create secret tls test-tls --key="tls.key" --cert="tls.crt"
58+
59+
helm install my-release pubsubplus --set solace.size=dev,solace.redundancy=true,tls.enabled=true,tls.serverCertificatesSecret=test-tls,solace.usernameAdminPassword=admin,image.repository=$REPO,image.tag=$TAG
5760
kubectl get statefulset,svc,pods,pvc,pv --show-labels
5861
echo "Waiting for broker to become active"
5962
sleep 40; kubectl describe nodes
@@ -62,19 +65,15 @@ jobs:
6265
until kubectl get pods --show-labels | grep pubsubplus-2 | grep -m 1 -E '1/1'; do sleep 10; done
6366
until kubectl get pods --show-labels | grep pubsubplus- | grep -m 1 -E 'active=true'; do sleep 10; done
6467
kubectl get statefulset,svc,pods,pvc,pv --show-labels
65-
if [[ `kubectl get po --show-labels | grep -c "1/1"` -ne 3 ]]; then echo "Some pods are not ready!"; kubectl get po --show-labels; exit 1; fi
66-
#
67-
kubectl logs my-release-pubsubplus-0 | grep [.]sh
68-
kubectl logs my-release-pubsubplus-1 | grep [.]sh
69-
kubectl logs my-release-pubsubplus-2 | grep [.]sh
70-
#
68+
bash -c 'if [[ `kubectl get po --show-labels | grep -c "1/1"` -ne 3 ]]; then echo "Some pods are not ready!"; kubectl get po --show-labels; exit 1; fi'
7169
export url="$(kubectl get statefulset,svc,pods,pvc,pv --show-labels | grep LoadBalancer | awk '{print $4}')"; echo $url
7270
curl -O https://sftp.solace.com/download/SDKPERF_C_LINUX64
7371
tar -xvf SDKPERF_C_LINUX64
74-
pubSubTools/sdkperf_c -cip=$url -mn=100000 -mr=0 -ptl=t1 -stl=t1 | grep "Total Messages"
72+
pubSubTools/sdkperf_c -cip=tcp://$url:55555 -mn=10000 -mr=0 -ptl=t1 -stl=t1 | grep "Total Messages"
73+
pubSubTools/sdkperf_c -cip=tcps://$url:55443 -mn=10000 -mr=0 -ptl=t1 -stl=t1 | grep "Total Messages"
7574
sleep 30
76-
curl -sS -u admin:admin http://$url:8080/SEMP -d "<rpc><show><redundancy></redundancy></show></rpc>"
77-
curl -sS -u admin:admin http://$url:8080/SEMP -d "<rpc><show><config-sync></config-sync></show></rpc>"
75+
curl -k -sS -u admin:admin https://$url:1943/SEMP -d "<rpc><show><redundancy></redundancy></show></rpc>"
76+
curl -k -sS -u admin:admin https://$url:1943/SEMP -d "<rpc><show><config-sync></config-sync></show></rpc>"
7877
if [[ -z `curl -sS -u admin:admin http://$url:8080/SEMP -d "<rpc><show><config-sync></config-sync></show></rpc>" | grep "<oper-status>Up</oper-status>"` ]] ; then echo "config-sync not up!"; exit 1; fi
7978
helm list
8079
helm delete $(helm list | grep deployed | awk '{print $1}')
@@ -125,4 +124,4 @@ jobs:
125124
if: ${{ always() }}
126125
run: |
127126
gcloud container clusters delete $TESTCLUSTERNAME --quiet --zone us-east4-a
128-
sleep 20; gcloud compute disks list | grep gha-test | sed 1d $rpt | while read -r a b c; do gcloud compute disks delete $a --zone $b --quiet || echo "Run into issues with deleting $a, skipping"; done
127+
gcloud compute disks list | grep gha-test | sed 1d $rpt | while read -r a b c; do gcloud compute disks delete $a --zone $b --quiet; done

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ The [Solace PubSub+ Platform](https://solace.com/products/platform/)'s [software
66

77
## Overview
88

9-
This document provides a quick getting started guide to install a software event broker in various configurations onto a [Kubernetes](https://kubernetes.io/docs/home/) cluster. The recommended software event broker version is 9.4 or later.
9+
This project is a best practice template intended for development and demo purposes. The tested and recommended Solace PubSub+ Software Event Broker version is 9.8.
1010

11-
*Detailed* *documentation* is provided in the [Solace PubSub+ Software Event Broker on Kubernetes Documentation](docs/PubSubPlusK8SDeployment.md).
11+
This document provides a quick getting started guide to install a software event broker in various configurations onto a [Kubernetes](https://kubernetes.io/docs/home/) cluster.
1212

13-
This quick start is intended mainly for development and demo purposes. Consult the [Deployment Considerations](https://github.com/SolaceProducts/pubsubplus-kubernetes-quickstart/blob/master/docs/PubSubPlusK8SDeployment.md#pubsub-event-broker-deployment-considerations) section of the Documentation when planning your deployment.
13+
Detailed documentation is provided in the [Solace PubSub+ Software Event Broker on Kubernetes Documentation](docs/PubSubPlusK8SDeployment.md). Consult the [Deployment Coonsiderations](https://github.com/SolaceProducts/pubsubplus-kubernetes-quickstart/blob/master/docs/PubSubPlusK8SDeployment.md#pubsub-event-broker-deployment-considerations) section of the Documentation when planning your deployment.
1414

1515
This document is applicable to any platform supporting Kubernetes, with specific hints on how to set up a simple MiniKube deployment on a Linux-based machine. To view examples of other Kubernetes platforms see:
1616

@@ -26,7 +26,7 @@ Solace PubSub+ Software Event Broker can be deployed in either a three-node High
2626

2727
We recommend using the Helm tool for convenience. An [alternative method](/docs/PubSubPlusK8SDeployment.md#alternative-deployment-with-generating-templates-for-the-kubernetes-kubectl-tool) using generated templates is also provided.
2828

29-
In this quick start we go through the steps to set up a PubSub+ Software Event Broker using [Solace PubSub+ Helm charts](//hub.helm.sh/charts/solace).
29+
In this quick start we go through the steps to set up a PubSub+ Software Event Broker using [Solace PubSub+ Helm charts](//artifacthub.io/packages/search?ts_query_web=solace).
3030

3131
There are three Helm chart variants available with default small-size configurations:
3232
1. `pubsubplus-dev` - recommended PubSub+ Software Event Broker for Developers (standalone) - no guaranteed performance

docs/PubSubPlusK8SDeployment.md

+51-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@ Contents:
1818
- [Creating a new storage class](#creating-a-new-storage-class)
1919
- [Using an existing PVC (Persistent Volume Claim)](#using-an-existing-pvc-persistent-volume-claim-)
2020
- [Using a pre-created provider-specific volume](#using-a-pre-created-provider-specific-volume)
21-
+ [Exposing the PubSub+ Event Broker Services](#exposing-the-pubsub-event-broker-services)
21+
+ [Exposing the PubSub+ Event Broker Services](#exposing-the-pubsub-software-event-broker-services)
2222
- [Using pod label "active" to identify the active event broker node](#using-pod-label-active-to-identify-the-active-event-broker-node)
23-
+ [The PubSub+ Docker image](#the-pubsub-docker-image)
23+
+ [Enabling use of TLS to access broker services](#enabling-use-of-tls-to-access-broker-services)
24+
- [Setting up TLS](#setting-up-tls)
25+
- [Rotating the server key](#rotating-the-server-key)
26+
+ [The PubSub+ Docker image](#the-pubsub-software-event-broker-docker-image)
2427
- [Using a public registry](#using-a-public-registry)
2528
- [Using private registries](#using-private-registries)
2629
- [Using ImagePullSecrets for signed images](#using-imagepullsecrets-for-signed-images)
@@ -242,6 +245,48 @@ This label is set by the `readiness_check.sh` script in `pubsubplus/templates/so
242245
- the Kubernetes service account associated with the Solace pod must have sufficient rights to patch the pod's label when the active event broker is service ready
243246
- the Solace pods must be able to communicate with the Kubernetes API at `kubernetes.default.svc.cluster.local` at port $KUBERNETES_SERVICE_PORT. You can find out the address and port by [SSH into the pod](#ssh-access-to-individual-message-brokers).
244247

248+
### Enabling use of TLS to access broker services
249+
250+
#### Setting up TLS
251+
252+
Default deployment does not have TLS over TCP enabled to access broker services. Although the exposed `service.ports` include ports for secured TCP, only the insecure ports can be used by default.
253+
254+
To enable accessing services over TLS a server key and certificate must be configured on the broker.
255+
256+
It is assumed that a provider out of scope of this document will be used to create a server key and certificate for the event broker, that meet the [requirements described in the Solace Documentation](https://docs.solace.com/Configuring-and-Managing/Managing-Server-Certs.htm). If the server key is password protected it shall be transformed to an unencrypted key, e.g.: `openssl rsa -in encryedprivate.key -out unencryed.key`.
257+
258+
The server key and certificate must be packaged in a Kubernetes secret, for example by [creating a TLS secret](https://kubernetes.io/docs/concepts/configuration/secret/#tls-secrets). Example:
259+
```
260+
kubectl create secret tls <my-tls-secret> --key="<my-server-key-file>" --cert="<my-certificate-file>"
261+
```
262+
263+
This secret name and related parameters shall be specified when deploying the PubSub+ Helm chart:
264+
```
265+
tls:
266+
enabled: true # set to false by default
267+
serverCertificatesSecret: <my-tls-secret> # replace by the actual name
268+
certFilename: # optional, default if not provided: tls.crt
269+
certKeyFilename: # optional, default if not provided: tls.key
270+
```
271+
272+
Note: ensure filenames are matching the files reported from running `kubectl describe secret <my-tls-secret>`.
273+
274+
Here is an example new deployment with TLS enabled using default `certFilename` and `certKeyFilename`:
275+
```
276+
helm install my-release solacecharts/pubsubplus \
277+
--set tls.enabled=true,tls.serverCertificatesSecret=<my-tls-secret>
278+
```
279+
280+
Important: it is not possible to update an existing deployment to enable TLS that has been created without TLS enabled, by a simply using the [modify deployment](#modifying-or-upgrading-a-deployment) procedure. In this case, for the first time, certificates need to be [manually loaded and set up](//docs.solace.com/Configuring-and-Managing/Managing-Server-Certs.htm) on each broker node. After that it is possible to use `helm upgrade` with a secret specified.
281+
282+
#### Rotating the server key
283+
284+
In the event the server key or certificate need to be rotated a new Kubernetes secret must be created, which may require deleting and recreating the old secret if using the same name.
285+
286+
Next, if using the same secret name, the broker Pods need to be restarted, one at a time waiting to reach `1/1` availability before continuing on the next one: starting with the Monitor (ordinal -2), followed by the node in backup role with `active=false` label, and finally the third node. If using a new secret name, the [modify deployment](#modifying-or-upgrading-a-deployment) procedure can be used and an automatic rolling update will follow these steps restarting the nodes one at a time.
287+
288+
Note: a pod restart will result in provisioning the server certificate from the secret again so it will revert back from any other server certificate that may have been provisioned on the broker through other mechanism.
289+
245290
### The PubSub+ Software Event Broker Docker image
246291
247292
The `image.repository` and `image.tag` parameters combined specify the PubSub+ Software Event Broker Docker image to be used for the deployment. They can either point to an image in a public or a private Docker container registry.
@@ -318,7 +363,7 @@ If other settings control `fsGroup` and `runAsUser`, e.g: when using a [PodSecur
318363

319364
#### Securing Helm v2
320365

321-
Using current Helm v2, Helm's server-side component Tiller must be installed in your Kubernetes environment with rights granted to manage deployments. By default, Tiller is deployed in a permissive configuration. There are best practices to secure Helm and Tiller, and they need to be applied carefully if strict security is required; for example, in a production environment.
366+
Using Helm v2, Helm's server-side component Tiller must be installed in your Kubernetes environment with rights granted to manage deployments. By default, Tiller is deployed in a permissive configuration. There are best practices to secure Helm and Tiller, and they need to be applied carefully if strict security is required; for example, in a production environment.
322367

323368
[Securing your Helm Installation](//v2.helm.sh/docs/using_helm/#securing-your-helm-installation ) provides an overview of the Tiller-related security issues and recommended best practices.
324369

@@ -329,6 +374,9 @@ Particularly, the [Role-based Access Control section of the Helm documentation](
329374
Services require [pod label "active"](#using-pod-label-active-to-identify-the-active-event-broker-node) of the serving event broker.
330375
* In a controlled environment it may be necessary to add a [NetworkPolicy](//kubernetes.io/docs/concepts/services-networking/network-policies/ ) to enable [required communication](#using-pod-label-active-to-identify-the-active-event-broker-node).
331376

377+
#### Securing TLS server key and certificate
378+
379+
Using secrets for TLS server keys and certificates follows Kubernetes recommendations, however, particularly in a production environment, additional steps are required to ensure only authorized access to these secrets following Kubernetes industry best practices, including setting tight RBAC permissions and fixing possible security holes.
332380

333381
## Deployment Prerequisites
334382

pubsubplus/Chart.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: v1
22
description: Deploy Solace PubSub+ Event Broker Singleton or HA redundancy group onto a Kubernetes Cluster
33
name: pubsubplus
4-
version: 2.3.0
4+
version: 2.4.0
55
icon: https://solaceproducts.github.io/pubsubplus-kubernetes-quickstart/images/PubSubPlus.png
66
maintainers:
77
- name: Solace Community Forum

pubsubplus/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ For more ways to override default chart values, refer to [Customizing the Helm C
9191
| `securityContext.runAsUser` | Specifies `runAsUser` in pod security context | set to default PubSub+ appuser id 1000001 |
9292
| `serviceAccount.create` | `true` will create a service account dedicated to the deployment in the namespace | `true` |
9393
| `serviceAccount.name` | Refer to https://helm.sh/docs/topics/chart_best_practices/rbac/#using-rbac-resources | Undefined |
94+
| `tls.enabled` | Enable to use TLS to access exposed broker services | `false` (not enabled) |
95+
| `tls.serverCertificatesSecret` | Name of the Kubernetes Secret that contains the certificates - required if TLS is enabled | Undefined |
96+
| `tls.certFilename` | Name of the Certificate file in the `serverCertificatesSecret` | `tls.crt` |
97+
| `tls.certKeyFilename` | Name of the Key file in the `serverCertificatesSecret` | `tls.key` |
9498
| `service.type` | How to expose the service: options include ClusterIP, NodePort, LoadBalancer | `LoadBalancer` |
9599
| `service.annotations` | service.annotations allows to add provider-specific service annotations | Undefined |
96100
| `service.ports` | Define PubSub+ service ports exposed. servicePorts are external, mapping to cluster-local pod containerPorts | initial set of frequently used ports, refer to values.yaml |

pubsubplus/templates/NOTES.txt

+7
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ Watch progress by running:
66

77
For troubleshooting, refer to ***TroubleShooting.md***
88

9+
== TLS support ==
10+
{{- if not .Values.tls.enabled }}
11+
TLS has not been enabled for this deployment.
12+
{{- else }}
13+
TLS is enabled, using secret {{ .Values.tls.serverCertificatesSecret }} for server certificates configuration.
14+
{{- end }}
15+
916
== Admin credentials and access ==
1017
{{- if not .Values.solace.usernameAdminPassword }}
1118
*********************************************************************

pubsubplus/templates/service-discovery.yaml

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@ metadata:
1313
spec:
1414
ports:
1515
- port: 8080
16-
name: semp
16+
name: tcp-semp
1717
- port: 8741
18-
name: ha-mate-link
18+
name: tcp-ha-mate-link
1919
- port: 8300
20-
name: ha-conf-sync0
20+
name: tcp-ha-conf-sync0
2121
- port: 8301
22-
name: ha-conf-sync1
22+
name: tcp-ha-conf-sync1
2323
- port: 8302
24-
name: ha-conf-sync2
24+
name: tcp-ha-conf-sync2
2525
clusterIP: None
2626
selector:
2727
app.kubernetes.io/name: {{ template "solace.name" . }}
2828
app.kubernetes.io/instance: {{ .Release.Name }}
2929
publishNotReadyAddresses: true
30-
{{- end }}
30+
{{- end }}

0 commit comments

Comments
 (0)