terraform-provider-kustomize

command module
v0.9.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

README

Kubestack, The Open Source Gitops Framework

Terraform Provider Kustomize

Status Run Tests GitHub Issues GitHub Pull Requests

GitHub Repo stars Twitter Follow

Join Our Contributors!

Introduction

The Terraform provider for Kustomize is available from the Terraform registry.

Please refer to the documentation for information on how to use the kustomization_build and kustomization_overlay data sources, or the kustomization_resource resource.

This is a standalone Terraform Provider, but is also used in the Terraform GitOps framework Kubestack.

Getting Help

Community Help
If you have any questions while following the tutorial, join the #kubestack channel on the Kubernetes community. To create an account request an invitation.

Professional Services
For organizations interested in accelerating their GitOps journey, professional services are available.

Contributing

Contributions to the Kubestack framework are welcome and encouraged. Before contributing, please read the Contributing and Code of Conduct Guidelines.

One super simple way to contribute to the success of this project is to give it a star.

GitHub Repo stars

Development Requirements

  • Terraform 0.12.x
  • Go 1.13 (to build the provider plugin)

Building and Developing the Provider

To work on the provider, you need go installed on your machine. The provider uses go mod to manage its dependencies, so GOPATH is not required.

To compile the provider, run make build as shown below. This will build the provider and put the provider binary in the terraform.d/plugins/linux_amd64/ directory.

make build

In order to test the provider, run the acceptance tests using make test. You have to set the KUBECONFIG_PATH environment variable to point the tests to a valid config file. Each tests uses an individual namespaces. Kind or Minikube clusters work well for testing.

make test

Running the provider under debug

Running in debug mode is a four step process - launch the plugin in debug mode under delve, connect your IDE to delve, connect terraform to the plugin, and then run terraform. Instructions here are for Visual Studio Code, configuring other IDEs is likely to be a similar process

  • Ensure you have delve installed
  • Build the plugin locally using go build ./...
  • From the terraform repository you wish to debug, run the following
    PLUGIN_PROTOCOL_VERSIONS=5 dlv exec --api-version=2 --listen=127.0.0.1:49188 --headless /path/to/terraform-provider-kustomization/terraform-provider-kustomize -- --debug
    
    If you run this outside of the terraform repository (e.g. in the plugin source directory), kustomize gets very confused when trying to find files
  • In Visual Studio Code, add the following configuration to launch.json
      {
          "name": "Connect to server",
          "type": "go",
          "request": "attach",
          "mode": "remote",
          "remotePath": "${workspaceFolder}",
          "port": 49188,
          "host": "127.0.0.1",
          "apiVersion": 2,
          "env": {
              "KUBECONFIG_PATH": "${HOME}/.kube/config"
          },
          "dlvLoadConfig": {
              "followPointers": true,
              "maxVariableRecurse": 1,
              "maxStringLen": 512,
              "maxArrayValues": 64,
              "maxStructFields": -1
          }
      }
    
  • Click the debug button and start Connect to server.
  • From the terminal you started dlv from, you will see something like:
    Provider server started; to attach Terraform, set TF_REATTACH_PROVIDERS to the following:
    {"registry.terraform.io/kbst/kustomization":{"Protocol":"grpc","Pid":13366,"Test":true,"Addr":{"Network":"unix","String":"/var/folders/7c/wdp684z11w1_6cj0d6lgl8hw0000gn/T/plugin2650218557"}}}
    
    Set this value using export TF_REATTACH_PROVIDERS={"registry...}}} in the terminal you want to run terraform from
  • Set any breakpoints you wish to use
  • Run terraform

Running a specific test in debug mode

  • Add the following configuration to .vscode/launch.json, updating the TestFunctionNameGoesHere to the name of the function you want to test:

    {
        "name": "Launch test function",
        "type": "go",
        "request": "launch",
        "mode": "test",
        "program": "${workspaceFolder}/kustomize",
        "env": {
            "TF_ACC": "1",
            "KUBECONFIG_PATH": "${env:HOME}/.kube/config"
        },
        "args": [
            "-test.v",
            "-test.run",
            "^TestFunctionNameGoesHere$",
        ],
    }
    
  • Set any breakpoints you want to set

  • Click the debug button and choose "Launch test function" in the dropdown

Kubestack Repositories

  • kbst/terraform-kubestack
    • Terraform GitOps Framework - Everything you need to build reliable automation for AKS, EKS and GKE Kubernetes clusters in one free and open-source framework.
  • kbst/kbst
    • Kubestack Framework CLI - All-in-one CLI to scaffold your Infrastructure as Code repository and deploy your entire platform stack locally for faster iteration.
  • kbst/terraform-provider-kustomization (this repository)
    • Kustomize Terraform Provider - A Kubestack maintained Terraform provider for Kustomize, available in the Terraform registry.
  • kbst/catalog
    • Catalog of cluster services as Kustomize bases - Continuously tested and updated Kubernetes services, installed and customizable using native Terraform syntax.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL