diff --git a/deployments/nimbus-kubearmor/Readme.md b/deployments/nimbus-kubearmor/Readme.md index 706237aa..968930e0 100644 --- a/deployments/nimbus-kubearmor/Readme.md +++ b/deployments/nimbus-kubearmor/Readme.md @@ -18,7 +18,7 @@ helm upgrade --install nimbus-kubearmor . -n nimbus | Key | Type | Default | Description | |------------------|--------|------------------------|----------------------------------------------------------------------------| | image.repository | string | 5gsec/nimbus-kubearmor | Image repository from which to pull the `nimbus-kubearmor` adapter's image | -| image.pullPolicy | string | IfNotPresent | `nimbus-kubearmor` adapter image pull policy | +| image.pullPolicy | string | Always | `nimbus-kubearmor` adapter image pull policy | | image.tag | string | latest | `nimbus-kubearmor` adapter image tag | ## Verify if all the resources are up and running @@ -37,7 +37,7 @@ NAME DESIRED CURRENT READY AGE replicaset.apps/nimbus-kubearmor-7f6854cf8f 1 1 1 3m25s ``` -## Uninstall the Operator +## Uninstall the KubeArmor adapter To uninstall, just run: diff --git a/deployments/nimbus-kubearmor/values.yaml b/deployments/nimbus-kubearmor/values.yaml index 29d2172e..8691d620 100644 --- a/deployments/nimbus-kubearmor/values.yaml +++ b/deployments/nimbus-kubearmor/values.yaml @@ -4,7 +4,7 @@ replicaCount: 1 image: repository: 5gsec/nimbus-kubearmor - pullPolicy: IfNotPresent + pullPolicy: Always # Overrides the image tag whose default is the chart appVersion. tag: "latest" diff --git a/deployments/nimbus-netpol/.helmignore b/deployments/nimbus-netpol/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/deployments/nimbus-netpol/.helmignore @@ -0,0 +1,23 @@ +# 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 +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/deployments/nimbus-netpol/Chart.yaml b/deployments/nimbus-netpol/Chart.yaml new file mode 100644 index 00000000..ece938f1 --- /dev/null +++ b/deployments/nimbus-netpol/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: nimbus-netpol +description: A Helm chart for Kubernetes NetworkPolicy as an adapter for Nimbus. + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "0.1.0" diff --git a/deployments/nimbus-netpol/Readme.md b/deployments/nimbus-netpol/Readme.md new file mode 100644 index 00000000..24fc6d8d --- /dev/null +++ b/deployments/nimbus-netpol/Readme.md @@ -0,0 +1,46 @@ +# Install NetworkPolicy adapter + +> [!Note] +> The `nimbus-netpol` adapter leverages +> the [network plugin](https://kubernetes.io/docs/concepts/extend-kubernetes/compute-storage-net/network-plugins/) +> for its functionality. +> To use this adapter, you must be using a networking solution which supports NetworkPolicy. + +Install `nimbus-netpol` adapter using Helm charts locally (for testing) + +```bash +cd deployments/nimbus-netpol/ +helm upgrade --install nimbus-netpol . -n nimbus +``` + +## Values + +| Key | Type | Default | Description | +|------------------|--------|---------------------|-------------------------------------------------------------------------| +| image.repository | string | 5gsec/nimbus-netpol | Image repository from which to pull the `nimbus-netpol` adapter's image | +| image.pullPolicy | string | Always | `nimbus-netpol` adapter image pull policy | +| image.tag | string | latest | `nimbus-netpol` adapter image tag | + +## Verify if all the resources are up and running + +Once done, the following resources will exist in your cluster: + +```shell +$ kubectl get all -n nimbus -l app.kubernetes.io/instance=nimbus-netpol +NAME READY STATUS RESTARTS AGE +pod/nimbus-netpol-6ccd868c49-wb54j 1/1 Running 0 3m57s + +NAME READY UP-TO-DATE AVAILABLE AGE +deployment.apps/nimbus-netpol 1/1 1 1 3m58s + +NAME DESIRED CURRENT READY AGE +replicaset.apps/nimbus-netpol-6ccd868c49 1 1 1 3m57s +``` + +## Uninstall the NetworkPolicy adapter + +To uninstall, just run: + +```bash +helm uninstall nimbus-netpol -n nimbus +``` diff --git a/deployments/nimbus-netpol/templates/_helpers.tpl b/deployments/nimbus-netpol/templates/_helpers.tpl new file mode 100644 index 00000000..c480047e --- /dev/null +++ b/deployments/nimbus-netpol/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "nimbus-netpol.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 "nimbus-netpol.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 "nimbus-netpol.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "nimbus-netpol.labels" -}} +helm.sh/chart: {{ include "nimbus-netpol.chart" . }} +{{ include "nimbus-netpol.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "nimbus-netpol.selectorLabels" -}} +app.kubernetes.io/name: {{ include "nimbus-netpol.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "nimbus-netpol.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "nimbus-netpol.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/deployments/nimbus-netpol/templates/deployment.yaml b/deployments/nimbus-netpol/templates/deployment.yaml new file mode 100644 index 00000000..384c68eb --- /dev/null +++ b/deployments/nimbus-netpol/templates/deployment.yaml @@ -0,0 +1,25 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "nimbus-netpol.fullname" . }} + labels: + {{- include "nimbus-netpol.labels" . | nindent 4 }} + namespace: {{ .Release.Namespace }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "nimbus-netpol.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + {{- include "nimbus-netpol.labels" . | nindent 8 }} + spec: + serviceAccountName: {{ include "nimbus-netpol.serviceAccountName" . }} + containers: + - name: {{ .Values.fullnameOverride }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + terminationGracePeriodSeconds: 10 diff --git a/deployments/nimbus-netpol/templates/role.yaml b/deployments/nimbus-netpol/templates/role.yaml new file mode 100644 index 00000000..4d4ee14e --- /dev/null +++ b/deployments/nimbus-netpol/templates/role.yaml @@ -0,0 +1,24 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: {{ include "nimbus-netpol.fullname" . }}-clusterrole +rules: + - apiGroups: + - intent.security.nimbus.com + resources: + - nimbuspolicies + - clusternimbuspolicies + verbs: + - get + - list + - watch + - apiGroups: + - networking.k8s.io + resources: + - networkpolicies + verbs: + - create + - delete + - get + - update + - watch diff --git a/deployments/nimbus-netpol/templates/rolebinding.yaml b/deployments/nimbus-netpol/templates/rolebinding.yaml new file mode 100644 index 00000000..a43927a7 --- /dev/null +++ b/deployments/nimbus-netpol/templates/rolebinding.yaml @@ -0,0 +1,12 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: {{ include "nimbus-netpol.fullname" . }}-clusterrole-binding +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: {{ include "nimbus-netpol.fullname" . }}-clusterrole +subjects: + - kind: ServiceAccount + name: {{ include "nimbus-netpol.serviceAccountName" . }} + namespace: {{ .Release.Namespace }} \ No newline at end of file diff --git a/deployments/nimbus-netpol/templates/serviceaccount.yaml b/deployments/nimbus-netpol/templates/serviceaccount.yaml new file mode 100644 index 00000000..7acbe673 --- /dev/null +++ b/deployments/nimbus-netpol/templates/serviceaccount.yaml @@ -0,0 +1,10 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "nimbus-netpol.serviceAccountName" . }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "nimbus-netpol.labels" . | nindent 4 }} +automountServiceAccountToken: {{ .Values.serviceAccount.automount }} +{{- end }} diff --git a/deployments/nimbus-netpol/values.yaml b/deployments/nimbus-netpol/values.yaml new file mode 100644 index 00000000..07f823f0 --- /dev/null +++ b/deployments/nimbus-netpol/values.yaml @@ -0,0 +1,25 @@ +# Default values for nimbus-netpol. + +replicaCount: 1 + +image: + repository: 5gsec/nimbus-netpol + pullPolicy: Always + # Overrides the image tag whose default is the chart appVersion. + tag: "latest" + +nameOverride: "" +fullnameOverride: "nimbus-netpol" + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Automatically mount a ServiceAccount's API credentials? + automount: true + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "nimbus-netpol" + +securityContext: + runAsNonRoot: true + runAsUser: 65532 diff --git a/deployments/nimbus/Readme.md b/deployments/nimbus/Readme.md index ac001cd7..be3d4947 100644 --- a/deployments/nimbus/Readme.md +++ b/deployments/nimbus/Readme.md @@ -12,7 +12,7 @@ helm upgrade --install nimbus-operator . -n nimbus --create-namespace | Key | Type | Default | Description | |------------------|--------|--------------|--------------------------------------------------------| | image.repository | string | 5gsec/nimbus | Image repository from which to pull the operator image | -| image.pullPolicy | string | IfNotPresent | Operator image pull policy | +| image.pullPolicy | string | Always | Operator image pull policy | | image.tag | string | latest | Operator image tag | ## Verify if all the resources are up and running diff --git a/deployments/nimbus/values.yaml b/deployments/nimbus/values.yaml index ccd8c618..a0d3a927 100644 --- a/deployments/nimbus/values.yaml +++ b/deployments/nimbus/values.yaml @@ -4,7 +4,7 @@ replicaCount: 1 image: repository: 5gsec/nimbus - pullPolicy: IfNotPresent + pullPolicy: Always # Overrides the image tag whose default is the chart appVersion. tag: "latest"