<p>What type of edits will change a ReplicaSet and StatefulSet AGE(CreationTimeStamp)?</p>
<p>I'm asking this because I noticed that</p>
<ol>
<li>If I change a Deployment image, a new ReplicaSet will be created.</li>
<li>The old ReplicaSet continues to exist with DESIRED set to 0.</li>
<li>If I change back to the previous container image, the 2 ReplicaSets don't change their age nor are recreated.</li>
</ol>
<p>So, what is the best way to verify if there were recent updates to a Deployment/ReplicaSet and StatefulSet?</p>
<p>So far, I'm using client-go to check these resources ages:</p>
<pre><code>func statefulsetCheck(namespace string, clientset *kubernetes.Clientset) bool {
    // get the statefulsets in the namespace
    statefulsets, err := clientset.AppsV1().StatefulSets(namespace).List(context.TODO(), metav1.ListOptions{})
    if errors.IsNotFound(err) {
        log.Fatal(&quot;\nNo statefulsets in the namespace&quot;, err)
    } else if err != nil {
        log.Fatal(&quot;\nFailed to fetch statefulsets in the namespace: &quot;, err)
    }

    var stsNames []string
    for _, sts := range statefulsets.Items {
        stsNames = append(stsNames, sts.Name)
    }
    fmt.Printf(&quot;\nStatefulsets in the namespace: %v&quot;, stsNames)
    
    // check if the statefulsets are older than the 9 days
    for _, sts := range statefulsets.Items {
        stsAge := time.Since(sts.CreationTimestamp.Time)
        fmt.Printf(&quot;\nStatefulset %v age: %v&quot;, sts.Name, stsAge)
        if stsAge.Minutes() &lt; 5 {
            fmt.Printf(&quot;\nStatefulset %v had recent updates. Skipping...&quot;, sts.Name)
            return true
        }
    }
    return false
}

func replicasetCheck(namespace string, clientset *kubernetes.Clientset) bool {
    // get the replicasets in the namespace
    replicasets, err := clientset.AppsV1().ReplicaSets(namespace).List(context.TODO(), metav1.ListOptions{})
    if errors.IsNotFound(err) {
        log.Fatal(&quot;\nNo replicasets in the namespace&quot;, err)
    } else if err != nil {
        log.Fatal(&quot;\nFailed to fetch replicasets in the namespace&quot;, err)
    }
    
    var rpsNames []string
    for _, rps := range replicasets.Items {
        rpsNames = append(rpsNames, rps.Name)
    }
    fmt.Printf(&quot;\nReplicasets in the namespace: %v&quot;, rpsNames)
    
    // check if the replicasets have recent updates
    for _, rps := range replicasets.Items {
        rpsAge := time.Since(rps.CreationTimestamp.Time)
        fmt.Printf(&quot;\nReplicaset %v age: %v&quot;, rps.Name, rpsAge)
        if rpsAge.Minutes() &lt; 5 {
            fmt.Printf(&quot;\nReplicaset %v had recent updates...&quot;, rps.Name)
            return true
        }
    }
    return false
}
</code></pre>

<blockquote>
<p>AGE(CreationTimeStamp)</p>
</blockquote>
<p>A resource's <code>CreationTimeStamp</code> (and thereby its age) is set when a resource is <strong>created</strong>. E.g. to change it, you must <em>delete</em> the resource and create it again.</p>
