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

kubeadm: Make it possible to configure volume mounts via the config file #49840

Merged

Conversation

andrewrynhard
Copy link
Contributor

@andrewrynhard andrewrynhard commented Jul 29, 2017

What this PR does / why we need it:
Kubeadm mounts host CA certs into api server and controller manager. It uses /etc/pki and does not allow for the path to be configurable. This PR adds a default to /etc/pki but also allows a user to configure the path in the config file. In the case of using Container Linux, the CAs are located at /usr/share/ca-certificates, so without this PR the hardcoded /etc/pki path is used and will break, for example, the --cloud-provider flag because of missing CAs.

Fixes kubernetes/kubeadm#484
Fixes kubernetes/kubeadm#476
Fixes kubernetes/kubeadm#441

/cc @luxas

@k8s-ci-robot
Copy link
Contributor

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please follow instructions at https://github.com/kubernetes/kubernetes/wiki/CLA-FAQ to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.


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 the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Jul 29, 2017
@k8s-github-robot k8s-github-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. release-note-label-needed labels Jul 29, 2017
@k8s-ci-robot
Copy link
Contributor

Hi @andrewrynhard. 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 the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jul 29, 2017
@andrewrynhard andrewrynhard force-pushed the variable_certs_dir branch 2 times, most recently from a3fc2c0 to ea1097b Compare July 29, 2017 21:09
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Jul 29, 2017
@andrewrynhard
Copy link
Contributor Author

Manifests are generated correctly

core # cat /etc/kubernetes/manifests/kube-apiserver.yaml | grep /usr/share/ca-certificates
    - mountPath: /usr/share/ca-certificates
      path: /usr/share/ca-certificates
core # cat /etc/kubernetes/manifests/kube-controller-manager.yaml | grep /usr/share/ca-certificates
    - mountPath: /usr/share/ca-certificates
      path: /usr/share/ca-certificates

@andrewrynhard andrewrynhard changed the title Make the CA PKI path configurable kubeadm: make the CA PKI path configurable Jul 30, 2017
Copy link
Member

@luxas luxas left a comment

Choose a reason for hiding this comment

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

I talked to @andrewrynhard about this on Slack and we decided that a generic variant of this is much better. Something like this:

type HostPathMount struct {
	Name string
	HostPath string
	MountPath string
}

type MasterConfiguration struct {
        ...
	APIServerExtraVolumes []HostPathMount
	ControllerManagerExtraVolumes []HostPathMount
	SchedulerExtraVolumes []HostPathMount
}

@luxas
Copy link
Member

luxas commented Jul 31, 2017

/release-note
/ok-to-test

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. release-note-label-needed labels Jul 31, 2017
@timothysc timothysc assigned luxas and unassigned timothysc Aug 1, 2017
@timothysc
Copy link
Member

@mattmoyer

Copy link
Contributor

@mattmoyer mattmoyer left a comment

Choose a reason for hiding this comment

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

I had a couple of style questions. Other than picking the right name and fixing some tests, I don't see a reason not to make this configurable.

Distros are pretty inconsistent about where they keep "system" trust stores (/etc/pki/ vs. /usr/share/ca-certificates vs. /etc/ssl/).

@@ -51,6 +51,8 @@ type MasterConfiguration struct {
APIServerCertSANs []string
// CertificatesDir specifies where to store or look for all required certificates
CertificatesDir string
// CACertificatesPkiDir specifies where to mount host CA certficates
CACertificatesPkiDir string
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a style nit but this should be CACertificatesPKIDir (per this guide).

I think the name is a little confusing too, since this doesn't have to do with the kubeadm-generated cluster CA like CertificatesDir does. Maybe SystemCACertificatesDir, HostCACertificatesDir, or ExternalCACertificatesDir?

@@ -51,6 +51,8 @@ type MasterConfiguration struct {
APIServerCertSANs []string `json:"apiServerCertSANs"`
// CertificatesDir specifies where to store or look for all required certificates
CertificatesDir string `json:"certificatesDir"`
// CACertificatesPkiDir specifies where to mount host CA certficates
CACertificatesPkiDir string `json:"caCertificatesPkiDir"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Same style nit here (s/Pki/PKI/).

@@ -135,7 +130,7 @@ func newVolumeMount(name, path string, readOnly bool) v1.VolumeMount {
}

// getEtcdCertVolumes returns the volumes/volumemounts needed for talking to an external etcd cluster
func getEtcdCertVolumes(etcdCfg kubeadmapi.Etcd) ([]v1.Volume, []v1.VolumeMount) {
func getEtcdCertVolumes(etcdCfg kubeadmapi.Etcd, caCertsPkiVolumePath string) ([]v1.Volume, []v1.VolumeMount) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same style nit here also (s/Pki/PKI/).

@@ -175,7 +170,7 @@ func getEtcdCertVolumes(etcdCfg kubeadmapi.Etcd) ([]v1.Volume, []v1.VolumeMount)
// isPkiVolumeMountNeeded specifies whether /etc/pki should be host-mounted into the containers
// On some systems were we host-mount /etc/ssl/certs, it is also required to mount /etc/pki. This is needed
// due to symlinks pointing from files in /etc/ssl/certs into /etc/pki/
func isPkiVolumeMountNeeded() bool {
func isPkiVolumeMountNeeded(caCertsPkiVolumePath string) bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same style nit here also (s/Pki/PKI/).

// caCertsPkiVolumePath specifies the path that can be conditionally mounted into the apiserver and controller-manager containers
// as /etc/ssl/certs might be a symlink to it. It's a variable since it may be changed in unit testing. This var MUST NOT be changed
// in normal codepaths during runtime.
var caCertsPkiVolumePath = "/etc/pki"
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like the unit tests that used this variable need a fix (test log):

[...]
W0804 00:30:36.473] # k8s.io/kubernetes/cmd/kubeadm/app/phases/controlplane
W0804 00:30:36.474] cmd/kubeadm/app/phases/controlplane/volumes_test.go:276: not enough arguments in call to getEtcdCertVolumes
W0804 00:30:36.474] 	have (kubeadm.Etcd)
W0804 00:30:36.475] 	want (kubeadm.Etcd, string)
W0804 00:30:36.475] cmd/kubeadm/app/phases/controlplane/volumes_test.go:514: undefined: caCertsPkiVolumePath
W0804 00:30:36.475] cmd/kubeadm/app/phases/controlplane/volumes_test.go:515: undefined: caCertsPkiVolumePath
[...]

@mattmoyer
Copy link
Contributor

I'm also +1 on the idea of a generic HostPathMount configuration.

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 10, 2017
@luxas
Copy link
Member

luxas commented Oct 20, 2017

ping @andrewrynhard You're gonna take a look at this soon, right?

@k8s-ci-robot k8s-ci-robot removed the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Oct 25, 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 31, 2017
@andrewrynhard
Copy link
Contributor Author

/retest

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

/test pull-kubernetes-unit

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

@luxas luxas 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-github-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: andrewrynhard, luxas

Associated issue: 484

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

@luxas
Copy link
Member

luxas commented Nov 1, 2017

/release-note-none

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Nov 1, 2017
@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to @fejta).

Review the full test history for this PR.

1 similar comment
@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to @fejta).

Review the full test history for this PR.

@k8s-github-robot
Copy link

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

@k8s-ci-robot
Copy link
Contributor

k8s-ci-robot commented Nov 1, 2017

@andrewrynhard: The following test failed, say /retest to rerun them all:

Test name Commit Details Rerun command
pull-kubernetes-bazel 6450d92 link /test pull-kubernetes-bazel

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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.

@andrewrynhard
Copy link
Contributor Author

/test pull-kubernetes-unit

@k8s-github-robot
Copy link

Automatic merge from submit-queue (batch tested with PRs 49840, 54937, 54543). If you want to cherry-pick this change to another branch, please follow the instructions here.

@ArchiFleKs
Copy link

Hi, does this PR allows to use volume type ? I'm trying with kubeadm config file to mount the cloud_config file for an OpenStack provider but all the extra volumes are of type DirectoryOrCreate

@luxas
Copy link
Member

luxas commented Jan 3, 2018

@ArchiFleKs Not right now, please file an issue with more details if that's something you'd like to see

@usernkey
Copy link

usernkey commented May 10, 2018

Is the feature of volume mounts via the config file been released on the current kubeadm?

I need to mount the cloud_config to add the AWS support :) using this approach

apiServerExtraArgs:
cloud-provider: "openstack"
cloud-config: "/etc/kubernetes/cloud.conf"
controllerManagerExtraArgs:
cloud-provider: "openstack"
cloud-config: "/etc/kubernetes/cloud.conf"

root@ip-10-1-18-136:~# kubeadm version
kubeadm version: &version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.2", GitCommit:"81753b10df112992bf51bbc2c2f85208aad78335", GitTreeState:"clean", BuildDate:"2018-04-27T09:10:24Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}

@andrewrynhard
Copy link
Contributor Author

andrewrynhard commented May 10, 2018

@usernkey
Copy link

usernkey commented May 11, 2018

cool thanks I'll try it

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. release-note-none Denotes a PR that doesn't merit a release note. 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.

None yet

10 participants