Applying Node Selectors to All Argo CD Workloads in the Akuity Namespace
How to use Kustomize to Enforce Node Scheduling Constraints
It is possible to set nodeSelector
constraints on all Argo CD workloads (Deployments) running in the akuity
namespace by applying a Kustomization patch.
This example shows how to patch all Argo CD Deployment
resources with the same nodeSelector
.
Below is a sample Kustomization manifest you can apply to your cluster:
apiVersion: kustomize.config.k8s.io/v1
kind: Kustomization
patches:
- patch: |-
apiVersion: apps/v1
kind: Deployment
metadata:
name: ignored-name # This field is ignored when using a target
spec:
template:
spec:
nodeSelector:
akuity: node
target:
kind: Deployment
This configuration:
-
Targets all
Deployment
resources in the namespace where you apply it -
Adds the
nodeSelector
constraint:nodeSelector:
akuity: node
Alternative: Using Affinity
If you prefer more advanced scheduling (e.g., selecting based on labels or anti-affinity), you can instead apply affinity
rules in the same way.
Example snippet (for reference):
spec:
template:
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/os
operator: In
values:
- linux
How to Apply
-
Save the YAML to a file (e.g.,
kustomization.yaml
) -
Apply it to the cluster with
kubectl apply -k ./
Notes
-
This approach does not require changing individual manifests for each workload.
-
It is safe to use in the Akuity Platform since it respects standard Kubernetes deployments.
-
Be sure to test in a lower environment before rolling out to production.