Skip to content

Commit

Permalink
Merge pull request #1 from liangyuanpeng/artifacthub
Browse files Browse the repository at this point in the history
chore: publish to artifacthub and add tests.
  • Loading branch information
liangyuanpeng authored Jul 28, 2024
2 parents 7cc5513 + bf2111a commit 85a324c
Show file tree
Hide file tree
Showing 10 changed files with 170 additions and 10 deletions.
60 changes: 55 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,68 @@ name: build

on:
push:
branches: [ main ]
branches:
- main
pull_request:

jobs:
env:
KIND_VERSION: v0.23.0

build:
jobs:
test-kind-create:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
image:
- kindest/node:v1.30.2
- kindest/node:v1.29.0
- kindest/node:v1.28.0
cpcount:
- 1
- 3
workercount:
- 0
- 1
- 3
steps:
- uses: actions/checkout@v4
- name: Install
run: |
wget -q https://kcl-lang.io/script/install-cli.sh -O - | /bin/bash
- name: install kind
run: |
wget https://kind.sigs.k8s.io/dl/latest/linux-amd64.tgz
tar xvfz linux-amd64.tgz
chmod +x kind
mv kind /usr/local/bin/
rm -f linux-amd64.tgz
rm -f e2e-k8s.sh
#wget https://github.com/kubernetes-sigs/kind/releases/download/${KIND_VERSION}/kind-linux-amd64
#chmod +x kind-linux-amd64
#mv kind-linux-amd64 /usr/local/bin/kind
- uses: actions/checkout@v4
- name: run
run: |
kcl run -D image=${{ matrix.image }} -D cpcount=${{ matrix.cpcount }} -D workercount=${{ matrix.workercount }}
- name: build
run: |
kcl run
#kcl run -D image=${{ matrix.image }} -D cpcount=${{ matrix.cpcount }} -D workercount=${{ matrix.workercount }}
kcl run -D image=${{ matrix.image }} -D cpcount=${{ matrix.cpcount }} -D workercount=${{ matrix.workercount }} | kind create cluster -v5 --wait 4m --retain --config=-
kubectl wait node --all --for condition=ready
kubectl wait --timeout=5m --for=condition=ready pods --namespace=kube-system --all
kubectl get node
kubectl get pod -A
test-push:
runs-on: ubuntu-latest
steps:
- name: Install
run: |
wget -q https://kcl-lang.io/script/install-cli.sh -O - | /bin/bash
- uses: actions/checkout@v4
- name: mod push
run: |
hack/test.sh
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

.kclvm

5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# kind-kcl
generate kind configuration with KCL

Generate the kind configuration with KCL.

[![Artifact Hub](https://img.shields.io/endpoint?url=https://artifacthub.io/badge/repository/kind-kcl)](https://artifacthub.io/packages/search?repo=kind-kcl)
28 changes: 28 additions & 0 deletions artifacthub-pkg.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
version: 0.0.1
name: kind-kcl
displayName: kind-kcl
createdAt: "2024-07-19T04:14:30Z"
description: '`kind-kcl` is working for generate the kind configuration with KCL.'
links:
- name: KCL homepage
url: https://www.kcl-lang.io/
- name: KCL repo
url: https://github.com/kcl-lang/kcl
- name: kind homepage
url: https://kind.sigs.k8s.io/
- name: kubeadm repo
url: https://github.com/kubernetes-sigs/kind
install: |
#### Add `kind-kcl` with tag `0.0.1` as dependency
```
kcl mod add oci://ghcr.io/liangyuanpeng/kind-kcl --tag 0.0.1
```
#### Pull `kind-kcl` with tag `0.0.1` to local
```
kcl mod pull oci://ghcr.io/liangyuanpeng/kind-kcl --tag 0.0.1
```
maintainers:
- name: Lan Liang
email: gcslyp@gmail.com
provider:
name: Lan Liang
5 changes: 5 additions & 0 deletions artifacthub-repo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# https://github.com/artifacthub/hub/blob/master/docs/metadata/artifacthub-repo.yml
repositoryID: df1cd444-06be-4109-8cc6-ced2cfb115e5
owners:
- name: Lan Liang
email: gcslyp@gmail.com
9 changes: 9 additions & 0 deletions hack/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

#TODO cleanup zot
export OCI_REG_PLAIN_HTTP=on
export ZOT_VERSION=${ZOT_VERSION:-"2.1.0"}
docker run -d -p 5000:5000 --name zot ghcr.io/project-zot/zot:v${ZOT_VERSION}
sleep 1
kcl mod push oci://localhost:5000/kind-kcl
kcl run oci://localhost:5000/kind-kcl
7 changes: 6 additions & 1 deletion kcl.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
[package]
name = "tmp"
name = "kind-kcl"
edition = "v0.9.0"
version = "0.0.1"

[dependencies]
kind = { oci = "oci://ghcr.io/kcl-lang/kind", tag = "0.0.2" }
kubeadm = { oci = "oci://ghcr.io/kcl-lang/kubeadm", tag = "0.0.2" }

15 changes: 15 additions & 0 deletions kcl.mod.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[dependencies]
[dependencies.kind]
name = "kind"
full_name = "kind_0.0.2"
version = "0.0.2"
reg = "ghcr.io"
repo = "/kcl-lang/kind"
oci_tag = "0.0.2"
[dependencies.kubeadm]
name = "kubeadm"
full_name = "kubeadm_0.0.2"
version = "0.0.2"
reg = "ghcr.io"
repo = "kcl-lang/kubeadm"
oci_tag = "0.0.2"
5 changes: 5 additions & 0 deletions kubeadmpatch.k
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import kubeadm.v1beta3 as kubeadm

_kubeadmpatches=[]

kubeadm.ClusterConfiguration{}
43 changes: 40 additions & 3 deletions main.k
Original file line number Diff line number Diff line change
@@ -1,12 +1,49 @@
import kind.v1alpha4 as kind
import kubeadm.v1beta3 as kubeadm
import yaml

_kubeadmpatches=[]

_nodes = [
]


_clusterConfiguration=kubeadm.ClusterConfiguration{
apiServer: kubeadm.ApiServer{}
}

_extraVolumes=[kubeadm.ExtraVolumeItem{
"name" = "audit-logs"
"hostPath" = "/var/log/audit"
"mountPath" = "/var/log/audit"
}]

_apiServerExtraArgs={
"runtime-config" = "api/all=true"
"storage-media-type" = option("storageMediaType",default="application/json")
"audit-log-path" = "/var/log/audit/kube-apiserver-audit.log"
"audit-policy-file" = "/etc/kubernetes/audit-policy/apiserver-audit-policy.yaml"
}

_apiServerExtraArgsEnabled=option("apiServerExtraArgsEnabled",default=False)
if _apiServerExtraArgsEnabled:
_clusterConfiguration.apiServer.extraArgs=_apiServerExtraArgs


_apiServerExtraVolumesEnabled=option("apiServerExtraVolumesEnabled",default=False)
if _apiServerExtraVolumesEnabled:
_clusterConfiguration.apiServer.extraVolumes=_extraVolumes


_server_yaml = yaml.encode(_clusterConfiguration)

_result = [(lambda x: int -> int {
_nodes+=[{
_nodes+=[kind.Node{
role = "control-plane"
image = option("image",default="kindest/node:v1.30.0")
image = option("image",default="kindest/node:v1.30.2")
kubeadmConfigPatches = [
_server_yaml
]
}
]
x
Expand All @@ -16,7 +53,7 @@ _result = [(lambda x: int -> int {
_result = [(lambda x: int -> int {
_nodes+=[{
role = "worker"
image = option("image",default="kindest/node:v1.30.0")
image = option("image",default="kindest/node:v1.30.2")
}
]
x
Expand Down

0 comments on commit 85a324c

Please sign in to comment.