Skip to content

Commit

Permalink
feat: added Helm chart definition for the namespace-permission-manager (
Browse files Browse the repository at this point in the history
#3)

* feat: added Helm chart definition for the namespace-permission-manager

* chore: renamed cluster_role, service_monitor and role_binding files
  • Loading branch information
leonsteinhaeuser authored Dec 1, 2023
1 parent e11ce54 commit 61047c6
Show file tree
Hide file tree
Showing 16 changed files with 587 additions and 0 deletions.
23 changes: 23 additions & 0 deletions charts/namespace-permission-manager/.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 charts/namespace-permission-manager/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: namespace-permission-manager
description: A Helm chart to deploy the kubernetes-namespace-permission-manager

# 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: "v0.1.0"
73 changes: 73 additions & 0 deletions charts/namespace-permission-manager/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# namespace-permission-manager

![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v0.1.0](https://img.shields.io/badge/AppVersion-v0.1.0-informational?style=flat-square)

A Helm chart to deploy the kubernetes-namespace-permission-manager

## Installation

Add Helm repository:

```bash
helm repo add tagesspiegel https://tagesspiegel.github.io/helm-charts
```

Upgrade or install the operator:

```bash
helm upgrade --install \
my-secret tagesspiegel/namespace-permission-manager
```

## Maintainers

| Name | Email | Url |
| ---- | ------ | --- |

## Requirements

| Repository | Name | Version |
|------------|------|---------|

## Values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| affinity | object | `{}` | |
| fullnameOverride | string | `""` | |
| image.pullPolicy | string | `"IfNotPresent"` | |
| image.repository | string | `"tagesspiegel/kubernetes-namespace-permission-manager"` | |
| image.tag | string | `""` | |
| imagePullSecrets | list | `[]` | |
| monitoring | object | `{"enabled":true,"rbacProxy":{"image":{"pullPolicy":"IfNotPresent","repository":"gcr.io/kubebuilder/kube-rbac-proxy","tag":"v0.15.0"},"resources":{}},"service":{"port":8443,"type":"ClusterIP"},"serviceMonitor":{"enabled":true,"namespace":""}}` | Monitoring configuration |
| monitoring.enabled | bool | `true` | Enable Prometheus Operator Monitoring |
| monitoring.rbacProxy | object | `{"image":{"pullPolicy":"IfNotPresent","repository":"gcr.io/kubebuilder/kube-rbac-proxy","tag":"v0.15.0"},"resources":{}}` | RBAC Proxy configuration |
| monitoring.rbacProxy.image | object | `{"pullPolicy":"IfNotPresent","repository":"gcr.io/kubebuilder/kube-rbac-proxy","tag":"v0.15.0"}` | Image to use for the RBAC Proxy |
| monitoring.rbacProxy.image.pullPolicy | string | `"IfNotPresent"` | Image pull policy |
| monitoring.rbacProxy.image.repository | string | `"gcr.io/kubebuilder/kube-rbac-proxy"` | Image repository |
| monitoring.rbacProxy.image.tag | string | `"v0.15.0"` | Tag overrides the image tag whose default is the chart appVersion. |
| monitoring.rbacProxy.resources | object | `{}` | RBAC Proxy resource configuration |
| monitoring.service.port | int | `8443` | Service port |
| monitoring.service.type | string | `"ClusterIP"` | Service configuration |
| monitoring.serviceMonitor | object | `{"enabled":true,"namespace":""}` | ServiceMonitor configuration |
| monitoring.serviceMonitor.enabled | bool | `true` | Enable ServiceMonitor |
| monitoring.serviceMonitor.namespace | string | `""` | Service Monitor namespace |
| nameOverride | string | `""` | |
| networkPolicy | object | `{"egress":[],"enabled":true,"ingress":[]}` | networkPolicy defines the network access to and from the operator |
| nodeSelector | object | `{}` | |
| pdb | object | `{"annotations":{},"enabled":true,"maxUnavailable":0,"minAvailable":1}` | pdb defines the pod disruption budget for the operator |
| podAnnotations | object | `{}` | |
| podSecurityContext.runAsNonRoot | bool | `true` | |
| rbac.enabled | bool | `true` | rbac.enabled specifies whether RBAC resources should be created If disabled, the operator will use the permissions of the service account the operator is running under |
| rbac.roleRules | list | `[{"apiGroups":["*"],"resources":["*"],"verbs":["*"]}]` | roleRules defines the permissions the operator has access to The operator needs at least access to: namespaces: [list, get, watch] roles: [list, get, watch, create, update, delete] rolebindings: [list, get, watch, create, update, delete] And to any resource defined in the ns.tagesspiegel.de/rolebinding-subjects, ns.tagesspiegel.de/rolebinding-roleref and ns.tagesspiegel.de/custom-role-rules annotations To simplify the configuration, the operator has access to all resources in all namespaces by default. |
| replicaCount | int | `1` | |
| resources | object | `{}` | |
| securityContext.allowPrivilegeEscalation | bool | `false` | |
| securityContext.capabilities.drop[0] | string | `"ALL"` | |
| serviceAccount.annotations | object | `{}` | |
| serviceAccount.create | bool | `true` | |
| serviceAccount.name | string | `""` | |
| tolerations | list | `[]` | |

----------------------------------------------
Autogenerated from chart metadata using [helm-docs v1.11.0](https://github.com/norwoodj/helm-docs/releases/v1.11.0)
32 changes: 32 additions & 0 deletions charts/namespace-permission-manager/README.md.gotmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{ template "chart.header" . }}

{{ template "chart.badgesSection" . }}

{{ template "chart.description" . }}

## Installation

Add Helm repository:

```bash
helm repo add tagesspiegel https://tagesspiegel.github.io/helm-charts
```

Upgrade or install the operator:

```bash
helm upgrade --install \
my-secret tagesspiegel/namespace-permission-manager
```

## Maintainers

{{ template "chart.maintainersTable" . }}

## Requirements

{{ template "chart.requirementsTable" . }}

{{ template "chart.valuesSection" . }}

{{ template "helm-docs.versionFooter" . }}
3 changes: 3 additions & 0 deletions charts/namespace-permission-manager/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
You are ready to go!

You can now start adding labels and annotations to your namespaces.
62 changes: 62 additions & 0 deletions charts/namespace-permission-manager/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "namespace-permission-manager.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 "namespace-permission-manager.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 "namespace-permission-manager.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "namespace-permission-manager.labels" -}}
helm.sh/chart: {{ include "namespace-permission-manager.chart" . }}
{{ include "namespace-permission-manager.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "namespace-permission-manager.selectorLabels" -}}
app.kubernetes.io/name: {{ include "namespace-permission-manager.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "namespace-permission-manager.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "namespace-permission-manager.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
10 changes: 10 additions & 0 deletions charts/namespace-permission-manager/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{- if .Values.rbac.enabled }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "namespace-permission-manager.fullname" . }}
labels:
{{- include "namespace-permission-manager.labels" . | nindent 4 }}
rules:
{{- toYaml .Values.rbac.roleRules | nindent 2 }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{- if .Values.rbac.enabled }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ include "namespace-permission-manager.fullname" . }}
labels:
{{- include "namespace-permission-manager.labels" . | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ include "namespace-permission-manager.fullname" . }}
subjects:
- kind: ServiceAccount
name: {{ include "namespace-permission-manager.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
{{- end }}
86 changes: 86 additions & 0 deletions charts/namespace-permission-manager/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "namespace-permission-manager.fullname" . }}
labels:
{{- include "namespace-permission-manager.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "namespace-permission-manager.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "namespace-permission-manager.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "namespace-permission-manager.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command:
- /controller
args:
- --health-probe-bind-address=:8081
- --metrics-bind-address=127.0.0.1:8080
- --leader-elect
livenessProbe:
httpGet:
path: /healthz
port: 8081
initialDelaySeconds: 15
periodSeconds: 20
readinessProbe:
httpGet:
path: /readyz
port: 8081
initialDelaySeconds: 5
periodSeconds: 10
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- if .Values.monitoring.enabled }}
- args:
- --secure-listen-address=0.0.0.0:8443
- --upstream=http://127.0.0.1:8080/
- --logtostderr=true
- --v=0
image: {{ .Values.monitoring.rbacProxy.image.repository }}:{{ .Values.monitoring.rbacProxy.image.tag }}
imagePullPolicy: {{ .Values.monitoring.rbacProxy.image.pullPolicy }}
name: kube-rbac-proxy
ports:
- containerPort: 8443
name: metrics
protocol: TCP
resources:
{{- toYaml .Values.monitoring.rbacProxy.resources | nindent 12 }}
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
27 changes: 27 additions & 0 deletions charts/namespace-permission-manager/templates/networkpolicy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{{- if .Values.networkPolicy.enabled }}
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: {{ include "namespace-permission-manager.fullname" . }}
labels:
{{- include "namespace-permission-manager.labels" . | nindent 4 }}
spec:
podSelector:
matchLabels:
{{- include "namespace-permission-manager.selectorLabels" . | nindent 6 }}
policyTypes:
{{- if .Values.networkPolicy.ingress }}
- Ingress
{{- end }}
{{- if .Values.networkPolicy.egress }}
- Egress
{{- end }}
{{- with .Values.networkPolicy.ingress }}
ingress:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.networkPolicy.egress }}
egress:
{{- toYaml . | nindent 4 }}
{{- end -}}
{{- end }}
22 changes: 22 additions & 0 deletions charts/namespace-permission-manager/templates/pdb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{{- if .Values.pdb.enabled }}
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: {{ include "namespace-permission-manager.fullname" . }}
labels:
{{- include "namespace-permission-manager.labels" . | nindent 4 }}
{{- with .Values.pdb.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- with .Values.pdb.maxUnavailable }}
maxUnavailable: {{ . }}
{{- end }}
{{- with .Values.pdb.minAvailable }}
minAvailable: {{ . }}
{{- end }}
selector:
matchLabels:
{{- include "namespace-permission-manager.selectorLabels" . | nindent 6 }}
{{- end }}
Loading

0 comments on commit 61047c6

Please sign in to comment.