Skip to content
This repository has been archived by the owner on Jun 24, 2020. It is now read-only.

Restrict RBAC for Operator #291

Merged
merged 1 commit into from
Mar 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
177 changes: 145 additions & 32 deletions config/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,99 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: rbac.authorization.k8s.io/v1
kind: Role
kind: ClusterRole
metadata:
name: knative-serving-operator-aggregated
aggregationRule:
clusterRoleSelectors:
# This (along with escalate below) allows the Operator to pick up any
# roles that are provided to the admin of the cluster by knative serving
# automatically.
- matchExpressions:
- {key: serving.knative.dev/release, operator: Exists}
rules: [] # Rules are automatically filled in by the controller manager.
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
creationTimestamp: null
name: knative-serving-operator
rules:
- apiGroups:
- operator.knative.dev
resources:
- '*'
verbs:
- '*'
# Bootstrapping permissions.
# Roles that are explicitly bound buch which are specified by this Operator
# MUST be specified here with 'get' and 'bind'.
- apiGroups:
- rbac.authorization.k8s.io
resources:
- clusterroles
resourceNames:
- system:auth-delegator
verbs:
- bind
- get
- apiGroups:
- rbac.authorization.k8s.io
resources:
- roles
resourceNames:
- extension-apiserver-authentication-reader
verbs:
- bind
- get
- apiGroups:
- rbac.authorization.k8s.io
resources:
- clusterroles
- roles
verbs:
- create
- delete
# Escalate is necessary in order to create a role using cluster role aggregation,
# and to allow the Operator to bootstrap itself into the necessary set of
# permissions, even as those continue to evolve upstream.
- escalate
- get
- list
- update
- apiGroups:
- rbac.authorization.k8s.io
resources:
- clusterrolebindings
- rolebindings
verbs:
- create
- delete
- list
- get
- update
# Permissions required for Knative controller
# infra.
- apiGroups:
- apiregistration.k8s.io
resources:
- apiservices
verbs:
- update
- apiGroups:
- ""
resources:
- pods
- services
- endpoints
- persistentvolumeclaims
- events
- configmaps
- secrets
verbs:
- create
- delete
- get
- list
- watch
- apiGroups:
- caching.internal.knative.dev
resources:
- images
verbs:
- '*'
- apiGroups:
Expand All @@ -36,6 +112,26 @@ rules:
- namespaces
verbs:
- get
- update
- watch
- apiGroups:
- ''
resources:
- events
verbs:
- create
- update
- patch
- apiGroups:
- ''
resources:
- configmaps
verbs:
- create
- delete
- get
- list
- watch
- apiGroups:
- apps
resources:
Expand All @@ -44,41 +140,58 @@ rules:
- replicasets
- statefulsets
verbs:
- '*'
- create
- delete
- get
- list
- watch
- apiGroups:
- monitoring.coreos.com
- apiregistration.k8s.io
resources:
- servicemonitors
- apiservices
verbs:
- get
- create
- delete
- get
- list
- apiGroups:
- apps
resourceNames:
- knative-serving-operator
- autoscaling
resources:
- deployments/finalizers
- horizontalpodautoscalers
verbs:
- update
- create
- delete
- get
- list
- apiGroups:
- operator.knative.dev
- coordination.k8s.io
resources:
- '*'
- leases
verbs:
- '*'
- apiGroups:
- coordination.k8s.io
- apiextensions.k8s.io
resources:
- leases
- customresourcedefinitions
verbs:
- '*'
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: knative-serving-operator
# This is necessary in order to use cluster role aggregation.
rules:
- apiGroups: ["*"]
resources: ["*"]
verbs: ["*"]
# Old resources that need cleaning up that are not in the knative-serving
# namespace.
- apiGroups:
- ""
resources:
- services
- deployments
- horizontalpodautoscalers
resourceNames:
- knative-ingressgateway
verbs:
- delete
- apiGroups:
- ""
resources:
- configmaps
resourceNames:
- config-controller
verbs:
- delete
17 changes: 9 additions & 8 deletions config/role_binding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,28 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

kind: RoleBinding
# TODO: Consider restriction of non-aggregated role to knativeservings namespaces.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: knative-serving-operator
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: knative-serving-operator
subjects:
- kind: ServiceAccount
name: knative-serving-operator
roleRef:
kind: Role
name: knative-serving-operator
apiGroup: rbac.authorization.k8s.io
namespace: default
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: knative-serving-operator
name: knative-serving-operator-aggregated
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: knative-serving-operator
name: knative-serving-operator-aggregated
subjects:
- kind: ServiceAccount
name: knative-serving-operator
Expand Down