[go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tfk8s crashes when piped a kube-promethes ServiceMonitor #35

Closed
FelipeLujan opened this issue Oct 15, 2021 · 1 comment
Closed

tfk8s crashes when piped a kube-promethes ServiceMonitor #35

FelipeLujan opened this issue Oct 15, 2021 · 1 comment

Comments

@FelipeLujan
Copy link

Greetings.

i have a fresh installation of kube-prometheus
It generates a CRD called ServiceMonitor.

When I pipe one of those CR into tfk8s it crashes gracefully.
Stack below


 k describe ServiceMonitor grafana -n monitoring | tfk8s  
panic: not a string

goroutine 1 [running]:
runtime/debug.Stack()
        /usr/local/go/src/runtime/debug/stack.go:24 +0x65
main.capturePanic()
        /Users/felipe/go/pkg/mod/github.com/jrhouston/tfk8s@v0.1.7/tfk8s.go:219 +0x39
panic({0x1173480, 0x11d9710})
        /usr/local/go/src/runtime/panic.go:1038 +0x215
github.com/zclconf/go-cty/cty.Value.AsString({{{0x0, 0x0}}, {0x0, 0x0}})
        /Users/felipe/go/pkg/mod/github.com/zclconf/go-cty@v1.8.0/cty/value_ops.go:1251 +0x138
main.yamlToHCL({{{0x11de128, 0xc0001ca220}}, {0x117adc0, 0xc0001ab2c0}}, {0x0, 0x0}, 0x0, 0x0)
        /Users/felipe/go/pkg/mod/github.com/jrhouston/tfk8s@v0.1.7/tfk8s.go:101 +0x11c
main.YAMLToTerraformResources({0x11daba0, 0xc000126000}, {0x0, 0x0}, 0x0, 0x0)
        /Users/felipe/go/pkg/mod/github.com/jrhouston/tfk8s@v0.1.7/tfk8s.go:194 +0x2d7
main.main()
        /Users/felipe/go/pkg/mod/github.com/jrhouston/tfk8s@v0.1.7/tfk8s.go:251 +0x334


⚠️  Oh no! Looks like your manifest caused tfk8s to crash.

Please open a GitHub issue and include your manifest YAML with the stack trace above,
or ping me on slack and I'll try and fix it!

GitHub: https://github.com/jrhouston/tfk8s/issues
Slack: #terraform-providers on https://kubernetes.slack.com

- Thanks, @jrhouston

@jrhouston
Copy link
Owner

I just tried this and it worked for me (using the helm chart to install the prometheus stack):

kubctl get servicemonitor prometheus-kube-prometheus-grafana -o yaml | tfk8s
resource "kubernetes_manifest" "servicemonitor_prometheus_kube_prometheus_grafana" {
  manifest = {
    "apiVersion" = "monitoring.coreos.com/v1"
    "kind" = "ServiceMonitor"
    "metadata" = {
      "annotations" = {
        "meta.helm.sh/release-name" = "prometheus"
        "meta.helm.sh/release-namespace" = "default"
      }
      "creationTimestamp" = "2021-10-16T09:08:48Z"
      "generation" = 1
      "labels" = {
        "app" = "kube-prometheus-stack-grafana"
        "app.kubernetes.io/instance" = "prometheus"
        "app.kubernetes.io/managed-by" = "Helm"
        "app.kubernetes.io/part-of" = "kube-prometheus-stack"
        "app.kubernetes.io/version" = "19.1.0"
        "chart" = "kube-prometheus-stack-19.1.0"
        "heritage" = "Helm"
        "release" = "prometheus"
      }
      "name" = "prometheus-kube-prometheus-grafana"
      "namespace" = "default"
      "resourceVersion" = "96148"
      "uid" = "45ade0f2-4b33-499f-89d0-fccb73ab74f9"
    }
    "spec" = {
      "endpoints" = [
        {
          "path" = "/metrics"
          "port" = "service"
        },
      ]
      "selector" = {
        "matchLabels" = {
          "app.kubernetes.io/instance" = "prometheus"
          "app.kubernetes.io/name" = "grafana"
        }
      }
    }
  }
}

I noticed here you used kubectl describe:

k describe ServiceMonitor grafana -n monitoring | tfk8s

which wont work because the output of describe is not YAML – although I see a different error from you when I try it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants