Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

feat(plugins/k8s): add prune_whitelist support #3868

Conversation

denysvitali
Copy link
Contributor

@denysvitali denysvitali commented Sep 13, 2022

With this commit it is now possible to specify a prune_whitelist array like:

 deploy {
   use "kubernetes-apply" {
     path        = templatedir("${path.app}/k8s", var)
     kubeconfig  = var.kube_config
     prune_label = "app=my-app"
     prune_whitelist = [
       "apps/v1/Deployment",
       "apps/v1/ReplicaSet"
     ]
   }
 }

This is extremely useful in case you don't have read permissions for all the resources in the cluster, or in case you want to be more conservative in what can be pruned.


Example usage:

app "otel-collector" {
  build {
    use "docker-pull" {
      image              = "traefik/whoami"
      tag                = "latest"
      disable_entrypoint = true
    }
  }

  deploy {
    use "kubernetes-apply" {
      path        = templatedir("${path.app}/k8s", var)
      prune_label = "app=traefik-whoami"
      prune_whitelist = [
        "apps/v1/Deployment",
        "apps/v1/ReplicaSet"
      ]
    }
  }

  release {
    use "kubernetes" {
    }
  }
}

This will in turn call:

kubectl apply \
  -R \
  -f \
  --prune \
  -l app=traefik-whoami \
  --prune-whitelist apps/v1/Deployment \
  --prune-whitelist apps/v1/ReplicaSet

With this commit it is now possible to specify a prune_whitelist
array like:

```hcl
 deploy {
   use "kubernetes-apply" {
     path        = templatedir("${path.app}/k8s", var)
     kubeconfig  = var.kube_config
     prune_label = "app=my-app"
     prune_whitelist = [
       "apps/v1/Deployment",
       "apps/v1/ReplicaSet"
     ]
   }
 }
```

This is extremely useful in case you don't have read permissions for all the resources in the cluster,
or in case you want to be more conservative in what can be pruned.
@denysvitali
Copy link
Contributor Author

Pinging the plugin owner (?): @mitchellh

Copy link
Member

@briancain briancain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me! 👍🏻

Copy link
Member

@briancain briancain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@denysvitali - You'll need to re-generate the website markdown to get the tests to pass! make gen/website-mdx

@denysvitali
Copy link
Contributor Author

@briancain:

I can't. next-hashicorp isn't public:

cd ./website; npx --no-install next-hashicorp format content # only format the content folder in website
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/next-hashicorp - Not found
npm ERR! 404 
npm ERR! 404  'next-hashicorp@latest' is not in this registry.
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

@paladin-devops
Copy link
Contributor

I can't. next-hashicorp isn't public:

@denysvitali I suggested this in a comment on another PR, but to close the gap here, I think that running npm install inside the website/ directory before make gen/website-mdx from the root of the repo should address this.

Copy link
Contributor

@paladin-devops paladin-devops left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also approved, pending the docs updates! 😄

@krantzinator
Copy link
Contributor

krantzinator commented Dec 20, 2022

I've handled the mdx generation over on #4345
Thank you so much @denysvitali for this contribution!

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

Successfully merging this pull request may close these issues.

4 participants