Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

neolit123
Copy link
Member

@neolit123 neolit123 commented Aug 19, 2020

What this PR does / why we need it:

  • Ensure the directory is created with 0700 via a new function
    called CreateDataDirectory().
  • Call this function in the init phases instead of the manual call
    to MkdirAll.
  • Call this function when joining control-plane nodes with local etcd.

If the directory creation is left to the kubelet via the
static Pod hostPath mounts, it will end up with 0755
which is not desired.

Which issue(s) this PR fixes:

xref kubernetes/kubeadm#2256

Special notes for your reviewer:
should be backported in case older versions of kubeadm decide to use newer etcd, which is a supported scenario by kubeadm.

Does this PR introduce a user-facing change?:

kubeadm: ensure the etcd data directory is created with 0700 permissions during control-plane init and join

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Aug 19, 2020
@neolit123
Copy link
Member Author

/kind regression bug
/priority important-soon
/milestone v1.19
/assign @fabriziopandini @rosti

@k8s-ci-robot k8s-ci-robot added kind/regression Categorizes issue or PR as related to a regression from a prior release. kind/bug Categorizes issue or PR as related to a bug. labels Aug 19, 2020
@k8s-ci-robot k8s-ci-robot added this to the v1.19 milestone Aug 19, 2020
@k8s-ci-robot k8s-ci-robot added priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. and removed needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Aug 19, 2020
@k8s-ci-robot k8s-ci-robot added area/kubeadm sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Aug 19, 2020
@neolit123
Copy link
Member Author

neolit123 commented Aug 19, 2020

/approve cancel

there is some discussion here whether this should be in 1.19 if a fix in etcd is made:
kubernetes/kubeadm#2256 (comment)

EDIT: if etcd ends up supporting other permissions than 0700, we should not enforce 0700 as it stomps existing custom permissions such as 0770.

@k8s-ci-robot k8s-ci-robot removed the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 19, 2020
@fabriziopandini
Copy link
Member

+1 to wait for an etcd fix (same as Kubernetes)
forcing to 0700 might break all sort of thing around this folder (e.g. backups), and this step should be taken only if there is no alternatives

Copy link
Contributor

@rosti rosti left a comment

Choose a reason for hiding this comment

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

Thanks @neolit123 !
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 20, 2020
@rosti
Copy link
Contributor

rosti commented Aug 20, 2020

@fabriziopandini @neolit123 the chmod call is not recursive, plus stomping on the permissions there and setting up secure sane permissions is a good thing to do. Imagine someone with 0777 there. Practically everyone can edit or delete the data store.

@neolit123 neolit123 force-pushed the 1.19-fix-etcd-700-perms branch from 8d65882 to 9231f47 Compare August 20, 2020 11:15
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 20, 2020
Copy link
Member

@SataQiu SataQiu 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 Aug 24, 2020
@fabriziopandini
Copy link
Member

@neolit123 if I got this right etcd is going to be fixed (it will throw a warning in case of permission different than 0700, but not block).

@neolit123
Copy link
Member Author

this is what i saw too.

we need to make sure that in 1.20 kubeadm defaults to an etcd version that does not break.
in the meantime the chmod part of this patch can be removed, as we don't want to override user chmod settings.

/milestone v1.20

@k8s-ci-robot k8s-ci-robot modified the milestones: v1.19, v1.20 Aug 24, 2020
@neolit123
Copy link
Member Author

neolit123 commented Aug 24, 2020

milestone v1.20

actually, with the new milestone rules critical fixes should merge last.

/milestone clear

@k8s-ci-robot k8s-ci-robot removed this from the v1.20 milestone Aug 24, 2020
@rosti
Copy link
Contributor

rosti commented Aug 24, 2020

If etcd folks decide to change the error to a warning, I'd suggest that we do a pre-flight check to verify the permissions if the etcd data dir exists and dump a warning on our side. In that case we should remove the chmod, but I would advocate to keep the mkdirs with 0700 so that kubeadm creates this directory with sane default permissions if it doesn't exist.

- Ensure the directory is created with 0700 via a new function
called CreateDataDirectory().
- Call this function in the init phases instead of the manual call
to MkdirAll.
- Call this function when joining control-plane nodes with local etcd.

If the directory creation is left to the kubelet via the
static Pod hostPath mounts, it will end up with 0755
which is not desired.
@neolit123 neolit123 force-pushed the 1.19-fix-etcd-700-perms branch from 9231f47 to ebf1636 Compare September 3, 2020 15:39
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 3, 2020
@neolit123
Copy link
Member Author

updated the PR to only create the directory if it does not exist on init/join-control-plane, but not chmod it.

/remove-priority important-soon
/priority backlog
lowering priority since the fix in etcd was applied and 1.20 will include 3.4.13+.

@k8s-ci-robot k8s-ci-robot added priority/backlog Higher priority than priority/awaiting-more-evidence. and removed priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. labels Sep 3, 2020
@neolit123
Copy link
Member Author

/retest

@neolit123
Copy link
Member Author

/milestone v1.20
/approve

/cc @rosti @SataQiu
looking for LGTM.

@k8s-ci-robot k8s-ci-robot added this to the v1.20 milestone Sep 9, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: neolit123

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 Sep 9, 2020
Copy link
Member

@fabriziopandini fabriziopandini 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 Sep 14, 2020
@k8s-ci-robot k8s-ci-robot merged commit 7ffc469 into kubernetes:master Sep 14, 2020
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. area/kubeadm cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. kind/regression Categorizes issue or PR as related to a regression from a prior release. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/backlog Higher priority than priority/awaiting-more-evidence. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. 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.

5 participants