feat: add clusterAccess option for Kubernetes RBAC in Helm chart
Adds a clusterAccess value with five levels: none — no cluster access (default, no RBAC resources created) readonlyns — Role + RoleBinding: get/list/watch in release namespace readwritens — Role + RoleBinding: full access in release namespace readonly — ClusterRole + ClusterRoleBinding: get/list/watch cluster-wide readwrite — ClusterRole + ClusterRoleBinding: full access cluster-wide A ServiceAccount is created for the pod whenever access != none and referenced in the Deployment's serviceAccountName. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -14,6 +14,9 @@ spec:
|
|||||||
labels:
|
labels:
|
||||||
{{- include "antigravity.labels" . | nindent 8 }}
|
{{- include "antigravity.labels" . | nindent 8 }}
|
||||||
spec:
|
spec:
|
||||||
|
{{- if ne (.Values.clusterAccess | default "none") "none" }}
|
||||||
|
serviceAccountName: {{ include "antigravity.fullname" . }}
|
||||||
|
{{- end }}
|
||||||
securityContext:
|
securityContext:
|
||||||
fsGroup: 1000
|
fsGroup: 1000
|
||||||
fsGroupChangePolicy: "OnRootMismatch"
|
fsGroupChangePolicy: "OnRootMismatch"
|
||||||
|
|||||||
@@ -0,0 +1,97 @@
|
|||||||
|
{{- $access := .Values.clusterAccess | default "none" }}
|
||||||
|
{{- $name := include "antigravity.fullname" . }}
|
||||||
|
{{- $ns := .Release.Namespace }}
|
||||||
|
{{- $labels := include "antigravity.labels" . }}
|
||||||
|
|
||||||
|
{{- if ne $access "none" }}
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ServiceAccount
|
||||||
|
metadata:
|
||||||
|
name: {{ $name }}
|
||||||
|
namespace: {{ $ns }}
|
||||||
|
labels:
|
||||||
|
{{- $labels | nindent 4 }}
|
||||||
|
|
||||||
|
{{- if or (eq $access "readonlyns") (eq $access "readwritens") }}
|
||||||
|
---
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
kind: Role
|
||||||
|
metadata:
|
||||||
|
name: {{ $name }}
|
||||||
|
namespace: {{ $ns }}
|
||||||
|
labels:
|
||||||
|
{{- $labels | nindent 4 }}
|
||||||
|
rules:
|
||||||
|
- apiGroups: ["*"]
|
||||||
|
resources: ["*"]
|
||||||
|
verbs:
|
||||||
|
{{- if eq $access "readonlyns" }}
|
||||||
|
- get
|
||||||
|
- list
|
||||||
|
- watch
|
||||||
|
{{- else }}
|
||||||
|
- "*"
|
||||||
|
{{- end }}
|
||||||
|
---
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
kind: RoleBinding
|
||||||
|
metadata:
|
||||||
|
name: {{ $name }}
|
||||||
|
namespace: {{ $ns }}
|
||||||
|
labels:
|
||||||
|
{{- $labels | nindent 4 }}
|
||||||
|
subjects:
|
||||||
|
- kind: ServiceAccount
|
||||||
|
name: {{ $name }}
|
||||||
|
namespace: {{ $ns }}
|
||||||
|
roleRef:
|
||||||
|
kind: Role
|
||||||
|
name: {{ $name }}
|
||||||
|
apiGroup: rbac.authorization.k8s.io
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
{{- if or (eq $access "readonly") (eq $access "readwrite") }}
|
||||||
|
---
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
kind: ClusterRole
|
||||||
|
metadata:
|
||||||
|
name: {{ $name }}
|
||||||
|
labels:
|
||||||
|
{{- $labels | nindent 4 }}
|
||||||
|
rules:
|
||||||
|
- apiGroups: ["*"]
|
||||||
|
resources: ["*"]
|
||||||
|
verbs:
|
||||||
|
{{- if eq $access "readonly" }}
|
||||||
|
- get
|
||||||
|
- list
|
||||||
|
- watch
|
||||||
|
{{- else }}
|
||||||
|
- "*"
|
||||||
|
{{- end }}
|
||||||
|
- nonResourceURLs: ["*"]
|
||||||
|
verbs:
|
||||||
|
{{- if eq $access "readonly" }}
|
||||||
|
- get
|
||||||
|
{{- else }}
|
||||||
|
- "*"
|
||||||
|
{{- end }}
|
||||||
|
---
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
kind: ClusterRoleBinding
|
||||||
|
metadata:
|
||||||
|
name: {{ $name }}
|
||||||
|
labels:
|
||||||
|
{{- $labels | nindent 4 }}
|
||||||
|
subjects:
|
||||||
|
- kind: ServiceAccount
|
||||||
|
name: {{ $name }}
|
||||||
|
namespace: {{ $ns }}
|
||||||
|
roleRef:
|
||||||
|
kind: ClusterRole
|
||||||
|
name: {{ $name }}
|
||||||
|
apiGroup: rbac.authorization.k8s.io
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
{{- end }}
|
||||||
@@ -38,6 +38,15 @@ resources:
|
|||||||
memory: "8Gi"
|
memory: "8Gi"
|
||||||
cpu: "4000m"
|
cpu: "4000m"
|
||||||
|
|
||||||
|
# Kubernetes cluster access granted to the devcontainer pod via RBAC.
|
||||||
|
# Options:
|
||||||
|
# none — no cluster access (default)
|
||||||
|
# readonlyns — get/list/watch all resources in the release namespace
|
||||||
|
# readwritens — full access to all resources in the release namespace
|
||||||
|
# readonly — get/list/watch all resources cluster-wide
|
||||||
|
# readwrite — full access to all resources cluster-wide
|
||||||
|
clusterAccess: none
|
||||||
|
|
||||||
# Name of existing Secret containing env vars (GITHUB_TOKEN, VNC_PASSWORD, etc.)
|
# Name of existing Secret containing env vars (GITHUB_TOKEN, VNC_PASSWORD, etc.)
|
||||||
# Defaults to: devcontainer-{name}-secrets-env
|
# Defaults to: devcontainer-{name}-secrets-env
|
||||||
envSecretName: ""
|
envSecretName: ""
|
||||||
|
|||||||
Reference in New Issue
Block a user