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

Add support for the PodNodeSelector admission controller #920

Merged
merged 9 commits into from
Jun 15, 2020

Conversation

xmudrii
Copy link
Member

@xmudrii xmudrii commented Jun 12, 2020

What this PR does / why we need it:

Add support for the PodNodeSelector admission controller.

The admission controller is enabled by enabling the appropriate feature, such as:

...
features:
  podNodeSelector:
    enable: true
    config:
      configFilePath: "./podnodeselector.yaml"

The podnodeselector.yaml file is located on the local file system and contains the plugin configuration. More about the configuration format can be found in the Kubernetes docs.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #852

Special notes for your reviewer:

  • To make the kube-system components able to get scheduled on all nodes, an empty scheduler.alpha.kubernetes.io/node-selector annotation is added to the kube-system namespace. The kube-system namespace mustn't be restricted in the plugin configuration, as pods such as CNI and kube-proxy must be scheduled on all nodes.
  • Before the kube-system namespace gets annotated, kubeadm creates deployments/daemonsets for the needed components. The underlying pods have the incorrect node selectors and therefore are stuck in the Pending state. To resolve this problem, all pending pods in the kube-system namespace are removed, so they get recreated with the correct node selector.
  • The AdmissionConfiguration API has been backported, so we don't have to import the k8s.io/apiserver package. Importing the package would require us to bump all Kubernetes dependencies to v1.18, as well as, controller-runtime to v0.5.0 or newer.

Does this PR introduce a user-facing change?:

Add support for the PodNodeSelector admission controller
BREAKING: Make paths for PodNodeSelector and StaticAudit configs relative to the manifest

/assign @kron4eg

@xmudrii xmudrii requested a review from kron4eg June 12, 2020 13:22
@kubermatic-bot kubermatic-bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note Denotes a PR that will be considered when it comes time to generate release notes. dco-signoff: yes Denotes that all commits in the pull request have the valid DCO signoff message. approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jun 12, 2020
@@ -215,6 +215,7 @@ type MachineControllerConfig struct {

// Features controls what features will be enabled on the cluster
type Features struct {
PodNodeSelector *PodNodeSelector `json:"podNodeSelector"`
Copy link
Member

Choose a reason for hiding this comment

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

While there is no technical obstacle to add this new feature to v1alpha1, I think we should avoid doing this, as v1alpha1 should be "conserved" and not changed anymore.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've thought about this as well, but I think we should keep both APIs in sync until we don't officially announce the deprecation with the 1.0 release. After that, only v1beta1 should be extended.

@xmudrii xmudrii changed the title [WIP] Add support for the PodNodeSelector admission controller Add support for the PodNodeSelector admission controller Jun 15, 2020
@kubermatic-bot kubermatic-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 15, 2020
@xmudrii
Copy link
Member Author

xmudrii commented Jun 15, 2020

@kron4eg PTAL

@xmudrii xmudrii requested a review from kron4eg June 15, 2020 07:23
// configuration file.
// ConfigFilePath is a required field.
// More info: https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/#podnodeselector
ConfigFilePath string `json:"configFilePath"`
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
ConfigFilePath string `json:"configFilePath"`
Config string `json:"config"`

Let's have it inline instead of file

Copy link
Member Author

Choose a reason for hiding this comment

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

I've thought about this as well and I'm not sure this is a good approach. I think we should have the standardized API, even if it's a little bit redundant sometimes. A couple of things I have on mind:

  • Config is a struct for all other features. Having it as a string here could introduce confusion
  • The problem mentioned above could be solved by calling it ConfigFilePath like it's now, but then we come to another problem...
  • If we ever have to add another field for any reason, we would drift from the standard API way too much and we would end up in a mess.

In the long run, I think it's better as it is right now.

@kron4eg
Copy link
Member

kron4eg commented Jun 15, 2020

Everything looks good, except one part that really bothers me, file references (namely ConfigFilePath fields), those are points to external resources that we have to dereference somehow. I know we already doing this and I'm concern about this too :)

Yet, the API design discussion probably doesn't belongs to this PR.

/lgtm
/approve

@kubermatic-bot kubermatic-bot added the lgtm Indicates that a PR is ready to be merged. label Jun 15, 2020
@kubermatic-bot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 2aa50f8ec7788a89f08d39c836dbf8ad7637c37c

@kubermatic-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kron4eg, xmudrii

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

@kubermatic-bot kubermatic-bot merged commit 85cd0d0 into master Jun 15, 2020
@kubermatic-bot kubermatic-bot added this to the v1.0 milestone Jun 15, 2020
@kubermatic-bot kubermatic-bot deleted the podnodeselector branch June 15, 2020 15:44
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. dco-signoff: yes Denotes that all commits in the pull request have the valid DCO signoff message. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for PodNodeSelector admission controller
3 participants