Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into release-3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
pixiake committed Jul 10, 2024
2 parents 7a184f7 + 21b8c5e commit 1415741
Show file tree
Hide file tree
Showing 45 changed files with 644 additions and 68 deletions.
9 changes: 9 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,15 @@
"contributions": [
"code"
]
},
{
"login": "knowmost",
"name": "knowmost",
"avatar_url": "https://avatars.githubusercontent.com/u/167442703?v=4",
"profile": "https://github.com/knowmost",
"contributions": [
"doc"
]
}
],
"contributorsPerLine": 7,
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ Contributions of any kind are welcome! Thanks goes to these wonderful contributo
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/xrwang8"><img src="https://avatars.githubusercontent.com/u/68765051?v=4?s=100" width="100px;" alt="Ronald Fletcher"/><br /><sub><b>Ronald Fletcher</b></sub></a><br /><a href="https://github.com/kubesphere/kubekey/commits?author=xrwang8" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/baikjy0215"><img src="https://avatars.githubusercontent.com/u/110450904?v=4?s=100" width="100px;" alt="baikjy0215"/><br /><sub><b>baikjy0215</b></sub></a><br /><a href="https://github.com/kubesphere/kubekey/commits?author=baikjy0215" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/knowmost"><img src="https://avatars.githubusercontent.com/u/167442703?v=4?s=100" width="100px;" alt="knowmost"/><br /><sub><b>knowmost</b></sub></a><br /><a href="https://github.com/kubesphere/kubekey/commits?author=knowmost" title="Documentation">📖</a></td>
</tr>
</tbody>
</table>
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/xrwang8"><img src="https://avatars.githubusercontent.com/u/68765051?v=4?s=100" width="100px;" alt="Ronald Fletcher"/><br /><sub><b>Ronald Fletcher</b></sub></a><br /><a href="https://github.com/kubesphere/kubekey/commits?author=xrwang8" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/baikjy0215"><img src="https://avatars.githubusercontent.com/u/110450904?v=4?s=100" width="100px;" alt="baikjy0215"/><br /><sub><b>baikjy0215</b></sub></a><br /><a href="https://github.com/kubesphere/kubekey/commits?author=baikjy0215" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/knowmost"><img src="https://avatars.githubusercontent.com/u/167442703?v=4?s=100" width="100px;" alt="knowmost"/><br /><sub><b>knowmost</b></sub></a><br /><a href="https://github.com/kubesphere/kubekey/commits?author=knowmost" title="Documentation">📖</a></td>
</tr>
</tbody>
</table>
Expand Down
1 change: 1 addition & 0 deletions README_zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ kubectl completion bash >/etc/bash_completion.d/kubectl
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/xrwang8"><img src="https://avatars.githubusercontent.com/u/68765051?v=4?s=100" width="100px;" alt="Ronald Fletcher"/><br /><sub><b>Ronald Fletcher</b></sub></a><br /><a href="https://github.com/kubesphere/kubekey/commits?author=xrwang8" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/baikjy0215"><img src="https://avatars.githubusercontent.com/u/110450904?v=4?s=100" width="100px;" alt="baikjy0215"/><br /><sub><b>baikjy0215</b></sub></a><br /><a href="https://github.com/kubesphere/kubekey/commits?author=baikjy0215" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/knowmost"><img src="https://avatars.githubusercontent.com/u/167442703?v=4?s=100" width="100px;" alt="knowmost"/><br /><sub><b>knowmost</b></sub></a><br /><a href="https://github.com/kubesphere/kubekey/commits?author=knowmost" title="Documentation">📖</a></td>
</tr>
</tbody>
</table>
Expand Down
12 changes: 7 additions & 5 deletions cmd/kk/apis/kubekey/v1alpha2/addons_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
package v1alpha2

type Addon struct {
Name string `yaml:"name" json:"name,omitempty"`
Namespace string `yaml:"namespace" json:"namespace,omitempty"`
Sources Sources `yaml:"sources" json:"sources,omitempty"`
Retries int `yaml:"retries" json:"retries,omitempty"`
Delay int `yaml:"delay" json:"delay,omitempty"`
Name string `yaml:"name" json:"name,omitempty"`
Namespace string `yaml:"namespace" json:"namespace,omitempty"`
PreInstall []CustomScripts `yaml:"preInstall" json:"preInstall,omitempty"`
Sources Sources `yaml:"sources" json:"sources,omitempty"`
PostInstall []CustomScripts `yaml:"postInstall" json:"postInstall,omitempty"`
Retries int `yaml:"retries" json:"retries,omitempty"`
Delay int `yaml:"delay" json:"delay,omitempty"`
}

type Sources struct {
Expand Down
16 changes: 9 additions & 7 deletions cmd/kk/apis/kubekey/v1alpha2/cluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,20 @@ type KubeVip struct {
type CustomScripts struct {
Name string `yaml:"name" json:"name,omitempty"`
Bash string `yaml:"bash" json:"bash,omitempty"`
Role string `yaml:"role" json:"role,omitempty"`
Materials []string `yaml:"materials" json:"materials,omitempty"`
}

// System defines the system config for each node in cluster.
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"`
PreInstall []CustomScripts `yaml:"preInstall" json:"preInstall,omitempty"`
PostInstall []CustomScripts `yaml:"postInstall" json:"postInstall,omitempty"`
SkipConfigureOS bool `yaml:"skipConfigureOS" json:"skipConfigureOS,omitempty"`
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"`
PreInstall []CustomScripts `yaml:"preInstall" json:"preInstall,omitempty"`
PostClusterInstall []CustomScripts `yaml:"postClusterInstall" json:"postClusterInstall,omitempty"`
PostInstall []CustomScripts `yaml:"postInstall" json:"postInstall,omitempty"`
SkipConfigureOS bool `yaml:"skipConfigureOS" json:"skipConfigureOS,omitempty"`
}

// RegistryConfig defines the configuration information of the image's repository.
Expand Down
1 change: 1 addition & 0 deletions cmd/kk/apis/kubekey/v1alpha2/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const (
DefaultEtcdPort = "2379"
DefaultDockerVersion = "24.0.9"
DefaultCriDockerdVersion = "0.3.10"
DefaultBuildxVersion = "v0.14.0"
DefaultContainerdVersion = "1.7.13"
DefaultRuncVersion = "v1.1.12"
DefaultCrictlVersion = "v1.29.0"
Expand Down
1 change: 1 addition & 0 deletions cmd/kk/apis/kubekey/v1alpha2/dns_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package v1alpha2

type DNS struct {
DNSEtcHosts string `yaml:"dnsEtcHosts" json:"dnsEtcHosts"`
NodeEtcHosts string `yaml:"nodeEtcHosts" json:"nodeEtcHosts,omitempty"`
CoreDNS CoreDNS `yaml:"coredns" json:"coredns"`
NodeLocalDNS NodeLocalDNS `yaml:"nodelocaldns" json:"nodelocaldns"`
}
Expand Down
1 change: 1 addition & 0 deletions cmd/kk/apis/kubekey/v1alpha2/manifest_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
type Iso struct {
LocalPath string `yaml:"localPath" json:"localPath"`
Url string `yaml:"url" json:"url"`
Checksum string `yaml:"checksum" json:"checksum"`
}

type Repository struct {
Expand Down
6 changes: 6 additions & 0 deletions cmd/kk/cmd/artifact/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ type ArtifactExportOptions struct {
Output string
CriSocket string
DownloadCmd string
ImageStartIndex int
ImageTransport string
SkipRemoveArtifact bool
}

Expand Down Expand Up @@ -80,6 +82,8 @@ func (o *ArtifactExportOptions) Run() error {
ManifestFile: o.ManifestFile,
Output: o.Output,
CriSocket: o.CriSocket,
ImageStartIndex: o.ImageStartIndex,
ImageTransport: o.ImageTransport,
Debug: o.CommonOptions.Verbose,
IgnoreErr: o.CommonOptions.IgnoreErr,
SkipRemoveArtifact: o.SkipRemoveArtifact,
Expand All @@ -93,6 +97,8 @@ func (o *ArtifactExportOptions) AddFlags(cmd *cobra.Command) {
cmd.Flags().StringVarP(&o.Output, "output", "o", "", "Path to a output path")
cmd.Flags().StringVarP(&o.DownloadCmd, "download-cmd", "", "curl -L -o %s %s",
`The user defined command to download the necessary binary files. The first param '%s' is output path, the second param '%s', is the URL`)
cmd.Flags().IntVarP(&o.ImageStartIndex, "image-start-index", "", 0, "Save images from specific index, default to 0")
cmd.Flags().StringVarP(&o.ImageTransport, "image-transport", "", "", "Image transport to pull from, take values from [docker, docker-daemon]")
cmd.Flags().BoolVarP(&o.SkipRemoveArtifact, "skip-remove-artifact", "", false, "Skip remove artifact")

}
16 changes: 10 additions & 6 deletions cmd/kk/cmd/artifact/images/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type ArtifactImagesPushOptions struct {
CommonOptions *options.CommonOptions

ImageDirPath string
ImageTransport string
Artifact string
ClusterCfgFile string
}
Expand Down Expand Up @@ -89,11 +90,12 @@ func (o *ArtifactImagesPushOptions) Validate(_ []string) error {

func (o *ArtifactImagesPushOptions) Run() error {
arg := common.Argument{
ImagesDir: o.ImageDirPath,
Artifact: o.Artifact,
FilePath: o.ClusterCfgFile,
Debug: o.CommonOptions.Verbose,
IgnoreErr: o.CommonOptions.IgnoreErr,
ImagesDir: o.ImageDirPath,
Artifact: o.Artifact,
FilePath: o.ClusterCfgFile,
ImageTransport: o.ImageTransport,
Debug: o.CommonOptions.Verbose,
IgnoreErr: o.CommonOptions.IgnoreErr,
}
return runPush(arg)
}
Expand All @@ -102,6 +104,7 @@ func (o *ArtifactImagesPushOptions) AddFlags(cmd *cobra.Command) {
cmd.Flags().StringVarP(&o.ImageDirPath, "images-dir", "", "", "Path to a KubeKey artifact images directory")
cmd.Flags().StringVarP(&o.Artifact, "artifact", "a", "", "Path to a KubeKey artifact")
cmd.Flags().StringVarP(&o.ClusterCfgFile, "filename", "f", "", "Path to a configuration file")
cmd.Flags().StringVarP(&o.ImageTransport, "image-transport", "", "", "Image transport to push to, take values from [docker, docker-daemon]")
}

func runPush(arg common.Argument) error {
Expand All @@ -122,7 +125,8 @@ func newImagesPushPipeline(runtime *common.KubeRuntime) error {

m := []module.Module{
&artifact.UnArchiveModule{Skip: noArtifact},
&images.CopyImagesToRegistryModule{ImagePath: runtime.Arg.ImagesDir},
&images.CopyImagesToRegistryModule{ImagePath: runtime.Arg.ImagesDir,
ImageTransport: runtime.Arg.ImageTransport},
&filesystem.ChownWorkDirModule{},
}

Expand Down
6 changes: 6 additions & 0 deletions cmd/kk/cmd/create/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@ type CreateClusterOptions struct {
EnableKubeSphere bool
KubeSphere string
LocalStorage bool
SkipInstallAddons bool
SkipPullImages bool
SkipPushImages bool
SecurityEnhancement bool
ContainerManager string
DownloadCmd string
Artifact string
InstallPackages bool
WithBuildx bool

localStorageChanged bool
}
Expand Down Expand Up @@ -112,6 +114,7 @@ func (o *CreateClusterOptions) Run() error {
KubernetesVersion: o.Kubernetes,
KsEnable: o.EnableKubeSphere,
KsVersion: o.KubeSphere,
SkipInstallAddons: o.SkipInstallAddons,
SkipPullImages: o.SkipPullImages,
SkipPushImages: o.SkipPushImages,
SecurityEnhancement: o.SecurityEnhancement,
Expand All @@ -122,6 +125,7 @@ func (o *CreateClusterOptions) Run() error {
Artifact: o.Artifact,
InstallPackages: o.InstallPackages,
Namespace: o.CommonOptions.Namespace,
WithBuildx: o.WithBuildx,
}

if o.localStorageChanged {
Expand All @@ -137,6 +141,7 @@ func (o *CreateClusterOptions) AddFlags(cmd *cobra.Command) {
cmd.Flags().StringVarP(&o.Kubernetes, "with-kubernetes", "", "", "Specify a supported version of kubernetes")
cmd.Flags().BoolVarP(&o.LocalStorage, "with-local-storage", "", false, "Deploy a local PV provisioner")
cmd.Flags().BoolVarP(&o.EnableKubeSphere, "with-kubesphere", "", false, fmt.Sprintf("Deploy a specific version of kubesphere (default %s)", kubesphere.Latest().Version))
cmd.Flags().BoolVarP(&o.SkipInstallAddons, "skip-install-addons", "", false, "Skip install addons")
cmd.Flags().BoolVarP(&o.SkipPullImages, "skip-pull-images", "", false, "Skip pre pull images")
cmd.Flags().BoolVarP(&o.SkipPushImages, "skip-push-images", "", false, "Skip pre push images")
cmd.Flags().BoolVarP(&o.SecurityEnhancement, "with-security-enhancement", "", false, "Security enhancement")
Expand All @@ -145,6 +150,7 @@ func (o *CreateClusterOptions) AddFlags(cmd *cobra.Command) {
`The user defined command to download the necessary binary files. The first param '%s' is output path, the second param '%s', is the URL`)
cmd.Flags().StringVarP(&o.Artifact, "artifact", "a", "", "Path to a KubeKey artifact")
cmd.Flags().BoolVarP(&o.InstallPackages, "with-packages", "", false, "install operation system packages by artifact")
cmd.Flags().BoolVarP(&o.WithBuildx, "with-buildx", "", false, "install buildx when Container runtime is docker")
}

func completionSetting(cmd *cobra.Command) (err error) {
Expand Down
49 changes: 49 additions & 0 deletions cmd/kk/cmd/create/phase/addons.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package phase

import (
"github.com/spf13/cobra"

"github.com/kubesphere/kubekey/v3/cmd/kk/cmd/options"
"github.com/kubesphere/kubekey/v3/cmd/kk/cmd/util"
"github.com/kubesphere/kubekey/v3/cmd/kk/pkg/common"
"github.com/kubesphere/kubekey/v3/cmd/kk/pkg/phase/addons"
)

type ApplyAddonsOptions struct {
CommonOptions *options.CommonOptions
ClusterCfgFile string
}

func NewApplyAddonsOptions() *ApplyAddonsOptions {
return &ApplyAddonsOptions{
CommonOptions: options.NewCommonOptions(),
}
}

func NewCmdApplyAddons() *cobra.Command {
o := NewApplyAddonsOptions()
cmd := &cobra.Command{
Use: "addons",
Short: "Apply cluster addons",
Run: func(cmd *cobra.Command, args []string) {
util.CheckErr(o.Run(args))
},
}

o.CommonOptions.AddCommonFlag(cmd)
o.AddFlags(cmd)
return cmd
}

func (o *ApplyAddonsOptions) Run(args []string) error {
arg := common.Argument{
FilePath: o.ClusterCfgFile,
Debug: o.CommonOptions.Verbose,
EnabledAddons: args,
}
return addons.ApplyClusterAddons(arg)
}

func (o *ApplyAddonsOptions) AddFlags(cmd *cobra.Command) {
cmd.Flags().StringVarP(&o.ClusterCfgFile, "filename", "f", "", "Path to a configuration file")
}
2 changes: 1 addition & 1 deletion cmd/kk/cmd/create/phase/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func NewCreateInitClusterOptions() *CreateInitClusterOptions {
}
}

// NewCmdUpgrade creates a new upgrade command
// NewCmdCreateInitCluster creates a new upgrade command
func NewCmdCreateInitCluster() *cobra.Command {
o := NewCreateInitClusterOptions()
cmd := &cobra.Command{
Expand Down
1 change: 1 addition & 0 deletions cmd/kk/cmd/create/phase/phase.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func NewPhaseCommand() *cobra.Command {
cmds.AddCommand(NewCmdCreateJoinNodes())
cmds.AddCommand(NewCmdCreateConfigureKubernetes())
cmds.AddCommand(NewCmdCreateKubeSphere())
cmds.AddCommand(NewCmdApplyAddons())

return cmds
}
2 changes: 1 addition & 1 deletion cmd/kk/cmd/upgrade/phase/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func NewUpgradeImagesOptions() *UpgradeImagesOptions {
}
}

// NewCmdUpgrade creates a new upgrade command
// NewCmdUpgradeImages creates a new upgrade command
func NewCmdUpgradeImages() *cobra.Command {
o := NewUpgradeImagesOptions()
cmd := &cobra.Command{
Expand Down
2 changes: 1 addition & 1 deletion cmd/kk/cmd/upgrade/phase/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func NewUpgradeNodesOptions() *UpgradeNodesOptions {
}
}

// NewCmdUpgrade creates a new upgrade command
// NewCmdUpgradeNodes creates a new upgrade command
func NewCmdUpgradeNodes() *cobra.Command {
o := NewUpgradeNodesOptions()
cmd := &cobra.Command{
Expand Down
23 changes: 23 additions & 0 deletions cmd/kk/pkg/addons/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
package addons

import (
"fmt"

kubekeyapiv1alpha2 "github.com/kubesphere/kubekey/v3/cmd/kk/apis/kubekey/v1alpha2"
"github.com/kubesphere/kubekey/v3/cmd/kk/pkg/common"
"github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/task"
)
Expand Down Expand Up @@ -44,3 +47,23 @@ func (a *AddonsModule) Init() {
install,
}
}

type AddonModule struct {
common.KubeModule
addon *kubekeyapiv1alpha2.Addon
}

func (s *AddonModule) Init() {
s.Name = "AddonModule"
s.Desc = fmt.Sprintf("Install addon %s", s.addon.Name)

install := &task.LocalTask{
Name: "InstallAddon",
Desc: fmt.Sprintf("Install addon %s", s.addon.Name),
Action: &InstallAddon{addon: s.addon},
}

s.Tasks = []task.Interface{
install,
}
}
Loading

0 comments on commit 1415741

Please sign in to comment.