Skip to content

Commit

Permalink
feat: [CHAOS-7188]: add ddcr rbac chart (#20)
Browse files Browse the repository at this point in the history
* feat: [CHAOS-7188]: add ddcr rbac chart

Signed-off-by: Shovan Maity <[email protected]>
  • Loading branch information
shovanmaity authored and Harness committed Feb 7, 2025
1 parent d36cd8a commit c37d986
Show file tree
Hide file tree
Showing 20 changed files with 436 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/chaos-infrastructure/Chart.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,8 @@ dependencies:
- name: agent-proxy
repository: file://../agent-proxy
version: 0.0.4
digest: sha256:f300205a2dc5098095480cd4549a718ef8a46895c4ea8ba7aa78b5cd3940f37c
generated: "2024-10-10T13:11:14.286581+05:30"
- name: ddcr-rbac
repository: file://../ddcr-rbac
version: 0.0.1
digest: sha256:cc8e2b18d0cf4602756d7de7f71bc9ea61ccf67a029dc7bc6bfc77e559a0759f
generated: "2025-02-07T15:46:53.848142+05:30"
6 changes: 5 additions & 1 deletion src/chaos-infrastructure/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,8 @@ dependencies:
repository: "file://../agent-proxy"
tags:
- agentProxy

- name: ddcr-rbac
version: 0.0.1
repository: "file://../ddcr-rbac"
tags:
- ddcrRBAC
Binary file modified src/chaos-infrastructure/charts/agent-proxy-0.0.4.tgz
Binary file not shown.
Binary file modified src/chaos-infrastructure/charts/chaos-crds-0.0.8.tgz
Binary file not shown.
Binary file modified src/chaos-infrastructure/charts/chaos-exporter-0.0.8.tgz
Binary file not shown.
Binary file modified src/chaos-infrastructure/charts/chaos-operator-0.0.9.tgz
Binary file not shown.
Binary file not shown.
Binary file modified src/chaos-infrastructure/charts/subscriber-0.0.10.tgz
Binary file not shown.
Binary file modified src/chaos-infrastructure/charts/workflow-controller-0.0.7.tgz
Binary file not shown.
1 change: 1 addition & 0 deletions src/chaos-infrastructure/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ tags:
namespaceMode: false
crdMode: false
agentProxy: false
ddcrRBAC: false
global:
clusterScope:
enabled: true
Expand Down
23 changes: 23 additions & 0 deletions src/ddcr-rbac/.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 src/ddcr-rbac/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: ddcr-rbac
description: A Helm chart for Kubernetes

# 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.0.1

# 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: "1.16.0"
106 changes: 106 additions & 0 deletions src/ddcr-rbac/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "ddcr-rbac.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 "ddcr-rbac.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 "ddcr-rbac.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "ddcr-rbac.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "ddcr-rbac.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{/*
Create the name of the role to use
*/}}
{{- define "ddcr-rbac.roleName" -}}
{{- if .Values.role.name }}
{{- .Values.role.name }}
{{- else }}
{{- default (include "ddcr-rbac.fullname" .) .Values.role.name }}
{{- end }}
{{- end }}

{{/*
Create the name of the role binding to use
*/}}
{{- define "ddcr-rbac.roleBindingName" -}}
{{- if .Values.roleBinding.name }}
{{- .Values.roleBinding.name }}
{{- else }}
{{- default (include "ddcr-rbac.fullname" .) .Values.roleBinding.name }}
{{- end }}
{{- end }}

{{/*
Create the name of the cluster role to use
*/}}
{{- define "ddcr-rbac.clusterRoleName" -}}
{{- if .Values.clusterRole.name }}
{{- .Values.clusterRole.name }}
{{- else }}
{{- default (include "ddcr-rbac.fullname" .) .Values.clusterRole.name }}
{{- end }}
{{- end }}

{{/*
Create the name of the cluster role binding to use
*/}}
{{- define "ddcr-rbac.clusterRoleBindingName" -}}
{{- if .Values.clusterRoleBinding.name }}
{{- .Values.clusterRoleBinding.name }}
{{- else }}
{{- default (include "ddcr-rbac.fullname" .) .Values.clusterRoleBinding.name }}
{{- end }}
{{- end }}
109 changes: 109 additions & 0 deletions src/ddcr-rbac/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "ddcr-rbac.clusterRoleName" . }}
labels:
{{- include "ddcr-rbac.labels" . | nindent 4 }}
{{- with .Values.clusterRole.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
rules:
# Discovery permissions
- apiGroups:
- apps
resources:
- deployments
- replicasets
- daemonsets
- statefulsets
verbs:
- watch
- list
- get
- apiGroups:
- ""
resources:
- pods
- replicationcontrollers
- services
- statefulsets
- nodes
- namespaces #(nodes and namespace permissions are required to autocreate network experiments)
verbs:
- watch
- list
- get
- apiGroups:
- batch
resources:
- jobs
- cronjobs
verbs:
- watch
- list
- get
# Chaos permissions
- apiGroups:
- ""
resources:
- pods
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- deletecollection
- apiGroups:
- networking.k8s.io
resources:
- networkpolicies
verbs:
- create
- delete
- get
- list
- apiGroups: #(Prerequisite: Metrics server should be installed on the cluster. This is required if you are running a custom script in command (CMD) source probe to get the CPU and memory metrics for pods and nodes.)
- metrics.k8s.io
resources:
- pods
- nodes
verbs:
- get
- list
- apiGroups:
- apps
resources:
- deployments
- replicasets
- daemonsets
- statefulsets
verbs:
- list
- get
- update
- apiGroups:
- ""
resources:
- replicationcontrollers
- services
verbs:
- get
- list
- apiGroups:
- apps.openshift.io
resources:
- deploymentconfigs
verbs:
- list
- get
- apiGroups:
- argoproj.io
resources:
- rollouts
verbs:
- list
- get
18 changes: 18 additions & 0 deletions src/ddcr-rbac/templates/clusterrolebinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ include "ddcr-rbac.clusterRoleBindingName" . }}
labels:
{{- include "ddcr-rbac.labels" . | nindent 4 }}
{{- with .Values.clusterRoleBinding.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ include "ddcr-rbac.clusterRoleName" . }}
subjects:
- kind: ServiceAccount
name: {{ include "ddcr-rbac.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
60 changes: 60 additions & 0 deletions src/ddcr-rbac/templates/role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
namespace: {{ .Release.Namespace }}
name: {{ include "ddcr-rbac.roleName" . }}
labels:
{{- include "ddcr-rbac.labels" . | nindent 4 }}
{{- with .Values.role.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
rules:
- apiGroups:
- apps
resources:
- deployments
- replicasets
- daemonsets
- statefulsets
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- deletecollection
- apiGroups:
- ""
resources:
- pods
- pods/log
- pods/exec
- secrets
- services
- configmaps
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- deletecollection
- apiGroups:
- batch
resources:
- jobs
- cronjobs
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- deletecollection
19 changes: 19 additions & 0 deletions src/ddcr-rbac/templates/rolebinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
namespace: {{ .Release.Namespace }}
name: {{ include "ddcr-rbac.roleBindingName" . }}
labels:
{{- include "ddcr-rbac.labels" . | nindent 4 }}
{{- with .Values.roleBinding.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
subjects:
- kind: ServiceAccount
name: {{ include "ddcr-rbac.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
roleRef:
kind: Role
name: {{ include "ddcr-rbac.roleName" . }}
apiGroup: rbac.authorization.k8s.io
Loading

0 comments on commit c37d986

Please sign in to comment.