Merge "fix two coredns pod in simplex system"
This commit is contained in:
commit
3db2a1f30e
@ -196,17 +196,6 @@ class platform::kubernetes::master::init
|
||||
logoutput => true,
|
||||
}
|
||||
|
||||
# Restrict the dns pod to master nodes
|
||||
-> exec { 'restrict coredns to master nodes':
|
||||
command => 'kubectl --kubeconfig=/etc/kubernetes/admin.conf -n kube-system patch deployment coredns -p \'{"spec":{"template":{"spec":{"nodeSelector":{"node-role.kubernetes.io/master":""}}}}}\'', # lint:ignore:140chars
|
||||
logoutput => true,
|
||||
}
|
||||
|
||||
-> exec { 'Use anti-affinity for coredns pods':
|
||||
command => 'kubectl --kubeconfig=/etc/kubernetes/admin.conf -n kube-system patch deployment coredns -p \'{"spec":{"template":{"spec":{"affinity":{"podAntiAffinity":{"requiredDuringSchedulingIgnoredDuringExecution":[{"labelSelector":{"matchExpressions":[{"key":"k8s-app","operator":"In","values":["kube-dns"]}]},"topologyKey":"kubernetes.io/hostname"}]}}}}}}\'', # lint:ignore:140chars
|
||||
logoutput => true,
|
||||
}
|
||||
|
||||
# Remove the taint from the master node
|
||||
-> exec { 'remove taint from master node':
|
||||
command => "kubectl --kubeconfig=/etc/kubernetes/admin.conf taint node ${::platform::params::hostname} node-role.kubernetes.io/master- || true", # lint:ignore:140chars
|
||||
@ -316,18 +305,6 @@ class platform::kubernetes::master::init
|
||||
source => "puppet:///modules/${module_name}/kubeconfig.sh"
|
||||
}
|
||||
|
||||
# Restrict the dns pod to master nodes. It seems that each time
|
||||
# kubeadm init is run, it undoes any changes to the deployment.
|
||||
-> exec { 'restrict coredns to master nodes':
|
||||
command => 'kubectl --kubeconfig=/etc/kubernetes/admin.conf -n kube-system patch deployment coredns -p \'{"spec":{"template":{"spec":{"nodeSelector":{"node-role.kubernetes.io/master":""}}}}}\'', # lint:ignore:140chars
|
||||
logoutput => true,
|
||||
}
|
||||
|
||||
-> exec { 'Use anti-affinity for coredns pods':
|
||||
command => 'kubectl --kubeconfig=/etc/kubernetes/admin.conf -n kube-system patch deployment coredns -p \'{"spec":{"template":{"spec":{"affinity":{"podAntiAffinity":{"requiredDuringSchedulingIgnoredDuringExecution":[{"labelSelector":{"matchExpressions":[{"key":"k8s-app","operator":"In","values":["kube-dns"]}]},"topologyKey":"kubernetes.io/hostname"}]}}}}}}\'', # lint:ignore:140chars
|
||||
logoutput => true,
|
||||
}
|
||||
|
||||
# Remove the taint from the master node
|
||||
-> exec { 'remove taint from master node':
|
||||
command => "kubectl --kubeconfig=/etc/kubernetes/admin.conf taint node ${::platform::params::hostname} node-role.kubernetes.io/master- || true", # lint:ignore:140chars
|
||||
@ -372,6 +349,7 @@ class platform::kubernetes::master
|
||||
contain ::platform::kubernetes::kubeadm
|
||||
contain ::platform::kubernetes::cgroup
|
||||
contain ::platform::kubernetes::master::init
|
||||
contain ::platform::kubernetes::coredns
|
||||
contain ::platform::kubernetes::firewall
|
||||
|
||||
Class['::platform::etcd'] -> Class[$name]
|
||||
@ -382,6 +360,7 @@ class platform::kubernetes::master
|
||||
Class['::platform::kubernetes::kubeadm']
|
||||
-> Class['::platform::kubernetes::cgroup']
|
||||
-> Class['::platform::kubernetes::master::init']
|
||||
-> Class['::platform::kubernetes::coredns']
|
||||
-> Class['::platform::kubernetes::firewall']
|
||||
}
|
||||
|
||||
@ -460,6 +439,32 @@ class platform::kubernetes::worker
|
||||
}
|
||||
}
|
||||
|
||||
class platform::kubernetes::coredns {
|
||||
|
||||
include ::platform::params
|
||||
|
||||
if $::platform::params::system_mode != 'simplex' {
|
||||
# For duplex and multi-node system
|
||||
# Restrict the dns pod to master nodes
|
||||
exec { 'restrict coredns to master nodes':
|
||||
command => 'kubectl --kubeconfig=/etc/kubernetes/admin.conf -n kube-system patch deployment coredns -p \'{"spec":{"template":{"spec":{"nodeSelector":{"node-role.kubernetes.io/master":""}}}}}\'', # lint:ignore:140chars
|
||||
logoutput => true,
|
||||
}
|
||||
|
||||
-> exec { 'Use anti-affinity for coredns pods':
|
||||
command => 'kubectl --kubeconfig=/etc/kubernetes/admin.conf -n kube-system patch deployment coredns -p \'{"spec":{"template":{"spec":{"affinity":{"podAntiAffinity":{"requiredDuringSchedulingIgnoredDuringExecution":[{"labelSelector":{"matchExpressions":[{"key":"k8s-app","operator":"In","values":["kube-dns"]}]},"topologyKey":"kubernetes.io/hostname"}]}}}}}}\'', # lint:ignore:140chars
|
||||
logoutput => true,
|
||||
}
|
||||
} else {
|
||||
# for simplex system, 1 coredns is enough
|
||||
exec { '1 coredns for simplex mode':
|
||||
command => 'kubectl --kubeconfig=/etc/kubernetes/admin.conf -n kube-system scale --replicas=1 deployment coredns', # lint:ignore:140chars
|
||||
logoutput => true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# TODO: remove port 9001 once we have a public docker image registry using standard ports.
|
||||
# add 5000 as the default port for private registry
|
||||
class platform::kubernetes::firewall::params (
|
||||
|
Loading…
Reference in New Issue
Block a user