sl1pm4t / k2tf

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

Add support for APIService #36

Closed pdecat closed 5 years ago

pdecat commented 5 years ago

This PR adds support for converting APIService to kubernetes_api_service.

kubernetes_api_service was implemented by https://github.com/terraform-providers/terraform-provider-kubernetes/pull/487 and released in v1.9.0 of the kubernetes provider.

pdecat commented 5 years ago

FYI, I've used this back in May to generate the following resources with k2tf from https://github.com/GoogleCloudPlatform/k8s-stackdriver/blob/prom-to-sd-v0.5.2/custom-metrics-stackdriver-adapter/deploy/production/adapter_new_resource_model.yaml#L109 :

resource "kubernetes_api_service" "v_1_beta_1_custom_metrics_k_8_s_io" {
  metadata {
    name = "v1beta1.custom.metrics.k8s.io"
  }

  spec {
    service {
      name      = "custom-metrics-stackdriver-adapter"
      namespace = "custom-metrics"
    }

    group                    = "custom.metrics.k8s.io"
    version                  = "v1beta1"
    insecure_skip_tls_verify = true
    group_priority_minimum   = 100
    version_priority         = 100
  }
}

resource "kubernetes_api_service" "v_1_beta_1_external_metrics_k_8_s_io" {
  metadata {
    name = "v1beta1.external.metrics.k8s.io"
  }

  spec {
    service {
      name      = "custom-metrics-stackdriver-adapter"
      namespace = "custom-metrics"
    }

    group                    = "external.metrics.k8s.io"
    version                  = "v1beta1"
    insecure_skip_tls_verify = true
    group_priority_minimum   = 100
    version_priority         = 100
  }
}

Full example at https://github.com/terraform-providers/terraform-provider-kubernetes/issues/237#issuecomment-507163952

pdecat commented 5 years ago

Build fails because of git.apache.org downtime:

go: git.apache.org/thrift.git@v0.0.0-20180902110319-2566ecd5d999: git fetch -f origin refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in /go/pkg/mod/cache/vcs/83dba939f95a790e497d565fc4418400145a1a514f955fa052f662d56e920c3e: exit status 128:
--
577 | fatal: unable to access 'https://git.apache.org/thrift.git/': Failed to connect to git.apache.org port 443: Connection timed out
578 | go: error loading module requirements
sl1pm4t commented 5 years ago

Thanks @pdecat - The test failure seems to be the same plague hitting lots of Golang projects at the moment. I haven't dug into the cause yet but I saw some HashiCorp folks talking about it.

pdecat commented 5 years ago

Indeed https://status.apache.org/incidents/63030p4241xj

sl1pm4t commented 5 years ago

Ok thanks for the link. There's probably not much point merging this until that resolves, because the subsequent builds would fail also.

sl1pm4t commented 5 years ago

I've subscribed to the Apache status, and will re-kick the tests once Apache is green. Thanks again!

pdecat commented 5 years ago

Enabling the Golang Proxy or upgrading to go 1.13 in .drone.yml should help.

pdecat commented 5 years ago

Work-around is to use github mirror with go mod edit -replace=git.apache.org/thrift.git=github.com/apache/thrift@v0.12.0