Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added proper RBAC rules to Prow #8288

Merged
merged 1 commit into from
Jun 25, 2018

Conversation

paulangton
Copy link
Contributor

Integrated RBAC rules from Openshift as per @stevekuznetsov 's suggestion. Rules were added en masse to starter.yaml, but also duplicated in separate deployment configs. Should fix #7950 and clean up leftovers from #8088

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 7, 2018
@BenTheElder
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jun 7, 2018
Copy link
Member

@cjwagner cjwagner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use legacy authorization on this cluster. Will that conflict with RBAC?

@@ -94,6 +94,7 @@ spec:
app: hook
spec:
terminationGracePeriodSeconds: 180
serviceAccountName: "hook"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll need to add the service accounts to the *_deployment.yaml files as well.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since our deployments won't be using RBAC we can't actually add the service account since we won't define it. Maybe add it to the deployment files, but comment it out with an explanation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in latest commit

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't appear to be?
I still see non-commented lines like serviceAccountName: "plank" in the deployment files.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

discussed this offline, definitely comment out with an explanation, someday we will be on RBAC and need to uncomment 🙃 (and also add these to the rules_k8s deployment)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added service accounts to the deployments and purposefully didnt comment them out, thought Ben's comment below was saying these wouldnt be deployed to prow.k8s.io.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Latest commit contains commented out service accounts in deployment files

@BenTheElder
Copy link
Member

We use legacy authorization on this cluster. Will that conflict with RBAC?

assuming you mean prow.k8s.io, nothing here should actually get deployed to it AFAICT.

@cjwagner
Copy link
Member

cjwagner commented Jun 7, 2018

nothing here should actually get deployed to it AFAICT.

Are we just adding it for completeness and other deployments then?

@BenTheElder
Copy link
Member

BenTheElder commented Jun 7, 2018 via email

@cjwagner
Copy link
Member

cjwagner commented Jun 7, 2018

This is for the getting started guide? We have separate config for k8s.io

It doesn't look like this is all meant for the starter yaml. starter.yaml has its RBAC rules defined there, but a bunch of other RBAC files were also added containing the same rules.

@BenTheElder
Copy link
Member

BenTheElder commented Jun 7, 2018

edit: ah, in this pr starter.yaml also gains RBAC

in any case, the bazel deployment at least is not applying these other files, and someday we will probably need the same rules outside of starter. I don't think they are harmful.

@fejta
Copy link
Contributor

fejta commented Jun 8, 2018

/assign @stevekuznetsov @BenTheElder @cjwagner

@paulangton
Copy link
Contributor Author

I decided to keep a copy of the RBAC deployments separate from starter.yaml for people who may want to deploy their own versions of specific services without having to apply starter.yaml for RBAC.

@stevekuznetsov
Copy link
Contributor

@paulangton did you have to edit any of the RBAC rules? Would be good to review the diff between what we have deployed and what you are proposing here. If there was no necessary diff, this LGTM

@paulangton
Copy link
Contributor Author

@stevekuznetsov I had to edit all of the RBAC rules. The ones in the Openshift repo were wrapped in Openshift Template kinds, which I removed. I also split the list of objects into their own documents and created a service account for each deployment.

Example: Diff between Openshift (left) and this PR (right):

apiVersion: template.openshift.io/v1			      |	apiVersion: v1
kind: Template						      |	kind: ServiceAccount
parameters:						      |	metadata:
- description: The name of the component.		      |	  name: "plank"
  name: NAME						      |	---
  value: plank						      |	kind: Role
objects:						      |	apiVersion: rbac.authorization.k8s.io/v1beta1
- apiVersion: v1					      |	metadata:
  kind: ServiceAccount					      |	  name: "plank"
  metadata:						      |	rules:
    name: "${NAME}"					      |	  - apiGroups:
- kind: Role						      |	      - ""
  apiVersion: rbac.authorization.k8s.io/v1beta1		      |	    resources:
  metadata:						      |	      - pods
    name: "${NAME}"					      |	    verbs:
  rules:						      |	      - create
    - apiGroups:					      |	      - delete
        - ""						      |	      - list
      resources:					      |	  - apiGroups:
        - pods						      |	      - "prow.k8s.io"
      verbs:						      |	    resources:
        - create					      |	      - prowjobs
        - delete					      |	    verbs:
        - list						      |	      - create
    - apiGroups:					      |	      - list
        - "prow.k8s.io"					      |	      - update
      resources:					      |	---
        - prowjobs					      |	kind: RoleBinding
      verbs:						      |	apiVersion: rbac.authorization.k8s.io/v1beta1
        - create					      |	metadata:
        - list						      |	  name: "plank"
        - update					      |	roleRef:
- kind: RoleBinding					      |	  apiGroup: rbac.authorization.k8s.io
  apiVersion: rbac.authorization.k8s.io/v1beta1		      |	  kind: Role
  metadata:						      |	  name: "plank"
    name: "${NAME}"					      |	subjects:
  roleRef:						      |	- kind: ServiceAccount
    apiGroup: rbac.authorization.k8s.io			      |	  name: "plank"
    kind: Role						      <
    name: "${NAME}"					      <
  subjects:						      <
  - kind: ServiceAccount				      <
    name: "${NAME}"					      <

@stevekuznetsov
Copy link
Contributor

OK, you could also use List objects to keep them nicely in one document per file. If the changes were:

  • remove Template and use List instead
  • evaluate the template parameters

Then these LGTM

@paulangton
Copy link
Contributor Author

@stevekuznetsov Unless there is some notable advantage I am not seeing to using a List type, I am going to leave it as is. K8s docs on general configuration as well as RBAC specify config files containing multiple objects separated by the triple hyphen instead of combined in a List type.

@stevekuznetsov
Copy link
Contributor

Sure, fine either way. Please add GET for ConfigMaps to the hook role, xref openshift/release#969 as required by recent additions to the config-updater plugin

@paulangton
Copy link
Contributor Author

hook Role now allows get

@paulangton
Copy link
Contributor Author

@stevekuznetsov @cjwagner lgty?

Copy link
Member

@cjwagner cjwagner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One change, otherwise this LGTM.

@@ -25,6 +25,7 @@ spec:
labels:
app: tide
spec:
serviceAccountName: "tide"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be commented as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, fixed in latest

removed permissive policy

added service account to deployments, removed tide rbac from starter.yaml

commented out serviceaccounts for use with RBAC

added get to hook rbac

fixed tide deployment
Copy link
Member

@cjwagner cjwagner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 25, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cjwagner, paulangton

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 25, 2018
@k8s-ci-robot k8s-ci-robot merged commit 89f42c7 into kubernetes:master Jun 25, 2018
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
name: "deck-oauth"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need this here; we use it in openshift because we run a deck instance for our private repos behind an oauth proxy. Unfortunately, the oauth proxy works only on openshift today :/

@@ -25,6 +25,7 @@ spec:
labels:
app: horologium
spec:
# serviceAccountName: "horologium" # Uncomment for use with RBAC
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should be able to use this service account regardless of running with rbac or not so it may be worth to uncomment upfront and move the service accounts alongside the deployment manifests.

@0xmichalis
Copy link
Contributor

I decided to keep a copy of the RBAC deployments separate from starter.yaml for people who may want to deploy their own versions of specific services without having to apply starter.yaml for RBAC.

It would be nice to include the jenkins operator rbac profile too. I don't know what's the best place to put that though, maybe just add it in the source code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

prow: error listing prow jobs / add RBAC rules
7 participants