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

Refactor addons into multiple packages #50214

Merged
merged 3 commits into from
Aug 14, 2017

Conversation

andrewrynhard
Copy link
Contributor

What this PR does / why we need it:
kubernetes/kubeadm#348

Which issue this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged): fixes #
kubernetes/kubeadm#348

@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 cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 6, 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-github-robot k8s-github-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. release-note-label-needed labels Aug 6, 2017
@@ -283,7 +284,11 @@ func (i *Init) Run(out io.Writer) error {
return err
}

if err := addonsphase.CreateEssentialAddons(i.cfg, client); err != nil {
if err := dnsaddonphase.CreateEsentialDNSAddon(i.cfg, client); err != nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wasn't certain if we wanted to keep this as just addonsphase. I can change if so.

Copy link
Member

Choose a reason for hiding this comment

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

This is fine but can just be EnsureDNSAddon()

return err
}

if err := proxyaddonphase.CreateEssentialProxyAddon(i.cfg, client); err != nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wasn't certain if we wanted to keep this as just addonsphase. I can change if so.

Copy link
Member

Choose a reason for hiding this comment

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

proxyaddonphase is fine but maybe EnsureProxyAddon()

@andrewrynhard
Copy link
Contributor Author

@luxas I have a few things I can clean up. Still a WIP.

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 know this is WIP, but left a couple of comments for guidance.

What I yet want to see here is moving the ServiceAccount generation from the apiconfig phase to each addon pkg respectively. The same goes for the kubeadm:node-proxier ClusterRoleBinding.

Sounds good to you? Thanks!

@@ -283,7 +284,11 @@ func (i *Init) Run(out io.Writer) error {
return err
}

if err := addonsphase.CreateEssentialAddons(i.cfg, client); err != nil {
if err := dnsaddonphase.CreateEsentialDNSAddon(i.cfg, client); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

This is fine but can just be EnsureDNSAddon()

return err
}

if err := proxyaddonphase.CreateEssentialProxyAddon(i.cfg, client); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

proxyaddonphase is fine but maybe EnsureProxyAddon()

}

// CreateEsentialDNSAddon creates the kube-dns addon
func CreateEsentialDNSAddon(cfg *kubeadmapi.MasterConfiguration, client clientset.Interface) error {
Copy link
Member

Choose a reason for hiding this comment

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

EnsureDNSAddon

fmt.Println("[addons] Applied essential addon: kube-proxy")

err = CreateKubeDNSAddon(dnsDeploymentBytes, dnsServiceBytes, client)
err = createKubeDNSAddon(dnsDeploymentBytes, dnsServiceBytes, client)
Copy link
Member

Choose a reason for hiding this comment

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

...IfNotExists

Copy link
Member

Choose a reason for hiding this comment

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

And inline this in the if-clause below

@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package addons
package dns
Copy link
Member

Choose a reason for hiding this comment

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

KubeProxy* shouldn't be left here, right?

expected bool
}{
{
manifest: KubeProxyConfigMap,
Copy link
Member

Choose a reason for hiding this comment

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

KubeProxy* shouldn't be here, right?

path: /run/xtables.lock
`

KubeDNSVersion = "1.14.4"
Copy link
Member

Choose a reason for hiding this comment

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

KubeDNS* shouldn't be in this file

@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package addons
package proxy
Copy link
Member

Choose a reason for hiding this comment

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

Move over TestCompileManifests with the right test cases.

return fmt.Errorf("error when parsing kube-proxy daemonset template: %v", err)
}

err = createKubeProxyAddon(proxyConfigMapBytes, proxyDaemonSetBytes, client)
Copy link
Member

Choose a reason for hiding this comment

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

move into if clause

@luxas
Copy link
Member

luxas commented Aug 7, 2017

/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 Aug 7, 2017
@luxas luxas added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-label-needed labels Aug 7, 2017
@luxas luxas assigned luxas and unassigned lukemarsden Aug 7, 2017
@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
@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 14, 2017
@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 Aug 14, 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.

Thanks a bunch! Only one primary comment; and some small nits to fix:

From golint:

W0814 06:27:07.535] cmd/kubeadm/app/phases/addons/dns/manifests.go:20:2: exported const KubeDNSVersion should have comment (or a comment on this block) or be unexported
W0814 06:27:07.535] cmd/kubeadm/app/phases/addons/proxy/manifests.go:20:2: exported const KubeProxyConfigMap should have comment (or a comment on this block) or be unexported

From unit/bazel:

cmd/kubeadm/app/phases/apiconfig/clusterroles_test.go:60: undefined: CreateServiceAccounts

if err := kuberuntime.DecodeInto(api.Codecs.UniversalDecoder(), daemonSetbytes, kubeproxyDaemonSet); err != nil {
return fmt.Errorf("unable to decode kube-proxy daemonset %v", err)
// CreateServiceAccount creates the necessary serviceaccounts that kubeadm uses/might use, if they don't already exist.
func CreateServiceAccount(client clientset.Interface) error {
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this needs to be exposed separately.
Well, if we do that it's fine by me, but at least EnsureDNSAddon should call it.
(EnsureDNSAddon should not have dependencies)


const (
// KubeProxyClusterRoleName sets the name for the kube-proxy ClusterRole
KubeProxyClusterRoleName = "system:node-proxier"
Copy link
Member

Choose a reason for hiding this comment

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

nit: Add // TODO: This k8s-generic, well-known constant should be fetchable from an other source, not be in this package

)

// EnsureProxyAddon creates the kube-proxy and kube-dns addons
func EnsureProxyAddon(cfg *kubeadmapi.MasterConfiguration, client clientset.Interface) error {
Copy link
Member

Choose a reason for hiding this comment

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

Again, the serviceaccount should be created as the first step here

}

func createClusterRoleBindings(client clientset.Interface) error {
// TODO: This ClusterRoleBinding should be created by the kube-proxy phase, not here
Copy link
Member

Choose a reason for hiding this comment

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

can remove this TODO now :)

return err
}

fmt.Println("[proxy] Created RBAC rules")
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we should print this; one line per addon phase is enough


// CreateRBACRules creates the essential RBAC rules for a minimally set-up cluster
func CreateRBACRules(client clientset.Interface, k8sVersion *k8sversion.Version) error {
if err := createClusterRoleBindings(client); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

I really like the idea of having EnsureFooAddon, CreateServiceAccount and CreateRBACRules as the three exported funcs of every addon phase (even if some of them no-op).

return err
}

if err := apiconfigphase.CreateRBACRules(client, k8sVersion); err != nil {
if err := dnsaddonphase.CreateServiceAccount(client); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

This should not be necessary

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 14, 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

Awesome to get this done!

@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

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

Associated issue: 348

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

@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 14, 2017
@k8s-github-robot k8s-github-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 14, 2017
@luxas luxas added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 14, 2017
@luxas
Copy link
Member

luxas commented Aug 14, 2017

@andrewrynhard kind of annoying, but please fix this

W0814 15:57:13.081] Some packages in hack/.golint_failures do not exist anymore. Please remove them.
W0814 15:57:13.082] 
W0814 15:57:13.082]   cmd/kubeadm/app/phases/addons

@k8s-github-robot k8s-github-robot removed approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm "Looks good to me", indicates that a PR is ready to be merged. labels Aug 14, 2017
@luxas luxas added approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm "Looks good to me", indicates that a PR is ready to be merged. labels Aug 14, 2017
@k8s-github-robot
Copy link

Automatic merge from submit-queue (batch tested with PRs 49904, 50484, 50214)

k8s-github-robot pushed a commit that referenced this pull request Aug 14, 2017
Automatic merge from submit-queue (batch tested with PRs 49904, 50484, 50214)

Refactor addons into multiple packages

**What this PR does / why we need it**:
kubernetes/kubeadm#348

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #
kubernetes/kubeadm#348
@k8s-github-robot k8s-github-robot merged commit a4996c9 into kubernetes:master Aug 14, 2017
@andrewrynhard andrewrynhard deleted the refactor_addons branch August 14, 2017 20:11
k8s-github-robot pushed a commit that referenced this pull request Aug 15, 2017
Automatic merge from submit-queue (batch tested with PRs 50626, 50683, 50679, 50684, 50460)

kubeadm: Centralize client create-or-update logic in one package

**What this PR does / why we need it**:

Moves all Create-or-Update logic into one package instead of duplicating that logic all around in the codebase.

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #

**Special notes for your reviewer**:

This PR depends on #50214.
Note that commit 2 is the only one that needs reviewing.
This PR is required for #48899 (kubeadm upgrade)

**Release note**:

```release-note
NONE
```
@kubernetes/sig-cluster-lifecycle-pr-reviews @mattmoyer @fabriziopandini
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 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.

6 participants