Skip to content

Commit

Permalink
Feature:Support specified kubeadm conf for join cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
liangyuanpeng committed Jan 27, 2021
1 parent dafdb99 commit ad81525
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
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 the kubeadm configuration file that is used by the kubelet service to join the cluster. N.B. the path on different Linux distro may vary.")
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 the kubeadm configuration file that is used by the kubelet service to join the cluster. N.B. the path on different Linux distro may vary.")

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}}
`
)

0 comments on commit ad81525

Please sign in to comment.