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(rbac): add rbac configuration to enable kubernetes tool #59

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions charts/homarr/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ name: homarr
description: A Helm chart to deploy homarr for Kubernetes
home: https://homarr-labs.github.io/charts/charts/homarr/
type: application
version: 2.9.0
version: 3.0.0
# renovate datasource=docker depName=ghcr.io/homarr-labs/homarr
appVersion: "v1.7.0"
icon: https://raw.githubusercontent.com/homarr-labs/charts/refs/heads/main/charts/homarr/icon.svg
kubeVersion: ">=1.22.0-0"
kubeVersion: ">=1.24.0-0"
dependencies:
- name: mysql
repository: "https://charts.bitnami.com/bitnami"
Expand All @@ -27,7 +27,7 @@ annotations:
url: https://homarr-labs.github.io/charts/pgp_keys.asc
artifacthub.io/changes: |-
- kind: added
description: persistence and declarative option for trusted certificates
description: add rbac configuration to enable kubernetes tool
artifacthub.io/links: |-
- name: App Source
url: https://github.com/homarr-labs/homarr
Expand Down
6 changes: 4 additions & 2 deletions charts/homarr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<img src="https://raw.githubusercontent.com/homarr-labs/charts/refs/heads/main/charts/homarr/icon.svg" align="right" width="92" alt="homarr logo">

![Version: 2.9.0](https://img.shields.io/badge/Version-2.9.0-informational?style=flat)
![Version: 3.0.0](https://img.shields.io/badge/Version-2.6.0-informational?style=flat)
![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat)
![AppVersion: v1.7.0](https://img.shields.io/badge/AppVersion-v1.7.0-informational?style=flat)

Expand All @@ -16,7 +16,7 @@ A Helm chart to deploy homarr for Kubernetes

## Requirements

Kubernetes: `>=1.22.0-0`
Kubernetes: `>=1.24.0-0`

## Dependencies

Expand Down Expand Up @@ -347,6 +347,8 @@ All available values are listed on the [artifacthub](https://artifacthub.io/pack
| podAnnotations | object | `{}` | Pod annotations |
| podLabels | object | `{}` | Pod labels |
| podSecurityContext | object | `{}` | Pod security context |
| rbac | object | `{"enabled":false}` | Enable RBAC resources for Kubernetes integration Creates Role, ClusterRole, and associated bindings for Homarr's Kubernetes features |
| rbac.enabled | bool | `false` | Enable to create RBAC resources and activate Kubernetes integration |
| readinessProbe.httpGet.path | string | `"/api/health/ready"` | This is the readiness check endpoint used by Kubernetes to determine if the application is ready to handle traffic. |
| readinessProbe.httpGet.port | int | `7575` | The port on which the readiness check will be performed. This must match the container's exposed port. |
| replicaCount | int | `1` | Number of replicas |
Expand Down
11 changes: 11 additions & 0 deletions charts/homarr/templates/homarr-dc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ spec:
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- if .Values.rbac.enabled }}
serviceAccountName: "{{ .Release.Name }}-sa"
{{- end }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
Expand Down Expand Up @@ -80,6 +83,14 @@ spec:
failureThreshold: 3
{{- end }}
env:
{{- if .Values.rbac.enabled }}
- name: KUBERNETES_SERVICE_ACCOUNT_NAME
value: {{ .Release.Name }}-sa
{{- end }}
- name: ENABLE_DOCKER
value: "false"
- name: ENABLE_KUBERNETES
value: {{ .Values.rbac.enabled | ternary "true" "false" | quote }}
{{- range $key, $value := .Values.env }}
- name: {{ $key }}
value: "{{ $value }}"
Expand Down
88 changes: 88 additions & 0 deletions charts/homarr/templates/homarr-rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
{{- if .Values.rbac.enabled }}
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ .Release.Name }}-sa
labels:
{{- include "homarr.labels" . | nindent 4 }}
---
apiVersion: v1
kind: Secret
metadata:
name: {{ .Release.Name }}-sa-token
annotations:
kubernetes.io/service-account.name: "{{ .Release.Name }}-sa"
type: kubernetes.io/service-account-token
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ .Release.Name }}-role
labels:
{{- include "homarr.labels" . | nindent 4 }}
rules:
- apiGroups: [ "" ]
resources: [ "pods", "services", "secrets", "configmaps", "persistentvolumeclaims", "namespaces", "persistentvolumes", "nodes" ]
verbs: [ "get", "list", "watch", "use" ]
- apiGroups: [ "apps" ]
resources: [ "deployments" ]
verbs: [ "get", "list", "watch" ]
- apiGroups: [ "networking.k8s.io" ]
resources: [ "ingresses" ]
verbs: [ "get", "list", "watch" ]
- apiGroups: [ "metrics.k8s.io" ]
resources: [ "nodes", "pods" ]
verbs: [ "get", "list", "watch" ]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ .Release.Name }}-rolebinding
labels:
{{- include "homarr.labels" . | nindent 4 }}
subjects:
- kind: ServiceAccount
name: {{ .Release.Name }}-sa
namespace: {{ .Release.Namespace }}
roleRef:
kind: Role
name: {{ .Release.Name }}-role
apiGroup: rbac.authorization.k8s.io
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ .Release.Name }}-cluster-role
labels:
{{- include "homarr.labels" . | nindent 4 }}
rules:
- apiGroups: [ "" ]
resources: [ "pods", "services", "secrets", "configmaps", "persistentvolumeclaims", "namespaces", "persistentvolumes", "nodes" ]
verbs: [ "get", "list", "watch", "use" ]
- apiGroups: [ "apps" ]
resources: [ "deployments" ]
verbs: [ "get", "list", "watch" ]
- apiGroups: [ "networking.k8s.io" ]
resources: [ "ingresses" ]
verbs: [ "get", "list", "watch" ]
- apiGroups: [ "metrics.k8s.io" ]
resources: [ "nodes", "pods" ]
verbs: [ "get", "list", "watch" ]

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ .Release.Name }}-cluster-rolebinding
labels:
{{- include "homarr.labels" . | nindent 4 }}
subjects:
- kind: ServiceAccount
name: {{ .Release.Name }}-sa
namespace: {{ .Release.Namespace }}
roleRef:
kind: ClusterRole
name: {{ .Release.Name }}-cluster-role
apiGroup: rbac.authorization.k8s.io
{{- end }}
6 changes: 6 additions & 0 deletions charts/homarr/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -315,3 +315,9 @@ mysql:
existingSecret: "db-secret"
username: homarr
database: homarrdb

# -- Enable RBAC resources for Kubernetes integration
# Creates Role, ClusterRole, and associated bindings for Homarr's Kubernetes features
rbac:
# -- Enable to create RBAC resources and activate Kubernetes integration
enabled: false