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

Adds Pod Affinity to Kubernetes driver #245

Merged
merged 2 commits into from
Mar 31, 2021

Conversation

simongdavies
Copy link
Contributor

@simongdavies simongdavies commented Mar 25, 2021

This change introduces a setting to specify labels to be used for affinity for the Kubernetes driver.

The driver uses a PVC to copy input and output data between the driver and the job that runs the invocation image, In some cases there is a need to make sure that the job runs on the same node as another pod. For example, where the PVC is bound to the node running the driver with ReadWriteOnce access mode then the job running the invocation image must run on the same node as the pod creating the PVC, this change enables a client to set pod affinity appropriately.

To specify affinity with a pod the client should set the environment variable AFFINITY_MATCH_LABELS with label name value pairs separated by whitespace. (e.g 'A=B X=Y'). These labels are used to set Pod Affinity constraints for the job running the invocation image.

Signed-off-by: Simon Davies [email protected]

@simongdavies simongdavies marked this pull request as draft March 25, 2021 21:39
@simongdavies simongdavies force-pushed the kubernetes-driver-affinity branch from 54166c9 to 4aa3690 Compare March 29, 2021 14:54
@simongdavies simongdavies changed the title Adds node selector to Kubernetes driver Adds Pod Affinity to Kubernetes driver Mar 29, 2021
@simongdavies simongdavies marked this pull request as ready for review March 29, 2021 15:01
@carolynvs
Copy link
Contributor

For the pod affinity label, is the plan that the k8s operator will generate a unique value, set that on the porter job container, and then pass through this label so that the k8s driver will also use the same label on the invocation image pod?

Copy link
Contributor

@carolynvs carolynvs left a comment

Choose a reason for hiding this comment

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

This looks great!

driver/kubernetes/kubernetes.go Show resolved Hide resolved
@simongdavies
Copy link
Contributor Author

For the pod affinity label, is the plan that the k8s operator will generate a unique value, set that on the porter job container, and then pass through this label so that the k8s driver will also use the same label on the invocation image pod?

@carolynvs The approach I have used in the controller is to set the AFFINITY_MATCH_LABELS to installation=inst.Name. I think this should work?

@carolynvs
Copy link
Contributor

We can chat about that once we have a PR against the operator with this change, but people can run actions against an installation at the same time, though I'd advise anyone against it right now. Ideally it is more unique than the installation name. In another place where I needed a unique value, I used the CRD revision that triggered the event appended to the installation name.

Copy link
Contributor

@carolynvs carolynvs left a comment

Choose a reason for hiding this comment

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

LGTM

@carolynvs carolynvs requested a review from vdice March 30, 2021 15:19
@simongdavies simongdavies requested review from vdice and removed request for radu-matei March 31, 2021 08:14
@carolynvs carolynvs merged commit f6df9a1 into cnabio:main Mar 31, 2021
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