Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPIKE - Wazuh Docker #1624

Open
teddytpc1 opened this issue Nov 20, 2024 · 5 comments
Open

SPIKE - Wazuh Docker #1624

teddytpc1 opened this issue Nov 20, 2024 · 5 comments
Assignees
Labels

Comments

@teddytpc1
Copy link
Member

teddytpc1 commented Nov 20, 2024

Objective
https://github.com/wazuh/internal-devel-requests/issues/1319

Description

As part of the DevOps overhaul objective we need to conduct research, analyze alternatives, and design how to implement the following changes.

  1. Docker image ownership:
  • Each subsystem owner is responsible for maintaining its Docker images.
  • Each image must run a primary process, and the container lifecycle must align with this process.
  1. DevOps-Owned Docker image build and registries:
  • Split the "Push Docker images" workflows into three separate workflows (one for each component) and migrate them to the respective repositories.
  • Allow development images to be pushed to a registry other than DockerHub.
  1. Docker Registry Analysis:
  • Research Docker registry alternatives for development images.
  • Evaluate if AWS ECR meets our needs for hosting development images.
  1. Repository Scope Clarification:
  • The Wazuh Docker repository should focus solely on container deployments.
  • Migrate all Docker image build-related code to their respective repositories.
  • The Docker deployment must use out-of-the-box Wazuh configurations.
  1. Build Process Simplification:
  • Docker images must use Wazuh package URLs instead of repositories.
  • Utilize out-of-the-box Wazuh configurations for builds and deployments.
  1. Testing Improvements:
  • Enhance deployment tests with additional checks, including log validation for errors and warnings.
  • Ensure each team has an automatic PR check (GHA) for validating changes.
  1. Documentation Updates:
  • Simplify Docker installation documentation.
  • Focus on prerequisites for Wazuh Docker deployment, using the Wazuh Kubernetes documentation as a reference.
  1. Multi-Node Deployment Decision:
  • Determine whether maintaining multi-node deployments is necessary. (definition: yes)
  1. Multi architecture Docker images:
  • The Docker images must be multi-arch. They must allow amd64 and arm64.

Implementation restrictions

  • Testing Environment: The tests must be implemented using GitHub Actions (GHA).
  • Compatibility: The workflow should be compatible with the environments used for PR testing and manual testing.
  • Logs Validation: The logs checking must identify and report critical issues (e.g., errors, warnings) in a clear and actionable way.
  • Minimal Maintenance: The implementation should aim for low complexity and minimal maintenance overhead.
  • Docker Registry: the development Registry must be private.

Plan

  1. Research & Analysis:
  • Identify key improvements for the Docker images and build process.
  • Evaluate AWS ECR and other registries as potential options for hosting development images.
  1. Repository Restructuring:
  • Migrate Docker image build code to subsystem repositories.
  • Refocus the Wazuh Docker repository on deployment.
  1. Workflow Development:
  • Split the "Push Docker images" workflows into three and migrate them to their respective repositories.
  • Define the non-DockerHub registry for development images.
  1. Test Design and Development:
  • Define additional deployment test cases to improve coverage and reliability.
  1. Configuration & Build Updates:
  • Transition Docker builds to use package URLs and out-of-the-box configurations.
  1. Documentation Updates:
  • Define the prerequisites to deploy Wazuh using Docker.
  • Use the Wazuh Kubernetes documentation style as a model.
  1. Multi-Node Decision:
  • Analyze the benefits and challenges of maintaining multi-node deployments. (it will be maintained)
  • Decide whether to continue supporting this feature and document the rationale.
  1. Multi architecture Docker images:
  • The Docker images must be multi-arch. They must allow amd64 and arm64.
@wazuhci wazuhci moved this to Backlog in Release 5.0.0 Nov 21, 2024
@wazuhci wazuhci moved this from Backlog to In progress in Release 5.0.0 Nov 22, 2024
@vcerenu
Copy link
Member

vcerenu commented Nov 22, 2024

Description

I've been looking into separating the Dockerfiles from the Docker images of each of the components of the Wazuh stack.

By making a few changes it is possible to generate them. The deployment has been tested and works without problems:

Wazuh manager

$ docker build -t wazuh/wazuh-manager:4.9.2 .
[+] Building 145.1s (24/24) FINISHED                                                                                                                                                    
 => [internal] load build definition from Dockerfile                                                                                                                               0.1s
 => => transferring dockerfile: 2.42kB                                                                                                                                             0.0s
 => [internal] load metadata for docker.io/library/amazonlinux:2023                                                                                                                3.1s
 => [auth] library/amazonlinux:pull token for registry-1.docker.io                                                                                                                 0.0s
 => [internal] load .dockerignore                                                                                                                                                  0.1s
 => => transferring context: 2B                                                                                                                                                    0.0s
 => [14/17] ADD https://raw.githubusercontent.com/wazuh/wazuh/v4.9.2/extensions/elasticsearch/7.x/wazuh-template.json /etc/filebeat                                                0.0s
 => [ 1/17] FROM docker.io/library/amazonlinux:2023@sha256:6c2c3bb2ce484e8496c83bd672a62528406b96c74594b195f70dc3d7b420c296                                                       14.3s
 => => resolve docker.io/library/amazonlinux:2023@sha256:6c2c3bb2ce484e8496c83bd672a62528406b96c74594b195f70dc3d7b420c296                                                          0.1s
 => => sha256:6c2c3bb2ce484e8496c83bd672a62528406b96c74594b195f70dc3d7b420c296 2.38kB / 2.38kB                                                                                     0.0s
 => => sha256:896212a6eb4bac05279a901518ced7b04623652be4aed944e5a3f63fed0ec981 1.02kB / 1.02kB                                                                                     0.0s
 => => sha256:77424cbe957ca5d9b174abd840881380567113c8e42acebdb0bd698b5dcdf166 575B / 575B                                                                                         0.0s
 => => sha256:46453255c2f610c1cb9c8197635e6d542bbd326425a9898df0de76e5bb566461 52.38MB / 52.38MB                                                                                   3.3s
 => => extracting sha256:46453255c2f610c1cb9c8197635e6d542bbd326425a9898df0de76e5bb566461                                                                                         10.7s
 => [internal] load build context                                                                                                                                                  0.1s
 => => transferring context: 27.79kB                                                                                                                                               0.0s
 => [ 2/17] RUN rm /bin/sh && ln -s /bin/bash /bin/sh                                                                                                                              1.6s
 => [ 3/17] RUN yum install curl-minimal xz gnupg tar gzip openssl findutils procps -y &&    yum clean all                                                                        17.3s
 => [ 4/17] COPY config/check_repository.sh /                                                                                                                                      0.2s 
 => [ 5/17] COPY config/filebeat_module.sh /                                                                                                                                       0.1s 
 => [ 6/17] COPY config/permanent_data.env config/permanent_data.sh /                                                                                                              0.1s 
 => [ 7/17] RUN chmod 775 /check_repository.sh                                                                                                                                     0.4s 
 => [ 8/17] RUN source /check_repository.sh                                                                                                                                        1.4s 
 => [ 9/17] RUN yum install wazuh-manager-4.9.2-1 -y &&     yum clean all &&     chmod 775 /filebeat_module.sh &&     source /filebeat_module.sh &&     rm /filebeat_module.sh &  96.3s 
 => [10/17] COPY config/etc/ /etc/                                                                                                                                                 0.1s
 => [11/17] COPY --chown=root:wazuh config/create_user.py /var/ossec/framework/scripts/create_user.py                                                                              0.2s 
 => [12/17] COPY config/filebeat.yml /etc/filebeat/                                                                                                                                0.1s 
 => [13/17] RUN chmod go-w /etc/filebeat/filebeat.yml                                                                                                                              0.5s 
 => [14/17] ADD https://raw.githubusercontent.com/wazuh/wazuh/v4.9.2/extensions/elasticsearch/7.x/wazuh-template.json /etc/filebeat                                                0.1s 
 => [15/17] RUN chmod go-w /etc/filebeat/wazuh-template.json                                                                                                                       0.4s 
 => [16/17] RUN mkdir -p /var/ossec/var/multigroups &&     chown root:wazuh /var/ossec/var/multigroups &&     chmod 770 /var/ossec/var/multigroups &&     mkdir -p /var/ossec/age  1.5s
 => [17/17] RUN rm /etc/yum.repos.d/wazuh.repo                                                                                                                                     0.5s
 => exporting to image                                                                                                                                                             6.3s
 => => exporting layers                                                                                                                                                            6.2s
 => => writing image sha256:2e96d7e9c374afcb8b3b07d3aa0b9ba76a62d860dfe93569eda2bb2ae2d1b96e                                                                                       0.0s
 => => naming to docker.io/wazuh/wazuh-manager:4.9.2     

Wazuh indexer

$ docker build -t wazuh/wazuh-indexer:4.9.2 .
[+] Building 118.6s (33/33) FINISHED                                                                                                                                                    
 => [internal] load build definition from Dockerfile                                                                                                                               0.0s
 => => transferring dockerfile: 2.77kB                                                                                                                                             0.0s
 => [internal] load metadata for docker.io/library/amazonlinux:2023                                                                                                                0.8s
 => [internal] load .dockerignore                                                                                                                                                  0.1s
 => => transferring context: 2B                                                                                                                                                    0.0s
 => CACHED [builder  1/13] FROM docker.io/library/amazonlinux:2023@sha256:6c2c3bb2ce484e8496c83bd672a62528406b96c74594b195f70dc3d7b420c296                                         0.0s
 => [internal] load build context                                                                                                                                                  0.1s
 => => transferring context: 19.34kB                                                                                                                                               0.0s
 => [stage-1  2/16] RUN yum install curl-minimal shadow-utils findutils hostname -y                                                                                               22.6s
 => [builder  2/13] RUN yum install curl-minimal openssl xz tar findutils shadow-utils -y                                                                                         13.3s
 => [builder  3/13] COPY config/check_repository.sh /                                                                                                                              0.2s
 => [builder  4/13] RUN chmod 775 /check_repository.sh &&     source /check_repository.sh                                                                                          1.1s
 => [builder  5/13] RUN yum install wazuh-indexer-4.9.2-1 -y &&     yum clean all                                                                                                 77.1s
 => [stage-1  3/16] RUN getent group wazuh-indexer || groupadd -r -g 1000 wazuh-indexer                                                                                            0.6s
 => [stage-1  4/16] RUN useradd --system             --uid 1000             --no-create-home             --home-dir /usr/share/wazuh-indexer             --gid wazuh-indexer       1.9s
 => [stage-1  5/16] WORKDIR /usr/share/wazuh-indexer                                                                                                                               0.4s 
 => [stage-1  6/16] COPY config/entrypoint.sh /                                                                                                                                    0.3s 
 => [stage-1  7/16] COPY config/securityadmin.sh /                                                                                                                                 0.3s 
 => [stage-1  8/16] RUN chmod 700 /entrypoint.sh && chmod 700 /securityadmin.sh                                                                                                    1.1s 
 => [stage-1  9/16] RUN chown 1000:1000 /*.sh                                                                                                                                      1.1s 
 => [builder  6/13] COPY config/opensearch.yml /                                                                                                                                   0.1s 
 => [builder  7/13] COPY config/config.sh .                                                                                                                                        0.1s 
 => [builder  8/13] COPY config/config.yml /                                                                                                                                       0.1s 
 => [builder  9/13] COPY config/action_groups.yml /                                                                                                                                0.1s 
 => [builder 10/13] COPY config/internal_users.yml /                                                                                                                               0.1s 
 => [builder 11/13] COPY config/roles_mapping.yml /                                                                                                                                0.1s 
 => [builder 12/13] COPY config/roles.yml /                                                                                                                                        0.1s
 => [builder 13/13] RUN bash config.sh                                                                                                                                             4.2s
 => [stage-1 10/16] COPY --from=builder --chown=1000:1000 /usr/share/wazuh-indexer /usr/share/wazuh-indexer                                                                        2.5s 
 => [stage-1 11/16] COPY --from=builder --chown=1000:1000 /etc/wazuh-indexer /usr/share/wazuh-indexer                                                                              0.1s 
 => [stage-1 12/16] COPY --from=builder --chown=0:0 /debian/wazuh-indexer/usr/lib/systemd /usr/lib/systemd                                                                         0.1s 
 => [stage-1 13/16] COPY --from=builder --chown=0:0 /debian/wazuh-indexer/usr/lib/sysctl.d /usr/lib/sysctl.d                                                                       0.2s 
 => [stage-1 14/16] COPY --from=builder --chown=0:0 /debian/wazuh-indexer/usr/lib/tmpfiles.d /usr/lib/tmpfiles.d                                                                   0.2s 
 => [stage-1 15/16] RUN chown -R 1000:1000 /usr/share/wazuh-indexer                                                                                                                7.7s 
 => [stage-1 16/16] RUN mkdir -p /var/lib/wazuh-indexer && chown 1000:1000 /var/lib/wazuh-indexer &&     mkdir -p /usr/share/wazuh-indexer/logs && chown 1000:1000 /usr/share/waz  0.6s
 => exporting to image                                                                                                                                                             5.0s
 => => exporting layers                                                                                                                                                            5.0s
 => => writing image sha256:a110f44fbd70f5af2ba38be179269803a65f378cb7b44625fc8e3f4b6b4c91c6                                                                                       0.0s
 => => naming to docker.io/wazuh/wazuh-indexer:4.9.2   

Wazuh dashboard

$ docker build -t wazuh/wazuh-dashboard:4.9.2 .
[+] Building 147.4s (30/30) FINISHED                                                                                                                                                    
 => [internal] load build definition from Dockerfile                                                                                                                               0.1s
 => => transferring dockerfile: 3.23kB                                                                                                                                             0.0s
 => [internal] load metadata for docker.io/library/amazonlinux:2023                                                                                                                1.7s
 => [auth] library/amazonlinux:pull token for registry-1.docker.io                                                                                                                 0.0s
 => [internal] load .dockerignore                                                                                                                                                  0.0s
 => => transferring context: 2B                                                                                                                                                    0.0s
 => [internal] load build context                                                                                                                                                  0.1s
 => => transferring context: 10.19kB                                                                                                                                               0.0s
 => CACHED [builder  1/12] FROM docker.io/library/amazonlinux:2023@sha256:6c2c3bb2ce484e8496c83bd672a62528406b96c74594b195f70dc3d7b420c296                                         0.0s
 => [stage-1  2/13] RUN yum install shadow-utils -y                                                                                                                               21.8s
 => [builder  2/12] RUN yum install curl-minimal libcap openssl -y                                                                                                                10.5s
 => [builder  3/12] COPY config/check_repository.sh /                                                                                                                              0.2s
 => [builder  4/12] RUN chmod 775 /check_repository.sh &&     source /check_repository.sh                                                                                          1.1s 
 => [builder  5/12] RUN yum install wazuh-dashboard-4.9.2-1 -y &&     yum clean all                                                                                               66.5s 
 => [stage-1  3/13] RUN getent group wazuh-dashboard || groupadd -r -g 1000 wazuh-dashboard                                                                                        0.7s 
 => [stage-1  4/13] RUN useradd --system             --uid 1000             --no-create-home             --home-dir /usr/share/wazuh-dashboard             --gid wazuh-dashboard   0.5s 
 => [stage-1  5/13] COPY config/entrypoint.sh /                                                                                                                                    0.1s 
 => [stage-1  6/13] COPY config/wazuh_app_config.sh /                                                                                                                              0.1s 
 => [stage-1  7/13] RUN chmod 700 /entrypoint.sh                                                                                                                                   0.7s 
 => [stage-1  8/13] RUN chmod 700 /wazuh_app_config.sh                                                                                                                             0.8s 
 => [stage-1  9/13] RUN chown 1000:1000 /*.sh                                                                                                                                      0.8s 
 => [builder  6/12] RUN mkdir -p /usr/share/wazuh-dashboard/data/wazuh && chmod -R 775 /usr/share/wazuh-dashboard/data/wazuh                                                       0.4s 
 => [builder  7/12] RUN mkdir -p /usr/share/wazuh-dashboard/data/wazuh/config && chmod -R 775 /usr/share/wazuh-dashboard/data/wazuh/config                                         0.4s 
 => [builder  8/12] RUN mkdir -p /usr/share/wazuh-dashboard/data/wazuh/logs && chmod -R 775 /usr/share/wazuh-dashboard/data/wazuh/logs                                             0.4s 
 => [builder  9/12] COPY config/wazuh.yml /usr/share/wazuh-dashboard/data/wazuh/config/                                                                                            0.1s 
 => [builder 10/12] COPY config/config.sh .                                                                                                                                        0.1s 
 => [builder 11/12] COPY config/config.yml /                                                                                                                                       0.1s 
 => [builder 12/12] RUN bash config.sh                                                                                                                                             2.8s
 => [stage-1 10/13] COPY --from=builder --chown=1000:1000 /usr/share/wazuh-dashboard /usr/share/wazuh-dashboard                                                                   42.4s 
 => [stage-1 11/13] RUN mkdir -p /usr/share/wazuh-dashboard/plugins/wazuh/public/assets/custom                                                                                     0.4s 
 => [stage-1 12/13] RUN chown 1000:1000 /usr/share/wazuh-dashboard/plugins/wazuh/public/assets/custom                                                                              0.4s 
 => [stage-1 13/13] WORKDIR /usr/share/wazuh-dashboard                                                                                                                             0.1s 
 => exporting to image                                                                                                                                                             8.7s 
 => => exporting layers                                                                                                                                                            8.7s 
 => => writing image sha256:f1ef95f13668c0f7a7bb4a102d46f3682277b1f6114e9dfbadc87013af4f611b                                                                                       0.0s
 => => naming to docker.io/wazuh/wazuh-dashboard:4.9.2                                       

Regarding the details of the spike, I have doubts regarding the modification of the build of the images, which require several changes and in many cases, adding functionalities that are not currently contemplated and that are necessary to be able to deploy the integrations that Wazuh currently has developed.

@vcerenu
Copy link
Member

vcerenu commented Nov 25, 2024

I've been looking at the options we have with AWS ECR, both with a public and private repository. What permissions are required for its use, pushing images to use and I'm looking at which options are best for Kubernetes tests, since a private repository can be accessed from EKS.

@vcerenu
Copy link
Member

vcerenu commented Nov 27, 2024

By performing several tests, it is possible to use private ECR registries in AWS.
I performed some tests both on local deployments and in EKS clusters and the results were satisfactory.

To use a private ECR repository in any VM where we are performing a test, it is necessary to have AWS cli installed, which we have in the VMs where we execute the GHA workflows, configure the keys of a user or assume a role with the necessary permissions and then we can run the docker login command to obtain the login credentials of the private ECR registry. After obtaining the login credentials, we can do without the login in AWS cli.

Login in ECR:

$ aws ecr get-login-password --region us-west-1 | docker login --username AWS --password-stdin <account-id>.dkr.ecr.<region>.amazonaws.com
WARNING! Your password will be stored unencrypted in /home/vcerenu/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credential-stores

Login Succeeded

docker-compose.yml and deploying with images hosted in the ECR private registry:

$ cat docker-compose.yml 
# Wazuh App Copyright (C) 2017, Wazuh Inc. (License GPLv2)
services:
  wazuh.manager:
    image: <account-id>.dkr.ecr.<region>.amazonaws.com/wazuh/wazuh-manager:4.9.2
    hostname: wazuh.manager
    restart: always
    ulimits:
      memlock:
        soft: -1
        hard: -1
      nofile:
        soft: 655360
        hard: 655360
    ports:
      - "1514:1514"
      - "1515:1515"
      - "514:514/udp"
      - "55000:55000"
    environment:
      - INDEXER_URL=https://wazuh.indexer:9200
      - INDEXER_USERNAME=admin
      - INDEXER_PASSWORD=SecretPassword
      - FILEBEAT_SSL_VERIFICATION_MODE=full
      - SSL_CERTIFICATE_AUTHORITIES=/etc/ssl/root-ca.pem
      - SSL_CERTIFICATE=/etc/ssl/filebeat.pem
      - SSL_KEY=/etc/ssl/filebeat.key
      - API_USERNAME=wazuh-wui
      - API_PASSWORD=MyS3cr37P450r.*-
    volumes:
      - wazuh_api_configuration:/var/ossec/api/configuration
      - wazuh_etc:/var/ossec/etc
      - wazuh_logs:/var/ossec/logs
      - wazuh_queue:/var/ossec/queue
      - wazuh_var_multigroups:/var/ossec/var/multigroups
      - wazuh_integrations:/var/ossec/integrations
      - wazuh_active_response:/var/ossec/active-response/bin
      - wazuh_agentless:/var/ossec/agentless
      - wazuh_wodles:/var/ossec/wodles
      - filebeat_etc:/etc/filebeat
      - filebeat_var:/var/lib/filebeat
      - ./config/wazuh_indexer_ssl_certs/root-ca-manager.pem:/etc/ssl/root-ca.pem
      - ./config/wazuh_indexer_ssl_certs/wazuh.manager.pem:/etc/ssl/filebeat.pem
      - ./config/wazuh_indexer_ssl_certs/wazuh.manager-key.pem:/etc/ssl/filebeat.key
      - ./config/wazuh_cluster/wazuh_manager.conf:/wazuh-config-mount/etc/ossec.conf

  wazuh.indexer:
    image: <account-id>.dkr.ecr.<region>.amazonaws.com/wazuh/wazuh-indexer:4.9.2
    hostname: wazuh.indexer
    restart: always
    ports:
      - "9200:9200"
    environment:
      - "OPENSEARCH_JAVA_OPTS=-Xms1g -Xmx1g"
    ulimits:
      memlock:
        soft: -1
        hard: -1
      nofile:
        soft: 65536
        hard: 65536
    volumes:
      - wazuh-indexer-data:/var/lib/wazuh-indexer
      - ./config/wazuh_indexer_ssl_certs/root-ca.pem:/usr/share/wazuh-indexer/certs/root-ca.pem
      - ./config/wazuh_indexer_ssl_certs/wazuh.indexer-key.pem:/usr/share/wazuh-indexer/certs/wazuh.indexer.key
      - ./config/wazuh_indexer_ssl_certs/wazuh.indexer.pem:/usr/share/wazuh-indexer/certs/wazuh.indexer.pem
      - ./config/wazuh_indexer_ssl_certs/admin.pem:/usr/share/wazuh-indexer/certs/admin.pem
      - ./config/wazuh_indexer_ssl_certs/admin-key.pem:/usr/share/wazuh-indexer/certs/admin-key.pem
      - ./config/wazuh_indexer/wazuh.indexer.yml:/usr/share/wazuh-indexer/opensearch.yml
      - ./config/wazuh_indexer/internal_users.yml:/usr/share/wazuh-indexer/opensearch-security/internal_users.yml

  wazuh.dashboard:
    image: <account-id>.dkr.ecr.<region>.amazonaws.com/wazuh/wazuh-dashboard:4.9.2
    hostname: wazuh.dashboard
    restart: always
    ports:
      - 443:5601
    environment:
      - INDEXER_USERNAME=admin
      - INDEXER_PASSWORD=SecretPassword
      - WAZUH_API_URL=https://wazuh.manager
      - DASHBOARD_USERNAME=kibanaserver
      - DASHBOARD_PASSWORD=kibanaserver
      - API_USERNAME=wazuh-wui
      - API_PASSWORD=MyS3cr37P450r.*-
    volumes:
      - ./config/wazuh_indexer_ssl_certs/wazuh.dashboard.pem:/usr/share/wazuh-dashboard/certs/wazuh-dashboard.pem
      - ./config/wazuh_indexer_ssl_certs/wazuh.dashboard-key.pem:/usr/share/wazuh-dashboard/certs/wazuh-dashboard-key.pem
      - ./config/wazuh_indexer_ssl_certs/root-ca.pem:/usr/share/wazuh-dashboard/certs/root-ca.pem
      - ./config/wazuh_dashboard/opensearch_dashboards.yml:/usr/share/wazuh-dashboard/config/opensearch_dashboards.yml
      - ./config/wazuh_dashboard/wazuh.yml:/usr/share/wazuh-dashboard/data/wazuh/config/wazuh.yml
      - wazuh-dashboard-config:/usr/share/wazuh-dashboard/data/wazuh/config
      - wazuh-dashboard-custom:/usr/share/wazuh-dashboard/plugins/wazuh/public/assets/custom
    depends_on:
      - wazuh.indexer
    links:
      - wazuh.indexer:wazuh.indexer
      - wazuh.manager:wazuh.manager

volumes:
  wazuh_api_configuration:
  wazuh_etc:
  wazuh_logs:
  wazuh_queue:
  wazuh_var_multigroups:
  wazuh_integrations:
  wazuh_active_response:
  wazuh_agentless:
  wazuh_wodles:
  filebeat_etc:
  filebeat_var:
  wazuh-indexer-data:
  wazuh-dashboard-config:
  wazuh-dashboard-custom:
$ docker compose up -d
[+] Running 47/35
 ✔ wazuh.manager Pulled                                                                                                                                                          193.9s 
 ✔ wazuh.indexer Pulled                                                                                                                                                          254.2s 
 ✔ wazuh.dashboard Pulled                                                                                                                                                        306.6s
[+] Running 18/18
 ✔ Network single-node_default                   Created                                                                                                                           0.3s 
 ✔ Volume "single-node_filebeat_var"             Created                                                                                                                           0.0s 
 ✔ Volume "single-node_wazuh_var_multigroups"    Created                                                                                                                           0.0s 
 ✔ Volume "single-node_filebeat_etc"             Created                                                                                                                           0.0s 
 ✔ Volume "single-node_wazuh_wodles"             Created                                                                                                                           0.0s 
 ✔ Volume "single-node_wazuh-dashboard-config"   Created                                                                                                                           0.0s 
 ✔ Volume "single-node_wazuh_active_response"    Created                                                                                                                           0.0s 
 ✔ Volume "single-node_wazuh_logs"               Created                                                                                                                           0.0s 
 ✔ Volume "single-node_wazuh-indexer-data"       Created                                                                                                                           0.0s 
 ✔ Volume "single-node_wazuh_api_configuration"  Created                                                                                                                           0.0s 
 ✔ Volume "single-node_wazuh_queue"              Created                                                                                                                           0.0s 
 ✔ Volume "single-node_wazuh_integrations"       Created                                                                                                                           0.0s 
 ✔ Volume "single-node_wazuh_agentless"          Created                                                                                                                           0.0s 
 ✔ Volume "single-node_wazuh-dashboard-custom"   Created                                                                                                                           0.0s 
 ✔ Volume "single-node_wazuh_etc"                Created                                                                                                                           0.0s 
 ✔ Container single-node-wazuh.manager-1         Started                                                                                                                           3.3s 
 ✔ Container single-node-wazuh.indexer-1         Started                                                                                                                           3.0s 
 ✔ Container single-node-wazuh.dashboard-1       Started                                                                                                                           1.9s 
$ docker ps
CONTAINER ID   IMAGE                                                                      COMMAND                  CREATED          STATUS         PORTS                                                                                                                                                           NAMES
c1a8543bd2fa   <account-id>.dkr.ecr.<region>.amazonaws.com/wazuh/wazuh-dashboard:4.9.2   "/entrypoint.sh"         8 seconds ago    Up 5 seconds   443/tcp, 0.0.0.0:443->5601/tcp, [::]:443->5601/tcp                                                                                                              single-node-wazuh.dashboard-1
f58aa0cdee35   <account-id>.dkr.ecr.<region>.amazonaws.com/wazuh/wazuh-indexer:4.9.2     "/entrypoint.sh open…"   10 seconds ago   Up 6 seconds   0.0.0.0:9200->9200/tcp, :::9200->9200/tcp                                                                                                                       single-node-wazuh.indexer-1
2ab0d8ec5dd3   <account-id>.dkr.ecr.<region>.amazonaws.com/wazuh/wazuh-manager:4.9.2     "/init"                  10 seconds ago   Up 6 seconds   0.0.0.0:1514-1515->1514-1515/tcp, :::1514-1515->1514-1515/tcp, 0.0.0.0:514->514/udp, :::514->514/udp, 0.0.0.0:55000->55000/tcp, :::55000->55000/tcp, 1516/tcp   single-node-wazuh.manager-1
$ 

I also performed tests on EKS with the private ECR repository and, without needing to add permissions after creating the cluster with eksctl, I was able to deploy without problems..

@vcerenu
Copy link
Member

vcerenu commented Dec 2, 2024

Reviewing previous tasks that we had pending for these changes, there was the issue of adapting the deployments by Docker Compose from v1 to v2, which I was investigating and we only have one line that generates a warning:

When we run with Docker Compose v2 we have the following message:

WARN[0000] /dev/wazuh-docker/single-node/docker-compose.yml: the attribute `version` is obsolete, it will be ignored, please remove it to avoid potential confusion

By removing this line from the yaml files with which we run tasks, we stop generating errors.

We have a community PR, which makes changes to the single-node/docker-compose.yml and multi-node/docker-compose.yml files: #1595

These changes are correct, but there are some more changes missing, regarding the yaml files for creating Wazuh Docker images and creating certificates in the deployment. I will modify these in the next PR: #1632

These changes remain pending to be applied during the tasks after SPIKE.

I have performed a test of creating images and deploying them on a single node and on multiple nodes, removing the tag and modifying the use of the docker-compose binary using the docker compose command. I did this test on the master branch, modifying the version parameters from 5.0.0 to 4.9.2 so that it can use the current packages:

~/wazuh-docker$ build-docker-images/build-images.sh 
[+] Building 540.7s (81/81) FINISHED                                                                                                                                     docker:default
 => [wazuh.manager internal] load build definition from Dockerfile                                                                                                                 0.1s
 => => transferring dockerfile: 2.38kB                                                                                                                                             0.0s
 => [wazuh.indexer internal] load build definition from Dockerfile                                                                                                                 0.1s
 => => transferring dockerfile: 3.00kB                                                                                                                                             0.0s
 => [wazuh.dashboard internal] load metadata for docker.io/library/amazonlinux:2023                                                                                                3.7s
 => [wazuh.indexer internal] load .dockerignore                                                                                                                                    0.1s
 => => transferring context: 2B                                                                                                                                                    0.0s
 => [wazuh.manager internal] load .dockerignore                                                                                                                                    0.1s
 => => transferring context: 2B                                                                                                                                                    0.0s
 => CACHED [wazuh.manager 14/17] ADD https://raw.githubusercontent.com/wazuh/wazuh/v4.9.2/extensions/elasticsearch/7.x/wazuh-template.json /etc/filebeat                           0.6s
 => [wazuh.manager internal] load build context                                                                                                                                    0.2s
 => => transferring context: 836B                                                                                                                                                  0.0s
 => CACHED [wazuh.dashboard builder  1/12] FROM docker.io/library/amazonlinux:2023@sha256:5cb6ab1a1a13f33425b6c660a45f06298e204a22df1f9eeefe69cda3735d9757                         0.0s
 => [wazuh.indexer internal] load build context                                                                                                                                    0.1s
 => => transferring context: 229B                                                                                                                                                  0.0s
 => [wazuh.indexer stage-1  2/17] RUN echo "export JAVA_HOME=/usr/share/wazuh-indexer/jdk" >> /etc/profile.d/java_home.sh &&     echo "export PATH=$PATH:$JAVA_HOME/bin" >> /etc/  0.9s
 => [wazuh.indexer builder 2/8] RUN yum install curl-minimal openssl xz tar findutils shadow-utils -y                                                                             25.2s
 => [wazuh.manager  2/17] RUN rm /bin/sh && ln -s /bin/bash /bin/sh                                                                                                                0.9s
 => [wazuh.manager  3/17] RUN yum install curl-minimal xz gnupg tar gzip openssl findutils procps -y &&    yum clean all                                                          24.2s
 => [wazuh.indexer stage-1  3/17] RUN yum install curl-minimal shadow-utils findutils hostname -y                                                                                 22.7s
 => [wazuh.indexer stage-1  4/17] RUN getent group wazuh-indexer || groupadd -r -g 1000 wazuh-indexer                                                                              0.7s
 => [wazuh.indexer stage-1  5/17] RUN useradd --system             --uid 1000             --no-create-home             --home-dir /usr/share/wazuh-indexer             --gid wazu  1.1s
 => [wazuh.manager  4/17] COPY config/check_repository.sh /                                                                                                                        0.4s
 => [wazuh.indexer builder 3/8] COPY config/check_repository.sh /                                                                                                                  0.4s
 => [wazuh.indexer stage-1  6/17] WORKDIR /usr/share/wazuh-indexer                                                                                                                 0.3s 
 => [wazuh.manager  5/17] COPY config/filebeat_module.sh /                                                                                                                         0.3s 
 => [wazuh.indexer builder 4/8] RUN chmod 775 /check_repository.sh &&     source /check_repository.sh                                                                              2.0s 
 => [wazuh.indexer stage-1  7/17] COPY config/entrypoint.sh /                                                                                                                      0.3s 
 => [wazuh.manager  6/17] COPY config/permanent_data.env config/permanent_data.sh /                                                                                                0.3s 
 => [wazuh.indexer stage-1  8/17] COPY config/securityadmin.sh /                                                                                                                   0.2s 
 => [wazuh.manager  7/17] RUN chmod 775 /check_repository.sh                                                                                                                       0.6s 
 => [wazuh.indexer stage-1  9/17] RUN chmod 700 /entrypoint.sh && chmod 700 /securityadmin.sh                                                                                      0.6s 
 => [wazuh.manager  8/17] RUN source /check_repository.sh                                                                                                                          1.3s 
 => [wazuh.indexer stage-1 10/17] RUN chown 1000:1000 /*.sh                                                                                                                        0.6s 
 => [wazuh.indexer builder 5/8] RUN yum install wazuh-indexer-4.9.2-1 -y &&     yum clean all                                                                                    209.2s 
 => [wazuh.manager  9/17] RUN yum install wazuh-manager-4.9.2-1 -y &&     yum clean all &&     chmod 775 /filebeat_module.sh &&     source /filebeat_module.sh &&     rm /fileb  205.1s 
 => [wazuh.manager 10/17] COPY config/etc/ /etc/                                                                                                                                   0.3s 
 => [wazuh.manager 11/17] COPY --chown=root:wazuh config/create_user.py /var/ossec/framework/scripts/create_user.py                                                                0.2s 
 => [wazuh.manager 12/17] COPY config/filebeat.yml /etc/filebeat/                                                                                                                  0.2s
 => [wazuh.manager 13/17] RUN chmod go-w /etc/filebeat/filebeat.yml                                                                                                                0.7s
 => [wazuh.manager 14/17] ADD https://raw.githubusercontent.com/wazuh/wazuh/v4.9.2/extensions/elasticsearch/7.x/wazuh-template.json /etc/filebeat                                  0.2s
 => [wazuh.manager 15/17] RUN chmod go-w /etc/filebeat/wazuh-template.json                                                                                                         1.3s
 => [wazuh.manager 16/17] RUN mkdir -p /var/ossec/var/multigroups &&     chown root:wazuh /var/ossec/var/multigroups &&     chmod 770 /var/ossec/var/multigroups &&     mkdir -p   2.3s
 => [wazuh.indexer builder 6/8] COPY config/config.sh .                                                                                                                            0.3s
 => [wazuh.indexer builder 7/8] COPY config/config.yml /                                                                                                                           0.2s
 => [wazuh.indexer builder 8/8] RUN bash config.sh                                                                                                                                 7.7s
 => [wazuh.manager 17/17] RUN rm /etc/yum.repos.d/wazuh.repo                                                                                                                       0.6s
 => [wazuh.manager] exporting to image                                                                                                                                            51.7s
 => => exporting layers                                                                                                                                                           51.6s
 => => writing image sha256:f92db999a394d25ecd05c0e7faab44965ea7e855d1ffba4b7f41f99f4766d40f                                                                                       0.0s
 => => naming to docker.io/wazuh/wazuh-manager:4.9.2                                                                                                                               0.0s
 => [wazuh.indexer stage-1 11/17] COPY --from=builder --chown=1000:1000 /usr/share/wazuh-indexer /usr/share/wazuh-indexer                                                         12.6s
 => [wazuh.indexer stage-1 12/17] COPY --from=builder --chown=1000:1000 /etc/wazuh-indexer /usr/share/wazuh-indexer                                                                0.2s
 => [wazuh.indexer stage-1 13/17] COPY --from=builder --chown=0:0 /debian/wazuh-indexer/usr/lib/systemd /usr/lib/systemd                                                           0.2s
 => [wazuh.indexer stage-1 14/17] COPY --from=builder --chown=0:0 /debian/wazuh-indexer/usr/lib/sysctl.d /usr/lib/sysctl.d                                                         0.2s
 => [wazuh.indexer stage-1 15/17] COPY --from=builder --chown=0:0 /debian/wazuh-indexer/usr/lib/tmpfiles.d /usr/lib/tmpfiles.d                                                     0.2s
 => [wazuh.indexer stage-1 16/17] RUN chown -R 1000:1000 /usr/share/wazuh-indexer                                                                                                 16.5s
 => [wazuh.indexer stage-1 17/17] RUN mkdir -p /var/lib/wazuh-indexer && chown 1000:1000 /var/lib/wazuh-indexer &&     mkdir -p /usr/share/wazuh-indexer/logs && chown 1000:1000   0.7s
 => [wazuh.indexer] exporting to image                                                                                                                                            10.2s
 => => exporting layers                                                                                                                                                           10.1s
 => => writing image sha256:7f875d89f1b9656495d4677171152b228977e8b2dabf3b7515973e98609c1a78                                                                                       0.0s
 => => naming to docker.io/wazuh/wazuh-indexer:4.9.2                                                                                                                               0.0s
 => [wazuh.manager] resolving provenance for metadata file                                                                                                                         0.1s
 => [wazuh.indexer] resolving provenance for metadata file                                                                                                                         0.0s
 => [wazuh.dashboard internal] load build definition from Dockerfile                                                                                                               0.1s
 => => transferring dockerfile: 3.25kB                                                                                                                                             0.0s
 => [wazuh.dashboard internal] load .dockerignore                                                                                                                                  0.0s
 => => transferring context: 2B                                                                                                                                                    0.0s
 => [wazuh.dashboard internal] load build context                                                                                                                                  0.1s
 => => transferring context: 268B                                                                                                                                                  0.0s
 => [wazuh.dashboard builder  2/12] RUN yum install curl-minimal libcap openssl -y                                                                                                19.7s
 => [wazuh.dashboard stage-1  2/14] RUN yum install shadow-utils -y                                                                                                               19.9s
 => [wazuh.dashboard builder  3/12] COPY config/check_repository.sh /                                                                                                              0.3s
 => [wazuh.dashboard stage-1  3/14] RUN getent group wazuh-dashboard || groupadd -r -g 1000 wazuh-dashboard                                                                        0.6s
 => [wazuh.dashboard builder  4/12] RUN chmod 775 /check_repository.sh &&     source /check_repository.sh                                                                          1.8s
 => [wazuh.dashboard stage-1  4/14] RUN useradd --system             --uid 1000             --no-create-home             --home-dir /usr/share/wazuh-dashboard             --gid   0.5s
 => [wazuh.dashboard stage-1  5/14] COPY config/entrypoint.sh /                                                                                                                    0.1s
 => [wazuh.dashboard stage-1  6/14] COPY config/wazuh_app_config.sh /                                                                                                              0.1s
 => [wazuh.dashboard stage-1  7/14] RUN chmod 700 /entrypoint.sh                                                                                                                   0.5s
 => [wazuh.dashboard stage-1  8/14] RUN chmod 700 /wazuh_app_config.sh                                                                                                             0.6s
 => [wazuh.dashboard builder  5/12] RUN yum install wazuh-dashboard-4.9.2-1 -y &&     yum clean all                                                                              100.6s
 => [wazuh.dashboard stage-1  9/14] RUN chown 1000:1000 /*.sh                                                                                                                      0.6s
 => [wazuh.dashboard builder  6/12] RUN mkdir -p /usr/share/wazuh-dashboard/data/wazuh && chmod -R 775 /usr/share/wazuh-dashboard/data/wazuh                                       0.4s
 => [wazuh.dashboard builder  7/12] RUN mkdir -p /usr/share/wazuh-dashboard/data/wazuh/config && chmod -R 775 /usr/share/wazuh-dashboard/data/wazuh/config                         0.4s
 => [wazuh.dashboard builder  8/12] RUN mkdir -p /usr/share/wazuh-dashboard/data/wazuh/logs && chmod -R 775 /usr/share/wazuh-dashboard/data/wazuh/logs                             0.5s
 => [wazuh.dashboard builder  9/12] COPY config/wazuh.yml /usr/share/wazuh-dashboard/data/wazuh/config/                                                                            0.1s
 => [wazuh.dashboard builder 10/12] COPY config/config.sh .                                                                                                                        0.1s
 => [wazuh.dashboard builder 11/12] COPY config/config.yml /                                                                                                                       0.2s
 => [wazuh.dashboard builder 12/12] RUN bash config.sh                                                                                                                             3.9s
 => [wazuh.dashboard stage-1 10/14] COPY --from=builder --chown=1000:1000 /usr/share/wazuh-dashboard /usr/share/wazuh-dashboard                                                   45.0s
 => [wazuh.dashboard stage-1 11/14] RUN mkdir -p /usr/share/wazuh-dashboard/plugins/wazuh/public/assets/custom                                                                     0.4s
 => [wazuh.dashboard stage-1 12/14] RUN chown 1000:1000 /usr/share/wazuh-dashboard/plugins/wazuh/public/assets/custom                                                              0.6s
 => [wazuh.dashboard stage-1 13/14] RUN echo "export JAVA_HOME=/usr/share/wazuh-dashboard/jdk" >> /etc/profile.d/java_home.sh &&     echo "export PATH=$PATH:$JAVA_HOME/bin" >> /  0.5s
 => [wazuh.dashboard stage-1 14/14] WORKDIR /usr/share/wazuh-dashboard                                                                                                             0.1s
 => [wazuh.dashboard] exporting to image                                                                                                                                          58.4s
 => => exporting layers                                                                                                                                                           58.3s
 => => writing image sha256:9dc69122ad5ce14cfdb397a1258c419b691078d2538583f1f1b65a805980b38f                                                                                       0.0s
 => => naming to docker.io/wazuh/wazuh-dashboard:4.9.2                                                                                                                             0.0s
 => [wazuh.dashboard] resolving provenance for metadata file                                                                                                                       0.1s
[+] Building 23.2s (9/9) FINISHED                                                                                                                                                       
 => [internal] load build definition from Dockerfile                                                                                                                               0.1s
 => => transferring dockerfile: 282B                                                                                                                                               0.0s
 => [internal] load metadata for docker.io/library/amazonlinux:2023                                                                                                                0.9s
 => [internal] load .dockerignore                                                                                                                                                  0.0s
 => => transferring context: 2B                                                                                                                                                    0.0s
 => CACHED [1/5] FROM docker.io/library/amazonlinux:2023@sha256:5cb6ab1a1a13f33425b6c660a45f06298e204a22df1f9eeefe69cda3735d9757                                                   0.0s
 => [internal] load build context                                                                                                                                                  0.1s
 => => transferring context: 2.49kB                                                                                                                                                0.0s
 => [2/5] RUN yum install curl-minimal openssl -y &&yum clean all                                                                                                                 21.2s
 => [3/5] COPY config/entrypoint.sh /                                                                                                                                              0.2s 
 => [4/5] RUN chmod 700 /entrypoint.sh                                                                                                                                             0.5s 
 => exporting to image                                                                                                                                                             0.2s 
 => => exporting layers                                                                                                                                                            0.2s 
 => => writing image sha256:ad4a24682edcc7019b845b4789c9066448dffbd550aa4c89014c7ba286791754                                                                                       0.0s 
 => => naming to docker.io/wazuh/wazuh-cert-tool:4.9.2                                                                                                                             0.0s 
~/wazuh-docker$ cd single-node/
~/wazuh-docker$ docker compose -f single-node/generate-certs.yml run --rm generator
[+] Creating 1/1
 ✔ Network single-node_default  Created                                                                                                                                            0.2s 
The tool to create the certificates exists in Packages-dev bucket
03/12/2024 13:06:27 INFO: Generating the root certificate.
03/12/2024 13:06:27 INFO: Generating Admin certificates.
03/12/2024 13:06:27 INFO: Admin certificates created.
03/12/2024 13:06:27 INFO: Generating Wazuh indexer certificates.
03/12/2024 13:06:28 INFO: Wazuh indexer certificates created.
03/12/2024 13:06:28 INFO: Generating Filebeat certificates.
03/12/2024 13:06:28 INFO: Wazuh Filebeat certificates created.
03/12/2024 13:06:28 INFO: Generating Wazuh dashboard certificates.
03/12/2024 13:06:28 INFO: Wazuh dashboard certificates created.
Moving created certificates to the destination directory
Changing certificate permissions
Setting UID indexer and dashboard
Setting UID for wazuh manager and worker
~/wazuh-docker/single-node$ docker compose up -d
[+] Running 18/18
 ✔ Network single-node_default                   Created                                                                                                                           0.2s 
 ✔ Volume "single-node_filebeat_etc"             Created                                                                                                                           0.0s 
 ✔ Volume "single-node_wazuh-dashboard-custom"   Created                                                                                                                           0.0s 
 ✔ Volume "single-node_wazuh_logs"               Created                                                                                                                           0.0s 
 ✔ Volume "single-node_filebeat_var"             Created                                                                                                                           0.0s 
 ✔ Volume "single-node_wazuh_agentless"          Created                                                                                                                           0.0s 
 ✔ Volume "single-node_wazuh_integrations"       Created                                                                                                                           0.0s 
 ✔ Volume "single-node_wazuh-dashboard-config"   Created                                                                                                                           0.0s 
 ✔ Volume "single-node_wazuh_active_response"    Created                                                                                                                           0.0s 
 ✔ Volume "single-node_wazuh-indexer-data"       Created                                                                                                                           0.0s 
 ✔ Volume "single-node_wazuh_api_configuration"  Created                                                                                                                           0.0s 
 ✔ Volume "single-node_wazuh_etc"                Created                                                                                                                           0.0s 
 ✔ Volume "single-node_wazuh_queue"              Created                                                                                                                           0.0s 
 ✔ Volume "single-node_wazuh_var_multigroups"    Created                                                                                                                           0.0s 
 ✔ Volume "single-node_wazuh_wodles"             Created                                                                                                                           0.0s 
 ✔ Container single-node-wazuh.manager-1         Started                                                                                                                           1.4s 
 ✔ Container single-node-wazuh.indexer-1         Started                                                                                                                           1.2s 
 ✔ Container single-node-wazuh.dashboard-1       Started                                                                                                                           1.9s 
~/wazuh-docker/single-node$ docker compose ps
NAME                            IMAGE                         COMMAND                  SERVICE           CREATED         STATUS         PORTS
single-node-wazuh.dashboard-1   wazuh/wazuh-dashboard:4.9.2   "/entrypoint.sh open…"   wazuh.dashboard   8 minutes ago   Up 8 minutes   443/tcp, 0.0.0.0:443->5601/tcp, [::]:443->5601/tcp
single-node-wazuh.indexer-1     wazuh/wazuh-indexer:4.9.2     "/entrypoint.sh open…"   wazuh.indexer     8 minutes ago   Up 8 minutes   0.0.0.0:9200->9200/tcp, :::9200->9200/tcp
single-node-wazuh.manager-1     wazuh/wazuh-manager:4.9.2     "/init"                  wazuh.manager     8 minutes ago   Up 8 minutes   0.0.0.0:1514-1515->1514-1515/tcp, :::1514-1515->1514-1515/tcp, 0.0.0.0:514->514/udp, :::514->514/udp, 0.0.0.0:55000->55000/tcp, :::55000->55000/tcp, 1516/tcp
~/wazuh-docker/single-node$ docker compose down -v
[+] Running 18/18
 ✔ Container single-node-wazuh.dashboard-1     Removed                                                                                                                            11.3s 
 ✔ Container single-node-wazuh.indexer-1       Removed                                                                                                                             0.8s 
 ✔ Container single-node-wazuh.manager-1       Removed                                                                                                                             4.3s 
 ✔ Volume single-node_wazuh-dashboard-custom   Removed                                                                                                                             0.0s 
 ✔ Volume single-node_wazuh_wodles             Removed                                                                                                                             0.1s 
 ✔ Volume single-node_filebeat_var             Removed                                                                                                                             0.0s 
 ✔ Volume single-node_wazuh_integrations       Removed                                                                                                                             0.0s 
 ✔ Volume single-node_filebeat_etc             Removed                                                                                                                             0.1s 
 ✔ Volume single-node_wazuh-indexer-data       Removed                                                                                                                             0.0s 
 ✔ Volume single-node_wazuh_active_response    Removed                                                                                                                             0.1s 
 ✔ Volume single-node_wazuh-dashboard-config   Removed                                                                                                                             0.0s 
 ✔ Volume single-node_wazuh_etc                Removed                                                                                                                             0.0s 
 ✔ Volume single-node_wazuh_logs               Removed                                                                                                                             0.1s 
 ✔ Volume single-node_wazuh_agentless          Removed                                                                                                                             0.1s 
 ✔ Volume single-node_wazuh_queue              Removed                                                                                                                             0.7s 
 ✔ Volume single-node_wazuh_var_multigroups    Removed                                                                                                                             0.1s 
 ✔ Volume single-node_wazuh_api_configuration  Removed                                                                                                                             0.2s 
 ✔ Network single-node_default                 Removed                                                                                                                             0.6s 
~/wazuh-docker/single-node$ cd ..
~/wazuh-docker$ cd multi-node/
~/wazuh-docker/multi-node$ docker compose -f generate-certs.yml run --rm generator
[+] Creating 1/1
 ✔ Network multi-node_default  Created                                                                                                                                             0.2s 
The tool to create the certificates exists in Packages-dev bucket
03/12/2024 13:18:49 INFO: Generating the root certificate.
03/12/2024 13:18:49 INFO: Generating Admin certificates.
03/12/2024 13:18:50 INFO: Admin certificates created.
03/12/2024 13:18:50 INFO: Generating Wazuh indexer certificates.
03/12/2024 13:18:50 INFO: Wazuh indexer certificates created.
03/12/2024 13:18:50 INFO: Generating Filebeat certificates.
03/12/2024 13:18:51 INFO: Wazuh Filebeat certificates created.
03/12/2024 13:18:51 INFO: Generating Wazuh dashboard certificates.
03/12/2024 13:18:51 INFO: Wazuh dashboard certificates created.
Moving created certificates to the destination directory
Changing certificate permissions
Setting UID indexer and dashboard
Setting UID for wazuh manager and worker
~/wazuh-docker/multi-node$ docker compose up -d
[+] Running 8/8
 ✔ nginx Pulled                                                                                                                                                                   24.9s 
   ✔ bc0965b23a04 Pull complete                                                                                                                                                   16.3s 
   ✔ af38aa266166 Pull complete                                                                                                                                                   20.2s 
   ✔ 53a8d9cbfd8a Pull complete                                                                                                                                                   20.3s 
   ✔ 61f8f240c02d Pull complete                                                                                                                                                   20.3s 
   ✔ 6aec90d25585 Pull complete                                                                                                                                                   20.4s 
   ✔ 209e8c8a5c7e Pull complete                                                                                                                                                   20.5s 
   ✔ 97fc0bab11f2 Pull complete                                                                                                                                                   20.6s 
[+] Running 34/34
 ✔ Volume "multi-node_worker-wazuh-integrations"       Created                                                                                                                     0.0s 
 ✔ Volume "multi-node_wazuh-dashboard-config"          Created                                                                                                                     0.0s 
 ✔ Volume "multi-node_master-wazuh-logs"               Created                                                                                                                     0.0s 
 ✔ Volume "multi-node_master-wazuh-active-response"    Created                                                                                                                     0.0s 
 ✔ Volume "multi-node_master-filebeat-var"             Created                                                                                                                     0.0s 
 ✔ Volume "multi-node_worker-filebeat-etc"             Created                                                                                                                     0.0s 
 ✔ Volume "multi-node_wazuh-dashboard-custom"          Created                                                                                                                     0.0s 
 ✔ Volume "multi-node_worker-wazuh-wodles"             Created                                                                                                                     0.0s 
 ✔ Volume "multi-node_worker-wazuh-api-configuration"  Created                                                                                                                     0.0s 
 ✔ Volume "multi-node_master-wazuh-queue"              Created                                                                                                                     0.0s 
 ✔ Volume "multi-node_wazuh-indexer-data-1"            Created                                                                                                                     0.0s 
 ✔ Volume "multi-node_worker-wazuh-queue"              Created                                                                                                                     0.0s 
 ✔ Volume "multi-node_worker-wazuh-agentless"          Created                                                                                                                     0.0s 
 ✔ Volume "multi-node_wazuh-indexer-data-2"            Created                                                                                                                     0.0s 
 ✔ Volume "multi-node_worker-wazuh-logs"               Created                                                                                                                     0.0s 
 ✔ Volume "multi-node_wazuh-indexer-data-3"            Created                                                                                                                     0.0s 
 ✔ Volume "multi-node_master-wazuh-api-configuration"  Created                                                                                                                     0.0s 
 ✔ Volume "multi-node_worker-wazuh-etc"                Created                                                                                                                     0.0s 
 ✔ Volume "multi-node_master-filebeat-etc"             Created                                                                                                                     0.0s 
 ✔ Volume "multi-node_worker-wazuh-active-response"    Created                                                                                                                     0.0s 
 ✔ Volume "multi-node_worker-wazuh-var-multigroups"    Created                                                                                                                     0.0s 
 ✔ Volume "multi-node_master-wazuh-agentless"          Created                                                                                                                     0.0s 
 ✔ Volume "multi-node_master-wazuh-integrations"       Created                                                                                                                     0.0s 
 ✔ Volume "multi-node_master-wazuh-etc"                Created                                                                                                                     0.0s 
 ✔ Volume "multi-node_worker-filebeat-var"             Created                                                                                                                     0.0s 
 ✔ Volume "multi-node_master-wazuh-var-multigroups"    Created                                                                                                                     0.0s 
 ✔ Volume "multi-node_master-wazuh-wodles"             Created                                                                                                                     0.0s 
 ✔ Container multi-node-wazuh.worker-1                 Started                                                                                                                     2.8s 
 ✔ Container multi-node-wazuh3.indexer-1               Started                                                                                                                     2.8s 
 ✔ Container multi-node-wazuh2.indexer-1               Started                                                                                                                     2.9s 
 ✔ Container multi-node-wazuh.master-1                 Started                                                                                                                     3.2s 
 ✔ Container multi-node-wazuh1.indexer-1               Started                                                                                                                     3.1s 
 ✔ Container multi-node-wazuh.dashboard-1              Started                                                                                                                     3.0s 
 ✔ Container multi-node-nginx-1                        Started                                                                                                                     4.3s 
~/wazuh-docker/multi-node$ docker compose ps
NAME                           IMAGE                         COMMAND                  SERVICE           CREATED              STATUS              PORTS
multi-node-nginx-1             nginx:stable                  "/docker-entrypoint.…"   nginx             About a minute ago   Up About a minute   80/tcp, 0.0.0.0:1514->1514/tcp, :::1514->1514/tcp
multi-node-wazuh.dashboard-1   wazuh/wazuh-dashboard:4.9.2   "/entrypoint.sh open…"   wazuh.dashboard   About a minute ago   Up About a minute   443/tcp, 0.0.0.0:443->5601/tcp, [::]:443->5601/tcp
multi-node-wazuh.master-1      wazuh/wazuh-manager:4.9.2     "/init"                  wazuh.master      About a minute ago   Up About a minute   1514/tcp, 0.0.0.0:1515->1515/tcp, :::1515->1515/tcp, 0.0.0.0:514->514/udp, :::514->514/udp, 1516/tcp, 0.0.0.0:55000->55000/tcp, :::55000->55000/tcp
multi-node-wazuh.worker-1      wazuh/wazuh-manager:4.9.2     "/init"                  wazuh.worker      About a minute ago   Up About a minute   1514-1516/tcp, 514/udp, 55000/tcp
multi-node-wazuh1.indexer-1    wazuh/wazuh-indexer:4.9.2     "/entrypoint.sh open…"   wazuh1.indexer    About a minute ago   Up About a minute   0.0.0.0:9200->9200/tcp, :::9200->9200/tcp
multi-node-wazuh2.indexer-1    wazuh/wazuh-indexer:4.9.2     "/entrypoint.sh open…"   wazuh2.indexer    About a minute ago   Up About a minute   9200/tcp
multi-node-wazuh3.indexer-1    wazuh/wazuh-indexer:4.9.2     "/entrypoint.sh open…"   wazuh3.indexer    About a minute ago   Up About a minute   9200/tcp
~/wazuh-docker/multi-node$ docker compose down -v
[+] Running 35/35
 ✔ Container multi-node-nginx-1                      Removed                                                                                                                       6.7s 
 ✔ Container multi-node-wazuh2.indexer-1             Removed                                                                                                                       6.8s 
 ✔ Container multi-node-wazuh3.indexer-1             Removed                                                                                                                       6.8s 
 ✔ Container multi-node-wazuh.dashboard-1            Removed                                                                                                                      12.7s 
 ✔ Container multi-node-wazuh.worker-1               Removed                                                                                                                       7.6s 
 ✔ Container multi-node-wazuh.master-1               Removed                                                                                                                       5.0s 
 ✔ Container multi-node-wazuh1.indexer-1             Removed                                                                                                                       1.3s 
 ✔ Volume multi-node_worker-wazuh-agentless          Removed                                                                                                                       0.0s 
 ✔ Volume multi-node_worker-filebeat-var             Removed                                                                                                                       0.3s 
 ✔ Volume multi-node_master-wazuh-var-multigroups    Removed                                                                                                                       0.3s 
 ✔ Volume multi-node_worker-wazuh-logs               Removed                                                                                                                       0.4s 
 ✔ Volume multi-node_master-wazuh-wodles             Removed                                                                                                                       0.3s 
 ✔ Volume multi-node_wazuh-dashboard-custom          Removed                                                                                                                       0.2s 
 ✔ Volume multi-node_master-wazuh-etc                Removed                                                                                                                       0.3s 
 ✔ Volume multi-node_master-wazuh-logs               Removed                                                                                                                       0.4s 
 ✔ Volume multi-node_master-wazuh-queue              Removed                                                                                                                       0.1s 
 ✔ Volume multi-node_worker-wazuh-api-configuration  Removed                                                                                                                       0.4s 
 ✔ Volume multi-node_worker-wazuh-etc                Removed                                                                                                                       0.4s 
 ✔ Volume multi-node_worker-wazuh-integrations       Removed                                                                                                                       0.3s 
 ✔ Volume multi-node_wazuh-indexer-data-2            Removed                                                                                                                       0.3s 
 ✔ Volume multi-node_worker-wazuh-queue              Removed                                                                                                                       0.3s 
 ✔ Volume multi-node_worker-wazuh-wodles             Removed                                                                                                                       0.0s 
 ✔ Volume multi-node_wazuh-indexer-data-1            Removed                                                                                                                       0.4s 
 ✔ Volume multi-node_wazuh-dashboard-config          Removed                                                                                                                       0.2s 
 ✔ Volume multi-node_master-filebeat-var             Removed                                                                                                                       0.2s 
 ✔ Volume multi-node_master-wazuh-api-configuration  Removed                                                                                                                       0.1s 
 ✔ Volume multi-node_master-filebeat-etc             Removed                                                                                                                       0.3s 
 ✔ Volume multi-node_master-wazuh-active-response    Removed                                                                                                                       0.3s 
 ✔ Volume multi-node_worker-wazuh-var-multigroups    Removed                                                                                                                       0.2s 
 ✔ Volume multi-node_master-wazuh-agentless          Removed                                                                                                                       0.3s 
 ✔ Volume multi-node_wazuh-indexer-data-3            Removed                                                                                                                       0.2s 
 ✔ Volume multi-node_master-wazuh-integrations       Removed                                                                                                                       0.2s 
 ✔ Volume multi-node_worker-filebeat-etc             Removed                                                                                                                       0.3s 
 ✔ Volume multi-node_worker-wazuh-active-response    Removed                                                                                                                       0.1s 
 ✔ Network multi-node_default                        Removed                                                                                                                       0.4s 
~/wazuh-docker/multi-node$ 

@wazuhci wazuhci moved this from In progress to On hold in Release 5.0.0 Dec 2, 2024
@vcerenu
Copy link
Member

vcerenu commented Dec 3, 2024

Conclusion

  1. Docker image ownership:
  • Each subsystem owner is responsible for maintaining its Docker images.
  • Each image must run a primary process, and the container lifecycle must align with this process.

This point requires a better understanding of the Wazuh 5.0.0 deployment, which is not yet finished, so this test is blocked.
It should be noted that the Wazuh indexer and Wazuh dashboard images currently meet the condition that the container's life cycle is linked to the application's primary process. Currently, the Wazuh manager does not meet this condition since it does not have a main process to which the life of the container is tied, so we cannot be 100% sure that while the container is running, all the services provided by the image are active.

  1. DevOps-Owned Docker image build and registries:
  • Split the "Push Docker images" workflows into three separate workflows (one for each component) and migrate them to the respective repositories.
  • Allow development images to be pushed to a registry other than DockerHub.

An image creation test was performed, directly using the Dockerfiles of each of the images, leaving aside the docker-compose.yml file that is currently executed to generate the images. With this test we know that we can migrate each of the directories found within the build-docker-images/ directory to a separate repository in order to assign each responsible team the creation of its own Docker image.
Regarding this section, we need the development packages to be able to test and also to be assigned which repositories we are going to use to create the development images.

  1. Docker Registry Analysis:
  • Research Docker registry alternatives for development images.
  • Evaluate if AWS ECR meets our needs for hosting development images.

I have been performing tests with AWS ECR and it seems to me to be the best solution to have private and secure development images, since both to push and pull images we only need to copy the Docker login credentials to the server where we perform the test. The use of these images hosted in ECR cannot be used directly (authentication is needed), although the name of the image registry is always the same, so it can be added in the tests.

  1. Repository Scope Clarification:
  • The Wazuh Docker repository should focus solely on container deployments.
  • Migrate all Docker image build-related code to their respective repositories.
  • The Docker deployment must use out-of-the-box Wazuh configurations.

The deployment of Wazuh with Docker images is currently possible if we move the respective code for the creation of images to each repository. Regarding out-of-the-box usage,, the image should allow us to set parameters from the deployment and the image to use them to make replacements (with sed or whatever we define) in the configuration files. Only the minimum necessary for communication between components will be parameterized (everything related to IPs/DNS).

  1. Build Process Simplification:
  • Docker images must use Wazuh package URLs instead of repositories.
  • Utilize out-of-the-box Wazuh configurations for builds and deployments.

Development packages will be obtained with a signed URL that the image building workflow has to generate. We expect that there will be a latest package for each version for each component so that we do not have to go looking for a fixed name when building a development image. Each development image that is uploaded must be uploaded with the commit in the tag and also as $VERSION-latest. Additionally, the workflow must allow entering the commit of each package of each component to build development images that are not the latest. In the case of pre-release and production images, it must be defined with the QA team to see how they are going to implement it:

  • that the workflow allows building from pre-release and for prod the pre-release image is downloaded, retrieval is made and the final production image is uploaded
  • that the workflow allows building from pre-release and from production
  1. Testing Improvements:
  • Enhance deployment tests with additional checks, including log validation for errors and warnings.
  • Ensure each team has an automatic PR check (GHA) for validating changes.

We currently have tests for all Wazuh components with Docker. We should use the latest tag for testing and the workflow should allow entering the image commit for each component in case it is required to test with specific images.
The rest of the teams should run deployment tests on each build of a new image (whether development or pre-release/prod). Define how they would do it (which images of the rest of the components should be used and if they would call our DevOps workflow).
If we are going to include multi-arch, we will have to test multi-arch.

  1. Documentation Updates:
  • Simplify Docker installation documentation.
  • Focus on prerequisites for Wazuh Docker deployment, using the Wazuh Kubernetes documentation as a reference.

This step can be solved by removing the documentation regarding the installation of Docker and referring to the use of the official Docker documentation. In our documentation we would maintain the prerequisites and Docker versions that we will support in our deployment.

  1. Multi-Node Deployment Decision:
  • Determine whether maintaining multi-node deployments is necessary. (definition: yes)

It was determined that the multi-node deployment will be maintained for 5.0.0, so we will maintain the current deployment that we have.

  1. Multi architecture Docker images:
  • The Docker images must be multi-arch. They must allow amd64 and arm64.

It should be noted that within this Review process we must also modify several parameters used in the docker-compose.yml deployment file, which include adaptations for the latest versions of docker compose, parameters that were not used previously and that would generate a more orderly deployment and adaptations to the new images, but these changes will be reviewed when we have the test images.

@wazuhci wazuhci moved this from On hold to In progress in Release 5.0.0 Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: In progress
Development

No branches or pull requests

2 participants