Using Existing Kubernetes Cluster

This guide explains how to use the provisioning script for generating all the Kubernetes components needed to run MetaDefender Core in you already created K8S cluster that depending on some configuration options chosen it will adapt the helm chart values for configuring it properly.

Also includes the details needed to understand how to install MetaDefender Core using directly the Helm chart.

Flowchart for MetaDefender K8S Script

The following flow chart represents how the MetaDefenderK8S script will configure the environment based on the options selected for installing MetaDefender products in an already created cluster.

Summary options to be selected

  1. Select your cluster context where you want to install the MetaDefender products

  2. Access to the K8S cluster. Generate Ingress or provide own access.

    1. An Ingress will be create per each product flag added as parameter to the script
    2. Own Access, you decide how to access to the cluster so it won't generate any ingress for accessing
  3. Have your own database or create new database

    1. Own database, will be asked if you want either

      1. the script to set up the credentials and database host url for you
      2. the script will just indicate the secrets to edit, later on by you, for connecting the MetaDefender Core with your database.
    2. Create new DB in K8S. It will generate a postgreSQL pod inside the cluster

MetaDefender K8S script details

  • Script path: https://github.com/OPSWAT/metadefender-k8s/blob/main/metadefenderk8s.sh

  • Programming Language: Bash

  • Installation Pre-requisites for installing:

  • MetaDefender Core License Key (Required with --mdcore parameter)

    • Set it in your local environment credentials under MDCORE_LICENSE_KEY

How to run script

Only MD Core
MD Core + MDSS
Copy

Script Parameters

ParameterFlagsOptionsDefaultDescriptionRequired/Optional
Cluster Name--namemd-k8sName of the cluster that will be used for naming all the resourcesRequired
MetaDefender Flag Installation

Combination of

  • --mdcore
  • --mdss
-Install MD Core in the cluster provisionedRequired
Image Version--imagelatest 5.0.1latestMD Core image version to installOptional
Region--region[AWS Regions](AWS Regions)eu-central-1AWS region where all the resources will be provisionedOptional
Number of Replicas--replicas[0-9]*1Number of replicas for MD Core serviceOptional
Namespace--namespace[A-Za-z]{1,10}Namespace where MetaDefender products will be installed in the K8S ClusterOptional Max Characters: 10

Install using the Helm chart

The MD Core k8s deployment can be performed directly using the provided helm chart in our public GitHub repo here and example configuration files for different environments are provided in the helm_charts directory.

Using the helm repository

The GitHub repository can be used directly as a helm repo:

Bash
Copy

Or the repository can be cloned locally:

Bash
Copy

Storage

MD Core containers are stateless and don't require any persistent storage. If the PostgreSQL database is deployed in the cluster, then it's recommended to use persistent storage managed by a cloud provider.

The helm chart can be configured to use a custom storage class or persistent volume by setting the storage_provisioner value to custom, adding the Kubernetes yaml for the persistent volume claim in the storage_configs value and then using the pvc name in the storage_name value to tell the Postgres pod where to save it's files. Here's an example using managed storage in Azure:

YAML
Copy

When using an external database that is not deployed from the MD Core chart, the deploy_with_core_db value has to be set to false in order to not deploy an additional database from the chart.

Exposing MD Core

By default, the helm chart deploys a ClusterIP service for MD Core and this can be changed to any service type supported by the Kubernetes cluster. For example, a LoadBalancerservice type can be created by overwriting the service_type value in the md-core component:

YAML
Copy

MD Core can also be exposed using an ingress:

YAML
Copy

Scaling MD Core

Multiple MD Core pods can be deployed by setting the replicasvalue in themd-core component:

YAML
Copy

TLS Configuration

In case we want to use a self-signed certificate, we need to create the secrets with the crt and key

Bash
Copy

We can set up the configuration parameters in the values.yaml file

YAML
Copy

Nginx Ingress Configuration

  1. In case we want to use a self-signed certificate, we need to create the tls secret with the crt and key
Bash
Copy
  1. Set up the following configuration parameters in the values.yaml file
YAML
Copy
  1. Install MetaDefender Core using Helm
  2. Install Nginx Ingress Controller (Example adapted to Azure, check your CSP to adapt the command to it)
Bash
Copy
Type to search, ESC to discard
Type to search, ESC to discard
Type to search, ESC to discard