banzaicloud / terraform-provider-k8s

Kubernetes Terraform provider with support for raw manifests
https://registry.terraform.io/providers/banzaicloud/k8s
MIT License
135 stars 30 forks source link

Provider should behave the same way as kubectl apply works #68

Open rishi-anand opened 3 years ago

rishi-anand commented 3 years ago

Is your feature request related to a problem? Please describe.

If a resource exists then it should be patched in create call as well.

Describe the solution you'd like to see

If a resource exists, it should be modified existing content. So that desired state is what is there in the content.

Describe alternatives you've considered

Additional context

k8s_manifest.nginx-deployment[5]: Creation complete after 18s [id=default::apps/v1::Deployment::nginx]
Error: priorityclasses.scheduling.k8s.io "nginx-critical" already exists
  on k8s_manifest.tf line 9, in resource "k8s_manifest" "nginx-deployment":
   9: resource "k8s_manifest" "nginx-deployment" {

Error: configmaps "log-parser-config" already exists
  on k8s_manifest.tf line 9, in resource "k8s_manifest" "nginx-deployment":
   9: resource "k8s_manifest" "nginx-deployment" {

rishi@Spectro k8s (brownfield) $ 
rishi-anand commented 3 years ago

I can work on the dev changes to patch resource.

pepov commented 3 years ago

Hey, thanks for the report! I beleive the correct workflow for existing resources is to import them first, or am I missing something?

rishi-anand commented 3 years ago

@pepov, You are right! I made a few changes in forked repo of banzai in which I added multi resource support in manifest and then I faced this issue as few resource was existing.