Awesome Open Source
Awesome Open Source

tfk8s Go Report Card tests

tfk8s is a tool that makes it easier to work with the Terraform Kubernetes Provider.

If you want to copy examples from the Kubernetes documentation or migrate existing YAML manifests and use them with Terraform without having to convert YAML to HCL by hand, this tool is for you.



  • Convert a YAML file containing multiple manifests
  • Strip out server side fields when piping kubectl get $R -o yaml | tfk8s --strip


go install[email protected]

Alternatively, clone this repo and run:

make install

If Go's bin directory is not in your PATH you will need to add it:

export PATH=$PATH:$(go env GOPATH)/bin


Creating Terraform configurations

tfk8s -f input.yaml -o

or, using pipes:

cat input.yaml | tfk8s >


apiVersion: v1
kind: ConfigMap
  name: test
  TEST: test

✨✨ magically becomes ✨✨

resource "kubernetes_manifest" "configmap_test" {
  manifest = {
    "apiVersion" = "v1"
    "data" = {
      "TEST" = "test"
    "kind" = "ConfigMap"
    "metadata" = {
      "name" = "test"

Use with kubectl to output maps instead of YAML

kubectl get ns default -o yaml | tfk8s -M
  "apiVersion" = "v1"
  "kind" = "Namespace"
  "metadata" = {
    "creationTimestamp" = "2020-05-02T15:01:32Z"
    "name" = "default"
    "resourceVersion" = "147"
    "selfLink" = "/api/v1/namespaces/default"
    "uid" = "6ac3424c-07a4-4a69-86ae-cc7a4ae72be3"
  "spec" = {
    "finalizers" = [
  "status" = {
    "phase" = "Active"

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
go (15,319
kubernetes (1,801
terraform (412
hcl (395
yaml (229
converter (171