Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
cff88e0
Update common.go
clcc2019 Nov 1, 2023
9b3776e
Update common.go
clcc2019 Mar 25, 2024
3c791d1
Update local.go skip tls verify
clcc2019 Apr 22, 2024
e78975f
Update local.go
clcc2019 Apr 22, 2024
4366a58
Update rollback.go
clcc2019 Aug 29, 2024
11825cd
Update upgrade.go
clcc2019 Aug 29, 2024
83a5297
Update host-alias.go
clcc2019 Aug 29, 2024
91623fa
Update installer.go
clcc2019 Aug 29, 2024
2c73e17
Update common.go
clcc2019 Sep 18, 2024
d2c54b9
Update common.go
clcc2019 Sep 18, 2024
1d76880
Update release.yml
clcc2019 Sep 18, 2024
e4181c5
Update common.go
clcc2019 Sep 18, 2024
4180d5d
Update release.yml
clcc2019 Sep 18, 2024
ed43e76
Update local.go
clcc2019 Sep 23, 2024
5fe2653
Update common.go
clcc2019 Sep 23, 2024
3019844
Update local.go
clcc2019 Sep 23, 2024
dbaceef
Update utils.go
clcc2019 Sep 23, 2024
d167011
Update local.go
clcc2019 Sep 23, 2024
ac494ba
fix(common): 更新 LvsCare 镜像路径并优化配置
clcc2019 Dec 24, 2024
cec2250
Update local.go
clcc2019 Jan 13, 2025
9f32cb9
Update local.go
clcc2019 Jan 13, 2025
c1ce891
Update local.go
clcc2019 Jan 13, 2025
d5447d4
Update local.go
clcc2019 Jan 13, 2025
a907107
Update local.go
clcc2019 Jan 13, 2025
244c485
Update local.go
clcc2019 Jan 13, 2025
40830df
Update common.go
clcc2019 Jan 13, 2025
cd233d8
fix(registry): 更新 lvscare 镜像地址并简化配置流程
clcc2019 Jan 13, 2025
db9eae2
refactor(cluster-runtime): 优化 LoadToRegistry 函数
clcc2019 Mar 5, 2025
6ff0cc0
fix(installer): 修复单节点集群安装问题
clcc2019 Mar 5, 2025
3486768
fix(installer): 修复无工作节点时的安装问题
clcc2019 Mar 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
echo "${{steps.drafter.outputs.body}}" >> release_note.md

- name: Save release notes
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: sealer-release-notes
path: src/github.com/sealerio/sealer/release_note.md
Expand Down Expand Up @@ -94,7 +94,7 @@ jobs:
working-directory: src/github.com/sealerio/sealer

- name: Save build binaries
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: sealer-binaries
path: src/github.com/sealerio/sealer/_output/assets/*.tar.gz*
Expand All @@ -108,7 +108,7 @@ jobs:

steps:
- name: Download builds and release notes
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
with:
path: builds
- name: Create Release
Expand All @@ -131,4 +131,4 @@ jobs:
releasever="${releasever#refs/tags/}"
wget http://gosspublic.alicdn.com/ossutil/1.6.19/ossutil64 && chmod 755 ossutil64 &&
./ossutil64 -i ${{ secrets.ACCESSKEYID }} -k ${{ secrets.ACCESSKEYSECRET }} -e oss-cn-shanghai.aliyuncs.com cp -rf ./builds/sealer-binaries/sealer-$releasever-linux-amd64.tar.gz oss://sealerio/releases/sealer-$releasever-linux-amd64.tar.gz &&
./ossutil64 -i ${{ secrets.ACCESSKEYID }} -k ${{ secrets.ACCESSKEYSECRET }} -e oss-cn-shanghai.aliyuncs.com cp -rf ./builds/sealer-binaries/sealer-$releasever-linux-arm64.tar.gz oss://sealerio/releases/sealer-$releasever-linux-arm64.tar.gz
./ossutil64 -i ${{ secrets.ACCESSKEYID }} -k ${{ secrets.ACCESSKEYSECRET }} -e oss-cn-shanghai.aliyuncs.com cp -rf ./builds/sealer-binaries/sealer-$releasever-linux-arm64.tar.gz oss://sealerio/releases/sealer-$releasever-linux-arm64.tar.gz
2 changes: 1 addition & 1 deletion cmd/sealer/cmd/alpha/host-alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func NewHostAliasCmd() *cobra.Command {

cf.SetCluster(desiredCluster)

return cf.SaveAll(clusterfile.SaveOptions{CommitToCluster: true})
return cf.SaveAll(clusterfile.SaveOptions{CommitToCluster: false})
},
}
cmd.Flags().StringVar(&hostAlias.IP, "ip", "", "host-alias ip")
Expand Down
43 changes: 33 additions & 10 deletions cmd/sealer/cmd/cluster/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (i AppInstaller) Install(imageName string, options AppInstallOptions) error
//save and commit
i.cf.SetApplication(i.appDriver.GetApplication())
confPath := clusterruntime.GetClusterConfPath(i.imageExtension.Labels)
if err := i.cf.SaveAll(clusterfile.SaveOptions{CommitToCluster: true, ConfPath: confPath}); err != nil {
if err := i.cf.SaveAll(clusterfile.SaveOptions{CommitToCluster: false, ConfPath: confPath}); err != nil {
return err
}

Expand Down Expand Up @@ -142,6 +142,11 @@ func (i AppInstaller) prepareMaterials(appImageName string, mode string, ignoreC
}

masters := i.infraDriver.GetHostIPListByRole(common.MASTER)

if len(masters) < 1 {
return fmt.Errorf("no deploy hosts found in the cluster")
}

regConfig := i.infraDriver.GetClusterRegistry()
// distribute rootfs

Expand All @@ -153,9 +158,21 @@ func (i AppInstaller) prepareMaterials(appImageName string, mode string, ignoreC
if regConfig.LocalRegistry == nil {
return nil
}
deployHosts := masters

deployHosts := i.infraDriver.GetHostIPListByRole(common.NODE)

if len(deployHosts) < 1 {
deployHosts = i.infraDriver.GetHostIPListByRole(common.MASTER)
}

if len(deployHosts) < 1 {
return fmt.Errorf("no deploy hosts found in the cluster")
}

node0 := deployHosts[0]

if !*regConfig.LocalRegistry.HA {
deployHosts = []net.IP{masters[0]}
deployHosts = []net.IP{node0}
}

registryConfigurator, err := registry.NewConfigurator(deployHosts,
Expand Down Expand Up @@ -350,7 +367,7 @@ func (k KubeInstaller) Install(kubeImageName string, options KubeInstallOptions)

//save and commit
confPath := clusterruntime.GetClusterConfPath(k.imageSpec.ImageExtension.Labels)
if err = k.cf.SaveAll(clusterfile.SaveOptions{CommitToCluster: true, ConfPath: confPath}); err != nil {
if err = k.cf.SaveAll(clusterfile.SaveOptions{CommitToCluster: false, ConfPath: confPath}); err != nil {
return err
}

Expand Down Expand Up @@ -436,7 +453,7 @@ func (k KubeInstaller) ScaleUp(scaleUpMasterIPList, scaleUpNodeIPList []net.IP,
}

confPath := clusterruntime.GetClusterConfPath(k.imageSpec.ImageExtension.Labels)
if err = k.cf.SaveAll(clusterfile.SaveOptions{CommitToCluster: true, ConfPath: confPath}); err != nil {
if err = k.cf.SaveAll(clusterfile.SaveOptions{CommitToCluster: false, ConfPath: confPath}); err != nil {
return err
}

Expand Down Expand Up @@ -519,7 +536,7 @@ func (k KubeInstaller) ScaleDown(deleteMasterIPList, deleteNodeIPList []net.IP,
k.cf.SetCluster(cluster)

confPath := clusterruntime.GetClusterConfPath(k.imageSpec.ImageExtension.Labels)
if err = k.cf.SaveAll(clusterfile.SaveOptions{CommitToCluster: true, ConfPath: confPath}); err != nil {
if err = k.cf.SaveAll(clusterfile.SaveOptions{CommitToCluster: false, ConfPath: confPath}); err != nil {
return err
}

Expand Down Expand Up @@ -652,15 +669,21 @@ func loadToRegistry(infraDriver infradriver.InfraDriver, distributor imagedistri
return nil
}

deployHosts := infraDriver.GetHostIPListByRole(common.MASTER)
deployHosts := infraDriver.GetHostIPListByRole(common.NODE)

if len(deployHosts) < 1 {
return fmt.Errorf("local registry host can not be nil")
deployHosts = infraDriver.GetHostIPListByRole(common.MASTER)
}
master0 := deployHosts[0]

if len(deployHosts) < 1 {
return fmt.Errorf("no deploy hosts found in the cluster")
}

node0 := deployHosts[0]

logrus.Infof("start to apply with mode(%s)", common.ApplyModeLoadImage)
if !*regConfig.LocalRegistry.HA {
deployHosts = []net.IP{master0}
deployHosts = []net.IP{node0}
}

if err := distributor.DistributeRegistry(deployHosts, filepath.Join(infraDriver.GetClusterRootfsPath(), "registry")); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/sealer/cmd/cluster/rollback.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func rollbackCluster(cf clusterfile.Interface, imageEngine imageengine.Interface
}

//save and commit
if err = cf.SaveAll(clusterfile.SaveOptions{CommitToCluster: true, ConfPath: confPath}); err != nil {
if err = cf.SaveAll(clusterfile.SaveOptions{CommitToCluster: false, ConfPath: confPath}); err != nil {
return err
}

Expand Down
5 changes: 2 additions & 3 deletions cmd/sealer/cmd/cluster/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ import (

var (
exampleForUpgradeCmd = `
sealer upgrade docker.io/sealerio/kubernetes:v1.22.15-upgrade
sealer upgrade -f Clusterfile
sealer upgrade -f upgrade.yaml
`
longDescriptionForUpgradeCmd = `upgrade command is used to upgrade a Kubernetes cluster via specified Clusterfile.`
)
Expand Down Expand Up @@ -209,7 +208,7 @@ func upgradeCluster(cf clusterfile.Interface, imageEngine imageengine.Interface,
}

//save and commit
if err = cf.SaveAll(clusterfile.SaveOptions{CommitToCluster: true, ConfPath: confPath}); err != nil {
if err = cf.SaveAll(clusterfile.SaveOptions{CommitToCluster: false, ConfPath: confPath}); err != nil {
return err
}

Expand Down
2 changes: 1 addition & 1 deletion common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const (
KubeLvsCareStaticPodName = "kube-lvscare"
RegLvsCareStaticPodName = "reg-lvscare"
StaticPodDir = "/etc/kubernetes/manifests"
LvsCareRepoAndTag = "sealerio/lvscare:v1.1.3-beta.8"
LvsCareRepoAndTag = "docker-cdv5ju.swr-pro.myhuaweicloud.com/global/lvscare:latest"
)

// Envs
Expand Down
12 changes: 10 additions & 2 deletions pkg/cluster-runtime/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,18 @@ func (i *Installer) Install() error {
var (
masters = i.infraDriver.GetHostIPListByRole(common.MASTER)
master0 = masters[0]
nodes = i.infraDriver.GetHostIPListByRole(common.NODE)
node0 net.IP
workers = getWorkerIPList(i.infraDriver)
all = append(masters, workers...)
rootfs = i.infraDriver.GetClusterRootfsPath()
)

if len(nodes) == 0 {
node0 = master0
} else {
node0 = nodes[0]
}

// set HostAlias
if err := i.infraDriver.SetClusterHostAliases(all); err != nil {
Expand Down Expand Up @@ -173,12 +181,12 @@ func (i *Installer) Install() error {
if i.regConfig.LocalRegistry != nil {
installer := registry.NewInstaller(nil, i.regConfig.LocalRegistry, i.infraDriver, i.Distributor)
if *i.regConfig.LocalRegistry.HA {
deployHosts, err = installer.Reconcile(masters)
deployHosts, err = installer.Reconcile(workers)
if err != nil {
return err
}
} else {
deployHosts, err = installer.Reconcile([]net.IP{master0})
deployHosts, err = installer.Reconcile([]net.IP{node0})
if err != nil {
return err
}
Expand Down
28 changes: 21 additions & 7 deletions pkg/cluster-runtime/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,27 +48,41 @@ func getWorkerIPList(infraDriver infradriver.InfraDriver) []net.IP {
// LoadToRegistry just load container image to local registry
func LoadToRegistry(infraDriver infradriver.InfraDriver, distributor imagedistributor.Distributor) error {
regConfig := infraDriver.GetClusterRegistry()
// todo only support load image to local registry at present

// Check if local registry configuration exists
if regConfig.LocalRegistry == nil {
logrus.Warn("No local registry configured, skipping load.")
return nil
}

deployHosts := infraDriver.GetHostIPListByRole(common.MASTER)
// Get the list of hosts by role
deployHosts := infraDriver.GetHostIPListByRole(common.NODE)

if len(deployHosts) < 1 {
return fmt.Errorf("local registry host can not be nil")
deployHosts = infraDriver.GetHostIPListByRole(common.MASTER)
}
master0 := deployHosts[0]

logrus.Infof("start to apply with mode(%s)", common.ApplyModeLoadImage)
if len(deployHosts) < 1 {
return fmt.Errorf("no deploy hosts found in the cluster")
}

node01 := deployHosts[0]

logrus.Infof("Starting image load with mode: %s", common.ApplyModeLoadImage)

// If HA mode is not enabled, restrict to a single node (node01)
if !*regConfig.LocalRegistry.HA {
deployHosts = []net.IP{master0}
logrus.Infof("HA mode is not enabled, limiting image load to node: %s", node01)
deployHosts = []net.IP{node01}
}

// Distribute the image to the registry
if err := distributor.DistributeRegistry(deployHosts, filepath.Join(infraDriver.GetClusterRootfsPath(), "registry")); err != nil {
logrus.Errorf("Failed to distribute registry: %v", err)
return err
}

logrus.Infof("load image success")
logrus.Infof("Image loaded successfully")
return nil
}

Expand Down
30 changes: 15 additions & 15 deletions pkg/registry/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"fmt"
"net"
"os"
"path"
"path/filepath"
"sort"
"strconv"
Expand Down Expand Up @@ -131,9 +130,9 @@ func (c *localConfigurator) InstallOn(masters, nodes []net.IP) error {
return err
}

if err := c.configureAccessCredential(hosts); err != nil {
return err
}
// if err := c.configureAccessCredential(hosts); err != nil {
// return err
// }

return nil
}
Expand All @@ -147,11 +146,11 @@ func (c *localConfigurator) configureRegistryNetwork(masters, nodes []net.IP) er

eg, _ := errgroup.WithContext(context.Background())

for i := range masters {
master := masters[i]
for i := range nodes {
node := nodes[i]
eg.Go(func() error {
cmd := shellcommand.CommandSetHostAlias(c.Domain, master.String())
if err := c.infraDriver.CmdAsync(master, nil, cmd); err != nil {
cmd := shellcommand.CommandSetHostAlias(c.Domain, node.String())
if err := c.infraDriver.CmdAsync(node, nil, cmd); err != nil {
return fmt.Errorf("failed to config masters hosts file: %v", err)
}
return nil
Expand Down Expand Up @@ -181,7 +180,7 @@ func (c *localConfigurator) configureLvs(registryHosts, clientHosts []net.IP) er
}

//todo should make lvs image name as const value in sealer repo.
lvsImageURL := path.Join(net.JoinHostPort(c.Domain, strconv.Itoa(c.Port)), common.LvsCareRepoAndTag)
lvsImageURL := common.LvsCareRepoAndTag

vip := GetRegistryVIP(c.infraDriver)

Expand Down Expand Up @@ -378,7 +377,7 @@ func (c *localConfigurator) configureDockerDaemonService(endpoint, daemonFile st
}
}

daemonConf.RegistryMirrors = append(daemonConf.RegistryMirrors, "https://"+endpoint)
daemonConf.RegistryMirrors = append(daemonConf.RegistryMirrors, "http://"+endpoint)

content, err := json.MarshalIndent(daemonConf, "", " ")

Expand All @@ -391,15 +390,15 @@ func (c *localConfigurator) configureDockerDaemonService(endpoint, daemonFile st

func (c *localConfigurator) configureContainerdDaemonService(endpoint, hostTomlFile string) error {
var (
caFile = c.Domain + ".crt"
registryCaCertPath = filepath.Join(c.containerRuntimeInfo.CertsDir, endpoint, caFile)
url = "https://" + endpoint
// caFile = c.Domain + ".crt"
// registryCaCertPath = filepath.Join(c.containerRuntimeInfo.CertsDir, endpoint, caFile)
url = "http://" + endpoint
)

cfg := Hosts{
Server: url,
HostConfigs: map[string]HostFileConfig{
url: {CACert: registryCaCertPath},
url: {SkipServerVerify: true},
},
}

Expand All @@ -424,7 +423,8 @@ type HostFileConfig struct {
// Accepted types
// - string - Single file with certificate(s)
// - []string - Multiple files with certificates
CACert interface{} `toml:"ca"`
// CACert interface{} `toml:"ca"`
SkipServerVerify bool `toml:"skip_verify"`
}

type DaemonConfig struct {
Expand Down
6 changes: 1 addition & 5 deletions pkg/runtime/kubernetes/kubeadm/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ networking:
serviceSubnet: 10.96.0.0/22
apiServer:
extraArgs:
feature-gates: TTLAfterFinished=true,EphemeralContainers=true
audit-policy-file: "/etc/kubernetes/audit-policy.yml"
audit-log-path: "/var/log/kubernetes/audit.log"
audit-log-format: json
Expand All @@ -65,17 +64,14 @@ apiServer:
pathType: File
controllerManager:
extraArgs:
feature-gates: TTLAfterFinished=true,EphemeralContainers=true
experimental-cluster-signing-duration: 876000h
cluster-signing-duration: 876000h
extraVolumes:
- hostPath: /etc/localtime
mountPath: /etc/localtime
name: localtime
readOnly: true
pathType: File
scheduler:
extraArgs:
feature-gates: TTLAfterFinished=true,EphemeralContainers=true
extraVolumes:
- hostPath: /etc/localtime
mountPath: /etc/localtime
Expand Down
3 changes: 1 addition & 2 deletions pkg/runtime/kubernetes/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"context"
"fmt"
"net"
"path"
"sort"
"strconv"
"strings"
Expand Down Expand Up @@ -187,7 +186,7 @@ func GetClientFromConfig(adminConfPath string) (runtimeClient.Client, error) {
}

func (k *Runtime) configureLvs(masterHosts, clientHosts []net.IP) error {
lvsImageURL := path.Join(k.Config.RegistryInfo.URL, common.LvsCareRepoAndTag)
lvsImageURL := common.LvsCareRepoAndTag

var rs []string
var realEndpoints []string
Expand Down
Loading