Customizing probe rules in ConfigMap
This section shows how to modify the default rules file in the probe ConfigMap
using the command line.
Note: The ConfigMap
will be deleted when the probe instance is deleted.
You should keep a copy of any custom rules file in case you need to use them in the future.
Getting the ConfigMap name and rules filename
You need to determine the probe instance name and get the ConfigMap
name that
contains the probe rules files. The ConfigMap
with the -rules
suffix should contain the rules files.
The following command uses example-kafkaprobe
as the probe instance name to
query the ConfigMap
using the app.kubernetes.io/instance
label.
The --namespace
option can also be specified if required:
$ kubectl get configmap -l app.kubernetes.io/instance=example-kafkaprobe
NAME DATA AGE
example-kafkaprobe-probe-mb-kfk-config 8 12d
example-kafkaprobe-probe-mb-kfk-rules 5 12d
Note: The rules file(s) name from the Data
field. You need to extract the
files that you want to customize. This example customizes the
message_bus.rules
.
$ kubectl describe configmap example-kafkaprobe-probe-mb-kfk-rules
Name: example-kafkaprobe-probe-mb-kfk-rules
Namespace: default
Labels: app.kubernetes.io/component=mb
app.kubernetes.io/instance=example-kafkaprobe
app.kubernetes.io/managed-by=Tiller
app.kubernetes.io/name=probe-mb-kfk
hdm.ibm.com/chartversion=3.0.0
hdm.ibm.com/lastreconciled=
hdm.ibm.com/resourceowner=
helm.sh/chart=ibm-netcool-probe-messagebus-kafka-prod
release=example-kafkaprobe
Annotations: hdm.ibm.com/lastknownstate: 67c4b74cd6d3b5c44718b38e3cd4517b
Data
====
message_bus.rules:
----
<message_bus.rules file content omitted>
message_bus_cbe.rules:
----
<message_bus_cbe.rules file content omitted>
message_bus_netcool.rules:
----
<message_bus_netcool.rules content omitted>
message_bus_wbe.rules:
----
<message_bus_wbe.rules content omitted>
message_bus_wef.rules:
----
<message_bus_wef.rules content omitted>
Events: <none>
Extracting and Customizing the rules file
To customize the message_bus.rules
file, first extract the file into you local
host:
kubectl get configmap example-kafkaprobe-probe-mb-kfk-rules -o jsonpath='{.data.message_bus\.rules}' > message_bus.rules
Then edit the file to make any customization. Ensure that the rules file's syntax is correct.
Patching the Configmap
To patch the ConfigMap
, first create a YAML file of the "new"
ConfigMap
using the command below. Note that the name of the
ConfigMap
must be the same as the original ConfigMap
. The output
of this command is saved into the file:
example-kafkaprobe-probe-mb-kfk-rules-custom.yaml.
kubectl create configmap --dry-run -o yaml \
--from-file=message_bus.rules \
example-kafkaprobe-probe-mb-kfk-rules.yaml > example-kafkaprobe-probe-mb-kfk-rules-custom.yaml
Use the kubectl patch
command to patch the existing ConfigMap
with the new YAML file (example-kafkaprobe-probe-mb-kfk-rules-custom.yaml)
kubectl patch configmap example-kafkaprobe-probe-mb-kfk-rules \
--patch "$(cat example-kafkaprobe-probe-mb-kfk-rules-custom.yaml)"
Verify that the ConfigMap
is correctly patched.
kubectl describe configmap example-kafkaprobe-probe-mb-kfk-rules-custom
Restarting the Probe Pods
Kubernetes pods do not detect any changes to the ConfigMap
and the probe pods
must be restarted to reload the updated ConfigMap
.
To restart the pod, scale down and scale up the deployment using the kubectl scale
deployment
command as shown below:
kubectl scale deployment example-kafkaprobe-probe-mb-kfk --replicas=0
kubectl scale deployment example-kafkaprobe-probe-mb-kfk --replicas=1
Verify that the container is restarting and running:
$ kubectl get pods -l app.kubernetes.io/instance=example-kafkaprobe
NAME READY STATUS RESTARTS AGE
example-kafkaprobe-probe-mb-kfk-8684b6b947-jk76q 1/1 Running 0 50s