Merge pull request #251 from zhangguanzhang/develop

init命令增加IPIP选项
This commit is contained in:
steven
2020-03-25 11:39:54 +08:00
committed by GitHub
8 changed files with 52 additions and 27 deletions
+2
View File
@@ -54,4 +54,6 @@ func init() {
initCmd.Flags().BoolVar(&install.WithoutCNI, "without-cni", false, "If true we not install cni plugin")
initCmd.Flags().StringVar(&install.Network, "network", "calico", "cni plugin, calico..")
initCmd.Flags().BoolVar(&install.IPIP, "ipip", true, "ipip mode enable, calico..")
initCmd.Flags().StringVar(&install.MTU, "mtu", "1440", "mtu of the ipip mode , calico..")
}
+3 -1
View File
@@ -56,7 +56,9 @@ func (c *SealConfig) Dump(path string) {
logger.Warn("create default sealos config dir failed, please create it by your self mkdir -p /root/.sealos && touch /root/.sealos/config.yaml")
}
ioutil.WriteFile(path, y, 0644)
if err = ioutil.WriteFile(path, y, 0644); err != nil{
logger.Warn("write to file %s failed: %s", path, err)
}
}
func Dump(path string, content interface{}) error {
+7 -1
View File
@@ -83,7 +83,13 @@ func (s *SealosInstaller) InstallMaster0() {
return
}
//cmd = `kubectl apply -f /root/kube/conf/net/calico.yaml || true`
netyaml := net.NewNetwork(Network, net.MetaData{Interface: Interface, CIDR: PodCIDR}).Manifests("")
netyaml := net.NewNetwork(Network, net.MetaData{
Interface: Interface,
CIDR: PodCIDR,
IPIP:IPIP,
MTU: MTU,
}).Manifests("")
logger.Info("calico yaml is : \n", netyaml)
cmd = fmt.Sprintf(`echo '%s' | kubectl apply -f -`, netyaml)
output = SSHConfig.Cmd(s.Masters[0], cmd)
+4
View File
@@ -24,6 +24,10 @@ var (
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)?)$")
+2 -2
View File
@@ -38,7 +38,7 @@ data:
calico_backend: "bird"
# Configure the MTU to use
veth_mtu: "1440"
veth_mtu: "{{ .MTU }}"
# The CNI network configuration to install on each node. The special
# values in this config will be automatically populated.
@@ -630,7 +630,7 @@ spec:
value: "interface={{ .Interface }}"
# Enable IPIP
- name: CALICO_IPV4POOL_IPIP
value: "Always"
value: "{{if not .IPIP }}Off{{else}}Always{{end}}"
# Set MTU for tunnel device used if ipip is enabled
- name: FELIX_IPINIPMTU
valueFrom:
+22 -22
View File
@@ -72,7 +72,7 @@ spec:
rule: 'RunAsAny'
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1beta1
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: flannel
rules:
@@ -101,7 +101,7 @@ rules:
- patch
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: flannel
roleRef:
@@ -194,7 +194,7 @@ spec:
serviceAccountName: flannel
initContainers:
- name: install-cni
image: quay.io/coreos/flannel:v0.11.0-amd64
image: quay.io.azk8s.cn/coreos/flannel:v0.11.0-amd64
command:
- cp
args:
@@ -208,7 +208,7 @@ spec:
mountPath: /etc/kube-flannel/
containers:
- name: kube-flannel
image: quay.io/coreos/flannel:v0.11.0-amd64
image: quay.io.azk8s.cn/coreos/flannel:v0.11.0-amd64
command:
- /opt/bin/flanneld
args:
@@ -220,8 +220,8 @@ spec:
cpu: "100m"
memory: "50Mi"
limits:
cpu: "100m"
memory: "50Mi"
cpu: "200m"
memory: "100Mi"
securityContext:
privileged: false
capabilities:
@@ -289,7 +289,7 @@ spec:
serviceAccountName: flannel
initContainers:
- name: install-cni
image: quay.io/coreos/flannel:v0.11.0-arm64
image: quay.io.azk8s.cn/coreos/flannel:v0.11.0-arm64
command:
- cp
args:
@@ -303,7 +303,7 @@ spec:
mountPath: /etc/kube-flannel/
containers:
- name: kube-flannel
image: quay.io/coreos/flannel:v0.11.0-arm64
image: quay.io.azk8s.cn/coreos/flannel:v0.11.0-arm64
command:
- /opt/bin/flanneld
args:
@@ -315,8 +315,8 @@ spec:
cpu: "100m"
memory: "50Mi"
limits:
cpu: "100m"
memory: "50Mi"
cpu: "200m"
memory: "100Mi"
securityContext:
privileged: false
capabilities:
@@ -384,7 +384,7 @@ spec:
serviceAccountName: flannel
initContainers:
- name: install-cni
image: quay.io/coreos/flannel:v0.11.0-arm
image: quay.io.azk8s.cn/coreos/flannel:v0.11.0-arm
command:
- cp
args:
@@ -398,7 +398,7 @@ spec:
mountPath: /etc/kube-flannel/
containers:
- name: kube-flannel
image: quay.io/coreos/flannel:v0.11.0-arm
image: quay.io.azk8s.cn/coreos/flannel:v0.11.0-arm
command:
- /opt/bin/flanneld
args:
@@ -410,8 +410,8 @@ spec:
cpu: "100m"
memory: "50Mi"
limits:
cpu: "100m"
memory: "50Mi"
cpu: "200m"
memory: "100Mi"
securityContext:
privileged: false
capabilities:
@@ -479,7 +479,7 @@ spec:
serviceAccountName: flannel
initContainers:
- name: install-cni
image: quay.io/coreos/flannel:v0.11.0-ppc64le
image: quay.io.azk8s.cn/coreos/flannel:v0.11.0-ppc64le
command:
- cp
args:
@@ -493,7 +493,7 @@ spec:
mountPath: /etc/kube-flannel/
containers:
- name: kube-flannel
image: quay.io/coreos/flannel:v0.11.0-ppc64le
image: quay.io.azk8s.cn/coreos/flannel:v0.11.0-ppc64le
command:
- /opt/bin/flanneld
args:
@@ -505,8 +505,8 @@ spec:
cpu: "100m"
memory: "50Mi"
limits:
cpu: "100m"
memory: "50Mi"
cpu: "200m"
memory: "100Mi"
securityContext:
privileged: false
capabilities:
@@ -574,7 +574,7 @@ spec:
serviceAccountName: flannel
initContainers:
- name: install-cni
image: quay.io/coreos/flannel:v0.11.0-s390x
image: quay.io.azk8s.cn/coreos/flannel:v0.11.0-s390x
command:
- cp
args:
@@ -588,7 +588,7 @@ spec:
mountPath: /etc/kube-flannel/
containers:
- name: kube-flannel
image: quay.io/coreos/flannel:v0.11.0-s390x
image: quay.io.azk8s.cn/coreos/flannel:v0.11.0-s390x
command:
- /opt/bin/flanneld
args:
@@ -600,8 +600,8 @@ spec:
cpu: "100m"
memory: "50Mi"
limits:
cpu: "100m"
memory: "50Mi"
cpu: "200m"
memory: "100Mi"
securityContext:
privileged: false
capabilities:
+6
View File
@@ -15,8 +15,13 @@ const (
type MetaData struct {
Interface string
CIDR string
// ipip mode for calico.yml
IPIP bool
// MTU size
MTU string
}
// Net is CNI interface
type Net interface {
// if template is "" using default template
@@ -25,6 +30,7 @@ type Net interface {
Template() string
}
func NewNetwork(t string, metadata MetaData) Net {
switch t {
case CALICO:
+6 -1
View File
@@ -6,6 +6,11 @@ import (
)
func TestNewNetwork(t *testing.T) {
netyaml := NewNetwork("calico", MetaData{Interface:"en.*|eth.*",CIDR:"10.1.1.1/24"}).Manifests("")
netyaml := NewNetwork("calico", MetaData{
Interface:"en.*|eth.*",
CIDR:"10.1.1.1/24",
IPIP: true,
MTU: "1440",
}).Manifests("")
fmt.Println(netyaml)
}