I wish to compare the new spec to the actual state to see if I allow some change (say upgrade)
I found this example from etcd operator and i was wondering if there are more common ways to retrieve some resource of my CRD (statefulset) :
podList, err := c.config.KubeCli.Core().Pods(c.cluster.Namespace).List(k8sutil.ClusterListOpt(c.cluster.Name))
exmaple from: https://github.com/coreos/etcd-operator/blob/534a00a970975a66b15e2ea3cd90eb6d5104c71b/pkg/cluster/cluster.go#L285
solution is using Get function: https://github.com/operator-framework/operator-sdk/blob/master/pkg/sdk/query.go
d := &apps_v1.Deployment{
TypeMeta: meta_v1.TypeMeta{
Kind: "Deployment",
APIVersion: "apps/v1",
}
ObjectMeta: metav_1.ObjectMeta{
Name: "example",
Namespace: "default",
}
}
// Get with default options
err := sdk.Get(d)
// Get with custom options
o := &meta_v1.GetOptions{ResourceVersion: "0"}
err := sdk.Get(d, sdk.WithGetOptions(o))