sl1pm4t/k2tf

Kubernetes YAML to Terraform HCL converter

Go

1,230

191 commits

updated Dec 12, 2025

See the code

README

k2tf - Kubernetes YAML to Terraform HCL converter

Build Status Go Report Card Release

A tool for converting Kubernetes API Objects (in YAML format) into HashiCorp's Terraform configuration language.

The converted .tf files are suitable for use with the Terraform Kubernetes Provider

asciicast

Installation

Pre-built Binaries

Download Binary from GitHub releases page.

Build from source

See below

Homebrew

$ brew install k2tf

asdf

Use the asdf-k2tf plugin.

Example Usage

Convert a single YAML file and write generated Terraform config to Stdout

$ k2tf -f test-fixtures/service.yaml

Convert a single YAML file and write output to file

$ k2tf -f test-fixtures/service.yaml -o service.tf

Convert a directory of Kubernetes YAML files

$ k2tf -f test-fixtures/

Read & convert Kubernetes objects directly from a cluster

$ kubectl get deployments -o yaml | ./k2tf -o deployments.tf

Building

NOTE Requires a working Golang build environment.

This project uses Golang modules for dependency management, so it can be cloned outside of the $GOPATH.

Clone the repository

$ git clone https://github.com/sl1pm4t/k2tf.git

Build

$ cd k2tf
$ make build

Run Tests

$ make test

Downloads

command-line-tool
converter
hashicorp
hashicorp-terraform
hcl
kubernetes
terraform
tool
utility
yaml

sl1pm4t/k2tf

Kubernetes YAML to Terraform HCL converter

Go

1,230

191 commits

updated Dec 12, 2025

See the code

README

k2tf - Kubernetes YAML to Terraform HCL converter

Build Status Go Report Card Release

A tool for converting Kubernetes API Objects (in YAML format) into HashiCorp's Terraform configuration language.

The converted .tf files are suitable for use with the Terraform Kubernetes Provider

asciicast

Installation

Pre-built Binaries

Download Binary from GitHub releases page.

Build from source

See below

Homebrew

$ brew install k2tf

asdf

Use the asdf-k2tf plugin.

Example Usage

Convert a single YAML file and write generated Terraform config to Stdout

$ k2tf -f test-fixtures/service.yaml

Convert a single YAML file and write output to file

$ k2tf -f test-fixtures/service.yaml -o service.tf

Convert a directory of Kubernetes YAML files

$ k2tf -f test-fixtures/

Read & convert Kubernetes objects directly from a cluster

$ kubectl get deployments -o yaml | ./k2tf -o deployments.tf

Building

NOTE Requires a working Golang build environment.

This project uses Golang modules for dependency management, so it can be cloned outside of the $GOPATH.

Clone the repository

$ git clone https://github.com/sl1pm4t/k2tf.git

Build

$ cd k2tf
$ make build

Run Tests

$ make test

Downloads

command-line-tool
converter
hashicorp
hashicorp-terraform
hcl
kubernetes
terraform
tool
utility
yaml

Project health

Overall

3.6/10

Maintained

0/10

Code review

4/10
OpenSSF Scorecard

Latest release

v0.8.0 · May 19, 2024

Releases this year

0

Significant stargazers

Jan-Otto Kröpke

741 followers · starred Nov 2022

Magnus Ericsson

400 followers · starred Aug 2026

Ahmed Kamal

67 followers · starred May 2019

Calvin Bui

82 followers · starred Jan 2020