-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add kubectl-ng cordon/uncordon (#500)
- Loading branch information
1 parent
f083525
commit 967b931
Showing
3 changed files
with
56 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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,44 @@ | ||
# SPDX-FileCopyrightText: Copyright (c) 2024, Kr8s Developers (See LICENSE for list) | ||
# SPDX-License-Identifier: BSD 3-Clause License | ||
|
||
import typer | ||
from rich.console import Console | ||
|
||
from kr8s.asyncio.objects import Node | ||
|
||
console = Console() | ||
|
||
|
||
# Missing Options | ||
# TODO --dry-run='none' | ||
# TODO -l, --selector='' | ||
|
||
|
||
async def cordon( | ||
node: str = typer.Argument(..., help="NODE"), | ||
): | ||
"""Mark node as unschedulable. | ||
Examples: | ||
# Mark node "foo" as unschedulable | ||
kubectl-ng cordon foo | ||
""" | ||
nodes = [await Node.get(node)] | ||
for node_instance in nodes: | ||
await node_instance.cordon() | ||
console.print(f"node/{node_instance.name} cordoned") | ||
|
||
|
||
async def uncordon( | ||
node: str = typer.Argument(..., help="NODE"), | ||
): | ||
"""Mark node as schedulable. | ||
Examples: | ||
# Mark node "foo" as schedulable | ||
kubectl-ng uncordon foo | ||
""" | ||
nodes = [await Node.get(node)] | ||
for node_instance in nodes: | ||
await node_instance.uncordon() | ||
console.print(f"node/{node_instance.name} uncordoned") |
This file contains 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 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