Commit 455dd4a
authored
feat(mcpserver): add ServiceAccount annotations and labels support (#95)
# Add ServiceAccount customization support for MCPServer
## Overview
This PR adds support for customizing ServiceAccount annotations and
labels in MCPServer resources, enabling cloud provider integrations such
as AWS IRSA (IAM Roles for Service Accounts).
## Motivation
Currently, MCPServers create ServiceAccounts with only basic metadata.
To enable cloud provider integrations (AWS IRSA, GCP Workload Identity,
Azure Managed Identity), users need the ability to add custom
annotations and labels to these ServiceAccounts.
## Changes
### 1. API Changes (`api/v1alpha1/mcpserver_types.go`)
- Added `ServiceAccountConfig` type with:
- `Annotations map[string]string` - for cloud provider annotations
(e.g., AWS IRSA role ARN)
- `Labels map[string]string` - for resource organization and policy
enforcement
- Added `ServiceAccount *ServiceAccountConfig` field to
`MCPServerDeployment`
- Comprehensive documentation with examples
### 2. Controller Changes
(`pkg/controller/transportadapter/transportadapter_translator.go`)
- Modified `translateTransportAdapterServiceAccount()` to apply custom
annotations and labels
- Maintains backward compatibility (defaults when not specified)
### 3. CRD Updates
- Generated updated CRD with new fields and validation
- Updated deepcopy code
### 4. Documentation
- Added example file:
`config/samples/mcpserver-serviceaccount-irsa.yaml`
- Shows complete AWS IRSA configuration example
## Use Cases
### AWS IRSA (IAM Roles for Service Accounts)
```yaml
spec:
deployment:
serviceAccount:
annotations:
eks.amazonaws.com/role-arn: "arn:aws:iam::123456789012:role/my-role"
eks.amazonaws.com/sts-regional-endpoints: "true"
labels:
team: platform
environment: production
```
Enables MCPServer pods to:
- Access AWS services (S3, DynamoDB, Secrets Manager, etc.) without
managing credentials
- Use temporary IAM credentials automatically refreshed by AWS
- Follow AWS security best practices (no long-lived credentials)
## Backward Compatibility
✅ **Fully backward compatible**:
- All new fields are optional (`omitempty`)
- Existing MCPServer resources continue working unchanged
- Default behavior preserved when fields not specified
## Testing
- [x] Code compiles successfully
- [x] `make generate` updates deepcopy code
- [x] `make manifests` generates valid CRDs
- [x] `make test` passes all unit tests
- [x] Example manifest validates configuration
## Checklist
- [x] API changes documented with clear comments
- [x] Controller implementation tested
- [x] CRDs regenerated
- [x] Example file provided
- [x] Backward compatibility maintained
- [x] Commit signed with DCO
## Migration Notes
No migration required. This is an additive change that does not affect
existing MCPServer resources.
Signed-off-by: skhedim <sebastien.khedim@gmail.com>
Signed-off-by: sebastien_khedim <Sebastien_KHEDIM@ext.connect-tech.sncf>1 parent 5c40e9d commit 455dd4a
5 files changed
Lines changed: 122 additions & 4 deletions
File tree
- api/v1alpha1
- config
- crd/bases
- samples
- pkg/controller/transportadapter
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
236 | 236 | | |
237 | 237 | | |
238 | 238 | | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
239 | 243 | | |
240 | 244 | | |
241 | 245 | | |
| |||
252 | 256 | | |
253 | 257 | | |
254 | 258 | | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
255 | 273 | | |
256 | 274 | | |
257 | 275 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
141 | 160 | | |
142 | 161 | | |
143 | 162 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
Lines changed: 16 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
286 | 286 | | |
287 | 287 | | |
288 | 288 | | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
289 | 304 | | |
290 | 305 | | |
291 | 306 | | |
292 | 307 | | |
293 | 308 | | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
| 309 | + | |
298 | 310 | | |
299 | 311 | | |
300 | 312 | | |
| |||
0 commit comments