Skip to content

Custom affinities and tolerations #758

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

Jancis
Copy link
Member

@Jancis Jancis commented Jun 18, 2025

Allows definition of custom node and pod affinities, along with tolerations.

  • Current drupal affinities moved from drupal template to values
  • Current tolerations, created by inverse nodeSelector rules are kept, provides backwards compatibility with current nodeSelector rules
  • Removes empty resources sections when no value present, instead of setting them to {}

Testing done with helm unittest and manually, by defining php.nodeSelector, php.tolerations, php.affinity, php.cron.nodeSelector, php.cron.tolerations, and php.cron.affinity values in various combinations, confirming expected output with helm template command.

@Jancis Jancis requested a review from Rade333 June 18, 2025 12:44
@Rade333 Rade333 requested a review from Copilot July 31, 2025 11:52
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request adds support for custom Kubernetes affinities and tolerations to the Drupal Helm chart, improving deployment flexibility and node scheduling control.

  • Moves default Drupal affinity rules from templates to values.yaml for better configurability
  • Adds tolerations and affinity configuration options to php, shell, backup, and cron components
  • Conditionally renders resource blocks only when values are present, avoiding empty configurations

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
values.yaml Adds tolerations and affinity configuration sections with default pod affinity rules moved from templates
values.schema.json Updates JSON schema to validate new tolerations and affinity fields
drupal_tolerations_test.yaml New test suite covering custom tolerations functionality
drupal_node_selector_test.yaml Updates existing tests to verify conditional rendering of node selectors
drupal_affinity_test.yaml New test suite covering custom affinity functionality
shell-deployment.yaml Implements conditional rendering for tolerations and affinity with fallback to php values
drupal-deployment.yaml Moves hardcoded affinity to values-based configuration with conditional rendering
drupal-cron.yaml Adds tolerations and affinity support to cron jobs with proper precedence
backup-cron.yaml Adds tolerations and affinity support to backup jobs

},
"tolerations": {
"type": ["array", "null"],
"additionalProperties": { "type": "string" }
Copy link
Preview

Copilot AI Jul 31, 2025

Choose a reason for hiding this comment

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

The tolerations field should not have additionalProperties set to string type. Tolerations is an array of objects with specific properties like key, operator, value, and effect.

Suggested change
"additionalProperties": { "type": "string" }
"items": {
"type": "object",
"properties": {
"key": { "type": "string" },
"operator": { "type": "string" },
"value": { "type": "string" },
"effect": { "type": "string" }
},
"additionalProperties": false
}

Copilot uses AI. Check for mistakes.

},
"affinity": {
"type": ["object", "null"],
"additionalProperties": { "type": "string" }
Copy link
Preview

Copilot AI Jul 31, 2025

Choose a reason for hiding this comment

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

The affinity field should not have additionalProperties set to string type. Affinity is an object with complex nested structures for nodeAffinity, podAffinity, and podAntiAffinity.

Suggested change
"additionalProperties": { "type": "string" }
"properties": {
"nodeAffinity": {
"type": ["object", "null"],
"properties": {
"requiredDuringSchedulingIgnoredDuringExecution": {
"type": ["object", "null"],
"properties": {
"nodeSelectorTerms": {
"type": "array",
"items": {
"type": "object",
"properties": {
"matchExpressions": {
"type": "array",
"items": {
"type": "object",
"properties": {
"key": { "type": "string" },
"operator": { "type": "string" },
"values": { "type": "array", "items": { "type": "string" } }
}
}
}
}
}
}
}
}
}
},
"podAffinity": {
"type": ["object", "null"],
"properties": {
"requiredDuringSchedulingIgnoredDuringExecution": {
"type": "array",
"items": {
"type": "object",
"properties": {
"labelSelector": {
"type": "object",
"properties": {
"matchLabels": {
"type": "object",
"additionalProperties": { "type": "string" }
}
}
},
"topologyKey": { "type": "string" }
}
}
}
}
},
"podAntiAffinity": {
"type": ["object", "null"],
"properties": {
"requiredDuringSchedulingIgnoredDuringExecution": {
"type": "array",
"items": {
"type": "object",
"properties": {
"labelSelector": {
"type": "object",
"properties": {
"matchLabels": {
"type": "object",
"additionalProperties": { "type": "string" }
}
}
},
"topologyKey": { "type": "string" }
}
}
}
}
}
}

Copilot uses AI. Check for mistakes.

operator: In
values:
- drupal
{{- tpl ( .Values.php.affinity | toYaml ) . | nindent 8 }}
Copy link
Preview

Copilot AI Jul 31, 2025

Choose a reason for hiding this comment

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

There is a trailing space at the end of line 189 that should be removed.

Suggested change
{{- tpl ( .Values.php.affinity | toYaml ) . | nindent 8 }}
{{- tpl ( .Values.php.affinity | toYaml ) . | nindent 8 }}

Copilot uses AI. Check for mistakes.

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.

1 participant