Skip to content

Commit

Permalink
Add eviction-hard and feature-gates flag (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
ojmhetar authored Oct 4, 2018
1 parent c22e7b4 commit 5e5dd95
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
23 changes: 20 additions & 3 deletions apis/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ func SetInitDefaults(config *InitConfiguration) {
config.MasterConfiguration.APIVersion = "kubeadm.k8s.io/v1alpha1"
config.MasterConfiguration.KubernetesVersion = constants.KubernetesVersion
config.MasterConfiguration.NoTaintMaster = true
config.MasterConfiguration.APIServerExtraArgs = map[string]string{
"service-node-port-range": constants.ServiceNodePortRange,
}

addOrAppend(&config.MasterConfiguration.APIServerExtraArgs, "feature-gates", constants.FeatureGates)
addOrAppend(&config.MasterConfiguration.ControllerManagerExtraArgs, "feature-gates", constants.FeatureGates)
addOrAppend(&config.MasterConfiguration.SchedulerExtraArgs, "feature-gates", constants.FeatureGates)

}

Expand Down Expand Up @@ -63,3 +64,19 @@ func SetMasterConfigurationNetworkingDefaultsWithNetworking(config *InitConfigur
config.MasterConfiguration.Networking.DNSDomain = config.Networking.DNSDomain
}
}

func addOrAppend(extraArgs *map[string]string, key string, value string) {
// Create a new map if it doesn't exist.
if *extraArgs == nil {
*extraArgs = make(map[string]string)
}
// Add the key with the value if it doesn't exist. Otherwise, append the value
// to the pre-existing values.
prevFeatureGates := (*extraArgs)[key]
if prevFeatureGates == "" {
(*extraArgs)[key] = value
} else {
featureGates := prevFeatureGates + "," + value
(*extraArgs)[key] = featureGates
}
}
5 changes: 4 additions & 1 deletion constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ const (
Execute = 0744
Read = 0644
ServiceNodePortRange = "80-32767"
// TODO: Add PodPriority when introduced in kubeadm
FeatureGates = "ExperimentalCriticalPodAnnotation=true"
)

const (
Expand Down Expand Up @@ -63,11 +65,12 @@ const (
KubeletMaxPods = 500
KubeletKubeAPIQPS = 20
KubeletKubeAPIBurst = 40
KubeletEvictionHard = "memory.available<600Mi,nodefs.available<10%"

NodeadmKubeletSystemdDropinFilename = "20-nodeadm.conf"
NodeadmKubeletSystemdDropinTemplate = `[Service]
Environment="KUBELET_DNS_ARGS=--cluster-dns={{ .ClusterDNS }} --cluster-domain={{ .ClusterDomain }}"
Environment="KUBELET_EXTRA_ARGS=--max-pods={{ .MaxPods }} --fail-swap-on={{ .FailSwapOn }} --hostname-override={{ .HostnameOverride }} --kube-api-qps={{ .KubeAPIQPS }} --kube-api-burst={{ .KubeAPIBurst }}"
Environment="KUBELET_EXTRA_ARGS=--max-pods={{ .MaxPods }} --fail-swap-on={{ .FailSwapOn }} --hostname-override={{ .HostnameOverride }} --kube-api-qps={{ .KubeAPIQPS }} --kube-api-burst={{ .KubeAPIBurst }} --feature-gates={{ .FeatureGates}} --eviction-hard={{ .EvictionHard }}"
`
)

Expand Down
5 changes: 5 additions & 0 deletions utils/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ func placeAndModifyNodeadmKubeletSystemdDropin(netConfig apis.Networking) {
HostnameOverride string
KubeAPIQPS int
KubeAPIBurst int
EvictionHard string
FeatureGates string
}{
FailSwapOn: constants.KubeletFailSwapOn,
MaxPods: constants.KubeletMaxPods,
Expand All @@ -128,6 +130,8 @@ func placeAndModifyNodeadmKubeletSystemdDropin(netConfig apis.Networking) {
HostnameOverride: hostnameOverride,
KubeAPIQPS: constants.KubeletKubeAPIQPS,
KubeAPIBurst: constants.KubeletKubeAPIBurst,
EvictionHard: constants.KubeletEvictionHard,
FeatureGates: constants.FeatureGates,
}

writeTemplateIntoFile(constants.NodeadmKubeletSystemdDropinTemplate, "nodeadm-kubelet-systemd-dropin", confFile, data)
Expand Down Expand Up @@ -259,6 +263,7 @@ ExecStartPre=-/usr/bin/docker kill vip
ExecStartPre=-/usr/bin/docker rm vip
ExecStop=/usr/bin/docker stop vip
Restart=on-failure
MemoryLow=10M
[Install]
WantedBy=multi-user.target
`
Expand Down

0 comments on commit 5e5dd95

Please sign in to comment.