sl1pm4t / k2tf

Kubernetes YAML to Terraform HCL converter
Mozilla Public License 2.0
1.17k stars 108 forks source link

Default values for terraform and kubectl can be different #44

Closed charlottemach closed 2 years ago

charlottemach commented 4 years ago

When converting a daemonset.yaml without explicitly setting automount_service_account_token to true (which is the kubectl default), terraform puts false as a default.

E.g. turning daemonset.yaml

apiVersion: apps/v1
kind: DaemonSet
metadata:
[...]
spec:
  template:
    spec:
[...]

into terraform:

resource "kubernetes_daemonset" "name" {
  metadata {
   [...]
  }
  spec {
    selector {
      match_labels = {
        [...]
      }
    }
    template {
      spec {
       [...]

results in:

apiVersion: apps/v1beta1
  kind: DaemonSet
  metadata:
    [...]
  spec:
    template:
      spec:
        automountServiceAccountToken: false

A specific example can be found here, when trying to use k2tf on the quickstart.yaml, it needs the automountServiceAccountToken to be explicitly set to true, otherwise the services can't connect.

charlottemach commented 4 years ago

https://github.com/terraform-providers/terraform-provider-kubernetes/issues/263 Related to that issue, seems to be in progress. But assuming a check in the tool can't hurt.

sl1pm4t commented 2 years ago

Looks like HashiCorp has fixed this upstream. Closing this issue. See the following comment for more info: https://github.com/sl1pm4t/k2tf/issues/78#issuecomment-841228202