Skip to content

Instantly share code, notes, and snippets.

@d-baranowski
Created November 27, 2019 10:40
Show Gist options
  • Save d-baranowski/0f727f1426df438f69e8c906adacc060 to your computer and use it in GitHub Desktop.
Save d-baranowski/0f727f1426df438f69e8c906adacc060 to your computer and use it in GitHub Desktop.
cluster autoscaler taint tags logs
resource "aws_autoscaling_group" "node_monitoring_asg_az1" {
launch_configuration = aws_launch_configuration.node_monitoring_node.id
max_size = var.monitoring_node_max_count
min_size = var.monitoring_node_min_count
name = "${var.product}-${var.environment}-asg-monitoring-az1-${var.app}"
vpc_zone_identifier = [element(var.cluster_subnet_ids, 0)]
enabled_metrics = [
"GroupMinSize",
"GroupMaxSize",
"GroupDesiredCapacity",
"GroupInServiceInstances",
"GroupPendingInstances",
"GroupStandbyInstances",
"GroupTerminatingInstances",
"GroupTotalInstances",
]
tags = flatten([
concat(
[
{
"key" = "k8s.io/cluster-autoscaler/node-template/taint/monitoring"
"value" = "true:NoSchedule"
"propagate_at_launch" = true
},
{
"key" = "k8s.io/cluster-autoscaler/node-template/label/restrict"
"value" = "monitoring-only"
"propagate_at_launch" = true
},
{
"key" = "Name"
"value" = "${var.product}-${var.environment}-asg-monitoring-az1-${var.app}"
"propagate_at_launch" = true
},
{
"key" = "kubernetes.io/cluster/${local.cluster_name}"
"value" = "owned"
"propagate_at_launch" = true
},
{
"key" = "k8s.io/cluster-autoscaler/enabled"
"value" = "true"
"propagate_at_launch" = true
},
],
local.asg_tags,
),
])
}
cluster-autoscaler/git branch [10:24:57]
* (HEAD detached from cluster-autoscaler-1.13.8)
diff --git a/cluster-autoscaler/cloudprovider/aws/aws_manager.go b/cluster-autoscaler/cloudprovider/aws/aws_manager.go
index 212e657dd..e27b34c29 100644
--- a/cluster-autoscaler/cloudprovider/aws/aws_manager.go
+++ b/cluster-autoscaler/cloudprovider/aws/aws_manager.go
@@ -263,6 +263,9 @@ func (m *AwsManager) buildNodeFromTemplate(asg *asg, template *asgTemplate) (*ap
node.Spec.Taints = extractTaintsFromAsg(template.Tags)
node.Status.Conditions = cloudprovider.BuildReadyConditions()
+
+ println("RESULTING NODE SPEC TAINTS buildNodeFromTemplate")
+ fmt.Printf("%v\n", node.Spec.Taints)
return &node, nil
}
@@ -297,6 +300,8 @@ func extractLabelsFromAsg(tags []*autoscaling.TagDescription) map[string]string
}
}
}
+ println("HELLO DANIEL")
+ fmt.Printf("%v\n", result)
return result
}
@@ -310,18 +315,40 @@ func extractTaintsFromAsg(tags []*autoscaling.TagDescription) []apiv1.Taint {
// The tag value must be in the format <tag>:NoSchedule
r, _ := regexp.Compile("(.*):(?:NoSchedule|NoExecute|PreferNoSchedule)")
if r.MatchString(v) {
+ println("IT MATCHES")
+ println(k)
+ println(v)
splits := strings.Split(k, "k8s.io/cluster-autoscaler/node-template/taint/")
if len(splits) > 1 {
values := strings.SplitN(v, ":", 2)
+ println("IT GOT A VALUE")
+ println(k)
+ println(v)
if len(values) > 1 {
+ println("IT GOT A APPENDED")
+ println(k)
+ println(v)
+
+ newKey := splits[1]
+ newValue := values[0]
+ newEffect := apiv1.TaintEffect(values[1])
+ fmt.Printf("\nNEWKEY\n%v", newKey)
+ fmt.Printf("\nNEWVALUE\n%v", newValue)
+ fmt.Printf("\nNEWEFFECT\n%v", newEffect)
+ fmt.Printf("\nNEWEFFECTVALUE\n%v", values[1])
+
+
taints = append(taints, apiv1.Taint{
- Key: splits[1],
- Value: values[0],
- Effect: apiv1.TaintEffect(values[1]),
+ Key: newKey,
+ Value: newValue,
+ Effect: newEffect,
})
}
}
}
}
+
+ println("HELLO DANIEL")
+ fmt.Printf("%v\n", taints)
return taints
}
diff --git a/cluster-autoscaler/core/utils.go b/cluster-autoscaler/core/utils.go
index 83006745f..07e849e37 100644
--- a/cluster-autoscaler/core/utils.go
+++ b/cluster-autoscaler/core/utils.go
@@ -340,6 +340,11 @@ func GetNodeInfoFromTemplate(nodeGroup cloudprovider.NodeGroup, daemonsets []*ex
if typedErr != nil {
return nil, typedErr
}
+
+ println("SANITIZED NODE INFO TAINTS GetNodeInfoFromTemplate")
+ logtaints, err := sanitizedNodeInfo.Taints()
+ fmt.Printf("%v\n", logtaints)
+ fmt.Printf("%v\n", err)
return sanitizedNodeInfo, nil
}
I1127 10:31:54.606405 1 static_autoscaler.go:370] Scale down status: unneededOnly=true lastScaleUpTime=2019-11-27 10:22:51.070932374 +0000 UTC m=+19.317614616 lastScaleDownDeleteTime=2019-11-27 10:22:51.070932462 +0000 UTC m=+19.317614705 lastScaleDownFailTime=2019-11-27 10:22:51.070932556 +0000 UTC m=+19.317614802 scaleDownForbidden=false isDeleteInProgress=false
I1127 10:32:04.699109 1 static_autoscaler.go:132] Starting main loop
HELLO DANIEL
Name
spl-test-asg-monitoring-az1-cluster
HELLO DANIEL
app
cluster
HELLO DANIEL
environment
test
HELLO DANIEL
k8s.io/cluster-autoscaler/enabled
true
HELLO DANIEL
k8s.io/cluster-autoscaler/node-template/label/restrict
monitoring-only
HELLO DANIEL
k8s.io/cluster-autoscaler/node-template/taint/monitoring
true:NoSchedule
HELLO DANIEL
kubernetes.io/cluster/spl-test-eks-cluster
owned
HELLO DANIEL
product
spl
HELLO DANIEL
map[restrict:monitoring-only]
IT MATCHES
k8s.io/cluster-autoscaler/node-template/taint/monitoring
true:NoSchedule
IT GOT A VALUE
k8s.io/cluster-autoscaler/node-template/taint/monitoring
true:NoSchedule
IT GOT A APPENDED
k8s.io/cluster-autoscaler/node-template/taint/monitoring
true:NoSchedule
NEWKEY
monitoring
NEWVALUE
true
NEWEFFECT
NoSchedule
NEWEFFECTVALUE
HELLO DANIEL
NoSchedule[{monitoring true NoSchedule <nil>}]
RESULTING NODE SPEC TAINTS buildNodeFromTemplate
[{monitoring true NoSchedule <nil>}]
SANITIZED NODE INFO TAINTS GetNodeInfoFromTemplate
[{monitoring true NoSchedule <nil>}]
<nil>
I1127 10:32:05.021857 1 auto_scaling_groups.go:344] Regenerating instance to ASG map for ASGs: [spl-test-asg-az2-cluster spl-test-asg-cluster spl-test-asg-monitoring-az1-cluster spl-test-asg-monitoring-az2-cluster]
I1127 10:32:05.104027 1 aws_manager.go:160] Refreshed ASG list, next refresh after 2019-11-27 10:33:05.10401841 +0000 UTC m=+633.350700721
I1127 10:32:05.105351 1 utils.go:569] No pod using affinity / antiaffinity found in cluster, disabling affinity predicate for this loop
I1127 10:32:05.105421 1 static_autoscaler.go:278] Filtering out schedulables
I1127 10:32:05.105937 1 static_autoscaler.go:288] No schedulable pods
I1127 10:32:05.106068 1 static_autoscaler.go:296] No unschedulable pods
I1127 10:32:05.106147 1 static_autoscaler.go:343] Calculating unneeded nodes
I1127 10:32:05.106641 1 scale_down.go:376] Scale-down calculation: ignoring 3 nodes unremovable in the last 5m0s
I1127 10:32:05.106727 1 scale_down.go:407] Node ip-10-120-70-77.eu-west-1.compute.internal - utilization 0.862500
I1127 10:32:05.106758 1 scale_down.go:411] Node ip-10-120-70-77.eu-west-1.compute.internal is not suitable for removal - utilization too big (0.862500)
I1127 10:32:05.106810 1 scale_down.go:407] Node ip-10-120-162-166.eu-west-1.compute.internal - utilization 0.830000
I1127 10:32:05.106835 1 scale_down.go:411] Node ip-10-120-162-166.eu-west-1.compute.internal is not suitable for removal - utilization too big (0.830000)
I1127 10:32:05.108331 1 static_autoscaler.go:370] Scale down status: unneededOnly=true lastScaleUpTime=2019-11-27 10:22:51.070932374 +0000 UTC m=+19.317614616 lastScaleDownDeleteTime=2019-11-27 10:22:51.070932462 +0000 UTC m=+19.317614705 lastScaleDownFailTime=2019-11-27 10:22:51.070932556 +0000 UTC m=+19.317614802 scaleDownForbidden=false isDeleteInProgress=false
I1127 10:32:15.124444 1 static_autoscaler.go:132] Starting main loop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment