1
0
mirror of https://github.com/rancher/rke.git synced 2025-08-14 21:14:04 +00:00

Add priority class name to addons

This commit is contained in:
Steven Crespo 2021-02-04 13:05:35 -08:00
parent 3c2c508492
commit 68453acb6e
4 changed files with 228 additions and 175 deletions

View File

@ -43,6 +43,11 @@ const (
KubeAPIAuthAppName = "kube-api-auth"
CattleClusterAgentAppName = "cattle-cluster-agent"
CoreDNSPriorityClassNameKey = "coredns_priority_class_name"
CoreDNSAutoscalerPriorityClassNameKey = "coredns_autoscaler_priority_class_name"
KubeDNSPriorityClassNameKey = "kube_dns_priority_class_name"
KubeDNSAutoscalerPriorityClassNameKey = "kube_dns_autoscaler_priority_class_name"
CoreDNSProvider = "coredns"
KubeDNSProvider = "kube-dns"
Nodelocal = "nodelocal"
@ -72,6 +77,8 @@ type ingressOptions struct {
DefaultBackend bool
UpdateStrategy *appsv1.DaemonSetUpdateStrategy
Tolerations []v1.Toleration
NginxIngressControllerPriorityClassName string
DefaultHTTPBackendPriorityClassName string
}
type MetricsServerOptions struct {
@ -83,6 +90,7 @@ type MetricsServerOptions struct {
UpdateStrategy *appsv1.DeploymentStrategy
Replicas *int32
Tolerations []v1.Toleration
MetricsServerPriorityClassName string
}
type CoreDNSOptions struct {
@ -97,6 +105,8 @@ type CoreDNSOptions struct {
UpdateStrategy *appsv1.DeploymentStrategy
LinearAutoscalerParams string
Tolerations []v1.Toleration
CoreDNSPriorityClassName string
CoreDNSAutoscalerPriorityClassName string
}
type KubeDNSOptions struct {
@ -114,6 +124,8 @@ type KubeDNSOptions struct {
UpdateStrategy *appsv1.DeploymentStrategy
LinearAutoscalerParams string
Tolerations []v1.Toleration
KubeDNSPriorityClassName string
KubeDNSAutoscalerPriorityClassName string
}
type NodelocalOptions struct {
@ -124,6 +136,7 @@ type NodelocalOptions struct {
IPAddress string
NodeSelector map[string]string
UpdateStrategy *appsv1.DaemonSetUpdateStrategy
NodeLocalDNSPriorityClassName string
}
type addonError struct {
@ -332,6 +345,8 @@ func (c *Cluster) deployKubeDNS(ctx context.Context, data map[string]interface{}
RollingUpdate: c.DNS.UpdateStrategy.RollingUpdate,
},
Tolerations: c.DNS.Tolerations,
KubeDNSPriorityClassName: c.DNS.Options[KubeDNSPriorityClassNameKey],
KubeDNSAutoscalerPriorityClassName: c.DNS.Options[KubeDNSAutoscalerPriorityClassNameKey],
}
linearModeBytes, err := json.Marshal(c.DNS.LinearAutoscalerParams)
if err != nil {
@ -369,6 +384,8 @@ func (c *Cluster) deployCoreDNS(ctx context.Context, data map[string]interface{}
RollingUpdate: c.DNS.UpdateStrategy.RollingUpdate,
},
Tolerations: c.DNS.Tolerations,
CoreDNSPriorityClassName: c.DNS.Options[CoreDNSPriorityClassNameKey],
CoreDNSAutoscalerPriorityClassName: c.DNS.Options[CoreDNSAutoscalerPriorityClassNameKey],
}
linearModeBytes, err := json.Marshal(c.DNS.LinearAutoscalerParams)
if err != nil {
@ -424,6 +441,7 @@ func (c *Cluster) deployMetricServer(ctx context.Context, data map[string]interf
},
Replicas: c.Monitoring.Replicas,
Tolerations: c.Monitoring.Tolerations,
MetricsServerPriorityClassName: c.Monitoring.MetricsServerPriorityClassName,
}
tmplt, err := templates.GetVersionedTemplates(kdm.MetricsServer, data, c.Version)
if err != nil {
@ -588,6 +606,8 @@ func (c *Cluster) deployIngress(ctx context.Context, data map[string]interface{}
RollingUpdate: c.Ingress.UpdateStrategy.RollingUpdate,
},
Tolerations: c.Ingress.Tolerations,
NginxIngressControllerPriorityClassName: c.Ingress.NginxIngressControllerPriorityClassName,
DefaultHTTPBackendPriorityClassName: c.Ingress.DefaultHTTPBackendPriorityClassName,
}
// since nginx ingress controller 0.16.0, it can be run as non-root and doesn't require privileged anymore.
// So we can use securityContext instead of setting privileges via initContainer.
@ -722,6 +742,7 @@ func (c *Cluster) deployNodelocal(ctx context.Context, data map[string]interface
ClusterDNSServer: c.ClusterDNSServer,
IPAddress: c.DNS.Nodelocal.IPAddress,
NodeSelector: c.DNS.Nodelocal.NodeSelector,
NodeLocalDNSPriorityClassName: c.DNS.Nodelocal.NodeLocalDNSPriorityClassName,
}
if c.DNS.Nodelocal.UpdateStrategy != nil {
NodelocalConfig.UpdateStrategy = &appsv1.DaemonSetUpdateStrategy{

View File

@ -557,6 +557,10 @@ func (c *Cluster) setClusterDNSDefaults() error {
}
c.DNS.Provider = ClusterDNSProvider
logrus.Debugf("DNS provider set to [%s]", ClusterDNSProvider)
if c.DNS.Options == nil {
// don't break if the user didn't define options
c.DNS.Options = make(map[string]string)
}
return nil
}

View File

@ -54,12 +54,15 @@ const (
FlannelBackendPort = "flannel_backend_port"
// FlannelBackendVxLanNetworkIdentify should be greater than or equal to 4096 if using VxLan mode in the cluster with Windows nodes
FlannelBackendVxLanNetworkIdentify = "flannel_backend_vni"
KubeFlannelPriorityClassNameKeyName = "kube_flannel_priority_class_name"
CalicoNetworkPlugin = "calico"
CalicoNodeLabel = "calico-node"
CalicoControllerLabel = "calico-kube-controllers"
CalicoCloudProvider = "calico_cloud_provider"
CalicoFlexVolPluginDirectory = "calico_flex_volume_plugin_dir"
CalicoNodePriorityClassNameKeyName = "calico_node_priority_class_name"
CalicoKubeControllersPriorityClassNameKeyName = "calico_kube_controllers_priority_class_name"
CanalNetworkPlugin = "canal"
CanalIface = "canal_iface"
@ -69,9 +72,11 @@ const (
// CanalFlannelBackendVxLanNetworkIdentify should be greater than or equal to 4096 if using Flannel VxLan mode in the cluster with Windows nodes
CanalFlannelBackendVxLanNetworkIdentify = "canal_flannel_backend_vni"
CanalFlexVolPluginDirectory = "canal_flex_volume_plugin_dir"
CanalPriorityClassNameKeyName = "canal_priority_class_name"
WeaveNetworkPlugin = "weave"
WeaveNetworkAppName = "weave-net"
WeaveNetPriorityClassNameKeyName = "weave_net_priority_class_name"
AciNetworkPlugin = "aci"
AciOVSMemoryLimit = "aci_ovs_memory_limit"
@ -170,9 +175,14 @@ const (
FlannelInterface = "FlannelInterface"
FlannelBackend = "FlannelBackend"
KubeFlannelPriorityClassName = "KubeFlannelPriorityClassName"
CalicoNodePriorityClassName = "CalicoNodePriorityClassName"
CalicoKubeControllersPriorityClassName = "CalicoKubeControllersPriorityClassName"
CanalInterface = "CanalInterface"
CanalPriorityClassName = "CanalPriorityClassName"
FlexVolPluginDir = "FlexVolPluginDir"
WeavePassword = "WeavePassword"
WeaveNetPriorityClassName = "WeaveNetPriorityClassName"
MTU = "MTU"
RBACConfig = "RBACConfig"
ClusterVersion = "ClusterVersion"
@ -328,6 +338,7 @@ func (c *Cluster) doFlannelDeploy(ctx context.Context, data map[string]interface
Type: c.Network.UpdateStrategy.Strategy,
RollingUpdate: c.Network.UpdateStrategy.RollingUpdate,
},
KubeFlannelPriorityClassName: c.Network.Options[KubeFlannelPriorityClassNameKeyName],
}
pluginYaml, err := c.getNetworkPluginManifest(flannelConfig, data)
if err != nil {
@ -355,8 +366,10 @@ func (c *Cluster) doCalicoDeploy(ctx context.Context, data map[string]interface{
Type: c.Network.UpdateStrategy.Strategy,
RollingUpdate: c.Network.UpdateStrategy.RollingUpdate,
},
FlexVolPluginDir: c.Network.Options[CalicoFlexVolPluginDirectory],
Tolerations: c.Network.Tolerations,
FlexVolPluginDir: c.Network.Options[CalicoFlexVolPluginDirectory],
CalicoNodePriorityClassName: c.Network.Options[CalicoNodePriorityClassNameKeyName],
CalicoKubeControllersPriorityClassName: c.Network.Options[CalicoKubeControllersPriorityClassNameKeyName],
}
pluginYaml, err := c.getNetworkPluginManifest(calicoConfig, data)
if err != nil {
@ -401,8 +414,10 @@ func (c *Cluster) doCanalDeploy(ctx context.Context, data map[string]interface{}
Type: c.Network.UpdateStrategy.Strategy,
RollingUpdate: c.Network.UpdateStrategy.RollingUpdate,
},
FlexVolPluginDir: c.Network.Options[CanalFlexVolPluginDirectory],
Tolerations: c.Network.Tolerations,
FlexVolPluginDir: c.Network.Options[CanalFlexVolPluginDirectory],
CanalPriorityClassName: c.Network.Options[CanalPriorityClassNameKeyName],
CalicoKubeControllersPriorityClassName: c.Network.Options[CalicoKubeControllersPriorityClassNameKeyName],
}
pluginYaml, err := c.getNetworkPluginManifest(canalConfig, data)
if err != nil {
@ -425,6 +440,7 @@ func (c *Cluster) doWeaveDeploy(ctx context.Context, data map[string]interface{}
Type: c.Network.UpdateStrategy.Strategy,
RollingUpdate: c.Network.UpdateStrategy.RollingUpdate,
},
WeaveNetPriorityClassName: c.Network.Options[WeaveNetPriorityClassNameKeyName],
}
pluginYaml, err := c.getNetworkPluginManifest(weaveConfig, data)
if err != nil {

View File

@ -421,7 +421,8 @@ type AuthzConfig struct {
type IngressConfig struct {
// Ingress controller type used by kubernetes
Provider string `yaml:"provider" json:"provider,omitempty" norman:"default=nginx"`
// Ingress controller options
// These options are NOT for configuring Ingress's addon template.
// They are used for its ConfigMap options specifically.
Options map[string]string `yaml:"options" json:"options,omitempty"`
// NodeSelector key pair
NodeSelector map[string]string `yaml:"node_selector" json:"nodeSelector,omitempty"`
@ -447,6 +448,10 @@ type IngressConfig struct {
Tolerations []v1.Toleration `yaml:"tolerations" json:"tolerations,omitempty"`
// Enable or disable nginx default-http-backend
DefaultBackend *bool `yaml:"default_backend" json:"defaultBackend,omitempty" norman:"default=true"`
// Priority class name for Nginx-Ingress's "default-http-backend" deployment
DefaultHTTPBackendPriorityClassName string `yaml:"default_http_backend_priority_class_name" json:"defaultHttpBackendPriorityClassName,omitempty"`
// Priority class name for Nginx-Ingress's "nginx-ingress-controller" daemonset
NginxIngressControllerPriorityClassName string `yaml:"nginx_ingress_controller_priority_class_name" json:"nginxIngressControllerPriorityClassName,omitempty"`
}
type ExtraEnv struct {
@ -895,7 +900,8 @@ type GlobalAwsOpts struct {
type MonitoringConfig struct {
// Monitoring server provider
Provider string `yaml:"provider" json:"provider,omitempty" norman:"default=metrics-server"`
// Metrics server options
// These options are NOT for configuring the Metrics-Server's addon template.
// They are used to pass command args to the metric-server's deployment containers specifically.
Options map[string]string `yaml:"options" json:"options,omitempty"`
// NodeSelector key pair
NodeSelector map[string]string `yaml:"node_selector" json:"nodeSelector,omitempty"`
@ -905,6 +911,8 @@ type MonitoringConfig struct {
Replicas *int32 `yaml:"replicas" json:"replicas,omitempty" norman:"default=1"`
// Tolerations for Deployments
Tolerations []v1.Toleration `yaml:"tolerations" json:"tolerations,omitempty"`
// Priority class name for Metrics-Server's "metrics-server" deployment
MetricsServerPriorityClassName string `yaml:"metrics_server_priority_class_name" json:"metricsServerPriorityClassName,omitempty"`
}
type RestoreConfig struct {
@ -921,6 +929,8 @@ type RotateCertificates struct {
type DNSConfig struct {
// DNS provider
Provider string `yaml:"provider" json:"provider,omitempty"`
// DNS config options
Options map[string]string `yaml:"options" json:"options,omitempty"`
// Upstream nameservers
UpstreamNameservers []string `yaml:"upstreamnameservers" json:"upstreamnameservers,omitempty"`
// ReverseCIDRs
@ -930,7 +940,7 @@ type DNSConfig struct {
// NodeSelector key pair
NodeSelector map[string]string `yaml:"node_selector" json:"nodeSelector,omitempty"`
// Nodelocal DNS
Nodelocal *Nodelocal `yaml:"nodelocal" json:"nodelocal,omitempy"`
Nodelocal *Nodelocal `yaml:"nodelocal" json:"nodelocal,omitempty"`
// Update strategy
UpdateStrategy *DeploymentStrategy `yaml:"update_strategy" json:"updateStrategy,omitempty"`
// Autoscaler fields to determine number of dns replicas
@ -941,11 +951,13 @@ type DNSConfig struct {
type Nodelocal struct {
// link-local IP for nodelocal DNS
IPAddress string `yaml:"ip_address" json:"ipAddress,omitempy"`
IPAddress string `yaml:"ip_address" json:"ipAddress,omitempty"`
// Nodelocal DNS daemonset upgrade strategy
UpdateStrategy *DaemonSetUpdateStrategy `yaml:"update_strategy" json:"updateStrategy,omitempty"`
// NodeSelector key pair
NodeSelector map[string]string `yaml:"node_selector" json:"nodeSelector,omitempty"`
// Priority class name for NodeLocal's "node-local-dns" daemonset
NodeLocalDNSPriorityClassName string `yaml:"node_local_dns_priority_class_name" json:"nodeLocalDnsPriorityClassName,omitempty"`
}
// LinearAutoscalerParams contains fields expected by the cluster-proportional-autoscaler https://github.com/kubernetes-incubator/cluster-proportional-autoscaler/blob/0c61e63fc81449abdd52315aa27179a17e5d1580/pkg/autoscaler/controller/linearcontroller/linear_controller.go#L50