Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for kustomize? #78

Open
matyat opened this issue Feb 17, 2021 · 2 comments
Open

Support for kustomize? #78

matyat opened this issue Feb 17, 2021 · 2 comments

Comments

@matyat
Copy link
Contributor

matyat commented Feb 17, 2021

Since kubectl supports kustomize out of the box now with the -k opt, it would be nice if this provider could work with that too.

I've put something together that more or less works for my current setup:

data "external" "kustomize" {
  program = ["./scripts/kustomize_build.sh"]

  query = {
    path = var.k8s_config_path
  }
}

data "kubectl_file_documents" "kustomize" {
  content = data.external.kustomize.result.rendered
}

resource "kubectl_manifest" "app" {
  for_each = toset(data.kubectl_file_documents.kustomize.documents)

  yaml_body = each.value
}

Where kustomize_build.sh is:

#! /bin/sh

set -o errexit

path=$(jq -r .path /dev/stdin)

output=$(kustomize build "$path")

jq -n --arg output "$output" '{"rendered":$output}'

But just wondering if a more integrated solution is on the table? Perhaps with a kubectl_kustomize_documents data type to render a list of documents?

@matyat
Copy link
Contributor Author

matyat commented Feb 17, 2021

More than happy to put a PR together if you think its a good idea.

@gavinbunney
Copy link
Owner

@Logibox I like that idea! It would make sense to implement it as another data_resource so you could preview the generated yaml. Happy to review a PR if you have some time to look into implementation :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants