Skip to content

Commit

Permalink
include token in tsb registration
Browse files Browse the repository at this point in the history
  • Loading branch information
bparees committed Aug 31, 2017
1 parent 5f0c7b2 commit a2c1538
Show file tree
Hide file tree
Showing 8 changed files with 395 additions and 210 deletions.
104 changes: 59 additions & 45 deletions examples/service-catalog/service-catalog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ metadata:
name: service-catalog
objects:

- kind: ClusterRole
apiVersion: v1
- apiVersion: authorization.openshift.io/v1
kind: ClusterRole
metadata:
name: servicecatalog-serviceclass-viewer
rules:
Expand All @@ -18,8 +18,8 @@ objects:
- watch
- get

- kind: ClusterRoleBinding
apiVersion: v1
- apiVersion: authorization.openshift.io/v1
kind: ClusterRoleBinding
metadata:
name: servicecatalog-serviceclass-viewer-binding
roleRef:
Expand All @@ -37,8 +37,8 @@ objects:
metadata:
name: service-catalog-apiserver

- kind: ClusterRole
apiVersion: v1
- apiVersion: authorization.openshift.io/v1
kind: ClusterRole
metadata:
name: sar-creator
rules:
Expand All @@ -49,17 +49,19 @@ objects:
verbs:
- create

- kind: ClusterRoleBinding
apiVersion: v1
- apiVersion: authorization.openshift.io/v1
kind: ClusterRoleBinding
metadata:
name: service-catalog-sar-creator-binding
roleRef:
name: sar-creator
userNames:
- system:serviceaccount:kube-service-catalog:service-catalog-apiserver
subjects:
- kind: ServiceAccount
name: service-catalog-apiserver
namespace: kube-service-catalog

- kind: ClusterRole
apiVersion: v1
- apiVersion: authorization.openshift.io/v1
kind: ClusterRole
metadata:
name: namespace-viewer
rules:
Expand All @@ -72,26 +74,30 @@ objects:
- watch
- get

- kind: ClusterRoleBinding
apiVersion: v1
- apiVersion: authorization.openshift.io/v1
kind: ClusterRoleBinding
metadata:
name: service-catalog-namespace-viewer-binding
roleRef:
name: namespace-viewer
userNames:
- system:serviceaccount:service-catalog:service-catalog-apiserver
subjects:
- kind: ServiceAccount
name: service-catalog-apiserver
namespace: kube-service-catalog

- kind: ClusterRoleBinding
apiVersion: v1
- apiVersion: authorization.openshift.io/v1
kind: ClusterRoleBinding
metadata:
name: service-catalog-controller-namespace-viewer-binding
roleRef:
name: namespace-viewer
userNames:
- system:serviceaccount:service-catalog:service-catalog-controller
subjects:
- kind: ServiceAccount
name: service-catalog-controller
namespace: kube-service-catalog

- kind: ClusterRole
apiVersion: v1
- apiVersion: authorization.openshift.io/v1
kind: ClusterRole
metadata:
name: service-catalog-controller
rules:
Expand Down Expand Up @@ -155,17 +161,19 @@ objects:
- list
- watch

- kind: ClusterRoleBinding
apiVersion: v1
- apiVersion: authorization.openshift.io/v1
kind: ClusterRoleBinding
metadata:
name: service-catalog-controller-binding
roleRef:
name: service-catalog-controller
userNames:
- system:serviceaccount:service-catalog:service-catalog-controller
subjects:
- kind: ServiceAccount
name: service-catalog-controller
namespace: kube-service-catalog

- kind: Role
apiVersion: v1
- apiVersion: authorization.openshift.io/v1
kind: Role
metadata:
name: endpoint-accessor
rules:
Expand All @@ -180,18 +188,20 @@ objects:
- create
- update

- kind: RoleBinding
apiVersion: v1
- apiVersion: authorization.openshift.io/v1
kind: RoleBinding
metadata:
name: endpointer-accessor-binding
roleRef:
name: endpoint-accessor
namespace: service-catalog
userNames:
- system:serviceaccount:service-catalog:service-catalog-controller
namespace: kube-service-catalog
subjects:
- kind: ServiceAccount
namespace: kube-service-catalog
name: service-catalog-controller

- kind: Role
apiVersion: v1
- apiVersion: authorization.openshift.io/v1
kind: Role
metadata:
name: extension-apiserver-authentication-reader
namespace: ${KUBE_SYSTEM_NAMESPACE}
Expand All @@ -205,25 +215,29 @@ objects:
verbs:
- get

- kind: RoleBinding
apiVersion: v1
- apiVersion: authorization.openshift.io/v1
kind: RoleBinding
metadata:
name: extension-apiserver-authentication-reader-binding
namespace: ${KUBE_SYSTEM_NAMESPACE}
roleRef:
name: extension-apiserver-authentication-reader
namespace: kube-system
userNames:
- system:serviceaccount:service-catalog:service-catalog-apiserver
namespace: ${KUBE_SYSTEM_NAMESPACE}
subjects:
- kind: ServiceAccount
name: service-catalog-apiserver
namespace: kube-service-catalog

- kind: ClusterRoleBinding
apiVersion: v1
- apiVersion: authorization.openshift.io/v1
kind: ClusterRoleBinding
metadata:
name: system:auth-delegator-binding
roleRef:
name: system:auth-delegator
userNames:
- system:serviceaccount:service-catalog:service-catalog-apiserver
subjects:
- kind: ServiceAccount
name: service-catalog-apiserver
namespace: kube-service-catalog


- kind: Deployment
Expand Down Expand Up @@ -351,7 +365,7 @@ objects:
- -v
- "5"
- --leader-election-namespace
- service-catalog
- kube-service-catalog
- --broker-relist-interval
- "5m"
image: ${SERVICE_CATALOG_IMAGE}
Expand Down
22 changes: 22 additions & 0 deletions install/templateservicebroker/apiserver-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ objects:
containers:
- name: c
image: ${IMAGE}
imagePullPolicy: IfNotPresent
command:
- "/usr/bin/openshift"
- "start"
Expand Down Expand Up @@ -98,3 +99,24 @@ objects:
ports:
- port: 443
targetPort: 8443

# This service account will be granted permission to call the TSB.
# The token for this SA will be provided to the service catalog for
# use when calling the TSB.
- apiVersion: v1
kind: ServiceAccount
metadata:
namespace: ${NAMESPACE}
name: templateservicebroker-client

# This secret will be populated with a copy of the templateservicebroker-client SA's
# auth token. Since this secret has a static name, it can be referenced more
# easily than the auto-generated secret for the service account.
- apiVersion: v1
kind: Secret
metadata:
namespace: ${NAMESPACE}
name: templateservicebroker-client
annotations:
kubernetes.io/service-account.name: templateservicebroker-client
type: kubernetes.io/service-account-token
40 changes: 40 additions & 0 deletions install/templateservicebroker/rbac-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ parameters:
value: kube-system
objects:

# Grant the service account permission to call the TSB
- apiVersion: authorization.openshift.io/v1
kind: ClusterRoleBinding
metadata:
name: templateservicebroker-client
roleRef:
name: system:openshift:templateservicebroker-client
subjects:
- kind: ServiceAccount
namespace: ${NAMESPACE}
name: templateservicebroker-client

# to delegate authentication and authorization
- apiVersion: authorization.openshift.io/v1
kind: ClusterRoleBinding
Expand Down Expand Up @@ -46,3 +58,31 @@ objects:
- kind: ServiceAccount
namespace: ${NAMESPACE}
name: apiserver

# allow the kube service catalog's SA to read the static secret defined
# above, which will contain the token for the SA that can call the TSB.
- apiVersion: authorization.openshift.io/v1
kind: Role
metadata:
name: templateservicebroker-auth-reader
namespace: ${NAMESPACE}
rules:
- apiGroups:
- ""
resourceNames:
- templateservicebroker-client
resources:
- secrets
verbs:
- get
- apiVersion: authorization.openshift.io/v1
kind: RoleBinding
metadata:
namespace: ${NAMESPACE}
name: templateservicebroker-auth-reader
roleRef:
name: templateservicebroker-auth-reader
subjects:
- kind: ServiceAccount
namespace: kube-service-catalog
name: service-catalog-controller
Loading

0 comments on commit a2c1538

Please sign in to comment.