Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gavinbunney/terraform-provider-kubectl
Terraform provider to handle raw kubernetes manifest yaml files
https://github.com/gavinbunney/terraform-provider-kubectl
kubernetes terraform terraform-provider
Last synced: 5 days ago
JSON representation
Terraform provider to handle raw kubernetes manifest yaml files
- Host: GitHub
- URL: https://github.com/gavinbunney/terraform-provider-kubectl
- Owner: gavinbunney
- License: mpl-2.0
- Created: 2019-08-26T16:24:53.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2025-02-03T16:44:18.000Z (17 days ago)
- Last Synced: 2025-02-08T19:00:41.651Z (12 days ago)
- Topics: kubernetes, terraform, terraform-provider
- Language: Go
- Homepage: https://registry.terraform.io/providers/gavinbunney/kubectl
- Size: 19.5 MB
- Stars: 643
- Watchers: 12
- Forks: 107
- Open Issues: 72
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Kubernetes "kubectl" Provider
![Build Status](https://github.com/gavinbunney/terraform-provider-kubectl/actions/workflows/build.yml/badge.svg) [![user guide](https://img.shields.io/badge/-user%20guide-blue)](https://registry.terraform.io/providers/gavinbunney/kubectl)
This provider is the best way of managing Kubernetes resources in Terraform, by allowing you to use the thing
Kubernetes loves best - yaml!The core of this provider is the `kubectl_manifest` resource, allowing free-form yaml to be processed and applied against Kubernetes.
This yaml object is then tracked and handles creation, updates and deleted seamlessly - including drift detection!A set of helpful data resources to process directories of yaml files and inline templating is available.
This `terraform-provider-kubectl` provider has been used by many large Kubernetes installations to completely
manage the lifecycle of Kubernetes resources.## Installation
### Terraform 0.13+
The provider can be installed and managed automatically by Terraform. Sample `versions.tf` file :
```hcl
terraform {
required_version = ">= 0.13"required_providers {
kubectl = {
source = "gavinbunney/kubectl"
version = ">= 1.7.0"
}
}
}
```### Terraform 0.12
#### Install latest version
The following one-liner script will fetch the latest provider version and download it to your `~/.terraform.d/plugins` directory.
```bash
$ mkdir -p ~/.terraform.d/plugins && \
curl -Ls https://api.github.com/repos/gavinbunney/terraform-provider-kubectl/releases/latest \
| jq -r ".assets[] | select(.browser_download_url | contains(\"$(uname -s | tr A-Z a-z)\")) | select(.browser_download_url | contains(\"amd64\")) | .browser_download_url" \
| xargs -n 1 curl -Lo ~/.terraform.d/plugins/terraform-provider-kubectl.zip && \
pushd ~/.terraform.d/plugins/ && \
unzip ~/.terraform.d/plugins/terraform-provider-kubectl.zip -d terraform-provider-kubectl-tmp && \
mv terraform-provider-kubectl-tmp/terraform-provider-kubectl* . && \
chmod +x terraform-provider-kubectl* && \
rm -rf terraform-provider-kubectl-tmp && \
rm -rf terraform-provider-kubectl.zip && \
popd
```#### Install manually
If you don't want to use the one-liner above, you can download a binary for your system from the [release page](https://github.com/gavinbunney/terraform-provider-kubectl/releases),
then either place it at the root of your Terraform folder or in the Terraform plugin folder on your system.## Quick Start
```hcl
provider "kubectl" {
host = var.eks_cluster_endpoint
cluster_ca_certificate = base64decode(var.eks_cluster_ca)
token = data.aws_eks_cluster_auth.main.token
load_config_file = false
}resource "kubectl_manifest" "test" {
yaml_body = < Note: The test infrastructure doesn't support multi-file TF configurations so ensure your test scenario is in a single file.In order to run the full suite of Acceptance tests, run `make testacc`.
*Note:* Acceptance tests create real resources, and often cost money to run.
```sh
$ make testacc
```### Inspiration
Thanks to the original provider by [nabancard and lawrecncegripper](https://github.com/nabancard/terraform-provider-kubernetes-yaml) on the original base of this provider.