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

allow default system namespace to be overridden using an env var #427

Merged
merged 4 commits into from
Feb 20, 2019
Merged

allow default system namespace to be overridden using an env var #427

merged 4 commits into from
Feb 20, 2019

Conversation

rawlingsj
Copy link
Contributor

@rawlingsj rawlingsj commented Jan 23, 2019

I'd like to install Build Pipeline in namespace other than tekton-pipelines. This change still uses tekton-pipelines as the default but allows folks to set an environment variable to override. As an example I've hacked a Helm chart for easy install while integrating with Build Pipeline, this uses the downward api to set the new env var to the current namespace.

If it's of interest this is the chart and override the new env var here.

Also deleted unused pkg/names.go as I think it was duplicated in pkg/system/names.go.

@googlebot googlebot added the cla: yes Trying to make the CLA bot happy with ppl from different companies work on one commit label Jan 23, 2019
@knative-prow-robot knative-prow-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jan 23, 2019
@rawlingsj
Copy link
Contributor Author

rawlingsj commented Jan 23, 2019

I probably ought to add the new env var to the docs somewhere too, in https:/knative/build-pipeline/blob/master/DEVELOPMENT.md#environment-setup maybe? Though that would complicate things as the current ./config yaml files would then also need to be updated to remove the namespace so maybe easier to not mention it yet as this seems only useful when installing using the helm chart I created for now?

@bobcatfish bobcatfish self-assigned this Jan 24, 2019
@bobcatfish
Copy link
Collaborator

Thanks for this @rawlingsj !! 🎉

I probably ought to add the new env var to the docs somewhere too

Definitely agree! I think what we really need is some docs about how to setup and configure pipelines, which we don't have yet 🤔 (kind of related to #385)

So some options:

but allows folks to set an environment variable to override

What do you think about configuring the namespace in a config-map instead of an environment variable? Just wondering cuz we already have a config-map for some other controller config. Maybe this doesn't make sense tho b/c the controller wouldn't even know what namespace to look for the namespace in 🤔

@bobcatfish
Copy link
Collaborator

@shashwathi and @imjasonh pointed out that there have been similar changes to serving: knative/serving#2708 <-- so as long as we do pretty much the same thing as that, we should be good! and it looks I think like this configuration also ends up using an env var

@markusthoemmes
Copy link

markusthoemmes commented Jan 25, 2019

FWIW and in addition to what @bobcatfish already pointed out, a generalized version of the serving bit was added to knative/pkg recently. I think all projects should be able to use that? knative/pkg#235

@abayer
Copy link
Contributor

abayer commented Jan 25, 2019

/ok-to-test

@knative-prow-robot knative-prow-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jan 25, 2019
@rawlingsj
Copy link
Contributor Author

ok great - thanks @bobcatfish @markusthoemmes - will take a look

@bobcatfish
Copy link
Collaborator

nice, thanks @markusthoemmes !!

@rawlingsj
Copy link
Contributor Author

sorry for the delay but juggling lots of things ATM, so we're suggesting we

If that's all correct and folks are happy I can close this PR and create a new with above?

@rawlingsj
Copy link
Contributor Author

Hmm - just started and suspect there's going to be a problem updating the ./config/*.yaml because there's a ClusterRoleBinding that needs the namespace that the serviceaccount lives in https:/knative/build-pipeline/blob/01853c6/config/201-clusterrolebinding.yaml#L21, we get around this in helm world by templating the namespace https:/jenkins-x-charts/knative-build-pipeline/blob/b8d1473/knative-build-pipeline/templates/200-clusterrolebinding.yaml#L21 so it's set at install time to the current namespace just as the downward api is set at install.

I'm not sure how we can use https:/knative/pkg/blob/8e50d82/system/names.go#L30 from this repo and keep the current approach of installing via ko apply -f config/, I think there needs to be some kinda templating on the ClusterRoleBinding to set the current namespace or update docs to change it which doesn't seem great.

Any other thoughts or ideas?

@rawlingsj
Copy link
Contributor Author

Might be nice to avoid the ClusterRoleBindings all together and create RoleBindings instead as that would get around the problem, not sure if the knative build pipeline need to be cluster wide role bindings?

@abayer
Copy link
Contributor

abayer commented Feb 6, 2019

Good question - @bobcatfish, do you know re ^^^?

@bobcatfish
Copy link
Collaborator

I'm not sure how we can use https:/knative/pkg/blob/8e50d82/system/names.go#L30 from this repo and keep the current approach of installing via ko apply -f config/, I think there needs to be some kinda templating on the ClusterRoleBinding to set the current namespace or update docs to change it which doesn't seem great.

Yeah this is weird, im looking at knative/serving to see how they've done it, since they seem to be using system.Namespace() (e.g. here), but they've still go the namespace hardcoded in all their yaml files (and the config to create the namespace still exists)

Looking at the PR where this was added knative/serving#2708 I get the impression there was no good story at that point either about how to handle those yamls, it seems like the assumption is that a user will change them manually 🤔

My only recommendation is to leave the namespace hard-coded in our .yaml files for now, and add some docs about how folks can change them manually (and use the downward api) - not sure there are any better options (maybe @imjasonh has some ideas)

@imjasonh
Copy link
Member

imjasonh commented Feb 6, 2019

@bobcatfish's suggestion about leaving hard-coded values in YAML and documenting changing it SGTM, especially if that's what Serving has today. When in doubt we should go along with what the other repos do to solve these problems, even if those solutions are half-baked.

@rawlingsj
Copy link
Contributor Author

Ok great, that all sounds good to me. I'll get onto it in the morning.

@rawlingsj
Copy link
Contributor Author

rawlingsj commented Feb 20, 2019

@imjasonh @bobcatfish @abayer I was tempted to submit a few PR options for this but figured I'd start simple. I've force pushed to this existing PR but to explain I've rebased which includes the tekton rename but doesn't include the knative/pkg#235 package as suggested in an earlier comment. My thinking is to keep the current config/*.yaml as is but I added docs to explain how to install into a custom namespace.

If you want me to vendor the knative/pkg repo instead I can do that and update the controller and webhook deployments to use the downward api (as the default panics if there's no SYSTEM_NAMESPACE env var set in that pkg) and update the docs to include that too.

@rawlingsj rawlingsj changed the title allow hardcoded system namespace to be overridden using an env var allow default system namespace to be overridden using an env var Feb 20, 2019
@abayer
Copy link
Contributor

abayer commented Feb 20, 2019

/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Feb 20, 2019
Copy link
Contributor

@shashwathi shashwathi left a comment

Choose a reason for hiding this comment

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

I have left comments on doc changes. I had trouble following instructions so thats my feedback.

DEVELOPMENT.md Outdated
@@ -118,6 +118,22 @@ kubectl create clusterrolebinding cluster-admin-binding \
--user="${USER}"
```

### Install in custom namespace
1. To install into a different namespace you will need to modify resources in the `./config`
- remove all `namespace: tekton` resources
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Can you update this to "remove all namespace: tekton references"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

DEVELOPMENT.md Outdated
### Install in custom namespace
1. To install into a different namespace you will need to modify resources in the `./config`
- remove all `namespace: tekton` resources
- delete the `namespace.yaml
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing "`" at end of file name. Also can you link the config namespace file here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

DEVELOPMENT.md Outdated
1. To install into a different namespace you will need to modify resources in the `./config`
- remove all `namespace: tekton` resources
- delete the `namespace.yaml
- modify the `subjects.namespace` value to the desired namespace
Copy link
Contributor

Choose a reason for hiding this comment

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

Again can you link clusterrolebinding yaml here? I think thats what you are referring here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

DEVELOPMENT.md Outdated
- remove all `namespace: tekton` resources
- delete the `namespace.yaml
- modify the `subjects.namespace` value to the desired namespace
- add `downwardapi` entry to webhook and controller `deployment` resources and set current namespace.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you provide an example of how to add downwardapi entry to both deployment resources?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

- add `downwardapi` entry to webhook and controller `deployment` resources and set current namespace.

e.g.
```yaml
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 can remove the additional space in yaml example. Markdown render looks bit weird

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@knative-prow-robot knative-prow-robot removed the lgtm Indicates that a PR is ready to be merged. label Feb 20, 2019
@rawlingsj
Copy link
Contributor Author

@shashwathi thanks for the comments. Think I just resolved them, hopefully it now reads better.

@@ -118,6 +118,20 @@ kubectl create clusterrolebinding cluster-admin-binding \
--user="${USER}"
```

### Install in custom namespace
Copy link
Collaborator

Choose a reason for hiding this comment

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

i have one completely minor piece of feedback: usually we have an extra newline after a header.

i'm also happy to lgtm and let @mattmoor-sockpuppet fix that tho XD

Copy link
Contributor Author

Choose a reason for hiding this comment

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

cool - thanks, I just added the extra newline anyways.

@abayer
Copy link
Contributor

abayer commented Feb 20, 2019

/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Feb 20, 2019
Copy link
Contributor

@shashwathi shashwathi left a comment

Choose a reason for hiding this comment

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

/lgtm

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 20, 2019
@knative-prow-robot knative-prow-robot removed the lgtm Indicates that a PR is ready to be merged. label Feb 20, 2019
@abayer
Copy link
Contributor

abayer commented Feb 20, 2019

/lgtm
/approve

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Feb 20, 2019
@knative-prow-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: abayer, rawlingsj, shashwathi

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

@abayer
Copy link
Contributor

abayer commented Feb 20, 2019

oh wait I don't have approve rights. heh.

@knative-prow-robot knative-prow-robot merged commit fdb9102 into tektoncd:master Feb 20, 2019
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. cla: yes Trying to make the CLA bot happy with ppl from different companies work on one commit lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants