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: set pod-infra-container-image for the kubelet #70603

Merged
merged 1 commit into from
Nov 13, 2018

Conversation

chuckha
Copy link
Contributor

@chuckha chuckha commented Nov 2, 2018

The kubelet allows you to set --pod-infra-container-image
(also called PodSandboxImage in the kubelet config),
which can be a custom location to the "pause" image in the case
of Docker. Other CRIs are not supported.

Set the CLI flag for the Docker case in flags.go using
WriteKubeletDynamicEnvFile().

This PR also cleans up some unwrapped errors.

What type of PR is this?

Uncomment only one, leave it on its own line:

/kind api-change
/kind bug
/kind cleanup
/kind design
/kind documentation
/kind failing-test
/kind feature
/kind flake

What this PR does / why we need it:
This PR properly allows image repository to be passed to the kubelet for the sandbox image.

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 kubernetes/kubeadm#1003

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

Kubeadm now respects the custom image registry configuration across joins and upgrades. Kubeadm passes the custom registry to the kubelet for a custom pause container.

@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/L Denotes a PR that changes 100-499 lines, ignoring generated files. kind/bug Categorizes issue or PR as related to a bug. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. 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. labels Nov 2, 2018
@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 Nov 2, 2018
@chuckha
Copy link
Contributor Author

chuckha commented Nov 2, 2018

/priority critical-urgent

(copying prio from bug kubernetes/kubeadm#1003)

@k8s-ci-robot k8s-ci-robot added priority/critical-urgent Highest priority. Must be actively worked on as someone's top priority right now. and removed needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Nov 2, 2018
@chuckha
Copy link
Contributor Author

chuckha commented Nov 2, 2018

/cc @kubernetes/sig-cluster-lifecycle-pr-reviews @mruepp

@k8s-ci-robot
Copy link
Contributor

@chuckha: GitHub didn't allow me to request PR reviews from the following users: mruepp.

Note that only kubernetes members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

/cc @kubernetes/sig-cluster-lifecycle-pr-reviews @mruepp

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.

@chuckha
Copy link
Contributor Author

chuckha commented Nov 2, 2018

docker images after an init:

812083501456.dkr.ecr.us-west-2.amazonaws.com/kube-proxy                v1.12.2             15e9da1ca195        9 days ago          96.5MB
812083501456.dkr.ecr.us-west-2.amazonaws.com/kube-apiserver            v1.12.2             51a9c329b7c5        9 days ago          194MB
812083501456.dkr.ecr.us-west-2.amazonaws.com/kube-controller-manager   v1.12.2             15548c720a70        9 days ago          164MB
812083501456.dkr.ecr.us-west-2.amazonaws.com/etcd                      3.2.24              3cab8e1b9802        6 weeks ago         220MB
812083501456.dkr.ecr.us-west-2.amazonaws.com/pause                     3.1                 da86e6ba6ca1        10 months ago       742kB

docker images after a join:

812083501456.dkr.ecr.us-west-2.amazonaws.com/pause        3.1                 da86e6ba6ca1        10 months ago       742kB

Copy link
Member

@neolit123 neolit123 left a comment

Choose a reason for hiding this comment

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

@chuckha thank you fixing this.
added a couple of comments about possible small changes.

@@ -250,6 +250,9 @@ const (
// PauseVersion indicates the default pause image version for kubeadm
PauseVersion = "3.1"

// DefaultPauseImageVersion indicates the default version for the pause image
DefaultPauseImageVersion = "3.1"
Copy link
Member

Choose a reason for hiding this comment

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

seems to be duplicate of the above PauseVersion constant.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

lol yes, it does 🤦‍♂️

cfg: &kubeadmapi.ClusterConfiguration{
ImageRepository: "test.repo",
},
expected: "test.repo/pause:" + constants.DefaultPauseImageVersion,
Copy link
Member

Choose a reason for hiding this comment

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

probably should be PauseVersion. same as GetPauseImage().

@@ -93,7 +91,7 @@ func getInitConfigurationFromCluster(kubeconfigDir string, client clientset.Inte
// Also, the config map really should be KubeadmConfigConfigMap...
configMap, err := client.CoreV1().ConfigMaps(metav1.NamespaceSystem).Get(constants.KubeadmConfigConfigMap, metav1.GetOptions{})
if err != nil {
return nil, err
return nil, errors.Wrap(err, "failed to get config map")
Copy link
Member

Choose a reason for hiding this comment

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

these Wrap calls are possibly outside of the scope of the PR?
but SGTM still.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yeah, I added these because when I wanted them when I was debugging. not strictly necessary, but imo an improvement

Copy link
Member

Choose a reason for hiding this comment

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

I will never complain about this...

@@ -96,7 +97,8 @@ func runKubeletStart(c workflow.RunData) error {
// Write env file with flags for the kubelet to use. We do not need to write the --register-with-taints for the master,
// as we handle that ourselves in the markmaster phase
// TODO: Maybe we want to do that some time in the future, in order to remove some logic from the markmaster phase?
if err := kubeletphase.WriteKubeletDynamicEnvFile(&data.Cfg().NodeRegistration, data.Cfg().FeatureGates, false, data.KubeletDir()); err != nil {
pauseImage := images.GetPauseImage(data.Cfg().ClusterConfiguration.ImageRepository)
if err := kubeletphase.WriteKubeletDynamicEnvFile(&data.Cfg().NodeRegistration, data.Cfg().FeatureGates, pauseImage, false, data.KubeletDir()); err != nil {
Copy link
Member

@neolit123 neolit123 Nov 2, 2018

Choose a reason for hiding this comment

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

something that @rosti suggested in the original PR was that we should pass ClusterConfiguration instead of feature gates and pause image to WriteKubeletDynamicEnvFile:
https://github.com/kubernetes/kubernetes/pull/66798/files#r206508620

Copy link
Contributor

Choose a reason for hiding this comment

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

In fact, we can replace the first three parameters with InitConfiguration here and move the GetPauseImage call to WriteKubeletDynamicEnvFile. This will have the benefit of tidying up the code and removing duplicate logic between here and postupgrade.go

@@ -56,6 +57,7 @@ func WriteKubeletDynamicEnvFile(nodeRegOpts *kubeadmapi.NodeRegistrationOptions,
flagOpts := kubeletFlagsOpts{
nodeRegOpts: nodeRegOpts,
featureGates: featureGates,
pauseImage: pauseImage,
Copy link
Member

Choose a reason for hiding this comment

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

i guess we can keep featureGates and pauseImage as part of kubeletFlagsOpts, but obtain them from a ClusterConfiguration argument.

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.

Overall looks OK. A few errors.Wrap and some empty lines removed from imports look like not belonging to this change.

@@ -532,11 +533,20 @@ func (j *Join) BootstrapKubelet(tlsBootstrapCfg *clientcmdapi.Config) error {
return err
}

imageRegistry := kubeadmapiv1beta1.DefaultImageRepository
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I know that "registry" is a more accurate term here, but I think, that we should be consistent with the reset of kubeadm and use the term "repository" 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.

hah, ok, that's reasonable, I will continue down the repository road

@@ -53,16 +53,19 @@ func GetEtcdImage(cfg *kubeadmapi.ClusterConfiguration) string {
return GetGenericImage(cfg.ImageRepository, constants.Etcd, etcdImageTag)
}

// GetPauseImage returns the image for the "pause" container
func GetPauseImage(registry string) string {
Copy link
Contributor

Choose a reason for hiding this comment

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

My vision for the funcs in the images files is for them to take ClusterConfiguration and then figure out from there how to generate the image string. This way we can keep future changes to the way we generate the images to this file only.
I know, that this will look like an overkill for GetPauseImage, but I think, that this may have benefits in the future and will keep things consistent with the rest of the bunch here.

@@ -96,7 +97,8 @@ func runKubeletStart(c workflow.RunData) error {
// Write env file with flags for the kubelet to use. We do not need to write the --register-with-taints for the master,
// as we handle that ourselves in the markmaster phase
// TODO: Maybe we want to do that some time in the future, in order to remove some logic from the markmaster phase?
if err := kubeletphase.WriteKubeletDynamicEnvFile(&data.Cfg().NodeRegistration, data.Cfg().FeatureGates, false, data.KubeletDir()); err != nil {
pauseImage := images.GetPauseImage(data.Cfg().ClusterConfiguration.ImageRepository)
if err := kubeletphase.WriteKubeletDynamicEnvFile(&data.Cfg().NodeRegistration, data.Cfg().FeatureGates, pauseImage, false, data.KubeletDir()); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

In fact, we can replace the first three parameters with InitConfiguration here and move the GetPauseImage call to WriteKubeletDynamicEnvFile. This will have the benefit of tidying up the code and removing duplicate logic between here and postupgrade.go

@chuckha chuckha force-pushed the pod-infra-container-image branch 3 times, most recently from 2900bb5 to 36f65e3 Compare November 7, 2018 19:47
@chuckha
Copy link
Contributor Author

chuckha commented Nov 7, 2018

I'm not sure why github is still showing me the outdated comments but I think this is ready for another review @rosti @neolit123.

@neolit123
Copy link
Member

cmd/kubeadm/app/images/images_test.go:147:28: cannot use tc.cfg.ImageRepository (variable of type string) as *k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm.ClusterConfiguration value in argument to GetPauseImage

images_test needs an update.

Copy link
Member

@neolit123 neolit123 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 update @chuckha
LGTM added one minor comment to fix CI.

}
for _, tc := range testcases {
t.Run(tc.name, func(t *testing.T) {
actual := GetPauseImage(tc.cfg.ImageRepository)
Copy link
Member

Choose a reason for hiding this comment

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

tc.cfg

@neolit123
Copy link
Member

/retest

@chuckha
Copy link
Contributor Author

chuckha commented Nov 8, 2018

/assign @timothysc

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 9, 2018
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 9, 2018
@chuckha
Copy link
Contributor Author

chuckha commented Nov 9, 2018

/test pull-kubernetes-integration

1 similar comment
@chuckha
Copy link
Contributor Author

chuckha commented Nov 9, 2018

/test pull-kubernetes-integration

@chuckha
Copy link
Contributor Author

chuckha commented Nov 9, 2018

/retest

@chuckha
Copy link
Contributor Author

chuckha commented Nov 9, 2018

/test pull-kubernetes-e2e-kops-aws

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 10, 2018
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 13, 2018
The kubelet allows you to set `--pod-infra-container-image`
(also called `PodSandboxImage` in the kubelet config),
which can be a custom location to the "pause" image in the case
of Docker. Other CRIs are not supported.

Set the CLI flag for the Docker case in flags.go using
WriteKubeletDynamicEnvFile().
@neolit123
Copy link
Member

/retest

1 similar comment
@neolit123
Copy link
Member

/retest

Copy link
Member

@timothysc timothysc left a comment

Choose a reason for hiding this comment

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

Nice work!
/lgtm
/approve

@@ -93,7 +91,7 @@ func getInitConfigurationFromCluster(kubeconfigDir string, client clientset.Inte
// Also, the config map really should be KubeadmConfigConfigMap...
configMap, err := client.CoreV1().ConfigMaps(metav1.NamespaceSystem).Get(constants.KubeadmConfigConfigMap, metav1.GetOptions{})
if err != nil {
return nil, err
return nil, errors.Wrap(err, "failed to get config map")
Copy link
Member

Choose a reason for hiding this comment

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

I will never complain about this...

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: chuckha, timothysc

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 Nov 13, 2018
@timothysc timothysc added this to the v1.13 milestone Nov 13, 2018
@timothysc
Copy link
Member

@chuckha I would revise the release notes to denote the behavior on the kubelet as well.

@chuckha
Copy link
Contributor Author

chuckha commented Nov 13, 2018

@timothysc updated

@kevinbin
Copy link

not support contained CRI?

@rosti
Copy link
Contributor

rosti commented Dec 16, 2019

not support contained CRI?

Currently, this option is only for Docker. If you use any other CRI you have to check with its documentation and pass an equivalent option manually.

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. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/critical-urgent Highest priority. Must be actively worked on as someone's top priority right now. 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/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.

kubeadm pulls pause on update and setup ignoring imageRepository: in config file
6 participants