title: How to compare a Kubernetes custom resource spec with expected spec in a GO controller?
body: <p>I am trying to implement my first Kubernetes operator. I want the operator controller to be able to compare the config in a running pod vs the expected config defined in a custom resource definition.</p>
  
  <p>Eg: Custom Resource</p>
  
  <pre><code>apiVersion: test.com/v1alpha1
  kind: TEST
  metadata::
    name: example-test
  spec:
    replicas: 3
    version: 20:03
    config:
      valueA: true
      valueB: 123
  </code></pre>
  
  <p>The above custom resource is deployed and 3 pods are running. A change is made such that the config "valueA" is changed to false.</p>
  
  <p>In the GO controller reconcile function I can get the TEST instance and see the "new" version of the config:</p>
  
  <pre><code>instance := &amp;testv1alpha1.TEST{}
  log.Info("New value : " + instance.Spec.Config.valueA)
  </code></pre>
  
  <p>I am wondering how I can access what the value of "valueA" is in my running pods so that I can compare and recreate the pods if it has changed?</p>
  
  <p>Also a secondary question, do I need to loop through all running pods in the reconcile function to check each or can I do this as a single operation?</p>