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

feat: Add helm chart for nimbus-netpol adapter #43

Merged
merged 3 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions deployments/nimbus-kubearmor/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:

Expand Down
2 changes: 1 addition & 1 deletion deployments/nimbus-kubearmor/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
23 changes: 23 additions & 0 deletions deployments/nimbus-netpol/.helmignore
Original file line number Diff line number Diff line change
@@ -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/
24 changes: 24 additions & 0 deletions deployments/nimbus-netpol/Chart.yaml
Original file line number Diff line number Diff line change
@@ -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"
46 changes: 46 additions & 0 deletions deployments/nimbus-netpol/Readme.md
Original file line number Diff line number Diff line change
@@ -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
```
62 changes: 62 additions & 0 deletions deployments/nimbus-netpol/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -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 }}
25 changes: 25 additions & 0 deletions deployments/nimbus-netpol/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -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
24 changes: 24 additions & 0 deletions deployments/nimbus-netpol/templates/role.yaml
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions deployments/nimbus-netpol/templates/rolebinding.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
10 changes: 10 additions & 0 deletions deployments/nimbus-netpol/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
25 changes: 25 additions & 0 deletions deployments/nimbus-netpol/values.yaml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion deployments/nimbus/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion deployments/nimbus/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
Loading