Skip to content

Smart Comparing Specs To Check If Dependent Resource Needs to Applied Again #920

Closed
@csviri

Description

@csviri

Problem Statement

For dependent resources we want to have a default behavior to compare k8s resource specs in order to check if the desired resource needs to be reapplied or not. For example if somebody provides a desired definition of a target resource, like a Deployment object , after the apply K8S fills some attributes with default values. So the actual resource on the server will be always different specified in desired. So we cannot simply compare specs.

A sample jsonpatch after deployment is applied (desired vs applied):

{"op":"add","path":"/template/spec/containers/0/ports/0/protocol","value":"TCP"}
{"op":"add","path":"/template/spec/containers/0/imagePullPolicy","value":"IfNotPresent"}
{"op":"add","path":"/template/spec/containers/0/resources","value":{}}
{"op":"add","path":"/template/spec/containers/0/terminationMessagePath","value":"/dev/termination-log"}
{"op":"add","path":"/template/spec/containers/0/terminationMessagePolicy","value":"File"}
{"op":"add","path":"/template/spec/volumes/0/configMap/defaultMode","value":420}
{"op":"add","path":"/template/spec/dnsPolicy","value":"ClusterFirst"}
{"op":"add","path":"/template/spec/restartPolicy","value":"Always"}
{"op":"add","path":"/template/spec/schedulerName","value":"default-scheduler"}
{"op":"add","path":"/template/spec/securityContext","value":{}}
{"op":"add","path":"/template/spec/terminationGracePeriodSeconds","value":30}
{"op":"add","path":"/progressDeadlineSeconds","value":600}
{"op":"add","path":"/revisionHistoryLimit","value":10}
{"op":"add","path":"/strategy","value":{"rollingUpdate":{"maxSurge":"25%","maxUnavailable":"25%"},"type":"RollingUpdate"}}

In addition to that, for resources like Service the ClusterIP is changes for different instances of Service. (If this diff would be the same, we could just cache the diff and apply before comparison).

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions