Skip to content

Commit af83085

Browse files
authored
Label updater + documentation fix (#93)
* Adjusting pod label update logic to not track label as updated at detected update fails. * Emphasize in documentation that node available resources must be meet by broker resource requirements.
1 parent c268704 commit af83085

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ For other PubSub+ Software Event Broker configurations or sizes, refer to the [P
3737

3838
### 1. Get a Kubernetes environment
3939

40-
Follow your Kubernetes provider's instructions ([other options available here](https://kubernetes.io/docs/setup/)). Ensure you meet [minimum CPU, Memory and Storage requirements](docs/PubSubPlusK8SDeployment.md#cpu-and-memory-requirements) for the targeted PubSub+ Software Event Broker configuration size.
40+
Follow your Kubernetes provider's instructions ([other options available here](https://kubernetes.io/docs/setup/)). Ensure you meet [minimum CPU, Memory and Storage requirements](docs/PubSubPlusK8SDeployment.md#cpu-and-memory-requirements) for the targeted PubSub+ Software Event Broker configuration size. Important: the broker resource requirements refer to available resources on a [Kubernetes node](https://kubernetes.io/docs/concepts/scheduling-eviction/kube-scheduler/#kube-scheduler).
4141
> Note: If using [MiniKube](https://kubernetes.io/docs/setup/learning-environment/minikube/), use `minikube start` with specifying the options `--memory` and `--cpu` to assign adequate resources to the MiniKube VM. The recommended memory is 1GB plus the minimum requirements of your event broker.
4242
4343
Also have the `kubectl` tool [installed](https://kubernetes.io/docs/tasks/tools/install-kubectl/) locally.
@@ -51,7 +51,7 @@ kubectl get nodes
5151
### 2. Install and configure Helm
5252

5353
Follow the [Helm Installation notes of your target release](https://github.com/helm/helm/releases) for your platform.
54-
Note that Helm is transitioning from v2 to v3. Many deployments still use v2. The event broker can be deployed using either version, however concurrent use of v2 and v3 from the same command-line environment is not supported.
54+
Note that Helm is transitioning from v2 to v3. Some deployments still use v2. The event broker can be deployed using either version, however concurrent use of v2 and v3 from the same command-line environment is not supported.
5555

5656
On Linux a simple option to set up the latest stable release is to run:
5757

@@ -100,7 +100,7 @@ Helm is configured properly if the command `helm version` returns no error.
100100

101101
(Click on the arrow to open instructions for Helm v2 or v3)
102102

103-
<details><summary><b>Instructions using Helm v2</b></summary>
103+
<details><summary><b>Install using Helm v2</b></summary>
104104
<p>
105105

106106
a) Create a Solace PubSub+ Software Event Broker deployment for development purposes using `pubsubplus-dev`. It requires a minimum of 1 CPU and 3.6 GB of memory be available to the event broker pod.
@@ -123,7 +123,7 @@ helm install --name my-release solacecharts/pubsubplus-ha
123123
</p>
124124
</details>
125125

126-
<details><summary><b>Instructions using Helm v3</b></summary>
126+
<details><summary><b>Install using Helm v3</b></summary>
127127
<p>
128128

129129
a) Create a Solace PubSub+ Software Event Broker deployment for development purposes using `pubsubplus-dev`. It requires a minimum of 1 CPU and 2 GB of memory available to the event broker pod.

pubsubplus/templates/solaceConfigMap.yaml

+6-6
Original file line numberDiff line numberDiff line change
@@ -237,14 +237,14 @@ data:
237237
238238
# Function to set Kubernetes metadata labels
239239
set_label () {
240+
# Params: $2 label set value; $3 file where internal tracking of label value stored
240241
#Prevent overdriving Kubernetes infra, don't set activity state to same as previous state
241242
previous_state=`cat $3`
242243
if [ "${2}" = "${previous_state}" ]; then
243-
#echo "`date` INFO: ${APP}-Current and Previous state match (${2}), not updating label"
244+
#echo "`date` INFO: ${APP}-Current and Previous state match (${2}), not updating pod label"
244245
:
245246
else
246-
echo "`date` INFO: ${APP}-Updating label from `cat ${3}` to ${2}"
247-
echo ${2} > ${3}
247+
echo "`date` INFO: ${APP}-Updating pod label using K8s API from `cat ${3}` to ${2}"
248248
echo "[{\"op\": \"add\", \"path\": \"/metadata/labels/${1}\", \"value\": \"${2}\" }]" > /tmp/patch_label.json
249249
K8S=https://kubernetes.default.svc.cluster.local:$KUBERNETES_SERVICE_PORT
250250
KUBE_TOKEN=$(</var/run/secrets/kubernetes.io/serviceaccount/token)
@@ -254,18 +254,18 @@ data:
254254
--request PATCH --data "$(cat /tmp/patch_label.json)" \
255255
-H "Authorization: Bearer $KUBE_TOKEN" -H "Content-Type:application/json-patch+json" \
256256
$K8S/api/v1/namespaces/$NAMESPACE/pods/$HOSTNAME ; then
257-
# Fall back to alternative method to update label
257+
# Label update didn't work this way, fall back to alternative legacy method to update label
258258
if ! curl -sSk --output /dev/null -H "Authorization: Bearer $KUBE_TOKEN" --request PATCH --data "$(cat /tmp/patch_label.json)" \
259259
-H "Content-Type:application/json-patch+json" \
260260
https://$KUBERNETES_SERVICE_HOST:$KUBERNETES_PORT_443_TCP_PORT/api/v1/namespaces/$STATEFULSET_NAMESPACE/pods/$HOSTNAME ; then
261261
echo "`date` ERROR: ${APP}-Unable to update pod label, check access from pod to K8s API or RBAC authorization" >&2
262262
exit 1
263263
fi
264-
echo "`date` INFO: ${APP}-Failed to update label from ${3} to ${2}, retrying"
265264
fi
265+
echo ${2} > ${3} # Track latest value of label
266266
fi
267267
}
268-
# note that there are no re-tries here, if check fails then return not ready.
268+
# Main logic: note that there are no re-tries here, if check fails then return not ready.
269269
APP=`basename "$0"`
270270
state_file=/tmp/activity_state
271271
if [ ! -f ${state_file} ]; then # State file not found, creating

0 commit comments

Comments
 (0)