2021-01-08 21:22:31 +00:00
|
|
|
#! Copyright 2020-2021 the Pinniped contributors. All Rights Reserved.
|
2020-08-25 01:07:34 +00:00
|
|
|
#! SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
2020-07-17 21:42:02 +00:00
|
|
|
#@ load("@ytt:data", "data")
|
2021-01-19 22:23:06 +00:00
|
|
|
#@ load("helpers.lib.yaml", "labels", "namespace", "defaultResourceName", "defaultResourceNameWithSuffix", "pinnipedDevAPIGroupWithPrefix")
|
2020-07-17 21:42:02 +00:00
|
|
|
|
2020-08-09 17:04:05 +00:00
|
|
|
#! Give permission to various cluster-scoped objects
|
2020-07-17 21:42:02 +00:00
|
|
|
---
|
|
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
|
|
|
kind: ClusterRole
|
|
|
|
metadata:
|
2020-10-14 22:05:42 +00:00
|
|
|
name: #@ defaultResourceNameWithSuffix("aggregated-api-server")
|
|
|
|
labels: #@ labels()
|
2020-07-17 21:42:02 +00:00
|
|
|
rules:
|
2020-10-14 22:05:42 +00:00
|
|
|
- apiGroups: [ "" ]
|
|
|
|
resources: [ namespaces ]
|
|
|
|
verbs: [ get, list, watch ]
|
|
|
|
- apiGroups: [ apiregistration.k8s.io ]
|
|
|
|
resources: [ apiservices ]
|
2021-02-10 23:02:18 +00:00
|
|
|
verbs: [ get, list, patch, update, watch ]
|
2020-10-14 22:05:42 +00:00
|
|
|
- apiGroups: [ admissionregistration.k8s.io ]
|
|
|
|
resources: [ validatingwebhookconfigurations, mutatingwebhookconfigurations ]
|
|
|
|
verbs: [ get, list, watch ]
|
2021-02-05 13:19:12 +00:00
|
|
|
- apiGroups: [ flowcontrol.apiserver.k8s.io ]
|
|
|
|
resources: [ flowschemas, prioritylevelconfigurations ]
|
|
|
|
verbs: [ get, list, watch ]
|
2020-11-18 22:08:45 +00:00
|
|
|
- apiGroups: [ security.openshift.io ]
|
|
|
|
resources: [ securitycontextconstraints ]
|
|
|
|
verbs: [ use ]
|
|
|
|
resourceNames: [ nonroot ]
|
2021-02-12 01:22:47 +00:00
|
|
|
- apiGroups: [ "" ]
|
|
|
|
resources: [ nodes ]
|
|
|
|
verbs: [ list ]
|
2021-02-09 18:59:32 +00:00
|
|
|
- apiGroups:
|
|
|
|
- #@ pinnipedDevAPIGroupWithPrefix("config.concierge")
|
|
|
|
resources: [ credentialissuers ]
|
2021-02-10 23:02:18 +00:00
|
|
|
verbs: [ get, list, watch, create ]
|
|
|
|
- apiGroups:
|
|
|
|
- #@ pinnipedDevAPIGroupWithPrefix("config.concierge")
|
|
|
|
resources: [ credentialissuers/status ]
|
2021-04-20 19:55:28 +00:00
|
|
|
verbs: [ get, patch, update ]
|
2021-02-09 18:59:32 +00:00
|
|
|
- apiGroups:
|
|
|
|
- #@ pinnipedDevAPIGroupWithPrefix("authentication.concierge")
|
|
|
|
resources: [ jwtauthenticators, webhookauthenticators ]
|
|
|
|
verbs: [ get, list, watch ]
|
2020-07-17 21:42:02 +00:00
|
|
|
---
|
|
|
|
kind: ClusterRoleBinding
|
|
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
|
|
|
metadata:
|
2020-10-14 22:05:42 +00:00
|
|
|
name: #@ defaultResourceNameWithSuffix("aggregated-api-server")
|
|
|
|
labels: #@ labels()
|
2020-07-17 21:42:02 +00:00
|
|
|
subjects:
|
|
|
|
- kind: ServiceAccount
|
2020-10-14 22:05:42 +00:00
|
|
|
name: #@ defaultResourceName()
|
|
|
|
namespace: #@ namespace()
|
2020-07-17 21:42:02 +00:00
|
|
|
roleRef:
|
|
|
|
kind: ClusterRole
|
2020-10-14 22:05:42 +00:00
|
|
|
name: #@ defaultResourceNameWithSuffix("aggregated-api-server")
|
2020-07-17 21:42:02 +00:00
|
|
|
apiGroup: rbac.authorization.k8s.io
|
2020-08-09 17:04:05 +00:00
|
|
|
|
2021-06-09 23:00:54 +00:00
|
|
|
#! Give minimal permissions to impersonation proxy service account
|
|
|
|
---
|
|
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
|
|
|
kind: ClusterRole
|
|
|
|
metadata:
|
|
|
|
name: #@ defaultResourceNameWithSuffix("impersonation-proxy")
|
|
|
|
labels: #@ labels()
|
|
|
|
rules:
|
|
|
|
- apiGroups: [ "" ]
|
|
|
|
resources: [ "users", "groups", "serviceaccounts" ]
|
|
|
|
verbs: [ "impersonate" ]
|
|
|
|
- apiGroups: [ "authentication.k8s.io" ]
|
|
|
|
resources: [ "*" ] #! What we really want is userextras/* but the RBAC authorizer only supports */subresource, not resource/*
|
|
|
|
verbs: [ "impersonate" ]
|
|
|
|
---
|
|
|
|
kind: ClusterRoleBinding
|
|
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
|
|
|
metadata:
|
|
|
|
name: #@ defaultResourceNameWithSuffix("impersonation-proxy")
|
|
|
|
labels: #@ labels()
|
|
|
|
subjects:
|
|
|
|
- kind: ServiceAccount
|
|
|
|
name: #@ defaultResourceNameWithSuffix("impersonation-proxy")
|
|
|
|
namespace: #@ namespace()
|
|
|
|
roleRef:
|
|
|
|
kind: ClusterRole
|
|
|
|
name: #@ defaultResourceNameWithSuffix("impersonation-proxy")
|
|
|
|
apiGroup: rbac.authorization.k8s.io
|
|
|
|
|
2021-05-03 21:31:48 +00:00
|
|
|
#! Give permission to the kube-cert-agent Pod to run privileged.
|
|
|
|
---
|
|
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
|
|
|
kind: Role
|
|
|
|
metadata:
|
|
|
|
name: #@ defaultResourceNameWithSuffix("kube-cert-agent")
|
|
|
|
namespace: #@ namespace()
|
|
|
|
labels: #@ labels()
|
|
|
|
rules:
|
|
|
|
- apiGroups: [ policy ]
|
|
|
|
resources: [ podsecuritypolicies ]
|
|
|
|
verbs: [ use ]
|
|
|
|
---
|
|
|
|
kind: RoleBinding
|
|
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
|
|
|
metadata:
|
|
|
|
name: #@ defaultResourceNameWithSuffix("kube-cert-agent")
|
|
|
|
namespace: #@ namespace()
|
|
|
|
labels: #@ labels()
|
|
|
|
subjects:
|
|
|
|
- kind: ServiceAccount
|
|
|
|
name: #@ defaultResourceNameWithSuffix("kube-cert-agent")
|
|
|
|
namespace: #@ namespace()
|
|
|
|
roleRef:
|
|
|
|
kind: Role
|
|
|
|
name: #@ defaultResourceNameWithSuffix("kube-cert-agent")
|
|
|
|
apiGroup: rbac.authorization.k8s.io
|
|
|
|
|
2020-08-09 17:04:05 +00:00
|
|
|
#! Give permission to various objects within the app's own namespace
|
2020-07-17 21:42:02 +00:00
|
|
|
---
|
|
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
|
|
|
kind: Role
|
|
|
|
metadata:
|
2020-10-14 22:05:42 +00:00
|
|
|
name: #@ defaultResourceNameWithSuffix("aggregated-api-server")
|
|
|
|
namespace: #@ namespace()
|
|
|
|
labels: #@ labels()
|
2020-07-17 21:42:02 +00:00
|
|
|
rules:
|
2020-10-14 22:05:42 +00:00
|
|
|
- apiGroups: [ "" ]
|
|
|
|
resources: [ services ]
|
2021-02-18 18:59:58 +00:00
|
|
|
verbs: [ create, get, list, patch, update, watch, delete ]
|
2020-10-14 22:05:42 +00:00
|
|
|
- apiGroups: [ "" ]
|
|
|
|
resources: [ secrets ]
|
|
|
|
verbs: [ create, get, list, patch, update, watch, delete ]
|
2021-04-20 19:55:28 +00:00
|
|
|
#! We need to be able to watch pods in our namespace so we can find the kube-cert-agent pods.
|
2020-10-14 22:05:42 +00:00
|
|
|
- apiGroups: [ "" ]
|
|
|
|
resources: [ pods ]
|
2021-04-20 19:55:28 +00:00
|
|
|
verbs: [ get, list, watch ]
|
2020-09-23 16:47:04 +00:00
|
|
|
#! We need to be able to exec into pods in our namespace so we can grab the API server's private key
|
2020-10-14 22:05:42 +00:00
|
|
|
- apiGroups: [ "" ]
|
|
|
|
resources: [ pods/exec ]
|
|
|
|
verbs: [ create ]
|
2021-04-20 19:56:43 +00:00
|
|
|
#! We need to be able to delete pods in our namespace so we can clean up legacy kube-cert-agent pods.
|
|
|
|
- apiGroups: [ "" ]
|
|
|
|
resources: [ pods ]
|
|
|
|
verbs: [ delete ]
|
2021-04-20 19:55:28 +00:00
|
|
|
#! We need to be able to create and update deployments in our namespace so we can manage the kube-cert-agent Deployment.
|
|
|
|
- apiGroups: [ apps ]
|
|
|
|
resources: [ deployments ]
|
|
|
|
verbs: [ create, get, list, patch, update, watch ]
|
|
|
|
#! We need to be able to get replicasets so we can form the correct owner references on our generated objects.
|
2021-02-12 01:22:47 +00:00
|
|
|
- apiGroups: [ apps ]
|
2021-04-20 19:55:28 +00:00
|
|
|
resources: [ replicasets ]
|
2021-02-12 01:22:47 +00:00
|
|
|
verbs: [ get ]
|
|
|
|
- apiGroups: [ "" ]
|
|
|
|
resources: [ configmaps ]
|
|
|
|
verbs: [ list, get, watch ]
|
2020-07-17 21:42:02 +00:00
|
|
|
---
|
|
|
|
kind: RoleBinding
|
|
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
|
|
|
metadata:
|
2020-10-14 22:05:42 +00:00
|
|
|
name: #@ defaultResourceNameWithSuffix("aggregated-api-server")
|
|
|
|
namespace: #@ namespace()
|
|
|
|
labels: #@ labels()
|
2020-07-17 21:42:02 +00:00
|
|
|
subjects:
|
|
|
|
- kind: ServiceAccount
|
2020-10-14 22:05:42 +00:00
|
|
|
name: #@ defaultResourceName()
|
|
|
|
namespace: #@ namespace()
|
2020-07-17 21:42:02 +00:00
|
|
|
roleRef:
|
|
|
|
kind: Role
|
2020-10-14 22:05:42 +00:00
|
|
|
name: #@ defaultResourceNameWithSuffix("aggregated-api-server")
|
2020-07-17 21:42:02 +00:00
|
|
|
apiGroup: rbac.authorization.k8s.io
|
2020-08-09 17:04:05 +00:00
|
|
|
|
2020-09-22 15:38:13 +00:00
|
|
|
#! Give permission to read pods in the kube-system namespace so we can find the API server's private key
|
2020-08-19 18:21:07 +00:00
|
|
|
---
|
|
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
|
|
|
kind: Role
|
|
|
|
metadata:
|
2020-10-14 22:05:42 +00:00
|
|
|
name: #@ defaultResourceNameWithSuffix("kube-system-pod-read")
|
2020-08-19 18:21:07 +00:00
|
|
|
namespace: kube-system
|
2020-10-14 22:05:42 +00:00
|
|
|
labels: #@ labels()
|
2020-08-19 18:21:07 +00:00
|
|
|
rules:
|
2020-10-14 22:05:42 +00:00
|
|
|
- apiGroups: [ "" ]
|
|
|
|
resources: [ pods ]
|
|
|
|
verbs: [ get, list, watch ]
|
2020-08-19 18:21:07 +00:00
|
|
|
---
|
|
|
|
kind: RoleBinding
|
|
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
|
|
|
metadata:
|
2020-10-14 22:05:42 +00:00
|
|
|
name: #@ defaultResourceNameWithSuffix("kube-system-pod-read")
|
2020-08-19 18:21:07 +00:00
|
|
|
namespace: kube-system
|
2020-10-14 22:05:42 +00:00
|
|
|
labels: #@ labels()
|
2020-08-19 18:21:07 +00:00
|
|
|
subjects:
|
|
|
|
- kind: ServiceAccount
|
2020-10-14 22:05:42 +00:00
|
|
|
name: #@ defaultResourceName()
|
|
|
|
namespace: #@ namespace()
|
2020-08-19 18:21:07 +00:00
|
|
|
roleRef:
|
|
|
|
kind: Role
|
2020-10-14 22:05:42 +00:00
|
|
|
name: #@ defaultResourceNameWithSuffix("kube-system-pod-read")
|
2020-08-19 18:21:07 +00:00
|
|
|
apiGroup: rbac.authorization.k8s.io
|
|
|
|
|
Rename many of resources that are created in Kubernetes by Pinniped
New resource naming conventions:
- Do not repeat the Kind in the name,
e.g. do not call it foo-cluster-role-binding, just call it foo
- Names will generally start with a prefix to identify our component,
so when a user lists all objects of that kind, they can tell to which
component it is related,
e.g. `kubectl get configmaps` would list one named "pinniped-config"
- It should be possible for an operator to make the word "pinniped"
mostly disappear if they choose, by specifying the app_name in
values.yaml, to the extent that is practical (but not from APIService
names because those are hardcoded in golang)
- Each role/clusterrole and its corresponding binding have the same name
- Pinniped resource names that must be known by the server golang code
are passed to the code at run time via ConfigMap, rather than
hardcoded in the golang code. This also allows them to be prepended
with the app_name from values.yaml while creating the ConfigMap.
- Since the CLI `get-kubeconfig` command cannot guess the name of the
CredentialIssuerConfig resource in advance anymore, it lists all
CredentialIssuerConfig in the app's namespace and returns an error
if there is not exactly one found, and then uses that one regardless
of its name
2020-09-18 22:56:50 +00:00
|
|
|
#! Allow both authenticated and unauthenticated TokenCredentialRequests (i.e. allow all requests)
|
2020-07-23 15:05:21 +00:00
|
|
|
---
|
|
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
|
|
|
kind: ClusterRole
|
|
|
|
metadata:
|
2021-02-19 18:21:10 +00:00
|
|
|
name: #@ defaultResourceNameWithSuffix("pre-authn-apis")
|
2020-10-14 22:05:42 +00:00
|
|
|
labels: #@ labels()
|
2020-07-23 15:05:21 +00:00
|
|
|
rules:
|
2021-01-19 22:23:06 +00:00
|
|
|
- apiGroups:
|
|
|
|
- #@ pinnipedDevAPIGroupWithPrefix("login.concierge")
|
2020-10-14 22:05:42 +00:00
|
|
|
resources: [ tokencredentialrequests ]
|
2021-02-19 18:21:10 +00:00
|
|
|
verbs: [ create, list ]
|
|
|
|
- apiGroups:
|
|
|
|
- #@ pinnipedDevAPIGroupWithPrefix("identity.concierge")
|
|
|
|
resources: [ whoamirequests ]
|
|
|
|
verbs: [ create, list ]
|
2020-07-23 15:05:21 +00:00
|
|
|
---
|
|
|
|
kind: ClusterRoleBinding
|
|
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
|
|
|
metadata:
|
2021-02-19 18:21:10 +00:00
|
|
|
name: #@ defaultResourceNameWithSuffix("pre-authn-apis")
|
2020-10-14 22:05:42 +00:00
|
|
|
labels: #@ labels()
|
2020-07-23 15:05:21 +00:00
|
|
|
subjects:
|
|
|
|
- kind: Group
|
|
|
|
name: system:authenticated
|
|
|
|
apiGroup: rbac.authorization.k8s.io
|
|
|
|
- kind: Group
|
|
|
|
name: system:unauthenticated
|
|
|
|
apiGroup: rbac.authorization.k8s.io
|
|
|
|
roleRef:
|
|
|
|
kind: ClusterRole
|
2021-02-19 18:21:10 +00:00
|
|
|
name: #@ defaultResourceNameWithSuffix("pre-authn-apis")
|
2020-07-23 15:05:21 +00:00
|
|
|
apiGroup: rbac.authorization.k8s.io
|
2020-08-09 17:04:05 +00:00
|
|
|
|
|
|
|
#! Give permissions for subjectaccessreviews, tokenreview that is needed by aggregated api servers
|
2020-07-23 15:05:21 +00:00
|
|
|
---
|
|
|
|
kind: ClusterRoleBinding
|
|
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
|
|
|
metadata:
|
2020-10-14 22:05:42 +00:00
|
|
|
name: #@ defaultResourceName()
|
|
|
|
labels: #@ labels()
|
2020-07-23 15:05:21 +00:00
|
|
|
subjects:
|
|
|
|
- kind: ServiceAccount
|
2020-10-14 22:05:42 +00:00
|
|
|
name: #@ defaultResourceName()
|
|
|
|
namespace: #@ namespace()
|
2020-07-23 15:05:21 +00:00
|
|
|
roleRef:
|
|
|
|
kind: ClusterRole
|
|
|
|
name: system:auth-delegator
|
|
|
|
apiGroup: rbac.authorization.k8s.io
|
2020-08-09 17:04:05 +00:00
|
|
|
|
|
|
|
#! Give permissions for a special configmap of CA bundles that is needed by aggregated api servers
|
2020-07-23 15:05:21 +00:00
|
|
|
---
|
|
|
|
kind: RoleBinding
|
|
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
|
|
|
metadata:
|
2020-10-14 22:05:42 +00:00
|
|
|
name: #@ defaultResourceNameWithSuffix("extension-apiserver-authentication-reader")
|
2020-07-23 15:05:21 +00:00
|
|
|
namespace: kube-system
|
2020-10-14 22:05:42 +00:00
|
|
|
labels: #@ labels()
|
2020-07-23 15:05:21 +00:00
|
|
|
subjects:
|
|
|
|
- kind: ServiceAccount
|
2020-10-14 22:05:42 +00:00
|
|
|
name: #@ defaultResourceName()
|
|
|
|
namespace: #@ namespace()
|
2020-07-23 15:05:21 +00:00
|
|
|
roleRef:
|
|
|
|
kind: Role
|
|
|
|
name: extension-apiserver-authentication-reader
|
|
|
|
apiGroup: rbac.authorization.k8s.io
|
2020-08-09 17:04:05 +00:00
|
|
|
|
|
|
|
#! Give permission to list and watch ConfigMaps in kube-public
|
2020-07-31 16:08:07 +00:00
|
|
|
---
|
|
|
|
kind: Role
|
|
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
|
|
|
metadata:
|
2020-10-14 22:05:42 +00:00
|
|
|
name: #@ defaultResourceNameWithSuffix("cluster-info-lister-watcher")
|
2020-07-31 16:08:07 +00:00
|
|
|
namespace: kube-public
|
2020-10-14 22:05:42 +00:00
|
|
|
labels: #@ labels()
|
2020-07-31 16:08:07 +00:00
|
|
|
rules:
|
2020-10-14 22:05:42 +00:00
|
|
|
- apiGroups: [ "" ]
|
|
|
|
resources: [ configmaps ]
|
|
|
|
verbs: [ list, watch ]
|
2020-07-31 16:08:07 +00:00
|
|
|
---
|
|
|
|
kind: RoleBinding
|
|
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
|
|
|
metadata:
|
2020-10-14 22:05:42 +00:00
|
|
|
name: #@ defaultResourceNameWithSuffix("cluster-info-lister-watcher")
|
2020-07-31 16:08:07 +00:00
|
|
|
namespace: kube-public
|
2020-10-14 22:05:42 +00:00
|
|
|
labels: #@ labels()
|
2020-07-31 16:08:07 +00:00
|
|
|
subjects:
|
|
|
|
- kind: ServiceAccount
|
2020-10-14 22:05:42 +00:00
|
|
|
name: #@ defaultResourceName()
|
|
|
|
namespace: #@ namespace()
|
2020-07-31 16:08:07 +00:00
|
|
|
roleRef:
|
|
|
|
kind: Role
|
2020-10-14 22:05:42 +00:00
|
|
|
name: #@ defaultResourceNameWithSuffix("cluster-info-lister-watcher")
|
2020-07-31 16:08:07 +00:00
|
|
|
apiGroup: rbac.authorization.k8s.io
|