Open wzshiming opened 1 month ago
@wzshiming What do you think about the below API ?
apiVersion: kwok.sigs.k8s.io/v1beta1
kind: NodePool
metadata:
name: nodepool-sample
spec:
nodeCount: 3
nodeTemplate:
apiVersion: v1
metadata:
annotations:
node.alpha.kubernetes.io/ttl: "0"
labels:
kubernetes.io/role: agent
nvidia.com/gpu.deploy.device-plugin: "true"
nvidia.com/gpu.deploy.dcgm-exporter: "true"
type: kwok
spec: {}
status:
allocatable:
cpu: 32
memory: 256Gi
pods: 110
capacity:
cpu: 32
memory: 256Gi
pods: 110
nodeInfo:
architecture: amd64
bootID: ""
containerRuntimeVersion: ""
kernelVersion: ""
kubeProxyVersion: fake
kubeletVersion: fake
machineID: ""
operatingSystem: linux
osImage: ""
systemUUID: ""
phase: Running
The kwok.x-k8s.io/node: fake
annotation and the node taint are automatically added to all nodes.
Simple struct by using the kubernetes corev1 Node object
// NodePoolSpec defines the desired state of NodePool
type NodePoolSpec struct {
NodeCount int32 `json:"nodeCount"`
NodeTemplate corev1.Node `json:"nodeTemplate"`
}
This is fine as a first version of the API, but if we have a requirement for a DeploymentPool, or any custom resource pool, do we still need to implement it?
Can you explain what is a DeploymentPool ? i thought kowk purpose is "fake" nodes
https://kwok.sigs.k8s.io/#what-is-kwok
kwok is the cornerstone of this project, responsible for simulating the lifecycle of fake nodes, pods, and other Kubernetes API resources.
The other Kubernetes API resources is also in the goal
Now it's support the simulation of other resources, such as Kubevirt's VMI. so there may be a need for VMI pools in the future
I see, i think that creating a dedicated API for each resource will benefit if different logic for different resources is needed ( e.g nodepool/ kubevirtPool , etc) Also IMHO, working with templates that are originally strings that converted into structs are very error prone. WDYT ?
Also IMHO, working with templates that are originally strings that converted into structs are very error prone.
I'm with you on that one.
In fact, current node and pod simulations are already using templates, then we'll do chaos simulation use it.
As a result, a validation tool was recently added to this batch of simulation stage templates in CI to ensure that the templates are properly
How can you prevent from a user to apply a malformed template for node ?
There is no way, we try not to let the user touch the template, if the user modifies the template, they will be responsible for it.
You see my definition above, in fact the user only needs to modify the Resource, the ResourceTemplate is the default for the user, that is enough!
Got it, thanks for the info. The way i see it, we can create an API for each type of resource KWOK support & create a generic one that can operate on a CR like you did:
template: |-
kind: ANY TYPE OF RESOURCE
How does that sound?
we can create an API for each type of resource KWOK support
All resources are now supported on kwok, but we should only need to support node and pod for this.
create a generic one that can operate on a CR like you did:
I don't quite understand this. you mean create a generic Template CR?
If it's needed, we can create an API for the operator to get any kind of resource as a string, and apply it to kubernetes. Same way you did with the template
Got it
What would you like to be added?
Why is this needed?
https://kubernetes.slack.com/archives/C04RG2YSK16/p1716989513415299?thread_ts=1716796734.402529&cid=C04RG2YSK16