-
Notifications
You must be signed in to change notification settings - Fork 43
Update Kueue and Jobset controller default limit value #502
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
Merged
ycchenzheng
merged 15 commits into
AI-Hypercomputer:develop
from
ycchenzheng:chzheng/controller-manager-limit
Jul 10, 2025
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
a875fdf
Update Kueue and Jobset controller default limit value
ycchenzheng 52915c9
Update cluster.py
ycchenzheng 734a724
Split into get and update manifest
ycchenzheng f1a26d8
Remove dup lines
ycchenzheng 66e263f
Organize code
ycchenzheng 389a62e
Redesign the feature
ycchenzheng d15cd93
Clean up code
ycchenzheng bab8a81
Correct wrong description
ycchenzheng 4702967
Merge branch 'develop' into chzheng/controller-manager-limit
ycchenzheng c4719a9
Remove unnecessary section of yaml
ycchenzheng ddebedf
Merge branch 'develop' into chzheng/controller-manager-limit
ycchenzheng 7b8e64e
Resolve lint issue
ycchenzheng 65c129c
Reformat the change
ycchenzheng 1ca1fe4
Merge branch 'develop' into chzheng/controller-manager-limit
ycchenzheng 0424d8a
Merge branch 'develop' into chzheng/controller-manager-limit
ycchenzheng File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
""" | ||
Copyright 2024 Google LLC | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
https://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
""" | ||
|
||
import math | ||
|
||
from ..utils.console import xpk_exit, xpk_print | ||
from ..utils.file import write_tmp_file | ||
from ..core.kueue import ( | ||
MEMORY_SIZE_PER_VM, | ||
MIN_MEMORY_LIMIT_SIZE, | ||
) | ||
from .commands import ( | ||
run_command_for_value, | ||
run_command_with_updates_retry, | ||
) | ||
|
||
jobset_controller_manager_yml = """ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
labels: | ||
app.kubernetes.io/component: manager | ||
app.kubernetes.io/created-by: jobset | ||
app.kubernetes.io/instance: controller-manager | ||
app.kubernetes.io/managed-by: kustomize | ||
app.kubernetes.io/name: deployment | ||
app.kubernetes.io/part-of: jobset | ||
control-plane: controller-manager | ||
name: jobset-controller-manager | ||
namespace: jobset-system | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
control-plane: controller-manager | ||
template: | ||
metadata: | ||
annotations: | ||
kubectl.kubernetes.io/default-container: manager | ||
labels: | ||
control-plane: controller-manager | ||
spec: | ||
containers: | ||
- args: | ||
- --config=/controller_manager_config.yaml | ||
- --zap-log-level=2 | ||
command: | ||
- /manager | ||
image: registry.k8s.io/jobset/jobset:v0.8.0 | ||
livenessProbe: | ||
httpGet: | ||
path: /healthz | ||
port: 8081 | ||
initialDelaySeconds: 15 | ||
periodSeconds: 20 | ||
name: manager | ||
ports: | ||
- containerPort: 9443 | ||
name: webhook-server | ||
protocol: TCP | ||
readinessProbe: | ||
httpGet: | ||
path: /readyz | ||
port: 8081 | ||
initialDelaySeconds: 5 | ||
periodSeconds: 10 | ||
resources: | ||
limits: | ||
memory: {memory_limit_size} | ||
requests: | ||
cpu: 500m | ||
memory: 128Mi | ||
securityContext: | ||
allowPrivilegeEscalation: false | ||
capabilities: | ||
drop: | ||
- ALL | ||
volumeMounts: | ||
- mountPath: /controller_manager_config.yaml | ||
name: manager-config | ||
subPath: controller_manager_config.yaml | ||
- mountPath: /tmp/k8s-webhook-server/serving-certs | ||
name: cert | ||
readOnly: true | ||
securityContext: | ||
runAsNonRoot: true | ||
serviceAccountName: jobset-controller-manager | ||
terminationGracePeriodSeconds: 10 | ||
volumes: | ||
- configMap: | ||
name: jobset-manager-config | ||
name: manager-config | ||
- name: cert | ||
secret: | ||
defaultMode: 420 | ||
secretName: jobset-webhook-server-cert | ||
""" | ||
|
||
|
||
def update_jobset_resources_if_necessary(args): | ||
"""Update the jobset manifest to increase the resources for the jobset controller manager. | ||
|
||
Args: | ||
args: user provided arguments for running the command. | ||
|
||
Returns: | ||
0 if successful and 1 otherwise. | ||
""" | ||
# Get total number of nodes | ||
cmd_total_node_num = 'kubectl get node --no-headers | wc -l' | ||
return_code, out = run_command_for_value( | ||
cmd_total_node_num, 'Count total nodes', args | ||
) | ||
if return_code != 0: | ||
xpk_exit(1) | ||
# 1.2MiB per VM or 4GiB (whichever is greater). | ||
new_memory_limit = ( | ||
f'{max(math.ceil(int(out) * MEMORY_SIZE_PER_VM), MIN_MEMORY_LIMIT_SIZE)}Mi' | ||
) | ||
yml_string = jobset_controller_manager_yml.format( | ||
memory_limit_size=new_memory_limit, | ||
) | ||
tmp = write_tmp_file(yml_string) | ||
command = f'kubectl apply -f {str(tmp.file.name)}' | ||
|
||
task = 'Updating jobset Controller Manager resources' | ||
return_code = run_command_with_updates_retry(command, task, args) | ||
if return_code != 0: | ||
xpk_print(f'{task} returned ERROR {return_code}') | ||
return return_code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.