-
Notifications
You must be signed in to change notification settings - Fork 50
refactor: judge kubernetes user guide structure #110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...orking-with-k8s/generate_k8s_manifests.md → ...king-with-k8s/2-generate-k8s-manifests.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
docs/user_docs/guides/working-with-k8s/3-mutate-manifests/1-kubectl-kcl-plugin.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| --- | ||
| title: "Kubectl KCL Plugin" | ||
| sidebar_position: 1 | ||
| --- | ||
|
|
||
| ## Introduction | ||
|
|
||
| [Kubectl](https://kubernetes.io/docs/reference/kubectl/) is a command line tool for communicating with a Kubernetes cluster's control plane, using the Kubernetes API. You can use the `Kubectl-KCL-Plugin` to | ||
|
|
||
| + Edit the YAML configuration in a hook way to separate data and logic for the Kubernetes manifests management. | ||
| + For multi-environment and multi-tenant scenarios, you can maintain these configurations gracefully rather than simply copy and paste. | ||
| + Validate all KRM resources using the KCL schema. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| + Install [Kubectl](https://github.com/kubernetes/kubectl) | ||
| + Install [Kubectl KCL Plugin](https://github.com/kcl-lang/kubectl-kcl) | ||
|
|
||
| ## Quick Start | ||
|
|
||
| Let’s write a KCL function which add annotation `managed-by=krm-kcl` only to `Deployment` resources in the helm chart. | ||
|
|
||
| ### 1. Get the Example | ||
|
|
||
| ```bash | ||
| git clone https://github.com/kcl-lang/kubectl-kcl.git/ | ||
| cd ./kubectl-kcl/examples/ | ||
| ``` | ||
|
|
||
| ### 2. Test and Run | ||
|
|
||
| Run the KCL code via the `Kubectl KCL Plugin`. | ||
|
|
||
| ```bash | ||
| kubectl kcl run -f ./kcl-run.yaml | ||
| ``` | ||
|
|
||
| The output yaml is | ||
|
|
||
| ```yaml | ||
| apiVersion: config.kubernetes.io/v1 | ||
| kind: ResourceList | ||
| items: | ||
| - apiVersion: apps/v1 | ||
| kind: Deployment | ||
| metadata: | ||
| annotations: | ||
| managed-by: krm-kcl | ||
| labels: | ||
| app: nginx | ||
| name: nginx-deployment | ||
| spec: | ||
| replicas: 3 | ||
| selector: | ||
| matchLabels: | ||
| app: nginx | ||
| template: | ||
| metadata: | ||
| labels: | ||
| app: nginx | ||
| spec: | ||
| containers: | ||
| - image: "nginx:1.14.2" | ||
| name: nginx | ||
| ports: | ||
| - containerPort: 80 | ||
| - apiVersion: v1 | ||
| kind: Service | ||
| metadata: | ||
| name: test | ||
| spec: | ||
| ports: | ||
| - port: 80 | ||
| protocol: TCP | ||
| targetPort: 9376 | ||
| selector: | ||
| app: MyApp | ||
| functionConfig: | ||
| # kcl-fn-config.yaml | ||
| apiVersion: krm.kcl.dev/v1alpha1 | ||
| kind: KCLRun | ||
| metadata: | ||
| # EDIT THE SOURCE! | ||
| # This should be your KCL code which preloads the `ResourceList` to `option("resource_list") | ||
| spec: | ||
| source: | | ||
| [resource | {if resource.kind == "Deployment": metadata.annotations: {"managed-by" = "krm-kcl"}} for resource in option("resource_list").items] | ||
| ``` | ||
|
|
||
| ## Guides for Developing KCL | ||
|
|
||
| Here's what you can do in the KCL code: | ||
|
|
||
| + Read resources from `option("resource_list")`. The `option("resource_list")` complies with the [KRM Functions Specification](https://kpt.dev/book/05-developing-functions/01-functions-specification). You can read the input resources from `option("resource_list")["items"]` and the `functionConfig` from `option("resource_list")["functionConfig"]`. | ||
| + Return a KPM list for output resources. | ||
| + Return an error using `assert {condition}, {error_message}`. | ||
|
|
||
| ## More Documents and Examples | ||
|
|
||
| + [Kubectl KCL Plugin](https://github.com/kcl-lang/kubectl-kcl) |
2 changes: 1 addition & 1 deletion
2
...uides/working-with-k8s/helm_kcl_plugin.md → ...s/3-mutate-manifests/2-helm-kcl-plugin.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| --- | ||
| title: "Helm KCL Plugin" | ||
| sidebar_position: 4 | ||
| sidebar_position: 2 | ||
| --- | ||
|
|
||
| ## Introduction | ||
|
|
||
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...cs/guides/working-with-k8s/kpt_kcl_sdk.md → ...h-k8s/3-mutate-manifests/4-kpt-kcl-sdk.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| --- | ||
| title: "KPT KCL SDK" | ||
| sidebar_position: 5 | ||
| sidebar_position: 4 | ||
| --- | ||
|
|
||
| ## Introduction | ||
|
|
||
4 changes: 4 additions & 0 deletions
4
docs/user_docs/guides/working-with-k8s/3-mutate-manifests/_category_.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "label": "Mutate or Validate Kubernetes Manifests", | ||
| "position": 3 | ||
| } |
2 changes: 1 addition & 1 deletion
2
...ides/_working-with-kusion/_category_.json → ...uides/working-with-kusion/_category_.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| { | ||
| "label": "KusionStack", | ||
| "position": 11 | ||
| "position": 13 | ||
| } |
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does that mean:
KCL also supports OpenAPI through the
kcl-openapi toolSeems this guide is exactly about kcl supporting OpenAPI and CRD through kcl-openapi tool?