Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
e21b1e7
feat(oauth-properties): add spec to specify oauth properties as confi…
tthvo Aug 17, 2022
ef7183a
docs(oauth): add docs on oauth properties spec
tthvo Aug 18, 2022
07c11ee
test(resources): add resources for testing cryostat with oauth proper…
tthvo Aug 18, 2022
028c7ca
test(oauth): add unit tests for present oauth properties
tthvo Aug 18, 2022
335e669
chore(test): rename test oauth-props configmap
tthvo Aug 18, 2022
a63ba6b
fix(tests): fix failed unit tests for oauth props
tthvo Aug 18, 2022
dd62b11
fix(manifests): update markers, manifests and bundle
tthvo Aug 18, 2022
715c8a7
fix(crd): rename prefix oauth to auth for permission mapping
tthvo Aug 18, 2022
8689c9d
docs(auth): update docs on permission mappings
tthvo Aug 18, 2022
d3bbbd6
docs(config): fix typo
tthvo Aug 18, 2022
7774e28
docs(config): fix report example yaml
tthvo Aug 18, 2022
4e47149
fix(apis): update descriptions for authProperties
tthvo Aug 18, 2022
9b5d94b
docs(config): update config docs
tthvo Aug 18, 2022
3495ebd
fix(apis): add full display name for auth properties
tthvo Aug 18, 2022
3113d70
fix(apis): make authProperties as pointer
tthvo Aug 18, 2022
7143ec9
docs(config): update config docs
tthvo Aug 18, 2022
8df56bc
fix(test): update methods name and context descriptions
tthvo Aug 18, 2022
4bd844b
fix(tests): use ConsistsOf to compare slices
tthvo Aug 18, 2022
6a69dea
fix(crds): refine authorization spec field
tthvo Aug 22, 2022
0232392
fix(crds): fix description typo
tthvo Aug 22, 2022
fb5f8c8
docs(config): update config docs
tthvo Aug 22, 2022
6b81673
fix(tests): fix test resource definition
tthvo Aug 22, 2022
956d338
tests(auth): update auth-props to check env vars on openshift
tthvo Aug 22, 2022
7a47f00
temp: modify default-oauth
tthvo Aug 23, 2022
44db0d0
fix(apis): update descriptions for CR specs
tthvo Aug 24, 2022
9ef15d6
fix(auth-props): only configure auth properties on Openshift
tthvo Aug 24, 2022
876a2b9
docs(config): update docs on custom auth properties
tthvo Aug 24, 2022
f59045b
fix(apis): add xdescriptor for auth filename, fix auth spec field typ…
tthvo Aug 24, 2022
0a803f7
fix(oauth): use default oauth-client-role as base
tthvo Aug 25, 2022
6468bc9
fix(rbac): update default oauth-client cluster role
tthvo Aug 25, 2022
f5a91df
docs(config): mention escalation issue if using secret in permission …
tthvo Aug 25, 2022
270ce84
fix(rbac): update base oauth-client role
tthvo Aug 26, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion api/v1beta1/cryostat_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ type CryostatSpec struct {
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec
Resources ResourceConfigList `json:"resources,omitempty"`
// Override default authorization properties for Cryostat on OpenShift.
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Authorization Properties",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"}
AuthProperties *AuthorizationProperties `json:"authProperties,omitempty"`
}

type ResourceConfigList struct {
Expand Down Expand Up @@ -151,7 +155,6 @@ type StorageConfiguration struct {
// +optional
// +operator-sdk:csv:customresourcedefinitions:type=spec
PVC *PersistentVolumeClaimConfig `json:"pvc,omitempty"`

// Configuration for an EmptyDir to be created
// by the operator instead of a PVC.
// +optional
Expand Down Expand Up @@ -402,3 +405,19 @@ type TemplateConfigMap struct {
// Filename within config map containing the template file
Filename string `json:"filename"`
}

// Authorization properties provide custom permission mapping between Cryostat resources to Kubernetes resources.
// If the mapping is updated, Cryostat must be manually restarted.
type AuthorizationProperties struct {
// Name of the ClusterRole to use when Cryostat requests a role-scoped OAuth token.
// This ClusterRole should contain permissions for all Kubernetes objects listed in custom permission mapping.
// More details: https://docs.openshift.com/container-platform/4.11/authentication/tokens-scoping.html#scoping-tokens-role-scope_configuring-internal-oauth
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="ClusterRole Name",xDescriptors={"urn:alm:descriptor:io.kubernetes:ClusterRole"}
ClusterRoleName string `json:"clusterRoleName"`
// Name of config map in the local namespace.
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="ConfigMap Name",xDescriptors={"urn:alm:descriptor:io.kubernetes:ConfigMap"}
ConfigMapName string `json:"configMapName"`
// Filename within config map containing the resource mapping.
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:text"}
Filename string `json:"filename"`
}
20 changes: 20 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,32 @@ metadata:
name: cryostat-operator-oauth-client
rules:
- apiGroups:
- ""
- operator.cryostat.io
resources:
- pods
- cryostats
verbs:
- create
- patch
- delete
- get
- apiGroups:
- ""
resources:
- replicationcontrollers
- endpoints
verbs:
- get
- apiGroups:
- operator.cryostat.io
resources:
- cryostats
- pods
- pods/exec
- services
verbs:
- create
- patch
- delete
- get
- apiGroups:
- operator.cryostat.io
- ""
resources:
- flightrecorders
- recordings
- replicationcontrollers
- endpoints
verbs:
- create
- delete
- get
- patch
- apiGroups:
- apps
resources:
Expand Down
22 changes: 22 additions & 0 deletions bundle/manifests/cryostat-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,28 @@ spec:
name: ""
version: v1
specDescriptors:
- description: Override default authorization properties for Cryostat on OpenShift.
displayName: Authorization Properties
path: authProperties
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:advanced
- description: 'Name of the ClusterRole to use when Cryostat requests a role-scoped
OAuth token. This ClusterRole should contain permissions for all Kubernetes
objects listed in custom permission mapping. More details: https://docs.openshift.com/container-platform/4.11/authentication/tokens-scoping.html#scoping-tokens-role-scope_configuring-internal-oauth'
displayName: ClusterRole Name
path: authProperties.clusterRoleName
x-descriptors:
- urn:alm:descriptor:io.kubernetes:ClusterRole
- description: Name of config map in the local namespace.
displayName: ConfigMap Name
path: authProperties.configMapName
x-descriptors:
- urn:alm:descriptor:io.kubernetes:ConfigMap
- description: Filename within config map containing the resource mapping.
displayName: Filename
path: authProperties.filename
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:text
- description: Use cert-manager to secure in-cluster communication between Cryostat
components. Requires cert-manager to be installed.
displayName: Enable cert-manager Integration
Expand Down
22 changes: 22 additions & 0 deletions bundle/manifests/operator.cryostat.io_cryostats.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,28 @@ spec:
spec:
description: CryostatSpec defines the desired state of Cryostat
properties:
authProperties:
description: Override default authorization properties for Cryostat
on OpenShift.
properties:
clusterRoleName:
description: 'Name of the ClusterRole to use when Cryostat requests
a role-scoped OAuth token. This ClusterRole should contain permissions
for all Kubernetes objects listed in custom permission mapping.
More details: https://docs.openshift.com/container-platform/4.11/authentication/tokens-scoping.html#scoping-tokens-role-scope_configuring-internal-oauth'
type: string
configMapName:
description: Name of config map in the local namespace.
type: string
filename:
description: Filename within config map containing the resource
mapping.
type: string
required:
- clusterRoleName
- configMapName
- filename
type: object
enableCertManager:
description: Use cert-manager to secure in-cluster communication between
Cryostat components. Requires cert-manager to be installed.
Expand Down
22 changes: 22 additions & 0 deletions config/crd/bases/operator.cryostat.io_cryostats.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,28 @@ spec:
spec:
description: CryostatSpec defines the desired state of Cryostat
properties:
authProperties:
description: Override default authorization properties for Cryostat
on OpenShift.
properties:
clusterRoleName:
description: 'Name of the ClusterRole to use when Cryostat requests
a role-scoped OAuth token. This ClusterRole should contain permissions
for all Kubernetes objects listed in custom permission mapping.
More details: https://docs.openshift.com/container-platform/4.11/authentication/tokens-scoping.html#scoping-tokens-role-scope_configuring-internal-oauth'
type: string
configMapName:
description: Name of config map in the local namespace.
type: string
filename:
description: Filename within config map containing the resource
mapping.
type: string
required:
- clusterRoleName
- configMapName
- filename
type: object
enableCertManager:
description: Use cert-manager to secure in-cluster communication between
Cryostat components. Requires cert-manager to be installed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,28 @@ spec:
name: ""
version: v1
specDescriptors:
- description: Override default authorization properties for Cryostat on OpenShift.
displayName: Authorization Properties
path: authProperties
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:advanced
- description: 'Name of the ClusterRole to use when Cryostat requests a role-scoped
OAuth token. This ClusterRole should contain permissions for all Kubernetes
objects listed in custom permission mapping. More details: https://docs.openshift.com/container-platform/4.11/authentication/tokens-scoping.html#scoping-tokens-role-scope_configuring-internal-oauth'
displayName: ClusterRole Name
path: authProperties.clusterRoleName
x-descriptors:
- urn:alm:descriptor:io.kubernetes:ClusterRole
- description: Name of config map in the local namespace.
displayName: ConfigMap Name
path: authProperties.configMapName
x-descriptors:
- urn:alm:descriptor:io.kubernetes:ConfigMap
- description: Filename within config map containing the resource mapping.
displayName: Filename
path: authProperties.filename
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:text
- description: Use cert-manager to secure in-cluster communication between Cryostat
components. Requires cert-manager to be installed.
displayName: Enable cert-manager Integration
Expand Down
27 changes: 11 additions & 16 deletions config/rbac/oauth_client.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,32 @@ metadata:
name: oauth-client
rules:
- apiGroups:
- ""
- operator.cryostat.io
resources:
- pods
- cryostats
verbs:
- create
- patch
- delete
- get
- apiGroups:
- ""
resources:
- replicationcontrollers
- endpoints
verbs:
- get
- apiGroups:
- operator.cryostat.io
resources:
- cryostats
- pods
- pods/exec
- services
verbs:
- create
- patch
- delete
- get
- apiGroups:
- operator.cryostat.io
- ""
resources:
- flightrecorders
- recordings
- replicationcontrollers
- endpoints
verbs:
- create
- delete
- get
- patch
- apiGroups:
- apps
resources:
Expand Down
48 changes: 45 additions & 3 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,10 @@ metadata:
spec:
reportOptions:
replicas: 1
requests:
cpu: 1000m
memory: 512Mi
resources:
requests:
cpu: 1000m
memory: 512Mi
```
If zero sidecar replicas are configured, SubProcessMaxHeapSize configures
the maximum heap size of the main Cryostat container's subprocess report generator in MiB.
Expand Down Expand Up @@ -267,3 +268,44 @@ spec:
targetCacheSize: -1
targetCacheTTL: 10
```


### Authorization Properties

When running on OpenShift, the user is required to have sufficient permissions for certain Kubernetes resources that are mapped into Cryostat-managed resources for authorization.

The mappings can be specified using a ConfigMap that is compatible with [`OpenShiftAuthManager.properties`](https://github.com/cryostatio/cryostat/blob/bd95e1a11e9e29cc39559f4a5fdeaae77e81b4c6/src/main/resources/io/cryostat/net/openshift/OpenShiftAuthManager.properties). For example:
```yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: auth-properties
data:
auth.properties: |
TARGET=pods,deployments.apps
RECORDING=pods,pods/exec
CERTIFICATE=deployments.apps,pods,cryostats.operator.cryostat.io
CREDENTIALS=cryostats.operator.cryostat.io
```

If custom mapping is specified, a ClusterRole must be defined and should contain permissions for all Kubernetes objects listed in custom permission mapping. This ClusterRole will give additional rules on top of [default rules](placeholder). <!-- FIXME add link after merging -->


**Note**: Using [`Secret`](https://kubernetes.io/docs/concepts/configuration/secret/) in mapping can fail with access denied under [security protection](https://kubernetes.io/docs/concepts/configuration/secret/#information-security-for-secrets) against escalations. Find more details about this issue [here](https://docs.openshift.com/container-platform/4.11/authentication/tokens-scoping.html#scoping-tokens-role-scope_configuring-internal-oauth).

The property `.spec.authProperties` can then be set to configure Cryostat to use this mapping instead of the default ones.
```yaml
apiVersion: operator.cryostat.io/v1beta1
kind: Cryostat
metadata:
name: cryostat-sample
spec:
authProperties:
configMapName: auth-properties
filename: auth.properties
clusterRoleName: oauth-cluster-role
```

Each `configMapName` must refer to the name of a Config Map in the same namespace as Cryostat. The corresponding `filename` must be a key within that Config Map containing resource mappings. The `clusterRoleName` must be a valid name of an existing Cluster Role.

**Note:** If the mapping is updated, Cryostat must be manually restarted.
Loading