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

Feature:Support specified kubeadm conf for join cluster #210

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions pkg/yurtctl/cmd/convert/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ type ConvertOptions struct {
YurttunnelServerImage string
YurttunnelAgentImage string
PodMainfestPath string
KubeadmConfPath string
DeployTunnel bool
kubeConfigPath string
}
Expand Down Expand Up @@ -101,6 +102,9 @@ func NewConvertCmd() *cobra.Command {
cmd.Flags().String("yurtctl-servant-image",
"openyurt/yurtctl-servant:latest",
"The yurtctl-servant image.")
cmd.Flags().String("kubeadm-conf-path",
"/etc/systemd/system/kubelet.service.d/10-kubeadm.conf",
"The path to kubelet service conf that is used by kubelet component to join the cluster on the edge node.")
cmd.Flags().String("yurt-tunnel-server-image",
"openyurt/yurt-tunnel-server:latest",
"The yurt-tunnel-server image.")
Expand Down Expand Up @@ -174,6 +178,12 @@ func (co *ConvertOptions) Complete(flags *pflag.FlagSet) error {
}
co.PodMainfestPath = pmp

kcp, err := flags.GetString("kubeadm-conf-path")
if err != nil {
return err
}
co.KubeadmConfPath = kcp

// parse kubeconfig and generate the clientset
co.clientSet, err = kubeutil.GenClientSet(flags)
if err != nil {
Expand Down Expand Up @@ -320,6 +330,7 @@ func (co *ConvertOptions) RunConvert() (err error) {
"yurthub_image": co.YurhubImage,
"joinToken": joinToken,
"pod_manifest_path": co.PodMainfestPath,
"kubeadm_conf_path": co.KubeadmConfPath,
}, edgeNodeNames); err != nil {
klog.Errorf("fail to run ServantJobs: %s", err)
return
Expand Down
11 changes: 11 additions & 0 deletions pkg/yurtctl/cmd/revert/revert.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
type RevertOptions struct {
clientSet *kubernetes.Clientset
YurtctlServantImage string
KubeadmConfPath string
}

// NewConvertOptions creates a new RevertOptions
Expand All @@ -65,6 +66,9 @@ func NewRevertCmd() *cobra.Command {
cmd.Flags().String("yurtctl-servant-image",
"openyurt/yurtctl-servant:latest",
"The yurtctl-servant image.")
cmd.Flags().String("kubeadm-conf-path",
"/etc/systemd/system/kubelet.service.d/10-kubeadm.conf",
"The path to kubelet service conf that is used by kubelet component to join the cluster on the edge node.")

return cmd
}
Expand All @@ -77,6 +81,12 @@ func (ro *RevertOptions) Complete(flags *pflag.FlagSet) error {
}
ro.YurtctlServantImage = ycsi

kcp, err := flags.GetString("kubeadm-conf-path")
if err != nil {
return err
}
ro.KubeadmConfPath = kcp

ro.clientSet, err = kubeutil.GenClientSet(flags)
if err != nil {
return err
Expand Down Expand Up @@ -224,6 +234,7 @@ func (ro *RevertOptions) RunRevert() (err error) {
map[string]string{
"action": "revert",
"yurtctl_servant_image": ro.YurtctlServantImage,
"kubeadm_conf_path": ro.KubeadmConfPath,
},
edgeNodeNames); err != nil {
klog.Errorf("fail to revert edge node: %s", err)
Expand Down
4 changes: 4 additions & 0 deletions pkg/yurtctl/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,5 +199,9 @@ spec:
fieldPath: spec.nodeName
- name: STATIC_POD_PATH
value: {{.pod_manifest_path}}
{{if .kubeadm_conf_path }}
- name: KUBELET_SVC
value: {{.kubeadm_conf_path}}
{{end}}
`
)