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

Add Argo Rollouts support #134

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tony2001
Copy link
Contributor

@tony2001 tony2001 commented Feb 5, 2024

We use Argo Rollouts for gradual deployment of our services, so we needed to detect missing images for them as well.
The support is quite straightforward, but it requires its own client, which I kinda dislike. I would be grateful if you can think of any way to get rid of it.

@nabokihms
Copy link
Member

@tony2001 thanks! The idea is excellent, but my only concern is importing the github.com/argoproj/argo-rollouts.

We can play around with it and use the dynamic client. This approach is more generic, and we will be able to add more resources in the future without importing the world.

Example:

var rolloutsResource = schema.GroupVersionResource{Group: "argoproj,io", Version: "v1alpha1", Resource: "rollouts"}

clusterClient, err := dynamic.NewForConfig(clusterConfig)
if err != nil {
    log.Fatalln(err)
}

informer = dynamicinformer.NewFilteredDynamicInformer(
    clusterClient,
    rolloutsResource,
    corev1.NamespaceAll,
    30*time.Second,
    cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
    nil,
)

To work with objects, there is the unstructured package.

containers, _, _ := unstructured.NestedSlice(obj.Object, "spec", "template", "spec", "containers")

res := make([]corev1.Container{}, 0, len(containers))

for _, c := range containers {
      if props, ok := c.(map[string]interface{}); ok {
            res := append(res, corev1.Container{
                Image: props["image"].(string),
                Name:  props["name"].(string),
             }) 
      }


}

return res 

@tony2001
Copy link
Contributor Author

tony2001 commented Feb 7, 2024

Sounds reasonable indeed!

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

Successfully merging this pull request may close these issues.

3 participants