diff --git a/src/chaos-infrastructure/Chart.lock b/src/chaos-infrastructure/Chart.lock index 874432a..3bdc7e2 100644 --- a/src/chaos-infrastructure/Chart.lock +++ b/src/chaos-infrastructure/Chart.lock @@ -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" diff --git a/src/chaos-infrastructure/Chart.yaml b/src/chaos-infrastructure/Chart.yaml index 3ed191b..b4df9ff 100644 --- a/src/chaos-infrastructure/Chart.yaml +++ b/src/chaos-infrastructure/Chart.yaml @@ -59,4 +59,8 @@ dependencies: repository: "file://../agent-proxy" tags: - agentProxy - + - name: ddcr-rbac + version: 0.0.1 + repository: "file://../ddcr-rbac" + tags: + - ddcrRBAC diff --git a/src/chaos-infrastructure/charts/agent-proxy-0.0.4.tgz b/src/chaos-infrastructure/charts/agent-proxy-0.0.4.tgz index ed13924..4bc713f 100644 Binary files a/src/chaos-infrastructure/charts/agent-proxy-0.0.4.tgz and b/src/chaos-infrastructure/charts/agent-proxy-0.0.4.tgz differ diff --git a/src/chaos-infrastructure/charts/chaos-crds-0.0.8.tgz b/src/chaos-infrastructure/charts/chaos-crds-0.0.8.tgz index 66956fd..6a039ff 100644 Binary files a/src/chaos-infrastructure/charts/chaos-crds-0.0.8.tgz and b/src/chaos-infrastructure/charts/chaos-crds-0.0.8.tgz differ diff --git a/src/chaos-infrastructure/charts/chaos-exporter-0.0.8.tgz b/src/chaos-infrastructure/charts/chaos-exporter-0.0.8.tgz index 44c7832..8e4841f 100644 Binary files a/src/chaos-infrastructure/charts/chaos-exporter-0.0.8.tgz and b/src/chaos-infrastructure/charts/chaos-exporter-0.0.8.tgz differ diff --git a/src/chaos-infrastructure/charts/chaos-operator-0.0.9.tgz b/src/chaos-infrastructure/charts/chaos-operator-0.0.9.tgz index fef91e6..aa9164d 100644 Binary files a/src/chaos-infrastructure/charts/chaos-operator-0.0.9.tgz and b/src/chaos-infrastructure/charts/chaos-operator-0.0.9.tgz differ diff --git a/src/chaos-infrastructure/charts/ddcr-rbac-0.0.1.tgz b/src/chaos-infrastructure/charts/ddcr-rbac-0.0.1.tgz new file mode 100644 index 0000000..683f141 Binary files /dev/null and b/src/chaos-infrastructure/charts/ddcr-rbac-0.0.1.tgz differ diff --git a/src/chaos-infrastructure/charts/subscriber-0.0.10.tgz b/src/chaos-infrastructure/charts/subscriber-0.0.10.tgz index cc9bfcc..3d618d2 100644 Binary files a/src/chaos-infrastructure/charts/subscriber-0.0.10.tgz and b/src/chaos-infrastructure/charts/subscriber-0.0.10.tgz differ diff --git a/src/chaos-infrastructure/charts/workflow-controller-0.0.7.tgz b/src/chaos-infrastructure/charts/workflow-controller-0.0.7.tgz index 03277dd..2b83f09 100644 Binary files a/src/chaos-infrastructure/charts/workflow-controller-0.0.7.tgz and b/src/chaos-infrastructure/charts/workflow-controller-0.0.7.tgz differ diff --git a/src/chaos-infrastructure/values.yaml b/src/chaos-infrastructure/values.yaml index 0769090..e06f1e4 100644 --- a/src/chaos-infrastructure/values.yaml +++ b/src/chaos-infrastructure/values.yaml @@ -3,6 +3,7 @@ tags: namespaceMode: false crdMode: false agentProxy: false + ddcrRBAC: false global: clusterScope: enabled: true diff --git a/src/ddcr-rbac/.helmignore b/src/ddcr-rbac/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/src/ddcr-rbac/.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/src/ddcr-rbac/Chart.yaml b/src/ddcr-rbac/Chart.yaml new file mode 100644 index 0000000..9d3e82a --- /dev/null +++ b/src/ddcr-rbac/Chart.yaml @@ -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" diff --git a/src/ddcr-rbac/templates/_helpers.tpl b/src/ddcr-rbac/templates/_helpers.tpl new file mode 100644 index 0000000..c9ffaf2 --- /dev/null +++ b/src/ddcr-rbac/templates/_helpers.tpl @@ -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 }} diff --git a/src/ddcr-rbac/templates/clusterrole.yaml b/src/ddcr-rbac/templates/clusterrole.yaml new file mode 100644 index 0000000..3f8c8fa --- /dev/null +++ b/src/ddcr-rbac/templates/clusterrole.yaml @@ -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 diff --git a/src/ddcr-rbac/templates/clusterrolebinding.yaml b/src/ddcr-rbac/templates/clusterrolebinding.yaml new file mode 100644 index 0000000..20fcb34 --- /dev/null +++ b/src/ddcr-rbac/templates/clusterrolebinding.yaml @@ -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 }} diff --git a/src/ddcr-rbac/templates/role.yaml b/src/ddcr-rbac/templates/role.yaml new file mode 100644 index 0000000..6a48f32 --- /dev/null +++ b/src/ddcr-rbac/templates/role.yaml @@ -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 diff --git a/src/ddcr-rbac/templates/rolebinding.yaml b/src/ddcr-rbac/templates/rolebinding.yaml new file mode 100644 index 0000000..e983e1c --- /dev/null +++ b/src/ddcr-rbac/templates/rolebinding.yaml @@ -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 diff --git a/src/ddcr-rbac/templates/secret.yaml b/src/ddcr-rbac/templates/secret.yaml new file mode 100644 index 0000000..f9e539e --- /dev/null +++ b/src/ddcr-rbac/templates/secret.yaml @@ -0,0 +1,14 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "ddcr-rbac.serviceAccountName" . }} + labels: + {{- include "ddcr-rbac.labels" . | nindent 4 }} + annotations: + kubernetes.io/service-account.name: {{ include "ddcr-rbac.serviceAccountName" . }} + {{- with .Values.serviceAccount.annotations }} + {{- toYaml . | nindent 4 }} + {{- end }} +type: kubernetes.io/service-account-token +{{- end }} \ No newline at end of file diff --git a/src/ddcr-rbac/templates/serviceaccount.yaml b/src/ddcr-rbac/templates/serviceaccount.yaml new file mode 100644 index 0000000..ee03284 --- /dev/null +++ b/src/ddcr-rbac/templates/serviceaccount.yaml @@ -0,0 +1,13 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "ddcr-rbac.serviceAccountName" . }} + labels: + {{- include "ddcr-rbac.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +automountServiceAccountToken: {{ .Values.serviceAccount.automount }} +{{- end }} diff --git a/src/ddcr-rbac/values.yaml b/src/ddcr-rbac/values.yaml new file mode 100644 index 0000000..9fb6431 --- /dev/null +++ b/src/ddcr-rbac/values.yaml @@ -0,0 +1,39 @@ +# Default values for ddcr-rbac. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Automatically mount a ServiceAccount's API credentials? + automount: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +role: + annotations: {} + # The name of the role to use. + # If empty a name is generated using the fullname template + name: "" + +roleBinding: + annotations: {} + # The name of the role binding to use. + # If empty a name is generated using the fullname template + name: "" + +clusterRole: + annotations: {} + # The name of the cluster role to use. + # If empty a name is generated using the fullname template + name: "" + +clusterRoleBinding: + annotations: {} + # The name of the cluster role binding to use. + # If empty a name is generated using the fullname template + name: ""