Skip to content

Commit a038a9d

Browse files
update new k8 Operator Permissions table to new format (#459)
Co-authored-by: Brian Rinaldi <brian.rinaldi@gmail.com>
1 parent 232bfde commit a038a9d

File tree

3 files changed

+301
-21
lines changed

3 files changed

+301
-21
lines changed
Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
import React from 'react';
2+
import {
3+
Table,
4+
TableHeader,
5+
TableBody,
6+
TableRow,
7+
TableHead,
8+
TableCell,
9+
} from '@/components/ui/table';
10+
import {
11+
useReactTable,
12+
getCoreRowModel,
13+
flexRender,
14+
} from '@tanstack/react-table';
15+
import type { ColumnDef } from '@tanstack/react-table';
16+
import permissionsData from '@/data/kubernetes/operator-permissions.json';
17+
18+
type PermissionRow = {
19+
kind?: string;
20+
name?: string;
21+
apiGroup?: string;
22+
resources?: string[];
23+
verbs: string[];
24+
nonResourceUrls?: string[];
25+
};
26+
27+
const rows = permissionsData as PermissionRow[];
28+
29+
const headerCellStyle: React.CSSProperties = {
30+
textAlign: 'left',
31+
border: '1px solid #999CAD',
32+
background: '#AFB2C2',
33+
color: 'var(--sl-color-gray-1)',
34+
fontFamily: 'AeonikFono',
35+
fontSize: '14px',
36+
fontWeight: '500',
37+
lineHeight: '16px',
38+
letterSpacing: '-0.15px',
39+
padding: '12px 8px',
40+
};
41+
42+
const bodyCellStyle: React.CSSProperties = {
43+
verticalAlign: 'top',
44+
textAlign: 'left',
45+
border: '1px solid #999CAD',
46+
color: 'var(--sl-color-gray-1)',
47+
fontFamily: 'AeonikFono',
48+
fontSize: '14px',
49+
fontWeight: '400',
50+
lineHeight: '16px',
51+
letterSpacing: '-0.15px',
52+
padding: '12px 8px',
53+
whiteSpace: 'normal',
54+
};
55+
56+
const renderCodeList = (values?: string[]) => {
57+
if (!values?.length) return null;
58+
return (
59+
<>
60+
{values.map((value, index) => (
61+
<React.Fragment key={`${value}-${index}`}>
62+
<code>{value}</code>
63+
{index < values.length - 1 ? ', ' : ''}
64+
</React.Fragment>
65+
))}
66+
</>
67+
);
68+
};
69+
70+
const columns: ColumnDef<PermissionRow>[] = [
71+
{
72+
accessorKey: 'kind',
73+
header: () => 'Kind',
74+
cell: ({ row }) => (row.original.kind ? <strong>{row.original.kind}</strong> : null),
75+
},
76+
{
77+
accessorKey: 'name',
78+
header: () => 'Name',
79+
cell: ({ row }) => (row.original.name ? <code>{row.original.name}</code> : null),
80+
},
81+
{
82+
accessorKey: 'apiGroup',
83+
header: () => 'API Groups',
84+
cell: ({ row }) => (row.original.apiGroup ? <code>{row.original.apiGroup}</code> : null),
85+
},
86+
{
87+
id: 'resources',
88+
header: () => 'Resources',
89+
cell: ({ row }) =>
90+
row.original.nonResourceUrls?.length ? (
91+
<> (nonResourceURLs: {renderCodeList(row.original.nonResourceUrls)})</>
92+
) : (
93+
renderCodeList(row.original.resources)
94+
),
95+
},
96+
{
97+
id: 'verbs',
98+
header: () => 'Verbs',
99+
cell: ({ row }) => row.original.verbs.join(', '),
100+
},
101+
];
102+
103+
export default function OperatorPermissionsTable() {
104+
const table = useReactTable({
105+
data: rows,
106+
columns,
107+
getCoreRowModel: getCoreRowModel(),
108+
debugTable: false,
109+
});
110+
111+
const getColumnWidth = (columnId: string) => {
112+
switch (columnId) {
113+
case 'kind':
114+
return '14%';
115+
case 'name':
116+
return '24%';
117+
case 'apiGroup':
118+
return '16%';
119+
case 'resources':
120+
return '23%';
121+
case 'verbs':
122+
return '23%';
123+
default:
124+
return 'auto';
125+
}
126+
};
127+
128+
const getMinWidth = (columnId: string) => {
129+
switch (columnId) {
130+
case 'kind':
131+
return '110px';
132+
case 'name':
133+
return '220px';
134+
case 'apiGroup':
135+
return '170px';
136+
case 'resources':
137+
return '260px';
138+
case 'verbs':
139+
return '300px';
140+
default:
141+
return '80px';
142+
}
143+
};
144+
145+
return (
146+
<div className="p-2 block max-w-full overflow-x-scroll overflow-y-hidden">
147+
<Table
148+
className="w-full"
149+
style={{
150+
borderCollapse: 'collapse',
151+
tableLayout: 'fixed',
152+
width: '100%',
153+
}}
154+
>
155+
<TableHeader>
156+
{table.getHeaderGroups().map((headerGroup) => (
157+
<TableRow key={headerGroup.id}>
158+
{headerGroup.headers.map((header) => (
159+
<TableHead
160+
key={header.id}
161+
style={{
162+
...headerCellStyle,
163+
width: getColumnWidth(header.id),
164+
minWidth: getMinWidth(header.id),
165+
}}
166+
>
167+
{flexRender(header.column.columnDef.header, header.getContext())}
168+
</TableHead>
169+
))}
170+
</TableRow>
171+
))}
172+
</TableHeader>
173+
<TableBody>
174+
{table.getRowModel().rows.map((row) => (
175+
<TableRow key={row.id}>
176+
{row.getVisibleCells().map((cell) => (
177+
<TableCell
178+
key={cell.id}
179+
style={{
180+
...bodyCellStyle,
181+
width: getColumnWidth(cell.column.id),
182+
minWidth: getMinWidth(cell.column.id),
183+
whiteSpace:
184+
cell.column.id === 'resources' || cell.column.id === 'verbs'
185+
? 'normal'
186+
: 'nowrap',
187+
}}
188+
>
189+
{flexRender(cell.column.columnDef.cell, cell.getContext())}
190+
</TableCell>
191+
))}
192+
</TableRow>
193+
))}
194+
</TableBody>
195+
</Table>
196+
</div>
197+
);
198+
}

src/content/docs/aws/enterprise/kubernetes/kubernetes-operator.md renamed to src/content/docs/aws/enterprise/kubernetes/kubernetes-operator.mdx

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ sidebar:
77
tags: ["Enterprise"]
88
---
99

10+
import OperatorPermissionsTable from '../../../../../components/kubernetes-operator/OperatorPermissionsTable';
11+
1012
The LocalStack Operator is our Kubernetes-native way to deploy and manage LocalStack instances. It abstracts Kubernetes-specific configuration and automates operational tasks, making LocalStack deployments more consistent and easier to maintain. It can manage multiple LocalStack instances within a cluster to provide isolated local clouds for multiple users.
1113

1214
The Operator manages the full lifecycle of LocalStack resources and enables advanced Kubernetes integrations that are difficult to configure manually.
@@ -140,27 +142,7 @@ CRD documentation is currently maintained manually. For a full reference of avai
140142

141143
The Operator manifest creates all required `Roles`, `ClusterRoles`, and `bindings`.
142144

143-
144-
| **Kind** | **Name** | **API Groups** | **Resources** | **Verbs** |
145-
| --- | --- | --- | --- | --- |
146-
| **Role** | `localstack-operator-leader-election-role` | | `configmaps` | get, list, watch, create, update, patch, delete |
147-
| | | `coordination.k8s.io` | `leases` | get, list, watch, create, update, patch, delete |
148-
| | | | `events` | create, patch |
149-
| **ClusterRole** | `localstack-operator-manager-role` | | `configmaps` | delete, get, list, patch, update, watch |
150-
| | | | `events` | create, patch |
151-
| | | | `pods`, `pods/exec`, `pods/log` | create, delete, deletecollection, get, list, patch, update, watch |
152-
| | | | `secrets` | get, list, watch |
153-
| | | | `serviceaccounts` | create, delete, get, list, update, watch |
154-
| | | | `services` | create, delete, get, list, patch, update, watch |
155-
| | | `api.localstack.cloud` | `localstacks` | create, delete, get, list, patch, update, watch |
156-
| | | `api.localstack.cloud` | `localstacks/finalizers` | update |
157-
| | | `api.localstack.cloud` | `localstacks/status` | get, patch, update |
158-
| | | `apps` | `deployments` | create, delete, get, list, patch, update, watch |
159-
| | | `apps` | `deployments/scale` | create, delete, get, list, patch, update, watch |
160-
| | | `rbac.authorization.k8s.io` | `rolebindings`, `roles` | create, delete, list, update, watch |
161-
| **ClusterRole** | `localstack-operator-metrics-reader` | | (nonResourceURLs: `/metrics`) | get |
162-
| **ClusterRole** | `localstack-operator-proxy-role` | `authentication.k8s.io` | `tokenreviews` | create |
163-
| | | `authorization.k8s.io` | `subjectaccessreviews` | create |
145+
<OperatorPermissionsTable />
164146

165147

166148
### Manager ClusterRole
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
[
2+
{
3+
"kind": "Role",
4+
"name": "localstack-operator-leader-election-role",
5+
"resources": ["configmaps"],
6+
"verbs": ["get", "list", "watch", "create", "update", "patch", "delete"]
7+
},
8+
{
9+
"apiGroup": "coordination.k8s.io",
10+
"resources": ["leases"],
11+
"verbs": ["get", "list", "watch", "create", "update", "patch", "delete"]
12+
},
13+
{
14+
"resources": ["events"],
15+
"verbs": ["create", "patch"]
16+
},
17+
{
18+
"kind": "ClusterRole",
19+
"name": "localstack-operator-manager-role",
20+
"resources": ["configmaps"],
21+
"verbs": ["delete", "get", "list", "patch", "update", "watch"]
22+
},
23+
{
24+
"resources": ["events"],
25+
"verbs": ["create", "patch"]
26+
},
27+
{
28+
"resources": ["pods", "pods/exec", "pods/log"],
29+
"verbs": [
30+
"create",
31+
"delete",
32+
"deletecollection",
33+
"get",
34+
"list",
35+
"patch",
36+
"update",
37+
"watch"
38+
]
39+
},
40+
{
41+
"resources": ["secrets"],
42+
"verbs": ["get", "list", "watch"]
43+
},
44+
{
45+
"resources": ["serviceaccounts"],
46+
"verbs": ["create", "delete", "get", "list", "update", "watch"]
47+
},
48+
{
49+
"resources": ["services"],
50+
"verbs": ["create", "delete", "get", "list", "patch", "update", "watch"]
51+
},
52+
{
53+
"apiGroup": "api.localstack.cloud",
54+
"resources": ["localstacks"],
55+
"verbs": ["create", "delete", "get", "list", "patch", "update", "watch"]
56+
},
57+
{
58+
"apiGroup": "api.localstack.cloud",
59+
"resources": ["localstacks/finalizers"],
60+
"verbs": ["update"]
61+
},
62+
{
63+
"apiGroup": "api.localstack.cloud",
64+
"resources": ["localstacks/status"],
65+
"verbs": ["get", "patch", "update"]
66+
},
67+
{
68+
"apiGroup": "apps",
69+
"resources": ["deployments"],
70+
"verbs": ["create", "delete", "get", "list", "patch", "update", "watch"]
71+
},
72+
{
73+
"apiGroup": "apps",
74+
"resources": ["deployments/scale"],
75+
"verbs": ["create", "delete", "get", "list", "patch", "update", "watch"]
76+
},
77+
{
78+
"apiGroup": "rbac.authorization.k8s.io",
79+
"resources": ["rolebindings", "roles"],
80+
"verbs": ["create", "delete", "list", "update", "watch"]
81+
},
82+
{
83+
"kind": "ClusterRole",
84+
"name": "localstack-operator-metrics-reader",
85+
"nonResourceUrls": ["/metrics"],
86+
"verbs": ["get"]
87+
},
88+
{
89+
"kind": "ClusterRole",
90+
"name": "localstack-operator-proxy-role",
91+
"apiGroup": "authentication.k8s.io",
92+
"resources": ["tokenreviews"],
93+
"verbs": ["create"]
94+
},
95+
{
96+
"apiGroup": "authorization.k8s.io",
97+
"resources": ["subjectaccessreviews"],
98+
"verbs": ["create"]
99+
}
100+
]

0 commit comments

Comments
 (0)