Skip to content

Commit

Permalink
feat(develop): lvscare版本支持
Browse files Browse the repository at this point in the history
  • Loading branch information
cuisongliu committed Apr 15, 2020
1 parent 5c619eb commit e4f8baf
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 11 deletions.
3 changes: 3 additions & 0 deletions cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ func init() {
initCmd.Flags().BoolVar(&install.IPIP, "ipip", true, "ipip mode enable, calico..")
initCmd.Flags().StringVar(&install.MTU, "mtu", "1440", "mtu of the ipip mode , calico..")

initCmd.Flags().StringVar(&install.LvscareImage.Image, "lvscare-image", "fanux/lvscare", "lvscare image name")
initCmd.Flags().StringVar(&install.LvscareImage.Tag, "lvscare-tag", "v1.0.0", "lvscare image tag name")

// 不像用户暴露
// initCmd.Flags().StringVar(&install.CertPath, "cert-path", "/root/.sealos/pki", "cert file path")
// initCmd.Flags().StringVar(&install.CertEtcdPath, "cert-etcd-path", "/root/.sealos/pki/etcd", "etcd cert file path")
Expand Down
14 changes: 11 additions & 3 deletions install/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ type SealConfig struct {
//certs location
CertPath string
CertEtcdPath string
//lvscare images
LvscareName string
LvscareTag string
}

//Dump is
Expand Down Expand Up @@ -62,7 +65,9 @@ func (c *SealConfig) Dump(path string) {
c.ApiServerCertSANs = ApiServerCertSANs
c.CertPath = CertPath
c.CertEtcdPath = CertEtcdPath

//lvscare
c.LvscareName = LvscareImage.Image
c.LvscareTag = LvscareImage.Tag
y, err := yaml.Marshal(c)
if err != nil {
logger.Error("dump config file failed: %s", err)
Expand Down Expand Up @@ -104,12 +109,12 @@ func (c *SealConfig) Load(path string) (err error) {

y, err := ioutil.ReadFile(path)
if err != nil {
return fmt.Errorf("read config file %s failed %w",path,err)
return fmt.Errorf("read config file %s failed %w", path, err)
}

err = yaml.Unmarshal(y, c)
if err != nil {
return fmt.Errorf("unmarshal config file failed: %w",err)
return fmt.Errorf("unmarshal config file failed: %w", err)
}

MasterIPs = c.Masters
Expand All @@ -129,6 +134,9 @@ func (c *SealConfig) Load(path string) (err error) {
ApiServerCertSANs = c.ApiServerCertSANs
CertPath = c.CertPath
CertEtcdPath = c.CertEtcdPath
//lvscare
LvscareImage.Image = c.LvscareName
LvscareImage.Tag = c.LvscareTag
return
}

Expand Down
6 changes: 4 additions & 2 deletions install/vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package install

import (
"github.com/fanux/lvscare/care"
"github.com/fanux/sealos/ipvs"
"github.com/fanux/sealos/pkg/sshcmd/sshutil"
"regexp"
)
Expand All @@ -27,8 +28,9 @@ var (
SvcCIDR string

//
Ipvs care.LvsCare
KubeadmFile string
Ipvs care.LvsCare
LvscareImage ipvs.LvscareImage
KubeadmFile string
// network type, calico or flannel etc..
Network string
// if true don't install cni plugin
Expand Down
16 changes: 10 additions & 6 deletions ipvs/lvscare.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,17 @@ import (
"strings"
)

const defaultImage = "fanux/lvscare:latest"
type LvscareImage struct {
Image string
Tag string
}

func (l *LvscareImage) toImageName() string {
return l.Image + ":" + l.Tag
}

// return lvscare static pod yaml
func LvsStaticPodYaml(vip string, masters []string, image string) string {
if image == "" {
image = defaultImage
}
func LvsStaticPodYaml(vip string, masters []string, image LvscareImage) string {
if vip == "" || len(masters) == 0 {
return ""
}
Expand All @@ -31,7 +35,7 @@ func LvsStaticPodYaml(vip string, masters []string, image string) string {
flag := true
pod := componentPod(v1.Container{
Name: "kube-sealyun-lvscare",
Image: image,
Image: image.toImageName(),
Command: []string{"/usr/bin/lvscare"},
Args: args,
ImagePullPolicy: v1.PullIfNotPresent,
Expand Down

0 comments on commit e4f8baf

Please sign in to comment.