Skip to content

Conversation

jay-hankins
Copy link

This pull request adds support for discovering and monitoring changes to Argo Rollout resources in a cluster.

It adds an argoRollout type to the K8S Client wrapper:

  • Underneath, it adds RolloutLister, RolloutNamespaceLister, making use of cache.Indexer to support the major use cases, to List() and get Rollouts().
  • We add top-level methods to Client to retrieve Rollouts.

Note that we hand-rolled the types to avoid bringing in a dependency on argoprojv1. This also means that we are using a dynamic client for Kubernetes, which uses type unstructured.Unstructred{} to support any generic kind of CRD.

We also add permissions:

  • in _permissions.tpl to get/list/watch aroproj.io rollouts
  • in permissions.go, to mark the resource permission as required (with graceful failure)

It adds testutil/dynamic_client.go to support creating a dynamic test-double (adding Argo Rollout and RolloutList to the schema). Because the wrapper Client is now using both a clientset (static types) and a dynamic client, the faked dynamic client is used by existing tests (e.g. container, daemonset, ..., etc.) even where they do not test Rollout functionality.

@joshiste joshiste requested review from ReuDa and joshiste August 28, 2025 06:47
# discovery.maxPodCount -- Skip listing pods, containers and hosts for deployments, statefulsets, etc. if there are more then the given pods.
maxPodCount: 50
# discovery.disableArgoRollouts -- Disable discovery of Argo rollouts (requires argoproj.io rollout CRDs)
disableArgoRollouts: true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 195ff has already some values to disable discoveries

AdviceSingleReplicaMinReplicas int `json:"adviceSingleReplicaMinReplicas" split_words:"true" required:"false" default:"2"`
DisableDiscoveryExcludes bool `required:"false" split_words:"true" default:"false"`
LogKubernetesHttpRequests bool `required:"false" split_words:"true" default:"false"`
DiscoveryDisabledArgoRollout bool `json:"discoveryDisabledArgoRollout" required:"false" split_words:"true" default:"true"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually default to "false" here and do the real defaulting via the helm values. At least your current impl of the helm chart wouldn't ever set this flag to "false"

- name: STEADYBIT_EXTENSION_DISCOVERY_MAX_POD_COUNT
value: "{{ .Values.discovery.maxPodCount }}"
{{- if .Values.discovery.disableArgoRollouts }}
- name: STEADYBIT_EXTENSION_DISCOVERY_DISABLE_ARGO_ROLLOUTS
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The env var is STEADYBIT_EXTENSION_DISCOVERY_DISABLED_ARGO_ROLLOUTS (missing D in disableD)

|------------------------------------------------------------------|---------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------|----------------------------------------------------------------------|
| `STEADYBIT_EXTENSION_KUBERNETES_CLUSTER_NAME` | `kubernetes.clusterName` | The name of the kubernetes cluster | yes | |
| `STEADYBIT_EXTENSION_DISABLE_DISCOVERY_EXCLUDES` | `discovery.disableExcludes` | Ignore discovery excludes specified by `steadybit.com/discovery-disabled` | false | `false` |
| `STEADYBIT_EXTENSION_DISCOVERY_DISABLE_ARGO_ROLLOUTS` | `discovery.disableArgoRollouts` | Disable discovery of Argo rollouts | false | `true` |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The env var is STEADYBIT_EXTENSION_DISCOVERY_DISABLED_ARGO_ROLLOUTS (missing D in disableD)

(Also the helm value - see my comment in the helm values.yaml)

{{- end }}
- name: STEADYBIT_EXTENSION_DISCOVERY_MAX_POD_COUNT
value: "{{ .Values.discovery.maxPodCount }}"
{{- if .Values.discovery.disableArgoRollouts }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a test to charts/steadybit-extension-kubernetes/tests/deployment_test.yaml -> manifest should match snapshot with disabled discoveries


// CreateClient is visible for testing
func CreateClient(clientset kubernetes.Interface, stopCh <-chan struct{}, rootApiPath string, permissions *PermissionCheckResult) *Client {
func CreateClient(clientset kubernetes.Interface, stopCh <-chan struct{}, rootApiPath string, permissions *PermissionCheckResult, config *rest.Config, dynamicClient dynamic.Interface) *Client {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

config *rest.Config seems to be unused

{group: "", resource: "pods", subresource: "eviction", verbs: []string{"create"}, allowGracefulFailure: true},
{group: "", resource: "nodes", verbs: []string{"patch"}, allowGracefulFailure: true},
{group: "", resource: "pods", subresource: "exec", verbs: []string{"create"}, allowGracefulFailure: true},
{group: "argoproj.io", resource: "rollouts", verbs: []string{"get", "list", "watch"}, allowGracefulFailure: true},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In line 76 you are adding these permission conditionally. Should that be removed from this list?

}
}

// TODO: Get HPA if exists
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's about these TODOs? Kube-Score will not show anything for Argo Rollouts. I guess we can remove these lines.

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.

2 participants