Files
homelab/proxmox/kustomize/wazuh/wazuh/wazuh_managers/wazuh-worker-sts.yaml
T
2026-10-24 01:05:15 +03:00

235 lines
9.0 KiB
YAML

# Copyright (C) 2019, Wazuh Inc.
#
# This program is a free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public
# License (version 2) as published by the FSF - Free Software
# Foundation.
# Wazuh workers StatefulSet
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: wazuh-manager-worker
namespace: wazuh
spec:
replicas: 2
selector:
matchLabels:
app: wazuh-manager
node-type: worker
serviceName: wazuh-cluster
podManagementPolicy: Parallel
template:
metadata:
labels:
app: wazuh-manager
node-type: worker
name: wazuh-manager-worker
spec:
# No workload talks to the Kubernetes API.
automountServiceAccountToken: false
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
topologyKey: kubernetes.io/hostname
labelSelector:
matchLabels:
app: wazuh-manager
node-type: worker
volumes:
# The Secret gets the pod's fsGroup and group read, so the service user
# could read it: an init container copies it to a root-only file.
- name: wazuh-credentials
emptyDir:
medium: Memory
sizeLimit: 1Mi
- name: wazuh-credentials-secret
secret:
secretName: manager-credentials
defaultMode: 0400
- name: wazuh-manager-certs-raw
secret:
secretName: manager-certs
defaultMode: 0400
- name: wazuh-manager-certs
emptyDir: {}
securityContext:
fsGroup: 101
initContainers:
- name: install-credentials
image: 'wazuh/wazuh-manager:5.0.0-rc1'
command:
- /bin/sh
- -c
- 'umask 077 && cp /credentials-secret/wazuh-credentials /run/secrets/wazuh-credentials && chmod 0400 /run/secrets/wazuh-credentials'
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop: ["ALL"]
resources:
requests:
cpu: 50m
memory: 64Mi
limits:
cpu: 100m
memory: 128Mi
volumeMounts:
- name: wazuh-credentials-secret
mountPath: /credentials-secret
readOnly: true
- name: wazuh-credentials
mountPath: /run/secrets
- name: init-wazuh-etc
image: 'wazuh/wazuh-manager:5.0.0-rc1'
command:
- /bin/sh
- -c
- |
if [ -z "$(ls -A /pvc-etc)" ]; then
cp -a /var/wazuh-manager/etc/* /pvc-etc/
chown root:101 /pvc-etc/certs
chmod 1770 /pvc-etc/certs
fi
# data/ is not in the image's permanent-data snapshot.
if [ -z "$(ls -A /pvc-data)" ]; then
cp -a /var/wazuh-manager/data/. /pvc-data/
fi
cp /tmp/certs-raw/root-ca.pem /etc/wazuh-certs-final/root-ca.pem
cp /tmp/certs-raw/manager.pem /etc/wazuh-certs-final/indexer-connector.pem
cp /tmp/certs-raw/manager-key.pem /etc/wazuh-certs-final/indexer-connector-key.pem
chown root:101 /etc/wazuh-certs-final/root-ca.pem /etc/wazuh-certs-final/indexer-connector.pem /etc/wazuh-certs-final/indexer-connector-key.pem
chmod 0640 /etc/wazuh-certs-final/root-ca.pem /etc/wazuh-certs-final/indexer-connector.pem /etc/wazuh-certs-final/indexer-connector-key.pem
# The agent listener pair is read by remoted after the manager drops
# privileges, so it is owned by the manager user (101:101) instead of
# root:101 like the files above.
cp /tmp/certs-raw/manager-remoted.pem /etc/wazuh-certs-final/remoted.pem
cp /tmp/certs-raw/manager-remoted-key.pem /etc/wazuh-certs-final/remoted-key.pem
chown 101:101 /etc/wazuh-certs-final/remoted.pem /etc/wazuh-certs-final/remoted-key.pem
chmod 0640 /etc/wazuh-certs-final/remoted.pem /etc/wazuh-certs-final/remoted-key.pem
volumeMounts:
- name: wazuh-manager-worker
mountPath: /pvc-etc
subPath: wazuh/var/wazuh-manager/etc
- name: wazuh-manager-worker
mountPath: /pvc-data
subPath: wazuh/var/wazuh-manager/data
- name: wazuh-manager-certs-raw
mountPath: /tmp/certs-raw
- name: wazuh-manager-certs
mountPath: /etc/wazuh-certs-final
containers:
- name: wazuh-manager
image: 'wazuh/wazuh-manager:5.0.0-rc1'
resources:
limits:
cpu: 400m
memory: 1Gi
securityContext:
capabilities:
add: ["SYS_CHROOT"]
volumeMounts:
- name: wazuh-credentials
mountPath: /run/secrets
readOnly: true
- name: wazuh-manager-worker
mountPath: /var/wazuh-manager/api/configuration
subPath: wazuh/var/wazuh-manager/api/configuration
- name: wazuh-manager-worker
mountPath: /var/wazuh-manager/etc
subPath: wazuh/var/wazuh-manager/etc
- name: wazuh-manager-certs
mountPath: /var/wazuh-manager/etc/certs/root-ca.pem
subPath: root-ca.pem
- name: wazuh-manager-certs
mountPath: /var/wazuh-manager/etc/certs/indexer-connector.pem
subPath: indexer-connector.pem
- name: wazuh-manager-certs
mountPath: /var/wazuh-manager/etc/certs/indexer-connector-key.pem
subPath: indexer-connector-key.pem
- name: wazuh-manager-certs
mountPath: /var/wazuh-manager/etc/certs/remoted.pem
subPath: remoted.pem
- name: wazuh-manager-certs
mountPath: /var/wazuh-manager/etc/certs/remoted-key.pem
subPath: remoted-key.pem
- name: wazuh-manager-worker
mountPath: /var/wazuh-manager/logs
subPath: wazuh/var/wazuh-manager/logs
- name: wazuh-manager-worker
mountPath: /var/wazuh-manager/queue
subPath: wazuh/var/wazuh-manager/queue
- name: wazuh-manager-worker
mountPath: /var/wazuh-manager/var/multigroups
subPath: wazuh/var/wazuh-manager/var/multigroups
- name: wazuh-manager-worker
mountPath: /var/wazuh-manager/data
subPath: wazuh/var/wazuh-manager/data
ports:
- containerPort: 1517
name: agents-https
- containerPort: 1514
name: agents-events
- containerPort: 1516
name: cluster
startupProbe:
exec:
command:
- /bin/sh
- -c
- /var/wazuh-manager/bin/wazuh-manager-control status 2>/dev/null | grep -v apid | grep -qE 'not running|failed to start|refused its configuration' && exit 1 || exit 0
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 12
readinessProbe:
exec:
command:
- /bin/sh
- -c
- /var/wazuh-manager/bin/wazuh-manager-control status 2>/dev/null | grep -v apid | grep -qE 'not running|failed to start|refused its configuration' && exit 1 || exit 0
periodSeconds: 15
timeoutSeconds: 5
failureThreshold: 5
livenessProbe:
exec:
command:
- /bin/sh
- -c
- /var/wazuh-manager/bin/wazuh-manager-control status 2>/dev/null | grep -v apid | grep -qE 'not running|failed to start|refused its configuration' && exit 1 || exit 0
periodSeconds: 15
timeoutSeconds: 5
failureThreshold: 5
env:
- name: WAZUH_INDEXER_HOSTS
value: 'wazuh-indexer-0.wazuh-indexer:9200,wazuh-indexer-1.wazuh-indexer:9200,wazuh-indexer-2.wazuh-indexer:9200'
- name: WAZUH_NODE_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: WAZUH_NODE_TYPE
value: 'worker'
- name: WAZUH_REMOTE_BIND_ADDR
value: '0.0.0.0'
- name: WAZUH_CLUSTER_BIND_ADDR
value: '0.0.0.0'
- name: WAZUH_CLUSTER_NODES
value: 'wazuh-manager-master-0.wazuh-cluster'
- name: WAZUH_CLUSTER_KEY
valueFrom:
secretKeyRef:
name: wazuh-cluster-key
key: key
volumeClaimTemplates:
- metadata:
name: wazuh-manager-worker
namespace: wazuh
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 500Mi