diff --git a/.github/workflows/helm-release.yml b/.github/workflows/helm-release.yml new file mode 100644 index 0000000..93813f4 --- /dev/null +++ b/.github/workflows/helm-release.yml @@ -0,0 +1,40 @@ +name: release helm chart + +on: + push: + branches: + - main + paths: + - charts/** + +permissions: + contents: write + packages: write + issues: write + +jobs: + release: + permissions: + contents: write + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Configure Git + run: | + git config user.name "$GITHUB_ACTOR" + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + + - name: Install Helm + uses: azure/setup-helm@v4.2.0 + + - name: Run chart-releaser + uses: helm/chart-releaser-action@v1.6.0 + with: + skip_existing: true + packages_with_index: true + env: + CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6274033..430ee6f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -60,8 +60,6 @@ jobs: tags: | type=schedule type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}} type=sha,prefix= - name: Build and push uses: docker/build-push-action@v6 diff --git a/.gitignore b/.gitignore index a324e40..c38dd20 100644 --- a/.gitignore +++ b/.gitignore @@ -28,6 +28,8 @@ !ui/tailwind.config.js !ui/tsconfig.json +!charts/** + !.github/* !.github/workflows/* !.github/ISSUE_TEMPLATE/* diff --git a/charts/rbac-wizard/.helmignore b/charts/rbac-wizard/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/rbac-wizard/.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/charts/rbac-wizard/Chart.yaml b/charts/rbac-wizard/Chart.yaml new file mode 100644 index 0000000..622aeff --- /dev/null +++ b/charts/rbac-wizard/Chart.yaml @@ -0,0 +1,12 @@ +apiVersion: v2 +name: rbac-wizard +home: https://github.com/pehlicd/rbac-wizard +description: A Helm chart for deploying RBAC Wizard to the Kubernetes +maintainers: + - name: pehlicd + email: furkanpehlivan34@gmail.com + url: https://github.com/pehlicd + +type: application +version: 0.1.0 +appVersion: "0.0.6" diff --git a/charts/rbac-wizard/README.md b/charts/rbac-wizard/README.md new file mode 100644 index 0000000..fd7f1b5 --- /dev/null +++ b/charts/rbac-wizard/README.md @@ -0,0 +1,62 @@ +# rbac-wizard + +![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: 0.0.6](https://img.shields.io/badge/AppVersion-0.0.6-informational?style=flat-square) + +A Helm chart for deploying RBAC Wizard to the Kubernetes + +**Homepage:** + +## Maintainers + +| Name | Email | Url | +| ---- | ------ | --- | +| pehlicd | | | + +## Values + +| Key | Type | Default | Description | +|-----|------|---------|-------------| +| affinity | object | `{}` | | +| autoscaling.enabled | bool | `false` | | +| autoscaling.maxReplicas | int | `100` | | +| autoscaling.minReplicas | int | `1` | | +| autoscaling.targetCPUUtilizationPercentage | int | `80` | | +| clusterRole.annotations | object | `{}` | | +| clusterRole.create | bool | `true` | | +| clusterRole.name | string | `""` | | +| clusterRoleBinding.annotations | object | `{}` | | +| clusterRoleBinding.create | bool | `true` | | +| clusterRoleBinding.name | string | `""` | | +| fullnameOverride | string | `""` | | +| image.pullPolicy | string | `"IfNotPresent"` | | +| image.repository | string | `"ghcr.io/pehlicd/rbac-wizard"` | | +| image.tag | string | `"latest"` | | +| imagePullSecrets | list | `[]` | | +| ingress.annotations | object | `{}` | | +| ingress.className | string | `""` | | +| ingress.enabled | bool | `true` | | +| ingress.hosts[0].host | string | `"rbac-wizard.local"` | | +| ingress.hosts[0].paths[0].path | string | `"/"` | | +| ingress.hosts[0].paths[0].pathType | string | `"ImplementationSpecific"` | | +| ingress.tls | list | `[]` | | +| livenessProbe.httpGet.path | string | `"/"` | | +| livenessProbe.httpGet.port | string | `"http"` | | +| nameOverride | string | `""` | | +| nodeSelector | object | `{}` | | +| podAnnotations | object | `{}` | | +| podLabels | object | `{}` | | +| podSecurityContext | object | `{}` | | +| readinessProbe.httpGet.path | string | `"/"` | | +| readinessProbe.httpGet.port | string | `"http"` | | +| replicaCount | int | `1` | | +| resources | object | `{}` | | +| securityContext | object | `{}` | | +| service.port | int | `8080` | | +| service.type | string | `"ClusterIP"` | | +| serviceAccount.annotations | object | `{}` | | +| serviceAccount.automount | bool | `true` | | +| serviceAccount.create | bool | `true` | | +| serviceAccount.name | string | `""` | | +| tolerations | list | `[]` | | +| volumeMounts | list | `[]` | | +| volumes | list | `[]` | | diff --git a/charts/rbac-wizard/templates/_helpers.tpl b/charts/rbac-wizard/templates/_helpers.tpl new file mode 100644 index 0000000..d6ed237 --- /dev/null +++ b/charts/rbac-wizard/templates/_helpers.tpl @@ -0,0 +1,78 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "rbac-wizard.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 "rbac-wizard.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 "rbac-wizard.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "rbac-wizard.labels" -}} +helm.sh/chart: {{ include "rbac-wizard.chart" . }} +{{ include "rbac-wizard.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "rbac-wizard.selectorLabels" -}} +app.kubernetes.io/name: {{ include "rbac-wizard.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "rbac-wizard.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "rbac-wizard.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} + +{{- define "rbac-wizard.clusterRoleName" -}} +{{- if .Values.clusterRole.create }} +{{- default (include "rbac-wizard.fullname" .) .Values.clusterRole.name }} +{{- else }} +{{- default "default" .Values.clusterRole.name }} +{{- end }} +{{- end }} + +{{- define "rbac-wizard.clusterRoleBindingName" -}} +{{- if .Values.clusterRoleBinding.create }} +{{- default (include "rbac-wizard.fullname" .) .Values.clusterRoleBinding.name }} +{{- else }} +{{- default "default" .Values.clusterRoleBinding.name }} +{{- end }} +{{- end }} diff --git a/charts/rbac-wizard/templates/clusterrole.yaml b/charts/rbac-wizard/templates/clusterrole.yaml new file mode 100644 index 0000000..27842b0 --- /dev/null +++ b/charts/rbac-wizard/templates/clusterrole.yaml @@ -0,0 +1,24 @@ +{{- if .Values.clusterRole.create -}} +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: {{ include "rbac-wizard.clusterRoleName" . }} + labels: + {{- include "rbac-wizard.labels" . | nindent 4 }} + {{- with .Values.clusterRole.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +rules: + - apiGroups: ["rbac.authorization.k8s.io"] + resources: + - roles + - rolebindings + - clusterroles + - clusterrolebindings + verbs: ["list", "get", "watch"] + - apiGroups: [""] + resources: + - serviceaccounts + verbs: ["list", "get", "watch"] +{{- end }} diff --git a/charts/rbac-wizard/templates/clusterrolebinding.yaml b/charts/rbac-wizard/templates/clusterrolebinding.yaml new file mode 100644 index 0000000..3da6c06 --- /dev/null +++ b/charts/rbac-wizard/templates/clusterrolebinding.yaml @@ -0,0 +1,20 @@ +{{- if .Values.clusterRoleBinding.create -}} +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: {{ include "rbac-wizard.clusterRoleBindingName" . }} + labels: + {{- include "rbac-wizard.labels" . | nindent 4 }} + {{- with .Values.clusterRoleBinding.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +subjects: +- kind: ServiceAccount + name: {{ include "rbac-wizard.serviceAccountName" . }} + namespace: {{ .Release.Namespace }} +roleRef: + kind: ClusterRole + name: {{ include "rbac-wizard.clusterRoleName" . }} + apiGroup: rbac.authorization.k8s.io +{{- end }} diff --git a/charts/rbac-wizard/templates/deployment.yaml b/charts/rbac-wizard/templates/deployment.yaml new file mode 100644 index 0000000..d0bd3d1 --- /dev/null +++ b/charts/rbac-wizard/templates/deployment.yaml @@ -0,0 +1,68 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "rbac-wizard.fullname" . }} + labels: + {{- include "rbac-wizard.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "rbac-wizard.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "rbac-wizard.labels" . | nindent 8 }} + {{- with .Values.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "rbac-wizard.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 }} + ports: + - name: http + containerPort: {{ .Values.service.port }} + protocol: TCP + livenessProbe: + {{- toYaml .Values.livenessProbe | nindent 12 }} + readinessProbe: + {{- toYaml .Values.readinessProbe | nindent 12 }} + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.volumeMounts }} + volumeMounts: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.volumes }} + volumes: + {{- toYaml . | nindent 8 }} + {{- 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 }} diff --git a/charts/rbac-wizard/templates/hpa.yaml b/charts/rbac-wizard/templates/hpa.yaml new file mode 100644 index 0000000..49f5dee --- /dev/null +++ b/charts/rbac-wizard/templates/hpa.yaml @@ -0,0 +1,32 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "rbac-wizard.fullname" . }} + labels: + {{- include "rbac-wizard.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "rbac-wizard.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/charts/rbac-wizard/templates/ingress.yaml b/charts/rbac-wizard/templates/ingress.yaml new file mode 100644 index 0000000..0063003 --- /dev/null +++ b/charts/rbac-wizard/templates/ingress.yaml @@ -0,0 +1,61 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "rbac-wizard.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "rbac-wizard.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/charts/rbac-wizard/templates/service.yaml b/charts/rbac-wizard/templates/service.yaml new file mode 100644 index 0000000..754f960 --- /dev/null +++ b/charts/rbac-wizard/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "rbac-wizard.fullname" . }} + labels: + {{- include "rbac-wizard.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "rbac-wizard.selectorLabels" . | nindent 4 }} diff --git a/charts/rbac-wizard/templates/serviceaccount.yaml b/charts/rbac-wizard/templates/serviceaccount.yaml new file mode 100644 index 0000000..aa9ac79 --- /dev/null +++ b/charts/rbac-wizard/templates/serviceaccount.yaml @@ -0,0 +1,13 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "rbac-wizard.serviceAccountName" . }} + labels: + {{- include "rbac-wizard.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +automountServiceAccountToken: {{ .Values.serviceAccount.automount }} +{{- end }} diff --git a/charts/rbac-wizard/templates/tests/test-connection.yaml b/charts/rbac-wizard/templates/tests/test-connection.yaml new file mode 100644 index 0000000..111afe5 --- /dev/null +++ b/charts/rbac-wizard/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "rbac-wizard.fullname" . }}-test-connection" + labels: + {{- include "rbac-wizard.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "rbac-wizard.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/charts/rbac-wizard/values.yaml b/charts/rbac-wizard/values.yaml new file mode 100644 index 0000000..c8d0cd7 --- /dev/null +++ b/charts/rbac-wizard/values.yaml @@ -0,0 +1,109 @@ +# Default values for rbac-wizard. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: ghcr.io/pehlicd/rbac-wizard + pullPolicy: IfNotPresent + tag: latest + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + create: true + automount: true + annotations: {} + name: "" + +clusterRole: + create: true + annotations: {} + name: "" + +clusterRoleBinding: + create: true + annotations: {} + name: "" + +podAnnotations: {} +podLabels: {} + +podSecurityContext: + {} + # fsGroup: 2000 + +securityContext: + {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 8080 + +ingress: + enabled: true + className: "" + annotations: + {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: rbac-wizard.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + # - secretName: rbac-wizard-tls + # hosts: + # - rbac-wizard.local + +resources: + {} + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +livenessProbe: + httpGet: + path: / + port: http +readinessProbe: + httpGet: + path: / + port: http + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +volumes: [] +# - name: foo +# secret: +# secretName: mysecret +# optional: false + +volumeMounts: [] +# - name: foo +# mountPath: "/etc/foo" +# readOnly: true + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/rbac-wizard.rb b/rbac-wizard.rb index 57eb807..b72814a 100644 --- a/rbac-wizard.rb +++ b/rbac-wizard.rb @@ -2,8 +2,8 @@ class RbacWizard < Formula desc "RBAC Wizard is a tool that helps you visualize and analyze the RBAC configurations of your Kubernetes cluster. It provides a graphical representation of the Kubernetes RBAC objects." homepage "https://github.com/pehlicd/rbac-wizard" url "https://github.com/pehlicd/rbac-wizard.git", - tag: "v0.0.5", - revision: "83edd789bda677231bd55eec319ac32ce6aacf68" + tag: "v0.0.6", + revision: "2aacf572eb466586d4dee921eedb5c61adfe86f5" license "MIT" head "https://github.com/pehlicd/rbac-wizard.git", branch: "main"