Skip to content

Commit

Permalink
Merge pull request #7 from Peefy/sync-api-definition-and-arch
Browse files Browse the repository at this point in the history
feat: sync operator API to krm-kcl spec and add arch image
  • Loading branch information
Peefy authored Aug 29, 2023
2 parents 0090a08 + febed0d commit 12f83aa
Show file tree
Hide file tree
Showing 16 changed files with 95 additions and 32 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/cla.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# the below token should have repo scope and must be manually added by you in the repository's secret
PERSONAL_ACCESS_TOKEN : ${{ secrets.KUSIONSTACK_BOT_TOKEN }}
PERSONAL_ACCESS_TOKEN : ${{ secrets.KCL_LANG_BOT_TOKEN }}
with:
path-to-document: 'https://github.com/KusionStack/.github/blob/main/CLA.md' # e.g. a CLA or a DCO document
path-to-document: 'https://github.com/kcl-lang/.github/blob/main/CLA.md' # e.g. a CLA or a DCO document

# branch should not be protected
lock-pullrequest-aftermerge: True
path-to-signatures: 'signatures/version1/cla.json'
remote-organization-name: KusionStack
remote-organization-name: kcl-lang
remote-repository-name: cla.db
branch: 'main'
allowlist: bot*
Expand All @@ -35,4 +35,4 @@ jobs:
#custom-pr-sign-comment: 'The signature to be committed in order to sign the CLA'
#custom-allsigned-prcomment: 'pull request comment when all contributors has signed, defaults to **CLA Assistant Lite bot** All Contributors have signed the CLA.'
#lock-pullrequest-aftermerge: false - if you don't want this bot to automatically lock the pull request after merging (default - true)
#use-dco-flag: true - If you are using DCO instead of CLA
#use-dco-flag: true - If you are using DCO instead of CLA
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ KCL Operator provides cluster integration, allowing you to use Access Webhook to
+ Validate all KRM resources using KCL schema.
+ Use an abstract model to generate KRM resources.

## Architecture

![architecture](./images/arch.png)

## CR Example

```yaml
Expand Down
4 changes: 2 additions & 2 deletions api/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ limitations under the License.

// Package v1alpha1 contains API Schema definitions for the krm.kcl.dev v1alpha1 API group
// +kubebuilder:object:generate=true
// +groupName=krm.kcl.dev.kcl-lang.io
// +groupName=krm.kcl.dev
package v1alpha1

import (
Expand All @@ -26,7 +26,7 @@ import (

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "krm.kcl.dev.kcl-lang.io", Version: "v1alpha1"}
GroupVersion = schema.GroupVersion{Group: "krm.kcl.dev", Version: "v1alpha1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
Expand Down
21 changes: 12 additions & 9 deletions api/v1alpha1/kclrun_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
Expand All @@ -28,8 +29,10 @@ type KCLRunSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

// Foo is an example field of KCLRun. Edit kclrun_types.go to remove/update
Foo string `json:"foo,omitempty"`
// Source is a required field for providing a KCL script inline.
Source string `json:"source" yaml:"source"`
// Params are the parameters in key-value pairs format.
Params unstructured.Unstructured `json:"params,omitempty" yaml:"params,omitempty"`
}

// KCLRunStatus defines the observed state of KCLRun
Expand All @@ -43,20 +46,20 @@ type KCLRunStatus struct {

// KCLRun is the Schema for the kclruns API
type KCLRun struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
metav1.TypeMeta `json:",inline" yaml:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty" yaml:"metadata,omitempty"`

Spec KCLRunSpec `json:"spec,omitempty"`
Status KCLRunStatus `json:"status,omitempty"`
Spec KCLRunSpec `json:"spec,omitempty" yaml:"spec,omitempty"`
Status KCLRunStatus `json:"status,omitempty" yaml:"status,omitempty"`
}

//+kubebuilder:object:root=true

// KCLRunList contains a list of KCLRun
type KCLRunList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []KCLRun `json:"items"`
metav1.TypeMeta `json:",inline" yaml:",inline"`
metav1.ListMeta `json:"metadata,omitempty" yaml:"metadata,omitempty"`
Items []KCLRun `json:"items" yaml:"items"`
}

func init() {
Expand Down
3 changes: 2 additions & 1 deletion api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions config/crd/bases/krm.kcl.dev.kcl-lang.io_kclruns.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.11.1
creationTimestamp: null
name: kclruns.krm.kcl.dev.kcl-lang.io
name: kclruns.krm.kcl.dev
spec:
group: krm.kcl.dev.kcl-lang.io
group: krm.kcl.dev
names:
kind: KCLRun
listKind: KCLRunList
Expand Down
55 changes: 55 additions & 0 deletions config/crd/bases/krm.kcl.dev_kclruns.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.11.1
creationTimestamp: null
name: kclruns.krm.kcl.dev
spec:
group: krm.kcl.dev
names:
kind: KCLRun
listKind: KCLRunList
plural: kclruns
singular: kclrun
scope: Namespaced
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
description: KCLRun is the Schema for the kclruns API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: KCLRunSpec defines the desired state of KCLRun
properties:
params:
description: Params are the parameters in key-value pairs format.
type: object
source:
description: Source is a required field for providing a KCL script
inline.
type: string
required:
- source
type: object
status:
description: KCLRunStatus defines the observed state of KCLRun
type: object
type: object
served: true
storage: true
subresources:
status: {}
2 changes: 1 addition & 1 deletion config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# since it depends on service name and namespace that are out of this kustomize package.
# It should be run by config/default
resources:
- bases/krm.kcl.dev.kcl-lang.io_kclruns.yaml
- bases/krm.kcl.dev_kclruns.yaml
#+kubebuilder:scaffold:crdkustomizeresource

patchesStrategicMerge:
Expand Down
2 changes: 1 addition & 1 deletion config/crd/patches/cainjection_in_kclruns.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ kind: CustomResourceDefinition
metadata:
annotations:
cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
name: kclruns.krm.kcl.dev.kcl-lang.io
name: kclruns.krm.kcl.dev
2 changes: 1 addition & 1 deletion config/crd/patches/webhook_in_kclruns.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: kclruns.krm.kcl.dev.kcl-lang.io
name: kclruns.krm.kcl.dev
spec:
conversion:
strategy: Webhook
Expand Down
4 changes: 2 additions & 2 deletions config/rbac/kclrun_editor_role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ metadata:
name: kclrun-editor-role
rules:
- apiGroups:
- krm.kcl.dev.kcl-lang.io
- krm.kcl.dev
resources:
- kclruns
verbs:
Expand All @@ -24,7 +24,7 @@ rules:
- update
- watch
- apiGroups:
- krm.kcl.dev.kcl-lang.io
- krm.kcl.dev
resources:
- kclruns/status
verbs:
Expand Down
4 changes: 2 additions & 2 deletions config/rbac/kclrun_viewer_role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ metadata:
name: kclrun-viewer-role
rules:
- apiGroups:
- krm.kcl.dev.kcl-lang.io
- krm.kcl.dev
resources:
- kclruns
verbs:
- get
- list
- watch
- apiGroups:
- krm.kcl.dev.kcl-lang.io
- krm.kcl.dev
resources:
- kclruns/status
verbs:
Expand Down
6 changes: 3 additions & 3 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
name: manager-role
rules:
- apiGroups:
- krm.kcl.dev.kcl-lang.io
- krm.kcl.dev
resources:
- kclruns
verbs:
Expand All @@ -18,13 +18,13 @@ rules:
- update
- watch
- apiGroups:
- krm.kcl.dev.kcl-lang.io
- krm.kcl.dev
resources:
- kclruns/finalizers
verbs:
- update
- apiGroups:
- krm.kcl.dev.kcl-lang.io
- krm.kcl.dev
resources:
- kclruns/status
verbs:
Expand Down
2 changes: 1 addition & 1 deletion config/samples/krm.kcl.dev_v1alpha1_kclrun.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: krm.kcl.dev.kcl-lang.io/v1alpha1
apiVersion: krm.kcl.dev/v1alpha1
kind: KCLRun
metadata:
labels:
Expand Down
6 changes: 3 additions & 3 deletions controllers/kclrun_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ type KCLRunReconciler struct {
Scheme *runtime.Scheme
}

//+kubebuilder:rbac:groups=krm.kcl.dev.kcl-lang.io,resources=kclruns,verbs=get;list;watch;create;update;patch;delete
//+kubebuilder:rbac:groups=krm.kcl.dev.kcl-lang.io,resources=kclruns/status,verbs=get;update;patch
//+kubebuilder:rbac:groups=krm.kcl.dev.kcl-lang.io,resources=kclruns/finalizers,verbs=update
//+kubebuilder:rbac:groups=krm.kcl.dev,resources=kclruns,verbs=get;list;watch;create;update;patch;delete
//+kubebuilder:rbac:groups=krm.kcl.dev,resources=kclruns/status,verbs=get;update;patch
//+kubebuilder:rbac:groups=krm.kcl.dev,resources=kclruns/finalizers,verbs=update

// Reconcile is part of the main kubernetes reconciliation loop which aims to
// move the current state of the cluster closer to the desired state.
Expand Down
Binary file added images/arch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 12f83aa

Please sign in to comment.