pod affinity/anti affinity is not supported?
ezlo-eugenek opened this issue · 3 comments
I've spec in statefulset:
spec:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: "service"
operator: In
values:
- kafka
topologyKey: "kubernetes.io/hostname"
podAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 1
podAffinityTerm:
labelSelector:
matchExpressions:
- key: "app"
operator: In
values:
- zk
And I get such error:
2:56PM Warn | excluding attribute [kubernetes_stateful_set.spec.template.spec.affinity.pod_affinity.preferred_during_scheduling_ignored_during_execution.pod_affinity_term.label_selector.match_expression] not found in Terraform schema field=StatefulSet.Spec.Template.Spec.Affinity.PodAffinity.PreferredDuringSchedulingIgnoredDuringExecution.PodAffinityTerm.LabelSelector.MatchExpressions name=kafka type=kubernetes_stateful_set
2:56PM Warn | excluding attribute [kubernetes_stateful_set.spec.template.spec.affinity.pod_anti_affinity.required_during_scheduling_ignored_during_execution.label_selector.match_expression] not found in Terraform schema field=StatefulSet.Spec.Template.Spec.Affinity.PodAntiAffinity.RequiredDuringSchedulingIgnoredDuringExecution.LabelSelector.MatchExpressions name=kafka type=kubernetes_stateful_set
Noticed this too. I have the latest version.
What caught my eye is the reference to the "label_selector.match_expression" (note the lack of s at the end of expression), even though in my K8s file I definitely have it.
I tried searching the repository if there's something specific handling this case but this seems to be part of an automated schema translation, so that would require more code-reading I guess 🙂
I have the same issue
using:
> k2tf --version
k2tf version: dev
output :
affinity {
node_affinity {
required_during_scheduling_ignored_during_execution {
node_selector_term {}
}
}
}
instead :
affinity {
node_affinity {
required_during_scheduling_ignored_during_execution {
node_selector_term {
match_expressions {
key = "cloud.google.com/gke-accelerator"
operator = "Exists"
}
}
}
}
}
$ k2tf --version
k2tf version: 0.5.0
ref: https://github.com/sl1pm4t/k2tf/blob/v0.5.0/hcl_writer.go#L213
if !includeUnsupported && current.unsupported {
// don't append this block or child blocks
w.warn().
Str("field", current.FullFieldName()).
Msgf("excluding attribute [%s] not found in Terraform schema", current.FullSchemaName())
}
There's a flag --include-unsupported
, and as mentioned by others the match_expressions
seems to be the cause as it's converted to match_expression
my scripts use
sed -e 's/match_expression/match_expressions/g'