mirror of
https://github.com/kubesphere/kubekey.git
synced 2025-12-26 01:22:51 +00:00
Merge pull request #1524 from kuops/master
feat: Add rpms and debs support.
This commit is contained in:
commit
a1c21de38d
|
|
@ -15,8 +15,8 @@ limitations under the License.
|
|||
*/
|
||||
|
||||
// Package v1alpha1 contains API Schema definitions for the kubekey v1alpha1 API group
|
||||
//+kubebuilder:object:generate=true
|
||||
//+groupName=kubekey.kubesphere.io
|
||||
// +kubebuilder:object:generate=true
|
||||
// +groupName=kubekey.kubesphere.io
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
|
|
|
|||
|
|
@ -173,6 +173,8 @@ type KubeVip struct {
|
|||
type System struct {
|
||||
NtpServers []string `yaml:"ntpServers" json:"ntpServers,omitempty"`
|
||||
Timezone string `yaml:"timezone" json:"timezone,omitempty"`
|
||||
Rpms []string `yaml:"rpms" json:"rpms,omitempty"`
|
||||
Debs []string `yaml:"debs" json:"debs,omitempty"`
|
||||
}
|
||||
|
||||
// RegistryConfig defines the configuration information of the image's repository.
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@
|
|||
*/
|
||||
|
||||
// Package v1alpha2 contains API Schema definitions for the kubekey v1alpha2 API group
|
||||
//+kubebuilder:object:generate=true
|
||||
//+groupName=kubekey.kubesphere.io
|
||||
// +kubebuilder:object:generate=true
|
||||
// +groupName=kubekey.kubesphere.io
|
||||
package v1alpha2
|
||||
|
||||
import (
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ func NewCmdCreateCluster() *cobra.Command {
|
|||
|
||||
o.CommonOptions.AddCommonFlag(cmd)
|
||||
o.AddFlags(cmd)
|
||||
|
||||
if err := completionSetting(cmd); err != nil {
|
||||
panic(fmt.Sprintf("Got error with the completion setting"))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,8 +18,9 @@ package repository
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/kubesphere/kubekey/pkg/core/connector"
|
||||
"strings"
|
||||
|
||||
"github.com/kubesphere/kubekey/pkg/core/connector"
|
||||
)
|
||||
|
||||
type Debian struct {
|
||||
|
|
@ -74,8 +75,11 @@ func (d *Debian) Update(runtime connector.Runtime) error {
|
|||
}
|
||||
|
||||
func (d *Debian) Install(runtime connector.Runtime, pkg ...string) error {
|
||||
defaultPkg := []string{"socat", "conntrack", "ipset", "ebtables", "chrony", "ipvsadm"}
|
||||
if len(pkg) == 0 {
|
||||
pkg = []string{"socat", "conntrack", "ipset", "ebtables", "chrony", "ipvsadm"}
|
||||
pkg = defaultPkg
|
||||
} else {
|
||||
pkg = append(pkg, defaultPkg...)
|
||||
}
|
||||
|
||||
str := strings.Join(pkg, " ")
|
||||
|
|
|
|||
|
|
@ -18,8 +18,9 @@ package repository
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/kubesphere/kubekey/pkg/core/connector"
|
||||
"strings"
|
||||
|
||||
"github.com/kubesphere/kubekey/pkg/core/connector"
|
||||
)
|
||||
|
||||
type RedhatPackageManager struct {
|
||||
|
|
@ -82,8 +83,11 @@ func (r *RedhatPackageManager) Update(runtime connector.Runtime) error {
|
|||
}
|
||||
|
||||
func (r *RedhatPackageManager) Install(runtime connector.Runtime, pkg ...string) error {
|
||||
defaultPkg := []string{"openssl", "socat", "conntrack", "ipset", "ebtables", "chrony", "ipvsadm"}
|
||||
if len(pkg) == 0 {
|
||||
pkg = []string{"openssl", "socat", "conntrack", "ipset", "ebtables", "chrony", "ipvsadm"}
|
||||
pkg = defaultPkg
|
||||
} else {
|
||||
pkg = append(pkg, defaultPkg...)
|
||||
}
|
||||
|
||||
str := strings.Join(pkg, " ")
|
||||
|
|
|
|||
|
|
@ -404,7 +404,14 @@ func (i *InstallPackage) Execute(runtime connector.Runtime) error {
|
|||
}
|
||||
r := repo.(repository.Interface)
|
||||
|
||||
if installErr := r.Install(runtime); installErr != nil {
|
||||
var pkg []string
|
||||
if _, ok := r.(*repository.Debian); ok {
|
||||
pkg = i.KubeConf.Cluster.System.Debs
|
||||
} else if _, ok := r.(*repository.RedhatPackageManager); ok {
|
||||
pkg = i.KubeConf.Cluster.System.Rpms
|
||||
}
|
||||
|
||||
if installErr := r.Install(runtime, pkg...); installErr != nil {
|
||||
return errors.Wrap(errors.WithStack(installErr), "install repository package failed")
|
||||
}
|
||||
return nil
|
||||
|
|
|
|||
Loading…
Reference in New Issue