Merge pull request #1524 from kuops/master

feat: Add rpms and debs support.
This commit is contained in:
KubeSphere CI Bot 2022-09-26 13:04:21 +08:00 committed by GitHub
commit a1c21de38d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 27 additions and 9 deletions

View File

@ -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 (

View File

@ -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.

View File

@ -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 (

View File

@ -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"))
}

View File

@ -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, " ")

View File

@ -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, " ")

View File

@ -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