The created workload will be deployed in the selected AZ.
This section uses an Nginx workload as an example to describe how to create a workload using kubectl.
Prerequisites
The ECS where the kubectl client runs has been connected to your cluster. For details, see Connecting to a Cluster Using kubectl.
Procedure
When using kubectl to create a Deployment or using kubectl to create a StatefulSet, configure workload-AZ affinity. The following is an example YAML file for workload-AZ affinity.
apiVersion: apps/v1 kind: Deployment metadata: name: az-in-deployment spec: replicas: 1 selector: matchLabels: app: az-in-deployment strategy: type: RollingUpdate template: metadata: labels: app: az-in-deployment spec: containers: - image: nginx imagePullPolicy: Always name: nginx imagePullSecrets: - name: default-secret affinity: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: nodeSelectorTerms: - matchExpressions: - key: failure-domain.beta.kubernetes.io/zone #node's label key operator: In values: - az1 #node's key value
This method can be used to add, edit, or delete scheduling policies.