collectord-splunk-openshift
Collectord chart for Monitoring OpenShift in Splunk Enterprise and Splunk Cloud
About this chart
Collectord Helm Charts for Monitoring OpenShift in Splunk Enterprise and Splunk Cloud
This helm chart provides a way to deploy Collectord in OpenShift clusters for monitoring OpenShift in Splunk Enterprise and Splunk Cloud. Please refer to the documentation on how to install Monitoring OpenShift application in Splunk here.
Prerequisites
- OpenShift 4.11+
- Helm 3.8+
Pod security
The DaemonSet reads the node's filesystem, journal and cgroup tree through a host mount, runs
on the host network and is privileged; the chart ships the SecurityContextConstraints that admits
it, bound to the release's service account, and OpenShift's Pod Security Admission label sync
follows that grant. The addon Deployment (the cluster-wide watcher for events, objects and
annotated Prometheus endpoints) runs without privileges, capabilities or privilege escalation and
under the runtime's default seccomp profile (collectord.deployment.securityContext). It runs as
root, and in the spc_t SELinux domain, only to read the state directory it shares with the
DaemonSet on its node: a hostPath the DaemonSet writes as root, which is never relabeled, so a
confined container could not read it.
The ClusterRole grants read access to the objects Collectord attaches as metadata and
nodes/metrics for the kubelet scrape, which goes to the kubelet on the node directly, at the
node's own IP (https://${KUBERNETES_NODEIP}:10250/metrics, read from the downward API). Not
loopback: the kubelet always listens on the node IP and holds that port before any pod can, while
loopback is free for a host-network pod to take and be handed the bearer token, the serving
certificate not being verified (OpenShift signs it with its kubelet-serving CA, not the service
account CA; point certPath at that CA and set insecure: false to verify, which also closes the
one residual exposure of an unverified scrape: a host-network pod that takes the port while the
kubelet restarts is handed the collector's read-only token). It does not grant nodes/proxy: that
subresource is only needed to reach the kubelet through the API server's node proxy, and a get
on it is enough to exec into any pod on the node - the same token, exec everywhere, with nothing
to race.
On secrets it grants get and nothing else - never list or watch, which cluster-wide
return the contents of every Secret in the cluster. The one feature that reads a Secret is a
SplunkOutput custom resource whose spec.tokenFromSecret names a Secret and a key instead of
carrying the HEC token inline: when an output setting points at that resource
(splunk::user/<namespace>/<name>, set through a collectord.io/output annotation or the
configuration), Collectord reads that one Secret by name, in that namespace. An annotation on a pod
or a namespace, or one a Configuration resource gives a pod, may name only a SplunkOutput of the
object's own namespace: naming another namespace's would send its data with that namespace's token
into that namespace's indexes, so Collectord rejects the annotation and keeps the output it would
have replaced. Set configuration.general.kubernetes.crossNamespaceUserOutputs: true where one
SplunkOutput serves several namespaces on purpose. If you add an
[input.kubernetes_watch::...] section with kind = Secret, that watch needs list and watch
on Secrets; add them under collectord.clusterRole.rules yourself, and prefer a namespace-scoped
watch and Role where you can.
The DaemonSet runs under the built-in system-node-critical PriorityClass and the addon Deployment
under system-cluster-critical, as a node's own agents do. The kubelet never evicts pods of these
classes, and while a node is under disk pressure it admits no other: under any lower class
Collectord is evicted and its replacement refused until the pressure ends, so the node stops
reporting when its disk alerts matter most. A new addon pod (an upgrade, a deleted pod) still waits
for a node without disk pressure: the scheduler places a pod on one only if it tolerates the
node.kubernetes.io/disk-pressure taint, as the DaemonSet's do. The scheduler and the kubelet
preempt lower-priority pods to make room for a Collectord pod that does not fit, and no eviction
bounds Collectord's own disk use, so Collectord bounds it: it lets go of the rotated logs it holds
open once the log filesystem's free space falls under
[input.files] retainedLogsMinFreeSpacePercent (20 by default). Kubernetes admits these classes in
any namespace, but a cluster can limit them to namespaces holding a ResourceQuota scoped to them, as
GKE Standard does; the chart renders one in the release namespace
(collectord.priorityClass.resourceQuota), which limits nothing elsewhere. To run both workloads
under a class of their own instead, as releases before 26.10.1 did, set
collectord.priorityClass.name: collectorforopenshift-critical: the chart creates it at the highest
value a user-defined class may have (collectord.priorityClass.value). With
collectord.priorityClass.create: false the name is a class that exists already
(collectorforopenshift-critical when none is set), and collectord.daemonset.priorityClassName
and collectord.deployment.priorityClassName name each workload's class apart.
Critical pods are also stopped last on a graceful node shutdown, in the kubelet's
shutdownGracePeriodCriticalPods window, which is where a log shipper wants to be, after the pods
whose last lines it forwards. Collectord's own shutdown drain, [general] shutdownTimeout, has to
fit inside that window and inside the pod's own grace period: the chart leaves
terminationGracePeriodSeconds at the Kubernetes default of 30 seconds, and a longer drain needs
it raised (collectord.daemonset.terminationGracePeriodSeconds, and the deployment twin), or the
kubelet kills the pod mid-drain.
Getting Started
At this point we assume that you have installed Monitoring OpenShift application in Splunk, and enabled Splunk HTTP Event Collector (HEC). Please refer to Monitoring OpenShift - Installation on how to do that.
Review and accept license agreement. If your organization has not purchased a license, request an evaluation license key with this automated form. License key will be sent to your email address immediately on request.
Create a file named my_values.yaml with the content similar to:
collectord:
configuration:
general:
acceptLicense: true
license: '<your_license_key>'
fields:
openshift_cluster: 'dev'
outputs:
splunk:
default:
url: 'https://hec.example.com:8088/services/collector/event/1.0'
token: 'B5A79AAD-D822-46CC-80D1-819F80D7BFB0'
insecure: true
Where you will agree to the license agreement, include your license key, and configure Splunk default output.
You can generate a YAML file for deployment using the following command:
helm template collectorforopenshift \
--namespace collectorforopenshift \
--create-namespace \
--include-crds \
-f my_values.yaml \
oci://registry.outcold.solutions/outcoldsolutions/charts/collectord-splunk-openshift > collectorforopenshift.yaml
To install the chart, run the following command:
helm install collectorforopenshift \
--namespace collectorforopenshift \
--create-namespace \
-f my_values.yaml \
oci://registry.outcold.solutions/outcoldsolutions/charts/collectord-splunk-openshift
The chart and Collectord's image come from registry.outcold.solutions, whose pulls also reach
ghcr.io and pkg-containers.githubusercontent.com: where egress is filtered, allow all three.
Docker Hub has the same chart, oci://registry-1.docker.io/outcoldsolutions/collectord-splunk-openshift,
and the same images: to pull the image from there, set
collectord.image.repository: docker.io/outcoldsolutions/collectorforopenshift.
To pin the image by digest, set collectord.image.digest to the sha256: digest of the tag you pull;
the tag then only labels it. Look the digest up with
docker buildx imagetools inspect registry.outcold.solutions/outcoldsolutions/collectorforopenshift:<tag>
(the Digest: line). The FIPS tag and the Red Hat certified image have digests of their own.
Uninstalling
helm uninstall collectorforopenshift --namespace collectorforopenshift
helm uninstall leaves the chart's SecurityContextConstraints in the cluster: the chart
installs it as a Helm hook, and Helm does not remove hook resources. It admits privileged pods
run by the service account collectorforopenshift of the release's namespace, and
would admit a service account created under that name later, so delete it as well. It is named
after the release, or scc.name when you set one:
oc delete scc collectorforopenshift
The custom resource definitions (configurations.collectord.io and splunkoutputs.collectord.io)
stay too, as Helm never deletes a chart's CRDs. Delete them only when no other Collectord release
is left in the cluster: deleting a definition deletes every object of that kind.
Configuration
Collectord is configured using the ini file format. You can find a reference with all possible configurations here.
This helm chart allows you to customize and override those configurations.
Using my_values.yaml as a template, you can customize the configuration to suit your needs. Please refer to the ./values.yaml for default configuration and possible values.
Using secrets
If you want to store some configurations in a secret, first you need to create a secret with the ini format, that Collectord can read from. For example, if we want to store license, and token in secret file,
first we will create a secret file with the ini format and .conf extension with name 101-general.conf.
[general]
license = <your_license_key>
[output.splunk]
token = B5A79AAD-D822-46CC-80D1-819F80D7BFB0
Using this file we can create a secret using the ini file:
oc new-project collectorforopenshift
oc create secret generic collectord-secret \
--from-file=101-general.conf=101-general.conf \
-n collectorforopenshift
After that we can remove values that we provided in the secret file in the my_values.yaml file.
collectord:
secrets:
- name: collectord-secret
configuration:
general:
acceptLicense: true
fields:
openshift_cluster: 'dev'
outputs:
splunk:
default:
url: 'https://hec.example.com:8088/services/collector/event/1.0'
insecure: true
And install it using the following command (don't need to create namespace as we already created it):
helm install collectorforopenshift \
--namespace collectorforopenshift \
-f my_values.yaml \
oci://registry.outcold.solutions/outcoldsolutions/charts/collectord-splunk-openshift
NOTE: Collectord reads all files with
.confextension from the/configdirectory and subdirectories. It will sort them by name in ascending order before reading them. In a case of file names001-general.confand101-general.conf, all values in101-general.confwill override values in001-general.conf.
Secondary Splunk Output
Collectord supports multiple Splunk outputs. You can configure an additional Splunk output by adding a new section to the my_values.yaml file. For example:
collectord:
configuration:
general:
acceptLicense: true
fields:
openshift_cluster: 'dev'
outputs:
splunk:
default:
url: 'https://hec.example.com:8088/services/collector/event/1.0'
token: 'B5A79AAD-D822-46CC-80D1-819F80D7BFB0'
insecure: true
apps:
url: 'https://hec-apps.example.com:8088/services/collector/event/1.0'
token: '107E857B-C311-4C72-97E4-FBE601A6B39E'
insecure: true
After that you can reference this output in annotations like collectord.io/output=splunk::apps
Sending events over Splunk-to-Splunk (S2S)
outputs.s2s sends events and metrics-index records to the indexers' receiving port (a splunktcp
input, splunktcp-ssl for tls://) with the protocol Splunk forwarders use, instead of to HTTP
Event Collector. The indexers must run Splunk 9.1 or later. Make it the default output, or name it
(s2s, s2s::<name>) in an input's output or metricsOutput; the HEC output (outputs.splunk)
can stay beside it. Indexer acknowledgements are always on: an event is acknowledged to its source
only once an indexer confirmed it, and whatever a connection carried when it ended is sent again
(and may be indexed twice: Splunk does not deduplicate). Each thread holds one connection and moves
to the next url every loadBalanceFrequency.
The S2S output is in beta in 26.10.2.
collectord:
configuration:
general:
defaultOutput: s2s
outputs:
s2s:
default:
url: 'tls://idx1.example.com:9998'
urls:
- 'tls://idx2.example.com:9998'
# the forwarder token of the indexers' [splunktcptoken://...] stanza, if they have one
token: ''
defaultIndex: 'openshift'
defaultMetricsIndex: 'openshift_metrics'
| Key | Default | |
|---|---|---|
url, urls | tcp://host:port or tls://host:port | |
urlSelection | random | random, round-robin (each thread starts on its own url) or random-with-round-robin (a random start, then the next url): where a thread starts and moves to |
token | the forwarder token of the indexers' `[splunktcpto |
Deploy collectord-splunk-openshift with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has collectord-splunk-openshift on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartcollectord-splunk-openshift is pinned at v2610.2.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below opentenant validate opentenant.yaml terraform init && terraform apply