mirror of
https://github.com/rancher/rke.git
synced 2025-07-03 18:47:58 +00:00
Extend rke to tolerate the Windows host
1. Support to configure Flannel as "host-gw" backend 2. Define the network component yaml and ingress controller yaml only schedule to non-Windows node 3. Support to configure Docker container's port publishing
This commit is contained in:
parent
dffc2b9443
commit
bcb6e13618
@ -190,6 +190,14 @@ func (c *Cluster) setClusterNetworkDefaults() {
|
|||||||
networkPluginConfigDefaultsMap = map[string]string{
|
networkPluginConfigDefaultsMap = map[string]string{
|
||||||
CalicoCloudProvider: DefaultNetworkCloudProvider,
|
CalicoCloudProvider: DefaultNetworkCloudProvider,
|
||||||
}
|
}
|
||||||
|
case FlannelNetworkPlugin:
|
||||||
|
networkPluginConfigDefaultsMap = map[string]string{
|
||||||
|
FlannelBackendType: "vxlan",
|
||||||
|
}
|
||||||
|
case CanalNetworkPlugin:
|
||||||
|
networkPluginConfigDefaultsMap = map[string]string{
|
||||||
|
CanalFlannelBackendType: "vxlan",
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if c.Network.CalicoNetworkProvider != nil {
|
if c.Network.CalicoNetworkProvider != nil {
|
||||||
setDefaultIfEmpty(&c.Network.CalicoNetworkProvider.CloudProvider, DefaultNetworkCloudProvider)
|
setDefaultIfEmpty(&c.Network.CalicoNetworkProvider.CloudProvider, DefaultNetworkCloudProvider)
|
||||||
@ -197,6 +205,7 @@ func (c *Cluster) setClusterNetworkDefaults() {
|
|||||||
}
|
}
|
||||||
if c.Network.FlannelNetworkProvider != nil {
|
if c.Network.FlannelNetworkProvider != nil {
|
||||||
networkPluginConfigDefaultsMap[FlannelIface] = c.Network.FlannelNetworkProvider.Iface
|
networkPluginConfigDefaultsMap[FlannelIface] = c.Network.FlannelNetworkProvider.Iface
|
||||||
|
|
||||||
}
|
}
|
||||||
if c.Network.CanalNetworkProvider != nil {
|
if c.Network.CanalNetworkProvider != nil {
|
||||||
networkPluginConfigDefaultsMap[CanalIface] = c.Network.CanalNetworkProvider.Iface
|
networkPluginConfigDefaultsMap[CanalIface] = c.Network.CanalNetworkProvider.Iface
|
||||||
|
@ -40,12 +40,14 @@ const (
|
|||||||
|
|
||||||
FlannelNetworkPlugin = "flannel"
|
FlannelNetworkPlugin = "flannel"
|
||||||
FlannelIface = "flannel_iface"
|
FlannelIface = "flannel_iface"
|
||||||
|
FlannelBackendType = "flannel_backend_type"
|
||||||
|
|
||||||
CalicoNetworkPlugin = "calico"
|
CalicoNetworkPlugin = "calico"
|
||||||
CalicoCloudProvider = "calico_cloud_provider"
|
CalicoCloudProvider = "calico_cloud_provider"
|
||||||
|
|
||||||
CanalNetworkPlugin = "canal"
|
CanalNetworkPlugin = "canal"
|
||||||
CanalIface = "canal_iface"
|
CanalIface = "canal_iface"
|
||||||
|
CanalFlannelBackendType = "canal_flannel_backend_type"
|
||||||
|
|
||||||
WeaveNetworkPlugin = "weave"
|
WeaveNetworkPlugin = "weave"
|
||||||
|
|
||||||
@ -83,6 +85,7 @@ const (
|
|||||||
Calicoctl = "Calicoctl"
|
Calicoctl = "Calicoctl"
|
||||||
|
|
||||||
FlannelInterface = "FlannelInterface"
|
FlannelInterface = "FlannelInterface"
|
||||||
|
FlannelBackend = "FlannelBackend"
|
||||||
CanalInterface = "CanalInterface"
|
CanalInterface = "CanalInterface"
|
||||||
RBACConfig = "RBACConfig"
|
RBACConfig = "RBACConfig"
|
||||||
)
|
)
|
||||||
@ -121,12 +124,15 @@ func (c *Cluster) deployNetworkPlugin(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Cluster) doFlannelDeploy(ctx context.Context) error {
|
func (c *Cluster) doFlannelDeploy(ctx context.Context) error {
|
||||||
flannelConfig := map[string]string{
|
flannelConfig := map[string]interface{}{
|
||||||
ClusterCIDR: c.ClusterCIDR,
|
ClusterCIDR: c.ClusterCIDR,
|
||||||
Image: c.SystemImages.Flannel,
|
Image: c.SystemImages.Flannel,
|
||||||
CNIImage: c.SystemImages.FlannelCNI,
|
CNIImage: c.SystemImages.FlannelCNI,
|
||||||
FlannelInterface: c.Network.Options[FlannelIface],
|
FlannelInterface: c.Network.Options[FlannelIface],
|
||||||
RBACConfig: c.Authorization.Mode,
|
FlannelBackend: map[string]interface{}{
|
||||||
|
"Type": c.Network.Options[FlannelBackendType],
|
||||||
|
},
|
||||||
|
RBACConfig: c.Authorization.Mode,
|
||||||
}
|
}
|
||||||
pluginYaml, err := c.getNetworkPluginManifest(flannelConfig)
|
pluginYaml, err := c.getNetworkPluginManifest(flannelConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -137,7 +143,7 @@ func (c *Cluster) doFlannelDeploy(ctx context.Context) error {
|
|||||||
|
|
||||||
func (c *Cluster) doCalicoDeploy(ctx context.Context) error {
|
func (c *Cluster) doCalicoDeploy(ctx context.Context) error {
|
||||||
clientConfig := pki.GetConfigPath(pki.KubeNodeCertName)
|
clientConfig := pki.GetConfigPath(pki.KubeNodeCertName)
|
||||||
calicoConfig := map[string]string{
|
calicoConfig := map[string]interface{}{
|
||||||
KubeCfg: clientConfig,
|
KubeCfg: clientConfig,
|
||||||
ClusterCIDR: c.ClusterCIDR,
|
ClusterCIDR: c.ClusterCIDR,
|
||||||
CNIImage: c.SystemImages.CalicoCNI,
|
CNIImage: c.SystemImages.CalicoCNI,
|
||||||
@ -155,7 +161,7 @@ func (c *Cluster) doCalicoDeploy(ctx context.Context) error {
|
|||||||
|
|
||||||
func (c *Cluster) doCanalDeploy(ctx context.Context) error {
|
func (c *Cluster) doCanalDeploy(ctx context.Context) error {
|
||||||
clientConfig := pki.GetConfigPath(pki.KubeNodeCertName)
|
clientConfig := pki.GetConfigPath(pki.KubeNodeCertName)
|
||||||
canalConfig := map[string]string{
|
canalConfig := map[string]interface{}{
|
||||||
ClientCertPath: pki.GetCertPath(pki.KubeNodeCertName),
|
ClientCertPath: pki.GetCertPath(pki.KubeNodeCertName),
|
||||||
APIRoot: "https://127.0.0.1:6443",
|
APIRoot: "https://127.0.0.1:6443",
|
||||||
ClientKeyPath: pki.GetKeyPath(pki.KubeNodeCertName),
|
ClientKeyPath: pki.GetKeyPath(pki.KubeNodeCertName),
|
||||||
@ -167,6 +173,9 @@ func (c *Cluster) doCanalDeploy(ctx context.Context) error {
|
|||||||
CanalFlannelImg: c.SystemImages.CanalFlannel,
|
CanalFlannelImg: c.SystemImages.CanalFlannel,
|
||||||
RBACConfig: c.Authorization.Mode,
|
RBACConfig: c.Authorization.Mode,
|
||||||
CanalInterface: c.Network.Options[CanalIface],
|
CanalInterface: c.Network.Options[CanalIface],
|
||||||
|
FlannelBackend: map[string]interface{}{
|
||||||
|
"Type": c.Network.Options[CanalFlannelBackendType],
|
||||||
|
},
|
||||||
}
|
}
|
||||||
pluginYaml, err := c.getNetworkPluginManifest(canalConfig)
|
pluginYaml, err := c.getNetworkPluginManifest(canalConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -176,7 +185,7 @@ func (c *Cluster) doCanalDeploy(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Cluster) doWeaveDeploy(ctx context.Context) error {
|
func (c *Cluster) doWeaveDeploy(ctx context.Context) error {
|
||||||
weaveConfig := map[string]string{
|
weaveConfig := map[string]interface{}{
|
||||||
ClusterCIDR: c.ClusterCIDR,
|
ClusterCIDR: c.ClusterCIDR,
|
||||||
Image: c.SystemImages.WeaveNode,
|
Image: c.SystemImages.WeaveNode,
|
||||||
CNIImage: c.SystemImages.WeaveCNI,
|
CNIImage: c.SystemImages.WeaveCNI,
|
||||||
@ -190,7 +199,7 @@ func (c *Cluster) doWeaveDeploy(ctx context.Context) error {
|
|||||||
return c.doAddonDeploy(ctx, pluginYaml, NetworkPluginResourceName, true)
|
return c.doAddonDeploy(ctx, pluginYaml, NetworkPluginResourceName, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Cluster) getNetworkPluginManifest(pluginConfig map[string]string) (string, error) {
|
func (c *Cluster) getNetworkPluginManifest(pluginConfig map[string]interface{}) (string, error) {
|
||||||
switch c.Network.Plugin {
|
switch c.Network.Plugin {
|
||||||
case FlannelNetworkPlugin:
|
case FlannelNetworkPlugin:
|
||||||
return templates.CompileTemplateFromMap(templates.FlannelTemplate, pluginConfig)
|
return templates.CompileTemplateFromMap(templates.FlannelTemplate, pluginConfig)
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types/container"
|
"github.com/docker/docker/api/types/container"
|
||||||
|
"github.com/docker/go-connections/nat"
|
||||||
"github.com/rancher/rke/docker"
|
"github.com/rancher/rke/docker"
|
||||||
"github.com/rancher/rke/hosts"
|
"github.com/rancher/rke/hosts"
|
||||||
"github.com/rancher/rke/log"
|
"github.com/rancher/rke/log"
|
||||||
@ -88,12 +89,14 @@ func GetProcessConfig(process v3.Process) (*container.Config, *container.HostCon
|
|||||||
}
|
}
|
||||||
// var pidMode container.PidMode
|
// var pidMode container.PidMode
|
||||||
// pidMode = process.PidMode
|
// pidMode = process.PidMode
|
||||||
|
_, portBindings, _ := nat.ParsePortSpecs(process.Publish)
|
||||||
hostCfg := &container.HostConfig{
|
hostCfg := &container.HostConfig{
|
||||||
VolumesFrom: process.VolumesFrom,
|
VolumesFrom: process.VolumesFrom,
|
||||||
Binds: process.Binds,
|
Binds: process.Binds,
|
||||||
NetworkMode: container.NetworkMode(process.NetworkMode),
|
NetworkMode: container.NetworkMode(process.NetworkMode),
|
||||||
PidMode: container.PidMode(process.PidMode),
|
PidMode: container.PidMode(process.PidMode),
|
||||||
Privileged: process.Privileged,
|
Privileged: process.Privileged,
|
||||||
|
PortBindings: portBindings,
|
||||||
}
|
}
|
||||||
if len(process.RestartPolicy) > 0 {
|
if len(process.RestartPolicy) > 0 {
|
||||||
hostCfg.RestartPolicy = container.RestartPolicy{Name: process.RestartPolicy}
|
hostCfg.RestartPolicy = container.RestartPolicy{Name: process.RestartPolicy}
|
||||||
|
@ -173,6 +173,15 @@ spec:
|
|||||||
# if it ever gets evicted.
|
# if it ever gets evicted.
|
||||||
scheduler.alpha.kubernetes.io/critical-pod: ''
|
scheduler.alpha.kubernetes.io/critical-pod: ''
|
||||||
spec:
|
spec:
|
||||||
|
affinity:
|
||||||
|
nodeAffinity:
|
||||||
|
requiredDuringSchedulingIgnoredDuringExecution:
|
||||||
|
nodeSelectorTerms:
|
||||||
|
- matchExpressions:
|
||||||
|
- key: beta.kubernetes.io/os
|
||||||
|
operator: NotIn
|
||||||
|
values:
|
||||||
|
- windows
|
||||||
hostNetwork: true
|
hostNetwork: true
|
||||||
tolerations:
|
tolerations:
|
||||||
# Make sure calico/node gets scheduled on all nodes.
|
# Make sure calico/node gets scheduled on all nodes.
|
||||||
|
@ -198,7 +198,7 @@ data:
|
|||||||
{
|
{
|
||||||
"Network": "{{.ClusterCIDR}}",
|
"Network": "{{.ClusterCIDR}}",
|
||||||
"Backend": {
|
"Backend": {
|
||||||
"Type": "vxlan"
|
"Type": "{{.FlannelBackend.Type}}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,6 +229,15 @@ spec:
|
|||||||
annotations:
|
annotations:
|
||||||
scheduler.alpha.kubernetes.io/critical-pod: ''
|
scheduler.alpha.kubernetes.io/critical-pod: ''
|
||||||
spec:
|
spec:
|
||||||
|
affinity:
|
||||||
|
nodeAffinity:
|
||||||
|
requiredDuringSchedulingIgnoredDuringExecution:
|
||||||
|
nodeSelectorTerms:
|
||||||
|
- matchExpressions:
|
||||||
|
- key: beta.kubernetes.io/os
|
||||||
|
operator: NotIn
|
||||||
|
values:
|
||||||
|
- windows
|
||||||
hostNetwork: true
|
hostNetwork: true
|
||||||
serviceAccountName: canal
|
serviceAccountName: canal
|
||||||
tolerations:
|
tolerations:
|
||||||
|
@ -75,7 +75,7 @@ data:
|
|||||||
{
|
{
|
||||||
"Network": "{{.ClusterCIDR}}",
|
"Network": "{{.ClusterCIDR}}",
|
||||||
"Backend": {
|
"Backend": {
|
||||||
"Type": "vxlan"
|
"Type": "{{.FlannelBackend.Type}}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
---
|
---
|
||||||
@ -94,6 +94,15 @@ spec:
|
|||||||
tier: node
|
tier: node
|
||||||
k8s-app: flannel
|
k8s-app: flannel
|
||||||
spec:
|
spec:
|
||||||
|
affinity:
|
||||||
|
nodeAffinity:
|
||||||
|
requiredDuringSchedulingIgnoredDuringExecution:
|
||||||
|
nodeSelectorTerms:
|
||||||
|
- matchExpressions:
|
||||||
|
- key: beta.kubernetes.io/os
|
||||||
|
operator: NotIn
|
||||||
|
values:
|
||||||
|
- windows
|
||||||
serviceAccountName: flannel
|
serviceAccountName: flannel
|
||||||
containers:
|
containers:
|
||||||
- name: kube-flannel
|
- name: kube-flannel
|
||||||
|
@ -176,6 +176,15 @@ spec:
|
|||||||
prometheus.io/port: '10254'
|
prometheus.io/port: '10254'
|
||||||
prometheus.io/scrape: 'true'
|
prometheus.io/scrape: 'true'
|
||||||
spec:
|
spec:
|
||||||
|
affinity:
|
||||||
|
nodeAffinity:
|
||||||
|
requiredDuringSchedulingIgnoredDuringExecution:
|
||||||
|
nodeSelectorTerms:
|
||||||
|
- matchExpressions:
|
||||||
|
- key: beta.kubernetes.io/os
|
||||||
|
operator: NotIn
|
||||||
|
values:
|
||||||
|
- windows
|
||||||
hostNetwork: true
|
hostNetwork: true
|
||||||
nodeSelector:
|
nodeSelector:
|
||||||
{{ range $k, $v := .NodeSelector }}
|
{{ range $k, $v := .NodeSelector }}
|
||||||
|
@ -24,6 +24,15 @@ items:
|
|||||||
labels:
|
labels:
|
||||||
name: weave-net
|
name: weave-net
|
||||||
spec:
|
spec:
|
||||||
|
affinity:
|
||||||
|
nodeAffinity:
|
||||||
|
requiredDuringSchedulingIgnoredDuringExecution:
|
||||||
|
nodeSelectorTerms:
|
||||||
|
- matchExpressions:
|
||||||
|
- key: beta.kubernetes.io/os
|
||||||
|
operator: NotIn
|
||||||
|
values:
|
||||||
|
- windows
|
||||||
containers:
|
containers:
|
||||||
- name: weave
|
- name: weave
|
||||||
command:
|
command:
|
||||||
|
Loading…
Reference in New Issue
Block a user