Skip to content

Commit

Permalink
document and minimize IAM rule policy for CSI (#19)
Browse files Browse the repository at this point in the history
We document the minimal IAM rule policy needed for the CSI to operate.

Co-authored-by: Arnaud Geiser <[email protected]>
  • Loading branch information
sauterp and arnaudgeiser authored Mar 7, 2024
1 parent 96b5084 commit f40ebce
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*.dll
*.so
*.dylib
/bin

# Test binary, built with `go test -c`
*.test
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

* go.mk: remove submodule and initialize through make #15
* integ-tests: use IAMv3 API key #13
* document and minimize IAM rule policy for CSI #19

## 0.29.2

Expand Down
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,25 @@ Exoscale Block Storage Container Storage Interface Driver.

* Make sure you have the [CCM](https://github.com/exoscale/exoscale-cloud-controller-manager) deployed and running in your cluster.

* Create secret with [exoscale-secret.sh](./deployment/exoscale-secret.sh).
* An API key associated to an IAM role with at least those permissions:
``` json
{
"default-service-strategy": "deny",
"services": {
"compute": {
"type": "rules",
"rules": [
{
"expression": "operation in ['list-zones', 'get-block-storage-volume', 'list-block-storage-volumes', 'create-block-storage-volume', 'delete-block-storage-volume', 'attach-block-storage-volume-to-instance', 'detach-block-storage-volume', 'update-block-storage-volume-labels', 'resize-block-storage-volume', 'get-block-storage-snapshot', 'list-block-storage-snapshots', 'create-block-storage-snapshot', 'delete-block-storage-snapshot']",
"action": "allow"
},
]
}
}
}
```

* Create a kubernetes secret for the API key with [exoscale-secret.sh](./deployment/exoscale-secret.sh).
```Bash
export EXOSCALE_API_KEY=EXOxxxxx
export EXOSCALE_API_SECRET=xxxxx
Expand Down
12 changes: 9 additions & 3 deletions internal/integ/cluster/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,14 @@ func (c *Cluster) applyCSI() error {
return err
}

allow := exov2.IAMPolicyService{
Type: ptr("allow"),
onlyAllowBlockStorageOperations := exov2.IAMPolicyService{
Type: ptr("rules"),
Rules: []exov2.IAMPolicyServiceRule{
exov2.IAMPolicyServiceRule{
Action: ptr("allow"),
Expression: ptr("operation in ['list-zones', 'get-block-storage-volume', 'list-block-storage-volumes', 'create-block-storage-volume', 'delete-block-storage-volume', 'attach-block-storage-volume-to-instance', 'detach-block-storage-volume', 'update-block-storage-volume-labels', 'resize-block-storage-volume', 'get-block-storage-snapshot', 'list-block-storage-snapshots', 'create-block-storage-snapshot', 'delete-block-storage-snapshot']"),
},
},
}

role, err := c.Ego.CreateIAMRole(c.exoV2Context, *flags.Zone, &exov2.IAMRole{
Expand All @@ -237,7 +243,7 @@ func (c *Cluster) applyCSI() error {
Policy: &exov2.IAMPolicy{
DefaultServiceStrategy: "deny",
Services: map[string]exov2.IAMPolicyService{
"compute": allow,
"compute": onlyAllowBlockStorageOperations,
},
},
})
Expand Down

0 comments on commit f40ebce

Please sign in to comment.