-
Notifications
You must be signed in to change notification settings - Fork 40k
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: add kubeadm phase addons
command
#51171
kubeadm: add kubeadm phase addons
command
#51171
Conversation
cmd/kubeadm/app/cmd/phases/addons.go
Outdated
var kubeConfigFile string | ||
cfg := &kubeadmapiext.MasterConfiguration{} | ||
cmd := &cobra.Command{ | ||
Use: "addon", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can change to plural "addons" if we want to allow multiple addons to be installed with one command.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd let this be addon
but have an addons
alias
cmd/kubeadm/app/cmd/phases/addons.go
Outdated
Aliases: []string{}, | ||
Short: "Install an addon to a Kubernetes cluster.", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
if len(args) != 1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to allow multiple addons to be installed with one command?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See certs|kubeconfig|controlplane phases; they have an all
command in addition
cmd/kubeadm/app/cmd/phases/addons.go
Outdated
kubeadmutil.CheckErr(err) | ||
addon := args[0] | ||
switch addon { | ||
case dnsaddon.KubeDNSServiceAccountName: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be hardcoded or should we stick to using the service account name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be that the ServiceAccountName constants are moved into the respective addon package eventually; so I'd hard-code kube-proxy|kube-dns here
@luxas I left a few comments. I can push updates based on your review. |
cmd/kubeadm/app/cmd/phases/addons.go
Outdated
client, err := kubeconfigutil.ClientSetFromFile(kubeConfigFile) | ||
kubeadmutil.CheckErr(err) | ||
addon := args[0] | ||
switch addon { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are not happy with a switch
statement, I can create a map[string]func(cfg, client)
, but that would depend on us sticking with the EnsureXXXAddon(cfg, client)
convention.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please try to model this as we've done for the other phases to be consistent here; a struct { }
slice should do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please provide users a way to inspect which addons could be managed with kubeadm addons
; other phases are doing this by leveraging on cobra native support for --help
and subcommands
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @andrewrynhard
I'd like it to be a little bit more like the certs, kubeconfig and controlplane phases if that's okay with you.
Please make it possible to configure the addon creation with CLI flags.
/assign @fabriziopandini
cmd/kubeadm/app/cmd/phases/addons.go
Outdated
var kubeConfigFile string | ||
cfg := &kubeadmapiext.MasterConfiguration{} | ||
cmd := &cobra.Command{ | ||
Use: "addon", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd let this be addon
but have an addons
alias
cmd/kubeadm/app/cmd/phases/addons.go
Outdated
Aliases: []string{}, | ||
Short: "Install an addon to a Kubernetes cluster.", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
if len(args) != 1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See certs|kubeconfig|controlplane phases; they have an all
command in addition
cmd/kubeadm/app/cmd/phases/addons.go
Outdated
kubeadmutil.CheckErr(err) | ||
addon := args[0] | ||
switch addon { | ||
case dnsaddon.KubeDNSServiceAccountName: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be that the ServiceAccountName constants are moved into the respective addon package eventually; so I'd hard-code kube-proxy|kube-dns here
cmd/kubeadm/app/cmd/phases/addons.go
Outdated
} | ||
|
||
cmd.Flags().StringVar(&kubeConfigFile, "kubeconfig", "/etc/kubernetes/admin.conf", "The KubeConfig file to use for talking to the cluster") | ||
return cmd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should take --config
as well and other relevant CLI args
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add support as well for validate mixed argument logic if --config
is combined with other flags. See e.g.
if err := validation.ValidateMixedArguments(cmd.Flags()); err != nil { |
cmd/kubeadm/app/cmd/phases/addons.go
Outdated
client, err := kubeconfigutil.ClientSetFromFile(kubeConfigFile) | ||
kubeadmutil.CheckErr(err) | ||
addon := args[0] | ||
switch addon { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please try to model this as we've done for the other phases to be consistent here; a struct { }
slice should do
46b22b8
to
989d9d9
Compare
@luxas PTAL, this is still a WIP but I believe it is a step in the direction you wanted. |
0a7c6b2
to
5a56adf
Compare
cmd/kubeadm/app/cmd/phases/addons.go
Outdated
return cmd | ||
} | ||
|
||
func EnsureAllAddons(cfg *kubeadmapi.MasterConfiguration, client clientset.Interface) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this function going to be replaced with https://github.com/kubernetes/kubernetes/pull/51171/files#diff-eadad99fe8edbb21ce1c0f32a362240a?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I will make that change and have it up in a bit.
@andrewrynhard 👍 from my side :-) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of change requests
) | ||
|
||
// EnsureAllAddons install all addons to a Kubernetes cluster. | ||
func EnsureAllAddons(cfg *kubeadmapi.MasterConfiguration, client clientset.Interface) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please move this function client-side to be consistent; i.e. in cmd/phases/addons.go
@@ -41,7 +41,12 @@ const ( | |||
) | |||
|
|||
// EnsureDNSAddon creates the kube-dns addon | |||
func EnsureDNSAddon(cfg *kubeadmapi.MasterConfiguration, client clientset.Interface, k8sVersion *version.Version) error { | |||
func EnsureDNSAddon(cfg *kubeadmapi.MasterConfiguration, client clientset.Interface) error { | |||
k8sVersion, err := version.ParseSemantic(cfg.KubernetesVersion) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to pass k8sVersion
still and do the parsing client-side in cmd/phases
Luckily, I expect to soon get rid of this in the v1.9 cycle by moving this into the internal variant of cfg or something so we can stop passing and parsing this all the time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only issue I had with this was that I needed all the EnsureXXXAddon
functions have the same signature. Look at the EnsureAllAddons
and runAddonsCmdFunc
functions. I'm happy to do something different if we still prefer to pass k8sVersion
in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok with this for now; will fix it for real later
|
||
// Add flags to the command | ||
cmd.Flags().StringVar(&kubeConfigFile, "kubeconfig", "/etc/kubernetes/admin.conf", "The KubeConfig file to use for talking to the cluster") | ||
cmd.Flags().StringVar(&cfgPath, "config", cfgPath, "Path to kubeadm config file (WARNING: Usage of a configuration file is experimental)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add flags for these fields:
common:
- KubernetesVersion
- ImageRepository
proxy:
- AdvertiseAddress
- BindPort
- PodSubnet
dns:
- DNSDomain
cmd/kubeadm/app/cmd/phases/addons.go
Outdated
}, | ||
{ | ||
use: "kube-dns", | ||
short: "Install kube-dns addon to a Kubernetes cluster.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Install the ...
cmd/kubeadm/app/cmd/phases/addons.go
Outdated
}, | ||
{ | ||
use: "kube-proxy", | ||
short: "Install kube-proxy addon to a Kubernetes cluster.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Install the ...
cmd/kubeadm/app/cmd/phases/addons.go
Outdated
api.Scheme.Convert(cfg, internalcfg, nil) | ||
client, err := kubeconfigutil.ClientSetFromFile(kubeConfigFile) | ||
kubeadmutil.CheckErr(err) | ||
// internalcfg, err := configutil.ConfigFileAndDefaultsToInternalConfig(*cfgPath, cfg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why commented out?
Also pass cfgPath
to this func
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops. This was a mistake.
5a56adf
to
48c8423
Compare
@fabriziopandini @luxas I believe I have everything done now. |
/retest Review the full test history for this PR. |
2 similar comments
/retest Review the full test history for this PR. |
/retest Review the full test history for this PR. |
/retest |
/retest Review the full test history for this PR. |
/retest |
@andrewrynhard this needs a rebase |
/retest Review the full test history for this PR. |
3 similar comments
/retest Review the full test history for this PR. |
/retest Review the full test history for this PR. |
/retest Review the full test history for this PR. |
13b9955
to
cf05141
Compare
/retest |
cf05141
to
d55cea6
Compare
/test pull-kubernetes-e2e-kops-aws |
/test pull-kubernetes-e2e-gce-etcd3 |
/test pull-kubernetes-e2e-kops-aws |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: andrewrynhard, luxas Associated issue: 418 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 |
/test all [submit-queue is verifying that this PR is safe to merge] |
Automatic merge from submit-queue |
@andrewrynhard: The following tests failed, say
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. |
👍 |
kubeadmutil.CheckErr(err) | ||
} | ||
|
||
var kubeConfigFile string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not able to actually get any of these commands working. Because of this closure, the kubeconfig value from the flag won't ever get used.
$ _output/bin/kubeadm alpha phase addon all --kubeconfig test
failed to load admin kubeconfig [open : no such file or directory]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can have a fix soon. Thanks @r2d4
What this PR does / why we need it:
Adds the
addons
phase command tokubeadm
fixes: kubernetes/kubeadm#418
/cc @luxas