Skip to content

Commit

Permalink
match specific tolerations
Browse files Browse the repository at this point in the history
  • Loading branch information
DrFaust92 committed Sep 25, 2020
1 parent 170ebfb commit 2a80b9d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions kubernetes/structures_pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,23 @@ import (
"fmt"
"log"
"strconv"
"strings"

"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
)

// https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/#taint-based-evictions
var builtInTolerations = map[string]string{
"node.kubernetes.io/not-ready": "",
"node.kubernetes.io/unreachable": "",
"node.kubernetes.io/out-of-disk": "",
"node.kubernetes.io/memory-pressure": "",
"node.kubernetes.io/disk-pressure": "",
"node.kubernetes.io/network-unavailable": "",
"node.kubernetes.io/unschedulable": "",
}

// Flatteners

func flattenPodSpec(in v1.PodSpec) ([]interface{}, error) {
Expand Down Expand Up @@ -219,7 +229,7 @@ func flattenTolerations(tolerations []v1.Toleration) []interface{} {
att := []interface{}{}
for _, v := range tolerations {
// The API Server may automatically add several Tolerations to pods, strip these to avoid TF diff.
if strings.Contains(v.Key, "node.kubernetes.io/") {
if _, ok := builtInTolerations[v.Key]; ok {
log.Printf("[INFO] ignoring toleration with key: %s", v.Key)
continue
}
Expand Down

0 comments on commit 2a80b9d

Please sign in to comment.