Skip to content

Commit

Permalink
Merge pull request rook#9964 from thotz/add-service-account-rgw
Browse files Browse the repository at this point in the history
object: add service account for RGW pod
  • Loading branch information
travisn authored Apr 4, 2022
2 parents 87c4319 + 5e72b26 commit 2357cb7
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 2 deletions.
1 change: 1 addition & 0 deletions Documentation/authenticated-registry.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ The service accounts are:
* `default` (namespace: `rook-ceph`): Will affect most pods in the `rook-ceph` namespace.
* `rook-ceph-mgr` (namespace: `rook-ceph`): Will affect the MGR pods in the `rook-ceph` namespace.
* `rook-ceph-osd` (namespace: `rook-ceph`): Will affect the OSD pods in the `rook-ceph` namespace.
* `rook-ceph-rgw` (namespace: `rook-ceph`): Will affect the RGW pods in the `rook-ceph` namespace.

You can do it either via e.g. `kubectl -n <namespace> edit serviceaccount default` or by modifying the [`operator.yaml`](https://github.com/rook/rook/blob/master/deploy/examples/operator.yaml)
and [`cluster.yaml`](https://github.com/rook/rook/blob/master/deploy/examples/cluster.yaml) before deploying them.
Expand Down
1 change: 1 addition & 0 deletions PendingReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
* Network compression is configurable with settings in the CephCluster CR. Requires Ceph Quincy (v17) or newer.
* Add support for custom ceph.conf for csi pods. See #9567
* Added and updated many Ceph prometheus rules, picked up from the ceph repo
* Added service account rook-ceph-rgw for the RGW pods.
12 changes: 12 additions & 0 deletions deploy/charts/library/templates/_cluster-serviceaccount.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,16 @@ metadata:
name: rook-ceph-purge-osd
namespace: {{ .Release.Namespace }} # namespace:cluster
{{ include "library.imagePullSecrets" . }}
---
# Service account for RGW server
apiVersion: v1
kind: ServiceAccount
metadata:
name: rook-ceph-rgw
namespace: {{ .Release.Namespace }} # namespace:cluster
labels:
operator: rook
storage-backend: ceph
{{- include "library.rook-ceph.labels" . | nindent 4 }}
{{ include "library.imagePullSecrets" . }}
{{ end }}
6 changes: 6 additions & 0 deletions deploy/examples/common-second-cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,9 @@ kind: ServiceAccount
metadata:
name: rook-ceph-purge-osd
namespace: $NAMESPACE
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: rook-ceph-rgw
namespace: $NAMESPACE
13 changes: 13 additions & 0 deletions deploy/examples/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1303,6 +1303,19 @@ metadata:
# imagePullSecrets:
# - name: my-registry-secret
---
# Service account for RGW server
apiVersion: v1
kind: ServiceAccount
metadata:
name: rook-ceph-rgw
namespace: rook-ceph # namespace:cluster
labels:
operator: rook
storage-backend: ceph
app.kubernetes.io/part-of: rook-ceph-operator
# imagePullSecrets:
# - name: my-registry-secret
---
# Service account for the Rook-Ceph operator
apiVersion: v1
kind: ServiceAccount
Expand Down
1 change: 1 addition & 0 deletions deploy/examples/operator-openshift.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ users:
- system:serviceaccount:rook-ceph:default # serviceaccount:namespace:cluster
- system:serviceaccount:rook-ceph:rook-ceph-mgr # serviceaccount:namespace:cluster
- system:serviceaccount:rook-ceph:rook-ceph-osd # serviceaccount:namespace:cluster
- system:serviceaccount:rook-ceph:rook-ceph-rgw # serviceaccount:namespace:cluster
---
# scc for the CSI driver
kind: SecurityContextConstraints
Expand Down
1 change: 1 addition & 0 deletions pkg/apis/ceph.rook.io/v1/scc.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func NewSecurityContextConstraints(name, namespace string) *secv1.SecurityContex
fmt.Sprintf("system:serviceaccount:%s:default", namespace),
fmt.Sprintf("system:serviceaccount:%s:rook-ceph-mgr", namespace),
fmt.Sprintf("system:serviceaccount:%s:rook-ceph-osd", namespace),
fmt.Sprintf("system:serviceaccount:%s:rook-ceph-rgw", namespace),
},
}
}
6 changes: 4 additions & 2 deletions pkg/operator/ceph/object/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import (

const (
readinessProbePath = "/swift/healthcheck"
serviceAccountName = "rook-ceph-rgw"
// #nosec G101 since this is not leaking any hardcoded details
setupVaultTokenFile = `
set -e
Expand Down Expand Up @@ -113,8 +114,9 @@ func (c *clusterConfig) makeRGWPodSpec(rgwConfig *rgwConfig) (v1.PodTemplateSpec
controller.DaemonVolumes(c.DataPathMap, rgwConfig.ResourceName),
c.mimeTypesVolume(),
),
HostNetwork: c.clusterSpec.Network.IsHost(),
PriorityClassName: c.store.Spec.Gateway.PriorityClassName,
HostNetwork: c.clusterSpec.Network.IsHost(),
PriorityClassName: c.store.Spec.Gateway.PriorityClassName,
ServiceAccountName: serviceAccountName,
}

// If the log collector is enabled we add the side-car container
Expand Down
1 change: 1 addition & 0 deletions tests/framework/installer/ceph_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ func replaceNamespaces(name, manifest, operatorNamespace, clusterNamespace strin
manifest = strings.ReplaceAll(manifest, "rook-ceph:rook-ceph-system # serviceaccount:namespace:operator", operatorNamespace+":rook-ceph-system")
manifest = strings.ReplaceAll(manifest, "rook-ceph:rook-ceph-mgr # serviceaccount:namespace:cluster", clusterNamespace+":rook-ceph-mgr")
manifest = strings.ReplaceAll(manifest, "rook-ceph:rook-ceph-osd # serviceaccount:namespace:cluster", clusterNamespace+":rook-ceph-osd")
manifest = strings.ReplaceAll(manifest, "rook-ceph:rook-ceph-rgw # serviceaccount:namespace:cluster", clusterNamespace+":rook-ceph-rgw")

// SCC namespaces for CSI driver
manifest = strings.ReplaceAll(manifest, "rook-ceph:rook-csi-rbd-plugin-sa # serviceaccount:namespace:operator", operatorNamespace+":rook-csi-rbd-plugin-sa")
Expand Down

0 comments on commit 2357cb7

Please sign in to comment.