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

Use last-applied-configuration #10

Open
kim0 opened this issue Oct 1, 2019 · 4 comments
Open

Use last-applied-configuration #10

kim0 opened this issue Oct 1, 2019 · 4 comments

Comments

@kim0
Copy link

kim0 commented Oct 1, 2019

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

Yes, when applying any manifest (say HPA). Then changing it live kubectl edit hpa foo. Then using terraform apply, it should but does NOT detect that the object has changed outside its control

Describe the solution you'd like to see

Kubernetes tracks the last applied configuration in kubectl.kubernetes.io/last-applied-configuration .. This provider after creating a resource, should parse out that field and store it in TF state. Every time the state is refreshed, it should be refreshed. In case, there is a difference between 2 runs, the update method should be called and the yaml files reapplied

Describe alternatives you've considered

  • Using resourceVersion numbers
  • Using kubectl diff -f to detect any drift
@kim0
Copy link
Author

kim0 commented Oct 1, 2019

@sagikazarmark .. I'm hitting major issues making use of this provider due to the above. Unfortunately, during the course of testing I have to live edit many objects and expected the provider to detect and re-apply the configs when run. That does not happen.

Hoping we can get a quick fix please, since detecting config drift, is a core feature of terraform.

Thanks a lot for this provider

@sagikazarmark
Copy link
Member

Hey @kim0

Sorry, I haven't been able to allocate much time on this provider lately.

I wonder if #2 would be a solution. We plan to rewrite the current provider using threeway diff checking (the same algorithm kubectl apply uses to decide what it should do).

@kim0
Copy link
Author

kim0 commented Oct 15, 2019

Thanks .. I guess I'm a little worried if you try to diff on your own, that the diffing would break from the many fields which are added dynamically by kubernetes (like, selflink, revision, last-applied-configuration ...etc). Not sure if there's a smart way to ignore those and only diff the "important" fields.

Actually, just diffing against last-applied-configuration, was my way of only diffing those important fields. I also know that recent version of kubernetes offer "server side diff", which might be something we want to use. But overall, I'm Ok with anything that works

PS: One last question, I'm a little confused if today, the provider is able to detect manual changes to kubernetes and reapply the yaml files, or not ? Does that functionality exist today, even if it's blindly reapplies ?

Thanks

@sagikazarmark
Copy link
Member

We wrote a library for diffing k8s objects: https://github.com/banzaicloud/k8s-objectmatcher

The plan is to use it in this provider as well.

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