kcl-lang / modules

Shared KCL Community Modules. View on Artifact Hub: https://artifacthub.io/packages/search?org=kcl&sort=relevance&page=1
https://kcl-lang.io
Apache License 2.0
14 stars 20 forks source link

Add module of Kind. #170

Closed liangyuanpeng closed 2 months ago

liangyuanpeng commented 2 months ago

1. Please confirm that you have read the document before PR submitted

2. Contact Information(Optional)

Have tested and it's working and the model is still relatively simple, but we can iterate it step by step.

main.k

import kind.v1alpha4 as kind

_nodes = [
    kind.Node{
        role = "hello"
    }
]

kind.Cluster{
    nodes = _nodes
}
$ kcl run
apiVersion: kind.x-k8s.io/v1alpha4
kind: Cluster
networking: {}
nodes:
- image: kindest/node:v1.30.0
  role: control-plane
$ kcl run | kind create cluster
Creating cluster "kind" ...
 βœ“ Ensuring node image (kindest/node:v1.30.0) πŸ–Ό 
 βœ“ Preparing nodes πŸ“¦  
 βœ“ Writing configuration πŸ“œ 
 βœ“ Starting control-plane πŸ•ΉοΈ 
 βœ“ Installing CNI πŸ”Œ 
 βœ“ Installing StorageClass πŸ’Ύ 
Set kubectl context to "kind-kind"
You can now use your cluster with:

kubectl cluster-info --context kind-kind

Not sure what to do next? πŸ˜…  Check out https://kind.sigs.k8s.io/docs/user/quick-start/

I also plan to submit a k8s-cluster-kind model so that kind configuration files can be directly generated using kcl run with oci.

If it is convenient, please provide your contact information so we can reach you when processing the PR: