generated from kubernetes/kubernetes-template-project
-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1140 from network-charles/network-charles-patch-2
Scheduler Testing with KWOK (Technical Outcome)
- Loading branch information
Showing
39 changed files
with
4,924 additions
and
1 deletion.
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
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
24 changes: 24 additions & 0 deletions
24
site/content/en/docs/technical-outcomes/scheduling/_index.md
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,24 @@ | ||
--- | ||
title: Scheduler Testing | ||
--- | ||
|
||
# Scheduler Testing with KWOK | ||
|
||
{{< hint "info" >}} | ||
|
||
This document walks you through the technical outcome of using KWOK for scheduler tests. | ||
|
||
{{< /hint >}} | ||
|
||
KWOK can be used to create fake nodes and pods in a simulated cluster. | ||
The cluster can be configured with scheduling policies that meet your scheduler's requirements. | ||
The scenarios below can be used to describe this: | ||
|
||
- [Scheduling pods with resource requests and limits](/docs/technical-outcomes/scheduling/requests-and-limits) | ||
- [Scheduling a pod to a particular node with node-affinity](/docs/technical-outcomes/scheduling/node-affinity) | ||
- [Scheduling pods with taints and tolerations](/docs/technical-outcomes/scheduling/taints-and-tolerations) | ||
- [Scheduling pods with a limit range](/docs/technical-outcomes/scheduling/limit-range) | ||
- [Scheduling pods using pod priority and preemption](/docs/technical-outcomes/scheduling/pod-priority-and-preemption) | ||
- [Scheduling pods using pod topology spread constraints](/docs/technical-outcomes/scheduling/pod-topology-spread-constraint) | ||
|
||
Other scheduling scenarios can also be simulated using KWOK. |
110 changes: 110 additions & 0 deletions
110
site/content/en/docs/technical-outcomes/scheduling/limit-range/_index.md
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,110 @@ | ||
--- | ||
title: "Limit Range" | ||
--- | ||
|
||
# Scheduling pods with a limit range | ||
|
||
A limit range schedule policy can be used in a KWOK cluster. | ||
|
||
<img width="700px" src="limit-range.svg"> | ||
|
||
## Prerequisites | ||
|
||
- KWOK must be installed on the machine. See [installation](https://kwok.sigs.k8s.io/docs/user/installation/). | ||
- Install [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/) | ||
|
||
## Create cluster | ||
|
||
```bash | ||
kwokctl create cluster | ||
``` | ||
|
||
## View clusters | ||
|
||
This ensures that the cluster was created successfully. | ||
|
||
```bash | ||
kwokctl get clusters | ||
``` | ||
|
||
## Create nodes | ||
|
||
```bash | ||
kwokctl scale node --replicas 1 | ||
``` | ||
|
||
## Create a resource limit | ||
|
||
{{< expand "limit-range.yaml" >}} | ||
|
||
{{< code-sample file="limit-range.yaml" >}} | ||
|
||
{{< /expand >}} | ||
|
||
```bash | ||
kubectl apply -f limit-range.yaml | ||
``` | ||
|
||
## Confirm the limit has the required values | ||
|
||
```bash | ||
kubectl describe limitranges cpu-resource-constraint | ||
|
||
Name: cpu-resource-constraint | ||
Namespace: default | ||
Type Resource Min Max Default Request Default Limit Max Limit/Request Ratio | ||
---- -------- --- --- --------------- ------------- ----------------------- | ||
Container cpu 100m 1 500m 500m - | ||
``` | ||
|
||
## Deploy a pod above the resource limit | ||
|
||
- Pod specification: | ||
- CPU Request: 700m | ||
|
||
{{< expand "pod-beyond-limit.yaml" >}} | ||
|
||
{{< code-sample file="pod-beyond-limit.yaml" >}} | ||
|
||
{{< /expand >}} | ||
|
||
```bash | ||
kubectl create -f pod-beyond-limit.yaml | ||
``` | ||
|
||
Notice the error `Invalid value: "700m": must be less than or equal to cpu limit of 500m` | ||
|
||
## Deploy a pod within the resource limit | ||
|
||
- Pod specification: | ||
- CPU Request: 400m | ||
|
||
{{< expand "pod-within-limit.yaml" >}} | ||
|
||
{{< code-sample file="pod-within-limit.yaml" >}} | ||
|
||
{{< /expand >}} | ||
|
||
```bash | ||
kubectl apply -f pod-within-limit.yaml | ||
``` | ||
|
||
## Confirm that the pod is running | ||
|
||
```bash | ||
kubectl get pod | ||
|
||
NAME READY STATUS RESTARTS AGE | ||
pod-within-limit 1/1 Running 0 10s | ||
``` | ||
|
||
## Delete the cluster | ||
|
||
```bash | ||
kwokctl delete cluster | ||
``` | ||
|
||
## Conclusion | ||
|
||
This example demonstrates how to use KWOK to simulate a scheduling | ||
scenario based on setting a [limit range](https://kubernetes.io/docs/concepts/policy/limit-range/) policy. |
Oops, something went wrong.