wazuh / wazuh-kubernetes

Wazuh - Wazuh Kubernetes
https://wazuh.com/
GNU General Public License v2.0
246 stars 151 forks source link

About deploying wazuh on k8s (kubeadmin) #622

Open xuhuajie990 opened 6 months ago

xuhuajie990 commented 6 months ago

environmental information:

kubeadmin deploys k8s

Use nfs as provisioner

Deployment steps:

  1. git clone https://github.com/wazuh/wazuh-kubernetes.git

  2. Create SC, PVC, and PV in the local k8s environment and use nfs. The configuration is as follows:

apiVersion: v1 kind: PersistentVolumeClaim metadata: name: wazuh-nfs-pvc namespace: wazuh spec: accessModes:

apiVersion: v1 kind: PersistentVolume metadata: name: wazuh-nfs-pv namespace: wazuh spec: storageClassName: wazuh-nfs-sc claimRef: name: wazuh-nfs-pvc namespace: wazuh accessModes: ReadWriteMany capacity: storage: 500Gi persistentVolumeReclaimPolicy: Retain nfs: server: 192.168.2.8 path: "/data/nfs/wazuh/server"

apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: wazuh-nfs-sc provisioner: nfs reclaimPolicy: Retain volumeBindingMode: WaitForFirstConsumer

  1. Modify storage-class.yaml under local-env:

apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: wazuh-nfs-sc namespace: wazuh

provisioner: nfs reclaimPolicy: Retain volumeBindingMode: WaitForFirstConsumer

  1. Execute manifest creation:

    kubectl apply -k envs/local-env/

  2. The pod cannot be started and is in the pending state. The reason is that the PVC does not have Bind.

/d/h/w/w/e/local-env# kubectl get pod -n wazuh NAME READY STATUS RESTARTS AGE wazuh-dashboard-7cfc7d959-prkqs 1/1 Running 0 33m wazuh-indexer-0 0/1 Pending 0 33m wazuh-manager-master-0 0/1 Pending 0 33m wazuh-manager-worker-0 0/1 Pending 0 33m

kubectl describe pod wazuh-manager-master-0 -n wazuh

Events: Type Reason Age From Message


Warning FailedScheduling 28m (x3 over 33m) default-scheduler 0/3 nodes are available: pod has unbound immediate PersistentVolumeClaims. preemption: 0/3 nodes are available: 3 Preemption is not helpful for scheduling.. Warning FailedScheduling 8m35s (x2 over 18m) default-scheduler running PreBind plugin "VolumeBinding": binding volumes: timed out waiting for the condition

Because I am deploying on local k8s, creating a dynamic PVC is not successful. Is it an environmental problem? How to configure an existing PVC?

henika1 commented 4 months ago

did you find a solution ?

Cloud2004 commented 3 months ago

The solution I found to work was use NFS CSI driver for Kubernetes as your StorageClass then edit:

wazuh/indexer_stack/wazuh-indexer/cluster/indexer-sts.yaml wazuh/wazuh_managers/wazuh-master-sts.yaml wazuh/wazuh_managers/wazuh-worker-sts.yaml

storageClassName: wazuh-storage to storageClassName: nfs-csi