1+ kind : ServiceAccount
2+ apiVersion : v1
3+ metadata :
4+ name : kubectl-ai
5+ ---
6+ # apiVersion: v1
7+ # kind: Pod
8+ # metadata:
9+ # name: kubectl-ai
10+ # labels:
11+ # app: kubectl-ai
12+ # spec:
13+ # serviceAccountName: kubectl-ai
14+ # containers:
15+ # - name: kubectl-ai
16+ # image: kubectl-ai:latest
17+ # args:
18+ # - --ui-type=web
19+ # - --ui-listen-address=0.0.0.0:8080
20+ # - --llm-provider=vertexai
21+ # - --v=4
22+ # - --alsologtostderr
23+ # env:
24+ # - name: GOOGLE_CLOUD_PROJECT
25+ # value: "PROJECT_ID"
26+ # - name: GOOGLE_CLOUD_LOCATION
27+ # value: "global"
28+ # ports:
29+ # - containerPort: 8080
30+ # ---
131kind : Deployment
232apiVersion : apps/v1
333metadata :
2757 - name : GOOGLE_CLOUD_LOCATION
2858 value : " global"
2959 # Vertex AI authentication will be handled via Workload Identity Federation
60+ # ---
3061---
31-
32- kind : ServiceAccount
33- apiVersion : v1
34- metadata :
35- name : kubectl-ai
36- # Using GKE Workload Identity Federation - no GSA impersonation needed
37- ---
38-
3962apiVersion : rbac.authorization.k8s.io/v1
4063kind : RoleBinding
4164metadata :
@@ -47,9 +70,7 @@ roleRef:
4770subjects :
4871- kind : ServiceAccount
4972 name : kubectl-ai
50-
5173---
52-
5374kind : Service
5475apiVersion : v1
5576metadata :
6283 ports :
6384 - port : 80
6485 targetPort : 8888
65- protocol : TCP
86+ protocol : TCP
87+ ---
88+ # 1. The ClusterRole that grants read-only access to most resources
89+ # This is a cluster-wide role, so it does not have a namespace.
90+ apiVersion : rbac.authorization.k8s.io/v1
91+ kind : ClusterRole
92+ metadata :
93+ # This name is shared across the cluster.
94+ name : read-only-except-secrets-cluster-role
95+ rules :
96+ - apiGroups :
97+ - " " # core API group
98+ resources :
99+ # List all core resource types EXCEPT "secrets"
100+ - configmaps
101+ - endpoints
102+ - events
103+ - limitranges
104+ - namespaces
105+ - nodes
106+ - persistentvolumeclaims
107+ - persistentvolumes
108+ - pods
109+ - podtemplates
110+ - replicationcontrollers
111+ - resourcequotas
112+ - serviceaccounts
113+ - services
114+ verbs :
115+ - get
116+ - list
117+ - watch
118+ - apiGroups :
119+ - " *" # All other current and future API groups
120+ resources :
121+ - " *" # All current and future resources in those groups (including CRDs and CRs)
122+ verbs :
123+ - get
124+ - list
125+ - watch
126+ ---
127+ # 2. The ClusterRoleBinding that connects the ServiceAccount to the Role
128+ apiVersion : rbac.authorization.k8s.io/v1
129+ kind : ClusterRoleBinding
130+ metadata :
131+ name : read-only-kubectl-ai-binding
132+ subjects :
133+ # Grant the permissions to the specific ServiceAccount in the specific namespace
134+ - kind : ServiceAccount
135+ name : kubectl-ai
136+ namespace : kubectl-ai
137+ roleRef :
138+ # This refers to the ClusterRole defined above
139+ kind : ClusterRole
140+ name : read-only-except-secrets-cluster-role
141+ apiGroup : rbac.authorization.k8s.io
142+ ---
143+ apiVersion : rbac.authorization.k8s.io/v1
144+ kind : ClusterRole
145+ metadata :
146+ name : kubectl-ai-computer-manager
147+ rules :
148+ - apiGroups :
149+ - " "
150+ resources :
151+ - pods
152+ - pods/exec
153+ - configmaps
154+ - secrets
155+ verbs :
156+ - create
157+ - get
158+ - delete
159+ ---
160+ apiVersion : rbac.authorization.k8s.io/v1
161+ kind : RoleBinding
162+ metadata :
163+ name : kubectl-ai-computer-manager-binding
164+ namespace : computer
165+ roleRef :
166+ apiGroup : rbac.authorization.k8s.io
167+ kind : ClusterRole
168+ name : kubectl-ai-computer-manager
169+ subjects :
170+ - kind : ServiceAccount
171+ name : kubectl-ai
172+ namespace : kubectl-ai
0 commit comments