You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By default, the aws-node-termination-handler will run on all of your nodes (on-demand and spot). If your spot instances are labeled, you can configure aws-node-termination-handler to only run on your labeled spot nodes. If you're using the tag `lifecycle=Ec2Spot`, you can run the following to apply our spot-node-selector overlay:
If you're using a different key/value tag to label your spot nodes, you can write your own overlay to set a spot-node-selector while still receiving updates of the base kubernetes resource files. See our [spot-node-selector](https://github.com/aws/aws-node-termination-handler/tree/master/config/overlays/spot-node-selector) overlay for an example.
log.Fatalln("Failed to get NODE_NAME from environment. "+
146
-
"Check that the kubernetes yaml file is configured correctly")
162
+
// Parse env var to int if key exists
163
+
funcgetIntEnv(keystring, fallbackint) int {
164
+
envStrValue:=getEnv(key, "")
165
+
ifenvStrValue=="" {
166
+
returnfallback
167
+
}
168
+
envIntValue, err:=strconv.Atoi(envStrValue)
169
+
iferr!=nil {
170
+
log.Fatalln("Env Var "+key+" must be an integer")
171
+
}
172
+
returnenvIntValue
173
+
}
174
+
175
+
// Parse env var to boolean if key exists
176
+
funcgetBoolEnv(keystring, fallbackbool) bool {
177
+
envStrValue:=getEnv(key, "")
178
+
ifenvStrValue=="" {
179
+
returnfallback
180
+
}
181
+
envBoolValue, err:=strconv.ParseBool(envStrValue)
182
+
iferr!=nil {
183
+
log.Fatalln("Env Var "+key+" must be either true or false")
184
+
}
185
+
returnenvBoolValue
186
+
}
187
+
188
+
funcparseCliArgs() {
189
+
flag.BoolVar(&dryRun, "dry-run", getBoolEnv(dryRunConfigKey, false), "If true, only log if a node would be drained")
190
+
flag.StringVar(&nodeName, "node-name", getEnv(nodeNameConfigKey, ""), "The kubernetes node name")
191
+
flag.StringVar(&metadataUrl, "metadata-url", getEnv(instanceMetadataUrlConfigKey, defaultInstanceMetadataUrl), "The URL of EC2 instance metadata. This shouldn't need to be changed unless you are testing.")
192
+
flag.BoolVar(&ignoreDaemonSets, "ignore-daemon-sets", getBoolEnv(ignoreDaemonSetsConfigKey, true), "If true, drain daemon sets when a spot interrupt is received.")
193
+
flag.BoolVar(&deleteLocalData, "delete-local-data", getBoolEnv(deleteLocalDataConfigKey, true), "If true, do not drain pods that are using local node storage in emptyDir")
194
+
flag.StringVar(&kubernetesServiceHost, "kubernetes-service-host", getEnv(kubernetesServiceHostConfigKey, ""), "[ADVANCED] The k8s service host to send api calls to.")
195
+
flag.StringVar(&kubernetesServicePort, "kubernetes-service-port", getEnv(kubernetesServicePortConfigKey, ""), "[ADVANCED] The k8s service port to send api calls to.")
196
+
flag.IntVar(&podTerminationGracePeriod, "grace-period", getIntEnv(podTerminationGracePeriodConfigKey, -1), "Period of time in seconds given to each pod to terminate gracefully. If negative, the default value specified in the pod will be used.")
197
+
198
+
flag.Parse()
199
+
200
+
ifnodeName=="" {
201
+
log.Fatalln("You must provide a node-name to the CLI or NODE_NAME environment variable.")
0 commit comments