Skip to content

Allow kustomization plugin to run in-cluster #122

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

Merged
merged 1 commit into from
Sep 30, 2021
Merged

Conversation

willthames
Copy link
Contributor

Ensure that plugin can run in cluster

@willthames willthames force-pushed the in-cluster branch 6 times, most recently from afa1058 to c673c7d Compare September 1, 2021 05:08
@pst
Copy link
Member

pst commented Sep 29, 2021

You can already run it inside a cluster by giving it a kubeconfig that instructs it to do so:

locals {
  kubeconfig = yamlencode({
    apiVersion      = "v1"
    kind            = "Config"
    preferences     = {}
    current-context = "incluster"
    clusters = [
      {
        name = "incluster"
        cluster = {
          certificate-authority-data = filebase64(var.kubeconfig_ca_path)
          server                     = var.kubeconfig_server
        }
      }
    ]
    users = [
      {
        name = "incluster"
        user = {
          token = file(var.kubeconfig_token_path)
        }
      }
    ]
    contexts = [
      {
        name = "incluster"
        context = {
          cluster = "incluster"
          user    = "incluster"
        }
      }
    ]
  })
}

provider "kustomization" {
  kubeconfig_raw = local.kubeconfig
}

That being said, your implementation in the provider makes it significantly more convenient. However, there's been a lot of concerns in the past, about the provider implicitly configuring itself. That's why I moved to the hard requirement that one of kubeconfig_path or kubeconfig_raw has to be set explicitly. So I suggest to add a third option, e.g. kubeconfig_incluster to keep this explicit. The incluster option, like the path should probably also be available via a environment variable.

@willthames
Copy link
Contributor Author

I can live with kubeconfig_incluster

@willthames
Copy link
Contributor Author

@pst hopefully my changes to this implementation meet the desired goals

@willthames willthames force-pushed the in-cluster branch 2 times, most recently from 91499c6 to 0d66ef9 Compare September 30, 2021 03:11
Ensure that plugin can run in cluster
@pst pst merged commit 9580139 into kbst:master Sep 30, 2021
@pst
Copy link
Member

pst commented Sep 30, 2021

Thanks, glad you accepted the explicit config. I did not want to force another change regarding this on users.

@willthames willthames deleted the in-cluster branch September 30, 2021 23:41
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

Successfully merging this pull request may close these issues.

2 participants