This section will guide you through the process of submitting jobs in Kubernetes by modifying the workload POD configuration and submitting the job to the Kubernetes cluster.
1. Modifying the Workload YAML File
To ensure that your workload runs on Exostellar nodes with certain attributes, and it is scheduled by the Karpenter autoscaler, you need to set affinity settings in your workload YAML file. Below is an example of how to modify your YAML file to include these settings.
apiVersion: v1 kind: Pod metadata: name: my-workload-pod spec: affinity: nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: nodeSelectorTerms: - matchExpressions: - key: karpenter.sh/nodepool operator: In values: - pool-a containers: - name: my-container image: my-image:latest ......
2. Adding Node Labels in Karpenter Node Pool
If your workload requires scheduling on nodes with specific labels, it is required to configure Karpenter Node Pool so nodes are created with needed labels in autoscaling process. To ensure that Karpenter provisions nodes with the appropriate labels, you need to update the Karpenter node pool configuration with the help the following command:
kubectl edit nodepool pool-a
An example nodepool configuration shown below creates nodes that has jobtype of batch and node family of c5
apiVersion: karpenter.sh/v1beta1 kind: NodePool metadata: annotations: karpenter.sh/nodepool-hash: "5387397268510218159" creationTimestamp: "2024-05-10T20:06:58Z" generation: 12 name: pool-a resourceVersion: "38017128" uid: e61de5dc-c6ca-4307-b5c6-8d43dd809c35 spec: disruption: consolidationPolicy: WhenUnderutilized expireAfter: Never limits: cpu: "420" template: metadata: labels: jobtype: batch nodeFamily: c5 spec: nodeClassRef: name: pool-a requirements: - key: topology.kubernetes.io/zone operator: In values: - us-east-1a resources: {} status: {}
3. Submitting the Workload Job
After modifying the workload YAML file, submit the job to Kubernetes cluster just like you would run a regular pod.
kubectl apply -f workload-pod.yaml
To monitor the job and check for its completion, use the following commands:
kubectl get pods
To view the scheduling events and further details for the workload POD:
kubectl describe pod my-workload-pod
To check the logs for the workload POD:
kubectl logs my-workload-pod