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 PolicyConfigMap and PolicyConfigMapNamespace to KubeSchedulerConfig #3546

Merged
merged 6 commits into from
Oct 10, 2017

Conversation

whs
Copy link
Contributor

@whs whs commented Oct 5, 2017

No description provided.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Oct 5, 2017
@k8s-ci-robot
Copy link
Contributor

Hi @whs. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Oct 5, 2017
Copy link
Contributor

@chrislovecnm chrislovecnm left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! Couple of questions. Which versions of k8s support the configmap? If we have support at the beginning of a specific version, we will need validation. Does the scheduler start without the configmap in place? Can you add some documentation in the configspec markdown doc under docs?

Always appreciate the help!

@@ -330,6 +330,10 @@ type KubeSchedulerConfig struct {
Image string `json:"image,omitempty"`
// LeaderElection defines the configuration of leader election client.
LeaderElection *LeaderElectionConfiguration `json:"leaderElection,omitempty"`
// Name of configmap to use for scheduler policy
PolicyConfigMap string `json:"policyConfigMap,omitempty" flag:"policy-configmap"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we re-word the API elements into the typical go syntax for comments? The first word of the comment is the name, in this case PolicyConfigMap.

See https://golang.org/doc/effective_go.html#commentary. Comments documenting declarations should be full sentences, even if that seems a little redundant. This approach makes them format well when extracted into godoc documentation. Comments should begin with the name of the thing being described and end in a period:

@chrislovecnm
Copy link
Contributor

/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 Oct 6, 2017
@whs
Copy link
Contributor Author

whs commented Oct 6, 2017

  • This feature was added in 1.7.0 (Scheduler can recieve its policy configuration from a ConfigMap kubernetes#43892). Reading that I'll need to add a note that the scheduler must be restarted manually when configmap is modified
  • The scheduler will exit if the configmap is not found. I'll add that to the comment, but do we have some way to validate it?
  • Could you point to where the docs for kube-scheduler is? I only see kubelet options is documented in the cluster spec and the other cluster services are undocumented. If we don't have one already I can add it.

@chrislovecnm
Copy link
Contributor

This feature was added in 1.7.0 (kubernetes/kubernetes#43892). Reading that I'll need to add a note that the scheduler must be restarted manually when configmap is modified

So we have a bit of a chicken and egg problem with the cluster starting properly.
@justinsb / @blakebarnett any ideas on how to address this? If the configmap does not exist, the scheduler will not start. Without the scheduler starting, cni will not install. Wonder if we can add a default config map in addons and then have that overriden? Interesting problem to solve.

@whs the chicken and egg problem is that in a usual case we need to cluster to start. The cluster depends on the scheduler to get components like CNI running, which is a base component. Would be optimal if this configmap was reloadable.

We will need to validate that the k8s cluster is over 1.7.x. You can see how we are validating at a component level here: https://github.com/kubernetes/kops/blob/master/pkg/model/components/kubecontrollermanager.go

There is a go file under the same package for the scheduler.

The scheduler will exit if the configmap is not found. I'll add that to the comment, but do we have some way to validate it?

We can validate that the k8s cluster version is compatible with the cli option. The chicken and egg problem with k8s being up and the configmap is kinda bugging me.

Could you point to where the docs for kube-scheduler is? I only see kubelet options is documented in the cluster spec and the other cluster services are undocumented. If we don't have one already I can add it.

K8s or kops?

@whs
Copy link
Contributor Author

whs commented Oct 6, 2017

K8s or kops?

In this file only kubelet is documented. Are there other place in kops docs that this option should be documented or should I add to that file?

@chrislovecnm
Copy link
Contributor

chrislovecnm commented Oct 6, 2017

@whs we do not have full documentation in that markdown file, but when new changes come in we try to add them there. Just cut a new section for the scheduler.

@whs
Copy link
Contributor Author

whs commented Oct 6, 2017 via email

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Oct 6, 2017
@whs
Copy link
Contributor Author

whs commented Oct 6, 2017

All pending concerns should be now resolved, except for that the cluster still won't start with this flag on. Either we do something about that or just document it.

@justinsb
Copy link
Member

justinsb commented Oct 9, 2017

So this PR as it stands is good. We can map flags, and you've done that perfectly (you've even matched the casing in pkg/apis/componentconfig/v1alpha1/types.go in k/k, which is great, because eventually we'll want to reconcile there so if we can avoid differences so much the better).

So the question is where should the configuration live, I guess. Is there a default scheduler configuration we could create? (just as we create a default LimitRange, for example: https://github.com/kubernetes/kops/blob/master/upup/models/cloudup/resources/addons/limit-range.addons.k8s.io/v1.5.0.yaml ). This feels like the first step towards componentconfig, which is super exciting.

I'm guessing what we should do is to automatically create a default scheduler configmap (perhaps in 1.9), and point the scheduler to read from that configmap. We'd have to make sure we didn't replace it on kops/kubernetes updates I guess. Does that sound right @whs ?

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 9, 2017
@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 9, 2017
@whs
Copy link
Contributor Author

whs commented Oct 9, 2017

The default config for kube-scheduler is hardcoded in scheduler's source. It should be like this if written as JSON.

I'm not sure that providing a default scheduler configmap would be the best solution here as we would have to keep track of scheduler default policy update, and update the file. (for example, when pod affinity it was implemented by adding a predicate and priority) Also, it leads to the question on what should we do if the user updated the file and upgrade the cluster.

To be clear, if the user doesn't provide --policy-configmap the scheduler would just start with the default configuration. The only problem is when this option is present, but the referenced configmap is not present.

Providing default configmap if the user specified this option is one way we could make this work, but it would be complicated. Since this is an option for advanced users, I think noting in the docs and godoc that this option will not work on cluster creation should be fine.

Is this ok with you? And is it possible to detect cluster creation when validating the spec so I can add this check in the code as well?

@k8s-github-robot
Copy link

/lgtm cancel //PR changed after LGTM, removing LGTM. @justinsb @whs

@k8s-github-robot k8s-github-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 10, 2017
@whs
Copy link
Contributor Author

whs commented Oct 10, 2017

I added the docs. I think we're ready to merge.

@justinsb
Copy link
Member

/lgtm

Hopefully they'll add reloading once it becomes clearer how reloading should work :-)

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 10, 2017
@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: justinsb

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

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@chrislovecnm
Copy link
Contributor

@whs something I thought about. We could have kops manage the config map.

@whs
Copy link
Contributor Author

whs commented Oct 10, 2017

That could work, and was pointed out by @justinsb earlier as well. As this option is optional (if you don't specify anything the scheduler have its hardcoded default), I think adding kops-managed scheduler policy would add more burden to the kops maintainers, as we need to keep track of upstream policy changes.

@chrislovecnm
Copy link
Contributor

@whs only create the config map if the user wants it. And set the scheduler flag. We have dynamic addons. Let me know if you are interested in how to do this.

@k8s-github-robot
Copy link

/test all [submit-queue is verifying that this PR is safe to merge]

@whs
Copy link
Contributor Author

whs commented Oct 10, 2017

I think I have some idea now. Give me an hour..

@k8s-github-robot
Copy link

Automatic merge from submit-queue.

@k8s-github-robot k8s-github-robot merged commit d7d62b8 into kubernetes:master Oct 10, 2017
k8s-github-robot pushed a commit that referenced this pull request Oct 27, 2017
Automatic merge from submit-queue.

UsePolicyConfigMap for kube-scheduler

Continued from #3546 

In this version, a single option `usePolicyConfigMap` is added that will install scheduler.addons.k8s.io, which contains a default configmap.
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.

None yet

5 participants