Skip to content

Commit 85a324c

Browse files
Merge pull request #1 from liangyuanpeng/artifacthub
chore: publish to artifacthub and add tests.
2 parents 7cc5513 + bf2111a commit 85a324c

10 files changed

+170
-10
lines changed

.github/workflows/ci.yml

+55-5
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,68 @@ name: build
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches:
6+
- main
67
pull_request:
78

8-
jobs:
9+
env:
10+
KIND_VERSION: v0.23.0
911

10-
build:
12+
jobs:
13+
test-kind-create:
1114
runs-on: ubuntu-latest
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
image:
19+
- kindest/node:v1.30.2
20+
- kindest/node:v1.29.0
21+
- kindest/node:v1.28.0
22+
cpcount:
23+
- 1
24+
- 3
25+
workercount:
26+
- 0
27+
- 1
28+
- 3
1229
steps:
13-
- uses: actions/checkout@v4
1430
- name: Install
1531
run: |
1632
wget -q https://kcl-lang.io/script/install-cli.sh -O - | /bin/bash
33+
- name: install kind
34+
run: |
35+
wget https://kind.sigs.k8s.io/dl/latest/linux-amd64.tgz
36+
tar xvfz linux-amd64.tgz
37+
chmod +x kind
38+
mv kind /usr/local/bin/
39+
rm -f linux-amd64.tgz
40+
rm -f e2e-k8s.sh
41+
#wget https://github.com/kubernetes-sigs/kind/releases/download/${KIND_VERSION}/kind-linux-amd64
42+
#chmod +x kind-linux-amd64
43+
#mv kind-linux-amd64 /usr/local/bin/kind
44+
- uses: actions/checkout@v4
45+
- name: run
46+
run: |
47+
kcl run -D image=${{ matrix.image }} -D cpcount=${{ matrix.cpcount }} -D workercount=${{ matrix.workercount }}
1748
- name: build
1849
run: |
19-
kcl run
50+
#kcl run -D image=${{ matrix.image }} -D cpcount=${{ matrix.cpcount }} -D workercount=${{ matrix.workercount }}
51+
kcl run -D image=${{ matrix.image }} -D cpcount=${{ matrix.cpcount }} -D workercount=${{ matrix.workercount }} | kind create cluster -v5 --wait 4m --retain --config=-
52+
kubectl wait node --all --for condition=ready
53+
kubectl wait --timeout=5m --for=condition=ready pods --namespace=kube-system --all
54+
kubectl get node
55+
kubectl get pod -A
56+
57+
58+
test-push:
59+
runs-on: ubuntu-latest
60+
steps:
61+
- name: Install
62+
run: |
63+
wget -q https://kcl-lang.io/script/install-cli.sh -O - | /bin/bash
64+
- uses: actions/checkout@v4
65+
- name: mod push
66+
run: |
67+
hack/test.sh
68+
69+

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
.kclvm
3+

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
# kind-kcl
2-
generate kind configuration with KCL
2+
3+
Generate the kind configuration with KCL.
4+
5+
[![Artifact Hub](https://img.shields.io/endpoint?url=https://artifacthub.io/badge/repository/kind-kcl)](https://artifacthub.io/packages/search?repo=kind-kcl)

artifacthub-pkg.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
version: 0.0.1
2+
name: kind-kcl
3+
displayName: kind-kcl
4+
createdAt: "2024-07-19T04:14:30Z"
5+
description: '`kind-kcl` is working for generate the kind configuration with KCL.'
6+
links:
7+
- name: KCL homepage
8+
url: https://www.kcl-lang.io/
9+
- name: KCL repo
10+
url: https://github.com/kcl-lang/kcl
11+
- name: kind homepage
12+
url: https://kind.sigs.k8s.io/
13+
- name: kubeadm repo
14+
url: https://github.com/kubernetes-sigs/kind
15+
install: |
16+
#### Add `kind-kcl` with tag `0.0.1` as dependency
17+
```
18+
kcl mod add oci://ghcr.io/liangyuanpeng/kind-kcl --tag 0.0.1
19+
```
20+
#### Pull `kind-kcl` with tag `0.0.1` to local
21+
```
22+
kcl mod pull oci://ghcr.io/liangyuanpeng/kind-kcl --tag 0.0.1
23+
```
24+
maintainers:
25+
- name: Lan Liang
26+
email: gcslyp@gmail.com
27+
provider:
28+
name: Lan Liang

artifacthub-repo.yml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# https://github.com/artifacthub/hub/blob/master/docs/metadata/artifacthub-repo.yml
2+
repositoryID: df1cd444-06be-4109-8cc6-ced2cfb115e5
3+
owners:
4+
- name: Lan Liang
5+
email: gcslyp@gmail.com

hack/test.sh

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
#TODO cleanup zot
4+
export OCI_REG_PLAIN_HTTP=on
5+
export ZOT_VERSION=${ZOT_VERSION:-"2.1.0"}
6+
docker run -d -p 5000:5000 --name zot ghcr.io/project-zot/zot:v${ZOT_VERSION}
7+
sleep 1
8+
kcl mod push oci://localhost:5000/kind-kcl
9+
kcl run oci://localhost:5000/kind-kcl

kcl.mod

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
[package]
2-
name = "tmp"
2+
name = "kind-kcl"
33
edition = "v0.9.0"
44
version = "0.0.1"
5+
6+
[dependencies]
7+
kind = { oci = "oci://ghcr.io/kcl-lang/kind", tag = "0.0.2" }
8+
kubeadm = { oci = "oci://ghcr.io/kcl-lang/kubeadm", tag = "0.0.2" }
9+

kcl.mod.lock

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[dependencies]
2+
[dependencies.kind]
3+
name = "kind"
4+
full_name = "kind_0.0.2"
5+
version = "0.0.2"
6+
reg = "ghcr.io"
7+
repo = "/kcl-lang/kind"
8+
oci_tag = "0.0.2"
9+
[dependencies.kubeadm]
10+
name = "kubeadm"
11+
full_name = "kubeadm_0.0.2"
12+
version = "0.0.2"
13+
reg = "ghcr.io"
14+
repo = "kcl-lang/kubeadm"
15+
oci_tag = "0.0.2"

kubeadmpatch.k

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import kubeadm.v1beta3 as kubeadm
2+
3+
_kubeadmpatches=[]
4+
5+
kubeadm.ClusterConfiguration{}

main.k

+40-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,49 @@
11
import kind.v1alpha4 as kind
2+
import kubeadm.v1beta3 as kubeadm
3+
import yaml
4+
5+
_kubeadmpatches=[]
26

37
_nodes = [
48
]
59

10+
11+
_clusterConfiguration=kubeadm.ClusterConfiguration{
12+
apiServer: kubeadm.ApiServer{}
13+
}
14+
15+
_extraVolumes=[kubeadm.ExtraVolumeItem{
16+
"name" = "audit-logs"
17+
"hostPath" = "/var/log/audit"
18+
"mountPath" = "/var/log/audit"
19+
}]
20+
21+
_apiServerExtraArgs={
22+
"runtime-config" = "api/all=true"
23+
"storage-media-type" = option("storageMediaType",default="application/json")
24+
"audit-log-path" = "/var/log/audit/kube-apiserver-audit.log"
25+
"audit-policy-file" = "/etc/kubernetes/audit-policy/apiserver-audit-policy.yaml"
26+
}
27+
28+
_apiServerExtraArgsEnabled=option("apiServerExtraArgsEnabled",default=False)
29+
if _apiServerExtraArgsEnabled:
30+
_clusterConfiguration.apiServer.extraArgs=_apiServerExtraArgs
31+
32+
33+
_apiServerExtraVolumesEnabled=option("apiServerExtraVolumesEnabled",default=False)
34+
if _apiServerExtraVolumesEnabled:
35+
_clusterConfiguration.apiServer.extraVolumes=_extraVolumes
36+
37+
38+
_server_yaml = yaml.encode(_clusterConfiguration)
39+
640
_result = [(lambda x: int -> int {
7-
_nodes+=[{
41+
_nodes+=[kind.Node{
842
role = "control-plane"
9-
image = option("image",default="kindest/node:v1.30.0")
43+
image = option("image",default="kindest/node:v1.30.2")
44+
kubeadmConfigPatches = [
45+
_server_yaml
46+
]
1047
}
1148
]
1249
x
@@ -16,7 +53,7 @@ _result = [(lambda x: int -> int {
1653
_result = [(lambda x: int -> int {
1754
_nodes+=[{
1855
role = "worker"
19-
image = option("image",default="kindest/node:v1.30.0")
56+
image = option("image",default="kindest/node:v1.30.2")
2057
}
2158
]
2259
x

0 commit comments

Comments
 (0)