From 5a8da80ad985aab32fcdccf9c8543accc8db08d4 Mon Sep 17 00:00:00 2001 From: Nicolas Kowenski Date: Mon, 18 Mar 2019 10:45:11 +0100 Subject: [PATCH] ClamAV OpenSource antivirus by Cisco - Talos. (#12022) * ClamAV Helm Chart Signed-off-by: nicolas kowenski * Readme.MD Signed-off-by: nicolas kowenski * Chart mantainers and Owners details Signed-off-by: nicolas kowenski * Update chart description Signed-off-by: nicolas kowenski * Update Readme with author information Signed-off-by: nicolas kowenski * Update Readme with memory and virus updates details Signed-off-by: nicolas kowenski * set version to 1.0.0 Signed-off-by: Paul Czarkowski --- stable/clamav/.helmignore | 21 ++++++++ stable/clamav/Chart.yaml | 9 ++++ stable/clamav/OWNERS | 4 ++ stable/clamav/README.md | 66 +++++++++++++++++++++++++ stable/clamav/templates/NOTES.txt | 19 +++++++ stable/clamav/templates/_helpers.tpl | 32 ++++++++++++ stable/clamav/templates/deployment.yaml | 51 +++++++++++++++++++ stable/clamav/templates/ingress.yaml | 38 ++++++++++++++ stable/clamav/templates/service.yaml | 19 +++++++ stable/clamav/values.yaml | 48 ++++++++++++++++++ 10 files changed, 307 insertions(+) create mode 100644 stable/clamav/.helmignore create mode 100644 stable/clamav/Chart.yaml create mode 100644 stable/clamav/OWNERS create mode 100644 stable/clamav/README.md create mode 100644 stable/clamav/templates/NOTES.txt create mode 100644 stable/clamav/templates/_helpers.tpl create mode 100644 stable/clamav/templates/deployment.yaml create mode 100644 stable/clamav/templates/ingress.yaml create mode 100644 stable/clamav/templates/service.yaml create mode 100644 stable/clamav/values.yaml diff --git a/stable/clamav/.helmignore b/stable/clamav/.helmignore new file mode 100644 index 0000000000..f0c1319444 --- /dev/null +++ b/stable/clamav/.helmignore @@ -0,0 +1,21 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj diff --git a/stable/clamav/Chart.yaml b/stable/clamav/Chart.yaml new file mode 100644 index 0000000000..26c2a68070 --- /dev/null +++ b/stable/clamav/Chart.yaml @@ -0,0 +1,9 @@ +apiVersion: v1 +appVersion: "1.0" +description: An Open-Source antivirus engine for detecting trojans, viruses, malware & other malicious threats. +name: clamav +version: 1.0.0 +home: https://www.clamav.net +maintainers: +- name: zakkg3 + email: zakkg3@gmail.com diff --git a/stable/clamav/OWNERS b/stable/clamav/OWNERS new file mode 100644 index 0000000000..c6c13219bf --- /dev/null +++ b/stable/clamav/OWNERS @@ -0,0 +1,4 @@ +approvers: +- zakkg3 +reviewers: +- zakkg3 diff --git a/stable/clamav/README.md b/stable/clamav/README.md new file mode 100644 index 0000000000..e4a07887ad --- /dev/null +++ b/stable/clamav/README.md @@ -0,0 +1,66 @@ +# ClamAV + +## An Open-Source antivirus engine for detecting trojans, viruses, malware & other malicious threats. + +[ClamAV](https://www.clamav.net/) is the open source standard for mail gateway scanning software. + Developed by [Cisco Talos](https://github.com/Cisco-Talos/clamav-devel). This Helm Chart uses the [MailU](https://github.com/Mailu/Mailu) Docker image. + +## QuickStart + +```bash +$ helm install stable/clamav --name foo --namespace bar +``` + +## Introduction + +This chart bootstraps a ClamAV deployment and service on a Kubernetes cluster using the Helm Package manager. + +## Prerequisites + +- Kubernetes 1.4+ +- PV provisioner support in the underlying infrastructure (optional) + +## Installing the Chart + +To install the chart with the release name `my-release`: + +```bash +$ helm install --name my-release stable/clamav +``` + +The command deploys ClamAV on the Kubernetes cluster in the default configuration. The [configuration](#configuration) section lists the parameters that can be configured during installation. + +> **Tip**: List all releases using `helm list` + +## Uninstalling the Chart + +To uninstall/delete the `my-release` deployment: + +```bash +$ helm delete my-release --purge +``` + +The command removes all the Kubernetes components associated with the chart and deletes the release. + +## Configuration + +The configurable parameters of the ClamAV chart and +their descriptions can be seen in `values.yaml`. The [full documentation](https://www.clamav.net/documents/clam-antivirus-0-101-0-user-manual) contains more information about running ClamAV in docker. + +> **Tip**: You can use the default [values.yaml](values.yaml) + +## Memory Usage + +ClamAV uses around 1 GB RAM. + + + + +# Virus Definitions + +For ClamAV to work properly, both the ClamAV engine and the ClamAV Virus Database (CVD) must be kept up to date. + +The virus database is usually updated many times per week. + +Freshclam should perform these updates automatically. Instructions for setting up Freshclam can be found in the [ documentation](https://www.clamav.net/documents/clam-antivirus-0-101-0-user-manual) section. +If your network is segmented or the end hosts are unable to reach the Internet, you should investigate setting up a private local mirror. If this is not viable, you may use these direct [ download](https://www.clamav.net/downloads) diff --git a/stable/clamav/templates/NOTES.txt b/stable/clamav/templates/NOTES.txt new file mode 100644 index 0000000000..0d36bbcb93 --- /dev/null +++ b/stable/clamav/templates/NOTES.txt @@ -0,0 +1,19 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range .Values.ingress.hosts }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "clamav.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get svc -w {{ include "clamav.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "clamav.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "clamav.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl port-forward $POD_NAME 8080:80 +{{- end }} diff --git a/stable/clamav/templates/_helpers.tpl b/stable/clamav/templates/_helpers.tpl new file mode 100644 index 0000000000..05851a8245 --- /dev/null +++ b/stable/clamav/templates/_helpers.tpl @@ -0,0 +1,32 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "clamav.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "clamav.fullname" -}} +{{- if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "clamav.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/stable/clamav/templates/deployment.yaml b/stable/clamav/templates/deployment.yaml new file mode 100644 index 0000000000..c1621312fa --- /dev/null +++ b/stable/clamav/templates/deployment.yaml @@ -0,0 +1,51 @@ +apiVersion: apps/v1beta2 +kind: Deployment +metadata: + name: {{ include "clamav.fullname" . }} + labels: + app.kubernetes.io/name: {{ include "clamav.name" . }} + helm.sh/chart: {{ include "clamav.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app.kubernetes.io/name: {{ include "clamav.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + template: + metadata: + labels: + app.kubernetes.io/name: {{ include "clamav.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + spec: + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: clamavport + containerPort: 3310 + protocol: TCP + livenessProbe: + tcpSocket: + port: clamavport + initialDelaySeconds: 300 + readinessProbe: + tcpSocket: + port: clamavport + initialDelaySeconds: 300 + resources: +{{ toYaml .Values.resources | indent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: +{{ toYaml . | indent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: +{{ toYaml . | indent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: +{{ toYaml . | indent 8 }} + {{- end }} diff --git a/stable/clamav/templates/ingress.yaml b/stable/clamav/templates/ingress.yaml new file mode 100644 index 0000000000..4956381f73 --- /dev/null +++ b/stable/clamav/templates/ingress.yaml @@ -0,0 +1,38 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "clamav.fullname" . -}} +{{- $ingressPath := .Values.ingress.path -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + app.kubernetes.io/name: {{ include "clamav.name" . }} + helm.sh/chart: {{ include "clamav.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- with .Values.ingress.annotations }} + annotations: +{{ toYaml . | indent 4 }} +{{- end }} +spec: +{{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} +{{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ . | quote }} + http: + paths: + - path: {{ $ingressPath }} + backend: + serviceName: {{ $fullName }} + servicePort: http + {{- end }} +{{- end }} diff --git a/stable/clamav/templates/service.yaml b/stable/clamav/templates/service.yaml new file mode 100644 index 0000000000..a23621bf75 --- /dev/null +++ b/stable/clamav/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "clamav.fullname" . }} + labels: + app.kubernetes.io/name: {{ include "clamav.name" . }} + helm.sh/chart: {{ include "clamav.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: 3310 + protocol: TCP + name: clamavport + selector: + app.kubernetes.io/name: {{ include "clamav.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} diff --git a/stable/clamav/values.yaml b/stable/clamav/values.yaml new file mode 100644 index 0000000000..2334199bee --- /dev/null +++ b/stable/clamav/values.yaml @@ -0,0 +1,48 @@ +# Default values for ClamAV. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: mailu/clamav + tag: latest + pullPolicy: IfNotPresent + +nameOverride: "" +fullnameOverride: "" + +service: + type: ClusterIP + port: 3310 + +ingress: + enabled: false + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + path: / + hosts: + - chart-example.local + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +nodeSelector: {} + +tolerations: [] + +affinity: {}