diff --git a/apis/v1alpha1/cluster.go b/apis/v1alpha1/cluster.go deleted file mode 100644 index aa9183d9..00000000 --- a/apis/v1alpha1/cluster.go +++ /dev/null @@ -1,149 +0,0 @@ -package v1alpha1 - -import ( - "fmt" - "github.com/pixiake/kubekey/util" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" -) - -const ( - DefaultPreDir = "kubekey" - DefaultSSHPort = "22" - DefaultDockerSockPath = "/var/run/docker.sock" - DefaultLBPort = "6443" - DefaultLBDomain = "lb.kubesphere.local" - DefaultNetworkPlugin = "calico" - DefaultPodsCIDR = "10.233.64.0/18" - DefaultServiceCIDR = "10.233.0.0/18" - DefaultKubeImageRepo = "kubekey" - DefaultClusterName = "cluster.local" - DefaultArch = "amd64" - DefaultHostName = "allinone" - DefaultEtcdRepo = "kubekey/etcd" - DefaultEtcdVersion = "v3.3.12" - DefaultEtcdPort = "2379" - DefaultKubeVersion = "v1.17.4" - DefaultCniVersion = "v0.8.2" - DefaultHelmVersion = "v3.1.2" - ETCDRole = "etcd" - MasterRole = "master" - WorkerRole = "worker" -) - -type K2Cluster struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - Spec ClusterCfg `json:"spec"` - //Status ClusterStatus `json:"status"` -} - -type ClusterCfg struct { - Hosts []HostCfg `yaml:"hosts" json:"hosts,omitempty"` - LBKubeApiserver LBKubeApiserverCfg `yaml:"lbKubeapiserver" json:"lbKubeapiserver,omitempty"` - KubeVersion string `yaml:"kubeVersion" json:"kubeVersion,omitempty"` - KubeImageRepo string `yaml:"kubeImageRepo" json:"kubeImageRepo,omitempty"` - KubeClusterName string `yaml:"kubeClusterName" json:"kubeClusterName,omitempty"` - Network NetworkConfig `yaml:"network" json:"network,omitempty"` -} - -func (c ClusterCfg) GetObjectKind() schema.ObjectKind { - panic("implement me") -} - -func (c ClusterCfg) DeepCopyObject() runtime.Object { - panic("implement me") -} - -type Taint struct { - Key string `json:"key,omitempty" yaml:"key"` - Value string `json:"value,omitempty" yaml:"value"` - Effect TaintEffect `json:"effect,omitempty" yaml:"effect"` -} - -type TaintEffect string - -const ( - TaintEffectNoSchedule TaintEffect = "NoSchedule" - TaintEffectPreferNoSchedule TaintEffect = "PreferNoSchedule" - TaintEffectNoExecute TaintEffect = "NoExecute" -) - -type NodeInfo struct { - HostName string -} - -type NetworkConfig struct { - Plugin string `yaml:"plugin" json:"plugin,omitempty"` - KubePodsCIDR string `yaml:"kube_pods_cidr" json:"kube_pods_cidr,omitempty"` - KubeServiceCIDR string `yaml:"kube_service_cidr" json:"kube_service_cidr,omitempty"` -} - -type LBKubeApiserverCfg struct { - Domain string `yaml:"domain" json:"domain,omitempty"` - Address string `yaml:"address" json:"address,omitempty"` - Port string `yaml:"port" json:"port,omitempty"` -} - -func addDefaultingFuncs(scheme *runtime.Scheme) error { - return RegisterDefaults(scheme) -} - -type ExternalEtcd struct { - Endpoints []string - CaFile string - CertFile string - KeyFile string -} - -func RegisterDefaults(scheme *runtime.Scheme) error { - scheme.AddTypeDefaultingFunc(&ClusterCfg{}, func(obj interface{}) { SetDefaultClusterCfg(obj.(*ClusterCfg)) }) - return nil -} - -func (cfg *ClusterCfg) GenerateHosts() []string { - var lbHost string - hostsList := []string{} - - _, _, masters, _, _ := cfg.GroupHosts() - if cfg.LBKubeApiserver.Address != "" { - lbHost = fmt.Sprintf("%s %s", cfg.LBKubeApiserver.Address, cfg.LBKubeApiserver.Domain) - } else { - lbHost = fmt.Sprintf("%s %s", masters.Hosts[0].InternalAddress, DefaultLBDomain) - } - - for _, host := range cfg.Hosts { - if host.HostName != "" { - hostsList = append(hostsList, fmt.Sprintf("%s %s.%s %s", host.InternalAddress, host.HostName, cfg.KubeClusterName, host.HostName)) - } - } - - hostsList = append(hostsList, lbHost) - return hostsList -} - -func (cfg *ClusterCfg) GenerateCertSANs() []string { - clusterSvc := fmt.Sprintf("kubernetes.default.svc.%s", cfg.KubeClusterName) - defaultCertSANs := []string{"kubernetes", "kubernetes.default", "kubernetes.default.svc", clusterSvc, "localhost", "127.0.0.1"} - extraCertSANs := []string{} - - extraCertSANs = append(extraCertSANs, cfg.LBKubeApiserver.Domain) - extraCertSANs = append(extraCertSANs, cfg.LBKubeApiserver.Address) - - for _, host := range cfg.Hosts { - extraCertSANs = append(extraCertSANs, host.HostName) - extraCertSANs = append(extraCertSANs, fmt.Sprintf("%s.%s", host.HostName, cfg.KubeClusterName)) - if host.SSHAddress != cfg.LBKubeApiserver.Address { - extraCertSANs = append(extraCertSANs, host.SSHAddress) - } - if host.InternalAddress != host.SSHAddress && host.InternalAddress != cfg.LBKubeApiserver.Address { - extraCertSANs = append(extraCertSANs, host.InternalAddress) - } - } - - extraCertSANs = append(extraCertSANs, util.ParseIp(cfg.Network.KubeServiceCIDR)[0]) - - defaultCertSANs = append(defaultCertSANs, extraCertSANs...) - return defaultCertSANs -} diff --git a/apis/v1alpha1/default.go b/apis/v1alpha1/default.go deleted file mode 100644 index b657c762..00000000 --- a/apis/v1alpha1/default.go +++ /dev/null @@ -1,44 +0,0 @@ -package v1alpha1 - -//const ( -// DefaultPreDir = "/tmp/kubekey" -// DefaultSSHPort = "22" -// DefaultDockerSockPath = "/var/run/docker.sock" -// DefaultLBPort = "6443" -// DefaultLBDomain = "lb.kubesphere.local" -// DefaultNetworkPlugin = "calico" -// DefaultPodsCIDR = "10.233.64.0/18" -// DefaultServiceCIDR = "10.233.0.0/18" -// DefaultKubeImageRepo = "kubekey" -// DefaultClusterName = "cluster.local" -// DefaultArch = "amd64" -// DefaultHostName = "allinone" -// DefaultEtcdRepo = "kubekey/etcd" -// DefaultEtcdVersion = "v3.3.12" -// DefaultEtcdPort = "2379" -// DefaultKubeVersion = "v1.17.4" -// DefaultCniVersion = "v0.8.2" -// DefaultHelmVersion = "v3.1.2" -// ETCDRole = "etcd" -// MasterRole = "master" -// WorkerRole = "worker" -//) -// -//type HostConfig struct { -// ID int `json:"-"` -// PublicAddress string `json:"publicAddress"` -// PrivateAddress string `json:"privateAddress"` -// SSHPort int `json:"sshPort"` -// SSHUsername string `json:"sshUsername"` -// SSHPrivateKeyFile string `json:"sshPrivateKeyFile"` -// SSHAgentSocket string `json:"sshAgentSocket"` -// Bastion string `json:"bastion"` -// BastionPort int `json:"bastionPort"` -// BastionUser string `json:"bastionUser"` -// Hostname string `json:"hostname"` -// IsLeader bool `json:"isLeader"` -// Untaint bool `json:"untaint"` -// -// // Information populated at the runtime -// OperatingSystem string `json:"-"` -//} diff --git a/apis/v1alpha1/host.go b/apis/v1alpha1/host.go deleted file mode 100644 index 1f150ec0..00000000 --- a/apis/v1alpha1/host.go +++ /dev/null @@ -1,58 +0,0 @@ -package v1alpha1 - -type HostCfg struct { - HostName string `yaml:"hostName" json:"hostName,omitempty"` - SSHAddress string `yaml:"sshAddress" json:"sshAddress,omitempty"` - InternalAddress string `yaml:"internalAddress" json:"internalAddress,omitempty"` - Port string `yaml:"port" json:"port,omitempty"` - User string `yaml:"user" json:"user,omitempty"` - Password string `yaml:"password, omitempty" json:"password,omitempty"` - SSHKeyPath string `yaml:"sshKeyPath, omitempty" json:"sshKeyPath,omitempty"` - Role []string `yaml:"role" json:"role,omitempty" norman:"type=array[enum],options=etcd|master|worker|client"` - ID int `yaml:"omitempty" json:"-"` - IsEtcd bool `yaml:"omitempty"` - IsMaster bool `yaml:"omitempty"` - IsWorker bool `yaml:"omitempty"` - IsClient bool `yaml:"omitempty"` -} - -type Hosts struct { - Hosts []HostCfg -} - -func (cfg *ClusterCfg) GroupHosts() (*Hosts, *Hosts, *Hosts, *Hosts, *Hosts) { - allHosts := Hosts{} - etcdHosts := Hosts{} - masterHosts := Hosts{} - workerHosts := Hosts{} - k8sHosts := Hosts{} - - for _, host := range cfg.Hosts { - //clusterNode := HostCfg{} - for _, role := range host.Role { - if role == "etcd" { - host.IsEtcd = true - } - if role == "master" { - host.IsMaster = true - } - if role == "worker" { - host.IsWorker = true - } - } - if host.IsEtcd == true { - etcdHosts.Hosts = append(etcdHosts.Hosts, host) - } - if host.IsMaster == true { - masterHosts.Hosts = append(masterHosts.Hosts, host) - } - if host.IsWorker == true { - workerHosts.Hosts = append(workerHosts.Hosts, host) - } - if host.IsMaster == true || host.IsWorker == true { - k8sHosts.Hosts = append(k8sHosts.Hosts, host) - } - allHosts.Hosts = append(allHosts.Hosts, host) - } - return &allHosts, &etcdHosts, &masterHosts, &workerHosts, &k8sHosts -} diff --git a/apis/v1alpha1/register.go b/apis/v1alpha1/register.go deleted file mode 100644 index 3c2ef57b..00000000 --- a/apis/v1alpha1/register.go +++ /dev/null @@ -1,42 +0,0 @@ -package v1alpha1 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" -) - -// GroupName is the name of the group used by this API -const GroupName = "kubekey.io" - -// SchemeGroupVersion is group version used to register API objects -var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"} - -var ( - // SchemeBuilder points to a list of functions added to Scheme - SchemeBuilder runtime.SchemeBuilder - localSchemeBuilder = &SchemeBuilder - // AddToScheme applies all the stored functions to the Scheme - AddToScheme = localSchemeBuilder.AddToScheme -) - -func init() { - localSchemeBuilder.Register(addKnownTypes, addDefaultingFuncs) -} - -// Kind takes an unqualified kind and returns GroupKind -func Kind(kind string) schema.GroupKind { - return SchemeGroupVersion.WithKind(kind).GroupKind() -} - -// Resource takes an unqualified resource and returns GroupResource -func Resource(resource string) schema.GroupResource { - return SchemeGroupVersion.WithResource(resource).GroupResource() -} - -func addKnownTypes(scheme *runtime.Scheme) error { - scheme.AddKnownTypes(SchemeGroupVersion, - &ClusterCfg{}) - metav1.AddToGroupVersion(scheme, SchemeGroupVersion) - return nil -} diff --git a/cmd/create/config.go b/cmd/create/config.go index 7d6ebeb3..f81179c7 100644 --- a/cmd/create/config.go +++ b/cmd/create/config.go @@ -4,8 +4,8 @@ import ( "encoding/base64" "fmt" "github.com/lithammer/dedent" - "github.com/pixiake/kubekey/util" - "github.com/pixiake/kubekey/util/manager" + "github.com/pixiake/kubekey/pkg/util" + "github.com/pixiake/kubekey/pkg/util/manager" "github.com/pkg/errors" "os" "os/exec" diff --git a/install/executor.go b/install/executor.go index 188a234b..4b7a18a4 100644 --- a/install/executor.go +++ b/install/executor.go @@ -1,18 +1,18 @@ package install import ( - kubekeyapi "github.com/pixiake/kubekey/apis/v1alpha1" - "github.com/pixiake/kubekey/util/manager" - ssh "github.com/pixiake/kubekey/util/ssh" + kubekeyapi "github.com/pixiake/kubekey/pkg/apis/kubekey/v1alpha1" + "github.com/pixiake/kubekey/pkg/util/manager" + ssh "github.com/pixiake/kubekey/pkg/util/ssh" "github.com/sirupsen/logrus" ) type Executor struct { - cluster *kubekeyapi.ClusterCfg + cluster *kubekeyapi.K2ClusterSpec logger *logrus.Logger } -func NewExecutor(cluster *kubekeyapi.ClusterCfg, logger *logrus.Logger) *Executor { +func NewExecutor(cluster *kubekeyapi.K2ClusterSpec, logger *logrus.Logger) *Executor { return &Executor{ cluster: cluster, logger: logger, diff --git a/install/install.go b/install/install.go index 3143b819..559106ae 100644 --- a/install/install.go +++ b/install/install.go @@ -1,13 +1,13 @@ package install import ( - "github.com/pixiake/kubekey/cluster/container-engine/docker" - "github.com/pixiake/kubekey/cluster/etcd" - "github.com/pixiake/kubekey/cluster/kubernetes" - "github.com/pixiake/kubekey/cluster/preinstall" - "github.com/pixiake/kubekey/plugins/network" - "github.com/pixiake/kubekey/util/manager" - "github.com/pixiake/kubekey/util/task" + "github.com/pixiake/kubekey/pkg/cluster/container-engine/docker" + "github.com/pixiake/kubekey/pkg/cluster/etcd" + "github.com/pixiake/kubekey/pkg/cluster/kubernetes" + "github.com/pixiake/kubekey/pkg/cluster/preinstall" + "github.com/pixiake/kubekey/pkg/plugins/network" + "github.com/pixiake/kubekey/pkg/util/manager" + "github.com/pixiake/kubekey/pkg/util/task" "github.com/pkg/errors" ) diff --git a/pkg/apis/kubekey/v1alpha1/default.go b/pkg/apis/kubekey/v1alpha1/default.go new file mode 100644 index 00000000..960cbb1c --- /dev/null +++ b/pkg/apis/kubekey/v1alpha1/default.go @@ -0,0 +1,25 @@ +package v1alpha1 + +const ( + DefaultPreDir = "kubekey" + DefaultSSHPort = "22" + DefaultDockerSockPath = "/var/run/docker.sock" + DefaultLBPort = "6443" + DefaultLBDomain = "lb.kubesphere.local" + DefaultNetworkPlugin = "calico" + DefaultPodsCIDR = "10.233.64.0/18" + DefaultServiceCIDR = "10.233.0.0/18" + DefaultKubeImageRepo = "kubekey" + DefaultClusterName = "cluster.local" + DefaultArch = "amd64" + DefaultHostName = "allinone" + DefaultEtcdRepo = "kubekey/etcd" + DefaultEtcdVersion = "v3.3.12" + DefaultEtcdPort = "2379" + DefaultKubeVersion = "v1.17.4" + DefaultCniVersion = "v0.8.2" + DefaultHelmVersion = "v3.1.2" + ETCDRole = "etcd" + MasterRole = "master" + WorkerRole = "worker" +) diff --git a/cluster/cluster.go b/pkg/cluster/cluster.go similarity index 100% rename from cluster/cluster.go rename to pkg/cluster/cluster.go diff --git a/cluster/container-engine/docker/docker.go b/pkg/cluster/container-engine/docker/docker.go similarity index 79% rename from cluster/container-engine/docker/docker.go rename to pkg/cluster/container-engine/docker/docker.go index 9b127fe5..09dd2bae 100644 --- a/cluster/container-engine/docker/docker.go +++ b/pkg/cluster/container-engine/docker/docker.go @@ -1,9 +1,9 @@ package docker import ( - kubekeyapi "github.com/pixiake/kubekey/apis/v1alpha1" - "github.com/pixiake/kubekey/util/manager" - "github.com/pixiake/kubekey/util/ssh" + kubekeyapi "github.com/pixiake/kubekey/pkg/apis/kubekey/v1alpha1" + "github.com/pixiake/kubekey/pkg/util/manager" + "github.com/pixiake/kubekey/pkg/util/ssh" "github.com/pkg/errors" ) diff --git a/cluster/etcd/etcd.go b/pkg/cluster/etcd/etcd.go similarity index 97% rename from cluster/etcd/etcd.go rename to pkg/cluster/etcd/etcd.go index 88b715c4..9486fef4 100644 --- a/cluster/etcd/etcd.go +++ b/pkg/cluster/etcd/etcd.go @@ -3,10 +3,10 @@ package etcd import ( "encoding/base64" "fmt" - kubekeyapi "github.com/pixiake/kubekey/apis/v1alpha1" - "github.com/pixiake/kubekey/cluster/etcd/tmpl" - "github.com/pixiake/kubekey/util/manager" - "github.com/pixiake/kubekey/util/ssh" + kubekeyapi "github.com/pixiake/kubekey/pkg/apis/kubekey/v1alpha1" + "github.com/pixiake/kubekey/pkg/cluster/etcd/tmpl" + "github.com/pixiake/kubekey/pkg/util/manager" + "github.com/pixiake/kubekey/pkg/util/ssh" "github.com/pkg/errors" "strings" "time" diff --git a/cluster/etcd/tmpl/certs.go b/pkg/cluster/etcd/tmpl/certs.go similarity index 95% rename from cluster/etcd/tmpl/certs.go rename to pkg/cluster/etcd/tmpl/certs.go index ec8974ca..29543459 100644 --- a/cluster/etcd/tmpl/certs.go +++ b/pkg/cluster/etcd/tmpl/certs.go @@ -2,8 +2,8 @@ package tmpl import ( "github.com/lithammer/dedent" - kubekeyapi "github.com/pixiake/kubekey/apis/v1alpha1" - "github.com/pixiake/kubekey/util" + kubekeyapi "github.com/pixiake/kubekey/pkg/apis/kubekey/v1alpha1" + "github.com/pixiake/kubekey/pkg/util" "strings" "text/template" ) @@ -159,7 +159,7 @@ mv *.pem ${SSLDIR}/ `))) ) -func GenerateEtcdSslCfg(cfg *kubekeyapi.ClusterCfg) (string, error) { +func GenerateEtcdSslCfg(cfg *kubekeyapi.K2ClusterSpec) (string, error) { dnsList := []string{"localhost", "etcd.kube-system.svc.cluster.local", "etcd.kube-system.svc", "etcd.kube-system", "etcd"} ipList := []string{"127.0.0.1"} @@ -180,7 +180,7 @@ func GenerateEtcdSslCfg(cfg *kubekeyapi.ClusterCfg) (string, error) { }) } -func GenerateEtcdSslScript(cfg *kubekeyapi.ClusterCfg) (string, error) { +func GenerateEtcdSslScript(cfg *kubekeyapi.K2ClusterSpec) (string, error) { var masters []string var hosts []string _, etcdNodes, masterNodes, _, _ := cfg.GroupHosts() diff --git a/cluster/etcd/tmpl/etcd.go b/pkg/cluster/etcd/tmpl/etcd.go similarity index 95% rename from cluster/etcd/tmpl/etcd.go rename to pkg/cluster/etcd/tmpl/etcd.go index 442a58c3..92515983 100644 --- a/cluster/etcd/tmpl/etcd.go +++ b/pkg/cluster/etcd/tmpl/etcd.go @@ -3,9 +3,9 @@ package tmpl import ( "fmt" "github.com/lithammer/dedent" - kubekeyapi "github.com/pixiake/kubekey/apis/v1alpha1" - "github.com/pixiake/kubekey/util" - "github.com/pixiake/kubekey/util/manager" + kubekeyapi "github.com/pixiake/kubekey/pkg/apis/kubekey/v1alpha1" + "github.com/pixiake/kubekey/pkg/util" + "github.com/pixiake/kubekey/pkg/util/manager" "strings" "text/template" ) diff --git a/cluster/kubernetes/master.go b/pkg/cluster/kubernetes/master.go similarity index 97% rename from cluster/kubernetes/master.go rename to pkg/cluster/kubernetes/master.go index a549252e..8aaa3032 100644 --- a/cluster/kubernetes/master.go +++ b/pkg/cluster/kubernetes/master.go @@ -3,10 +3,10 @@ package kubernetes import ( "encoding/base64" "fmt" - kubekeyapi "github.com/pixiake/kubekey/apis/v1alpha1" - "github.com/pixiake/kubekey/cluster/kubernetes/tmpl" - "github.com/pixiake/kubekey/util/manager" - "github.com/pixiake/kubekey/util/ssh" + kubekeyapi "github.com/pixiake/kubekey/pkg/apis/kubekey/v1alpha1" + "github.com/pixiake/kubekey/pkg/cluster/kubernetes/tmpl" + "github.com/pixiake/kubekey/pkg/util/manager" + "github.com/pixiake/kubekey/pkg/util/ssh" "github.com/pkg/errors" "os" "os/exec" diff --git a/cluster/kubernetes/nodes.go b/pkg/cluster/kubernetes/nodes.go similarity index 93% rename from cluster/kubernetes/nodes.go rename to pkg/cluster/kubernetes/nodes.go index e671b149..795a32a1 100644 --- a/cluster/kubernetes/nodes.go +++ b/pkg/cluster/kubernetes/nodes.go @@ -3,10 +3,10 @@ package kubernetes import ( "encoding/base64" "fmt" - kubekeyapi "github.com/pixiake/kubekey/apis/v1alpha1" - "github.com/pixiake/kubekey/cluster/kubernetes/tmpl" - "github.com/pixiake/kubekey/util/manager" - "github.com/pixiake/kubekey/util/ssh" + kubekeyapi "github.com/pixiake/kubekey/pkg/apis/kubekey/v1alpha1" + "github.com/pixiake/kubekey/pkg/cluster/kubernetes/tmpl" + "github.com/pixiake/kubekey/pkg/util/manager" + "github.com/pixiake/kubekey/pkg/util/ssh" "github.com/pkg/errors" "os" "path/filepath" diff --git a/cluster/kubernetes/tmpl/kubeadm.go b/pkg/cluster/kubernetes/tmpl/kubeadm.go similarity index 95% rename from cluster/kubernetes/tmpl/kubeadm.go rename to pkg/cluster/kubernetes/tmpl/kubeadm.go index 96cd6e6f..c35a757b 100644 --- a/cluster/kubernetes/tmpl/kubeadm.go +++ b/pkg/cluster/kubernetes/tmpl/kubeadm.go @@ -3,9 +3,9 @@ package tmpl import ( "fmt" "github.com/lithammer/dedent" - kubekeyapi "github.com/pixiake/kubekey/apis/v1alpha1" - "github.com/pixiake/kubekey/util" - "github.com/pixiake/kubekey/util/manager" + kubekeyapi "github.com/pixiake/kubekey/pkg/apis/kubekey/v1alpha1" + "github.com/pixiake/kubekey/pkg/util" + "github.com/pixiake/kubekey/pkg/util/manager" "text/template" ) diff --git a/cluster/kubernetes/tmpl/kubelet.go b/pkg/cluster/kubernetes/tmpl/kubelet.go similarity index 85% rename from cluster/kubernetes/tmpl/kubelet.go rename to pkg/cluster/kubernetes/tmpl/kubelet.go index 609c1faa..a242834d 100644 --- a/cluster/kubernetes/tmpl/kubelet.go +++ b/pkg/cluster/kubernetes/tmpl/kubelet.go @@ -2,8 +2,8 @@ package tmpl import ( "github.com/lithammer/dedent" - kubekeyapi "github.com/pixiake/kubekey/apis/v1alpha1" - "github.com/pixiake/kubekey/util" + kubekeyapi "github.com/pixiake/kubekey/pkg/apis/kubekey/v1alpha1" + "github.com/pixiake/kubekey/pkg/util" "text/template" ) @@ -38,10 +38,10 @@ ExecStart=/usr/local/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $ `))) ) -func GenerateKubeletService(cfg *kubekeyapi.ClusterCfg) (string, error) { +func GenerateKubeletService(cfg *kubekeyapi.K2ClusterSpec) (string, error) { return util.Render(KubeletServiceTempl, util.Data{}) } -func GenerateKubeletEnv(cfg *kubekeyapi.ClusterCfg) (string, error) { +func GenerateKubeletEnv(cfg *kubekeyapi.K2ClusterSpec) (string, error) { return util.Render(KubeletEnvTempl, util.Data{}) } diff --git a/cluster/preinstall/initOS.go b/pkg/cluster/preinstall/initOS.go similarity index 86% rename from cluster/preinstall/initOS.go rename to pkg/cluster/preinstall/initOS.go index 47c99dc8..8e1ca2c5 100644 --- a/cluster/preinstall/initOS.go +++ b/pkg/cluster/preinstall/initOS.go @@ -3,10 +3,10 @@ package preinstall import ( "encoding/base64" "fmt" - kubekeyapi "github.com/pixiake/kubekey/apis/v1alpha1" - "github.com/pixiake/kubekey/cluster/preinstall/tmpl" - "github.com/pixiake/kubekey/util/manager" - "github.com/pixiake/kubekey/util/ssh" + kubekeyapi "github.com/pixiake/kubekey/pkg/apis/kubekey/v1alpha1" + "github.com/pixiake/kubekey/pkg/cluster/preinstall/tmpl" + "github.com/pixiake/kubekey/pkg/util/manager" + "github.com/pixiake/kubekey/pkg/util/ssh" "github.com/pkg/errors" ) diff --git a/cluster/preinstall/preinstall.go b/pkg/cluster/preinstall/preinstall.go similarity index 92% rename from cluster/preinstall/preinstall.go rename to pkg/cluster/preinstall/preinstall.go index 74d6d5ac..b6c20d65 100644 --- a/cluster/preinstall/preinstall.go +++ b/pkg/cluster/preinstall/preinstall.go @@ -2,8 +2,8 @@ package preinstall import ( "fmt" - kubekeyapi "github.com/pixiake/kubekey/apis/v1alpha1" - "github.com/pixiake/kubekey/util" + kubekeyapi "github.com/pixiake/kubekey/pkg/apis/kubekey/v1alpha1" + "github.com/pixiake/kubekey/pkg/util" "github.com/pkg/errors" log "github.com/sirupsen/logrus" "os" @@ -11,7 +11,7 @@ import ( "path/filepath" ) -func FilesDownloadHttp(cfg *kubekeyapi.ClusterCfg, filepath string, logger *log.Logger) error { +func FilesDownloadHttp(cfg *kubekeyapi.K2ClusterSpec, filepath string, logger *log.Logger) error { kubeVersion := cfg.KubeVersion kubeadmUrl := fmt.Sprintf("https://kubernetes-release.pek3b.qingstor.com/release/%s/bin/linux/%s/kubeadm", kubeVersion, kubekeyapi.DefaultArch) @@ -75,7 +75,7 @@ func FilesDownloadHttp(cfg *kubekeyapi.ClusterCfg, filepath string, logger *log. return nil } -func Prepare(cfg *kubekeyapi.ClusterCfg, logger *log.Logger) error { +func Prepare(cfg *kubekeyapi.K2ClusterSpec, logger *log.Logger) error { logger.Info("Install Files Download") currentDir, err := filepath.Abs(filepath.Dir(os.Args[0])) diff --git a/cluster/preinstall/tmpl/InitOS.go b/pkg/cluster/preinstall/tmpl/InitOS.go similarity index 93% rename from cluster/preinstall/tmpl/InitOS.go rename to pkg/cluster/preinstall/tmpl/InitOS.go index bf99188b..243c876b 100644 --- a/cluster/preinstall/tmpl/InitOS.go +++ b/pkg/cluster/preinstall/tmpl/InitOS.go @@ -2,8 +2,8 @@ package tmpl import ( "github.com/lithammer/dedent" - kubekeyapi "github.com/pixiake/kubekey/apis/v1alpha1" - "github.com/pixiake/kubekey/util" + kubekeyapi "github.com/pixiake/kubekey/pkg/apis/kubekey/v1alpha1" + "github.com/pixiake/kubekey/pkg/util" "text/template" ) @@ -72,7 +72,7 @@ cat >>/etc/hosts<