install

package
v3.3.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 6, 2020 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const TemplateText = string(`apiVersion: kubeadm.k8s.io/v1beta1
kind: ClusterConfiguration
kubernetesVersion: {{.Version}}
controlPlaneEndpoint: "{{.ApiServer}}:6443"
imageRepository: {{.Repo}}
networking:
  # dnsDomain: cluster.local
  podSubnet: {{.PodCIDR}}
  serviceSubnet: {{.SvcCIDR}}
apiServer:
  certSANs:
  - 127.0.0.1
  - {{.ApiServer}}
  {{range .Masters -}}
  - {{.}}
  {{end -}}
  - {{.VIP}}
  extraArgs:
    feature-gates: TTLAfterFinished=true
  extraVolumes:
  - name: localtime
    hostPath: /etc/localtime
    mountPath: /etc/localtime
    readOnly: true
    pathType: File
controllerManager:
  extraArgs:
    feature-gates: TTLAfterFinished=true
    experimental-cluster-signing-duration: 876000h
  extraVolumes:
  - hostPath: /etc/localtime
    mountPath: /etc/localtime
    name: localtime
    readOnly: true
    pathType: File
scheduler:
  extraArgs:
    feature-gates: TTLAfterFinished=true
  extraVolumes:
  - hostPath: /etc/localtime
    mountPath: /etc/localtime
    name: localtime
    readOnly: true
    pathType: File
---
apiVersion: kubeproxy.config.k8s.io/v1alpha1
kind: KubeProxyConfiguration
mode: "ipvs"
ipvs:
  excludeCIDRs: 
  - "{{.VIP}}/32"`)

Variables

View Source
var (
	VersionURL string
	URLmap     map[string]string
	DefaultURL = "https://sealyun.oss-cn-beijing.aliyuncs.com/37374d999dbadb788ef0461844a70151-1.16.0/kube1.16.0.tar.gz"
)

VersionURL is base64 encode k8s version and offline package url

View Source
var (
	JoinToken       string
	TokenCaCertHash string
	CertificateKey  string
)
View Source
var (
	MasterIPs []string
	NodeIPs   []string
	//config from kubeadm.cfg
	DnsDomain         string
	ApiServerCertSANs []string
	//
	SSHConfig sshutil.SSH
	ApiServer string
	//cert abs path
	CertPath     = "/root/.sealos/pki"
	CertEtcdPath = "/root/.sealos/pki/etcd"

	VIP     string
	PkgUrl  string
	Version string
	Repo    string
	PodCIDR string
	SvcCIDR string

	//
	Ipvs         care.LvsCare
	LvscareImage ipvs.LvscareImage
	KubeadmFile  string
	// network type, calico or flannel etc..
	Network string
	// if true don't install cni plugin
	WithoutCNI bool
	//network interface name, like "eth.*|en.*"
	Interface string
	// the ipip mode of the calico
	IPIP bool
	// mtu size
	MTU string

	YesRx = regexp.MustCompile("^(?i:y(?:es)?)$")

	CleanForce bool
	CleanAll   bool
)
View Source
var ClusterDir = "/root/.sealos/clusters/"
View Source
var ConfigType string

Functions

func AppInstall

func AppInstall(url string)

AppInstall is

func BuildClean

func BuildClean(deleteNodes, deleteMasters []string)

BuildClean is

func BuildInit

func BuildInit()

BuildInit is

func BuildJoin

func BuildJoin(joinMasters, joinNodes []string)

BuildJoin is

func CloudInstall

func CloudInstall(c *Cluster)

2019.11.28 今天刚修完陪产假,在新装修的公寓中写代码,刚配的眼镜感觉带着有点不舒服,看屏幕不是很清楚

配眼镜的人也不是很专业,二宝还是个女儿,非常可爱而且非常乖,不像大宝那么吵。 一直很想写日记但是不知道往哪里写合适
既然github要把代码存两千年那为啥不写到代码里,如此这便成为我第一篇代码日记。

碳纤维地暖开了半天还是冰凉的,感觉是被忽悠了。

一写代码就精神万分,一搞管理上的杂事就效率很低,所以做技术还是要专注些。

func CmdWorkSpace

func CmdWorkSpace(node, cmd, workdir string)

func Cmp

func Cmp(a, b net.IP) int

Cmp compares two IPs, returning the usual ordering: a < b : -1 a == b : 0 a > b : 1

func Config

func Config()

func Confirm

func Confirm(prompt string) bool

send the prompt and get result

func DecodeIPs

func DecodeIPs(ips []string) []string

func Dump

func Dump(path string, content interface{}) error

func Exec

func Exec(c *PkgConfig, config SealConfig)

func FetchSealosAbsPath

func FetchSealosAbsPath() string

获取sealos绝对路径

func GetConfirmResult

func GetConfirmResult(str string) bool

like y|yes|Y|YES return true

func GetRemoteHostName

func GetRemoteHostName(hostIP string) string

func IpFormat

func IpFormat(host string) string

IpFormat is

func Load

func Load(path string, content interface{}) error

func NewCommands

func NewCommands(cmds []Command) (Runner, Runner)

return command run on every nodes and run only on master node

func NextIP

func NextIP(ip net.IP) net.IP

NextIP returns IP incremented by 1

func ParseIPs

func ParseIPs(ips []string) []string

ParseIPs 解析ip 192.168.0.2-192.168.0.6

func RandString

func RandString(len int) string

RandString 生成随机字符串

func SendPackage

func SendPackage(location string, hosts []string, dst string, before, after *string) string

location : url md5 dst: /root hook: cd /root && rm -rf kube && tar zxvf %s && cd /root/kube/shell && sh init.sh

func SliceRemoveStr

func SliceRemoveStr(ss []string, s string) (result []string)

func Template

func Template() []byte

Template is

func TemplateFromTemplateContent

func TemplateFromTemplateContent(templateContent string) []byte

func VersionToInt

func VersionToInt(version string) int

VersionToInt v1.15.6 => 115

Types

type Apply

type Apply interface {
	KubeApply(name string)
}

type Check

type Check interface {
	CheckValid()
}

type Clean

type Clean interface {
	Clean()
}

Clean is

type CleanCluster

type CleanCluster interface {
	Check
	Clean
}

type Cluster

type Cluster struct {
	cloud.Config
	Flags
	Name            string
	Masters         []cloud.VM
	Nodes           []cloud.VM
	VPCID           string
	SwitchID        string
	SecuretyGroupID string
}

Cluster is cluster metadata

var C Cluster

Global config

type Command

type Command struct {
	Name string // LOAD START APPLY DELETE STOP REMOVE
	Cmd  string // kubectl apply -k
	Type string
}

Command is

type CommandType

type CommandType string
const InitMaster CommandType = "initMaster"

command type

const JoinMaster CommandType = "joinMaster"
const JoinNode CommandType = "joinNode"

type Flags

type Flags struct {
	Master      int
	MasterType  string
	Node        int
	NodeType    string
	Version     string
	Flavor      string
	Passwd      string
	Zone        string
	Interaction bool
	Image       string
}

Flags is command line paras

type Init

type Init interface {
	Check
	Send
	PreInit
	Join
	Print
}

type Install

type Install interface {
	Check
	Send
	Apply
}

type Join

type Join interface {
	JoinMasters()
	JoinNodes()
	GeneratorToken()
}

Join is

type JoinNodeAndMaster

type JoinNodeAndMaster interface {
	Check
	Send
	Join
}

type KubeadmType

type KubeadmType struct {
	Kind      string `yaml:"kind,omitempty"`
	ApiServer struct {
		CertSANs []string `yaml:"certSANs,omitempty"`
	} `yaml:"apiServer"`
	Networking struct {
		DnsDomain string `yaml:"dnsDomain,omitempty"`
	} `yaml:"networking"`
}

func KubeadmDataFromYaml

func KubeadmDataFromYaml(context string) *KubeadmType

根据yaml转换kubeadm结构

type PkgConfig

type PkgConfig struct {
	Cmds []Command
	URL  string
	Name string
}

func LoadConfig

func LoadConfig(packageFile string) (*PkgConfig, error)

LoadConfig from tar package

kube.tar

config
images.tar

config content:

LOAD docker load -i images.tar START systemctl start docker DELETE docker rmi STOP systemctl top APPLY kubectl apply -f

type PreInit

type PreInit interface {
	KubeadmConfigInstall()
	InstallMaster0()
}

PreInit is

type Print

type Print interface {
	Print(process ...string)
}

Print is

type RunOnEveryNodes

type RunOnEveryNodes struct {
	Cmd []Command
}

func (*RunOnEveryNodes) Run

func (r *RunOnEveryNodes) Run(config SealConfig, url, pkgName string)

type RunOnMaster

type RunOnMaster struct {
	Cmd []Command
}

func (*RunOnMaster) Run

func (r *RunOnMaster) Run(config SealConfig, url, pkgName string)

type Runner

type Runner interface {
	Run(config SealConfig, url, pkgName string)
}

type SealConfig

type SealConfig struct {
	Masters []string
	Nodes   []string
	//config from kubeadm.cfg. ex. cluster.local
	DnsDomain         string
	ApiServerCertSANs []string

	//SSHConfig
	User       string
	Passwd     string
	PrivateKey string
	//ApiServer ex. apiserver.cluster.local
	ApiServerDomian string

	VIP     string
	PkgURL  string
	Version string
	Repo    string
	PodCIDR string
	SvcCIDR string
	//certs location
	CertPath     string
	CertEtcdPath string
	//lvscare images
	LvscareName string
	LvscareTag  string
}

SealConfig for ~/.sealos/config.yaml

func (*SealConfig) Dump

func (c *SealConfig) Dump(path string)

Dump is

func (*SealConfig) Load

func (c *SealConfig) Load(path string) (err error)

Load is

func (*SealConfig) ShowDefaultConfig

func (c *SealConfig) ShowDefaultConfig()

type SealosClean

type SealosClean struct {
	SealosInstaller
	// contains filtered or unexported fields
}

func (*SealosClean) Clean

func (s *SealosClean) Clean()

CleanCluster is

type SealosInstaller

type SealosInstaller struct {
	Hosts   []string
	Masters []string
	Nodes   []string
}

SealosInstaller is

func (*SealosInstaller) CheckValid

func (s *SealosInstaller) CheckValid()

CheckValid is

func (*SealosInstaller) Command

func (s *SealosInstaller) Command(version string, name CommandType) (cmd string)

func (*SealosInstaller) CreateKubeconfig

func (s *SealosInstaller) CreateKubeconfig()

func (*SealosInstaller) GenerateCert

func (s *SealosInstaller) GenerateCert()

func (*SealosInstaller) GeneratorCerts

func (s *SealosInstaller) GeneratorCerts()

GeneratorToken is 这里主要是为了获取CertificateKey

func (*SealosInstaller) GeneratorToken

func (s *SealosInstaller) GeneratorToken()

GeneratorToken is

func (*SealosInstaller) InstallMaster0

func (s *SealosInstaller) InstallMaster0()

InstallMaster0 is

func (*SealosInstaller) JoinMasters

func (s *SealosInstaller) JoinMasters(masters []string)

JoinMasters is

func (*SealosInstaller) JoinNodes

func (s *SealosInstaller) JoinNodes()

JoinNodes is

func (*SealosInstaller) KubeadmConfigInstall

func (s *SealosInstaller) KubeadmConfigInstall()

KubeadmConfigInstall is

func (*SealosInstaller) Print

func (s *SealosInstaller) Print(process ...string)

Print is

func (*SealosInstaller) PrintFinish

func (s *SealosInstaller) PrintFinish()

func (*SealosInstaller) SendKubeConfigs

func (s *SealosInstaller) SendKubeConfigs(masters []string, isMaster0 bool)

SendKubeConfigs

func (*SealosInstaller) SendPackage

func (s *SealosInstaller) SendPackage()

SendPackage is

type Send

type Send interface {
	SendPackage()
}

Send is

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL