All Projects → gavinbunney → Terraform Provider Kubectl

gavinbunney / Terraform Provider Kubectl

Licence: mpl-2.0
Terraform provider to handle raw kubernetes manifest yaml files

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Terraform Provider Kubectl

Terraform Provider Vultr
Terraform Vultr Provider
Stars: ✭ 172 (-1.15%)
Mutual labels:  terraform, terraform-provider
Terraform Provider Shell
Terraform provider for executing shell commands and saving output to state file
Stars: ✭ 172 (-1.15%)
Mutual labels:  terraform, terraform-provider
Terraform Provider Databricks
Databricks Terraform Provider
Stars: ✭ 119 (-31.61%)
Mutual labels:  terraform, terraform-provider
Terraform Provider Pagerduty
Terraform PagerDuty provider
Stars: ✭ 106 (-39.08%)
Mutual labels:  terraform, terraform-provider
Terraform Provider Docker
As part of our introduction to self-service publishing in the Terraform Registry, this copy of the provider has been archived, and ownership has been transferred to active maintainers in the community. Please see the new location on the Terraform Registry: https://registry.terraform.io/providers/kreuzwerker/docker/latest
Stars: ✭ 131 (-24.71%)
Mutual labels:  terraform, terraform-provider
Terraform Provider Okta
🎉 Now an official Terraform provider! 🚚 We've moved to https://github.com/terraform-providers/terraform-provider-okta/
Stars: ✭ 111 (-36.21%)
Mutual labels:  terraform, terraform-provider
Terraform Provider Grafana
Terraform Grafana provider
Stars: ✭ 118 (-32.18%)
Mutual labels:  terraform, terraform-provider
Terraform Provider Matchbox
Terraform provider for Matchbox on-premise / bare-metal provisioning
Stars: ✭ 100 (-42.53%)
Mutual labels:  terraform, terraform-provider
Terraform Provider Rancher2
Terraform Rancher2 provider
Stars: ✭ 129 (-25.86%)
Mutual labels:  terraform, terraform-provider
Terraform Provider Mongodbatlas
Terraform provider for MongoDB Atlas
Stars: ✭ 126 (-27.59%)
Mutual labels:  terraform, terraform-provider
Terraform Provider Linode
Terraform Linode provider
Stars: ✭ 105 (-39.66%)
Mutual labels:  terraform, terraform-provider
Terraform Provider Stripe
A Terraform Provider for Stripe
Stars: ✭ 143 (-17.82%)
Mutual labels:  terraform, terraform-provider
Terraform Provider Postgresql
As part of our introduction to self-service publishing in the Terraform Registry, this copy of the provider has been archived, and ownership has been transferred to active maintainers in the community. Please see the new location on the Terraform Registry: https://registry.terraform.io/providers/cyrilgdn/postgresql
Stars: ✭ 101 (-41.95%)
Mutual labels:  terraform, terraform-provider
Terraform Provider Zerotier
Create, modify and destroy ZeroTier networks and members through Terraform.
Stars: ✭ 113 (-35.06%)
Mutual labels:  terraform, terraform-provider
Terraform Provider Namecheap
Terraform provider for Namecheap
Stars: ✭ 101 (-41.95%)
Mutual labels:  terraform, terraform-provider
Terraform Provider Template
Terraform template provider
Stars: ✭ 119 (-31.61%)
Mutual labels:  terraform, terraform-provider
Terraform Provider Tls
Provides utilities for working with Transport Layer Security keys and certificates. It provides resources that allow private keys, certificates and certficate requests to be created as part of a Terraform deployment.
Stars: ✭ 88 (-49.43%)
Mutual labels:  terraform, terraform-provider
Terraform Provider Google
Terraform Google Cloud Platform provider
Stars: ✭ 1,318 (+657.47%)
Mutual labels:  terraform, terraform-provider
Terraform Provider Google Beta
Terraform Google Cloud Platform Beta provider
Stars: ✭ 123 (-29.31%)
Mutual labels:  terraform, terraform-provider
Terraform Provider Scaffolding
Quick start repository for creating a Terraform provider
Stars: ✭ 129 (-25.86%)
Mutual labels:  terraform, terraform-provider

Kubernetes "kubectl" Provider

Build Status codecov user guide

This provider is the best way of managing Kubernetes resources in Terraform, by allowing you to use the thing Kubernetes loves best - yaml!

This 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 :

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.

$ 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, then either place it at the root of your Terraform folder or in the Terraform plugin folder on your system.

Quick Start

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 = <<YAML
apiVersion: couchbase.com/v1
kind: CouchbaseCluster
metadata:
  name: name-here-cluster
spec:
  baseImage: name-here-image
  version: name-here-image-version
  authSecret: name-here-operator-secret-name
  exposeAdminConsole: true
  adminConsoleServices:
    - data
  cluster:
    dataServiceMemoryQuota: 256
    indexServiceMemoryQuota: 256
    searchServiceMemoryQuota: 256
    eventingServiceMemoryQuota: 256
    analyticsServiceMemoryQuota: 1024
    indexStorageSetting: memory_optimized
    autoFailoverTimeout: 120
    autoFailoverMaxCount: 3
    autoFailoverOnDataDiskIssues: true
    autoFailoverOnDataDiskIssuesTimePeriod: 120
    autoFailoverServerGroup: false
YAML
}

See User Guide for details on installation and all the provided data and resource types.


Development Guide

If you wish to work on the provider, you'll first need Go installed on your machine (version 1.12+ is required). You'll also need to correctly setup a GOPATH, as well as adding $GOPATH/bin to your $PATH.

To compile the provider, run make build. This will build the provider and put the provider binary in the $GOPATH/bin directory.

Building The Provider

$ go get github.com/gavinbunney/terraform-provider-kubectl

Enter the provider directory and build the provider

$ cd $GOPATH/src/github.com/gavinbunney/terraform-provider-kubectl
$ make build

Testing

In order to test the provider, you can simply run make test.

$ make test

The provider uses k3s to run integration tests. These tests look for any *.tf files in the _examples folder and run an plan, apply, refresh and plan loop over each file.

Inside each file the string name-here is replaced with a unique name during test execution. This is a simple string replace before the TF is applied to ensure that tests don't fail due to naming clashes.

Each scenario can be placed in a folder, to help others navigate and use the examples, and added to the README.MD.

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.

$ make testacc

Inspiration

Thanks to the original provider by nabancard and lawrecncegripper on the original base of this provider.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].