mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 17:12:51 +00:00
Docs: Auto-fix markdownlint issues
This commit is contained in:
@@ -28,7 +28,6 @@ linkTitle = "Kustomize"
|
||||
|
||||
{{< blocks/section >}}
|
||||
|
||||
|
||||
{{% blocks/feature icon="fab fa-github" title="参与贡献" %}}
|
||||
欢迎在 **Github** 提交 [RP](https://github.com/kubernetes-sigs/kustomize/pulls),贡献你的力量。
|
||||
{{% /blocks/feature %}}
|
||||
|
||||
@@ -96,4 +96,4 @@ spec:
|
||||
app: bingo
|
||||
owner: alice
|
||||
someName: someValue
|
||||
```
|
||||
```
|
||||
|
||||
@@ -9,6 +9,7 @@ description: >
|
||||
列表中的每个条目都将生成一个 ConfigMap (合计可以生成 n 个 ConfigMap)。
|
||||
|
||||
以下示例创建四个 ConfigMap:
|
||||
|
||||
- 第一个使用给定文件的名称和内容创建数据
|
||||
- 第二个使用文件中的键/值对将数据创建为键/值
|
||||
- 第三个使用 `literals` 中的键/值对创建数据作为键/值
|
||||
@@ -69,4 +70,4 @@ configMapGenerator:
|
||||
- name: app-whatever
|
||||
files:
|
||||
- myFileName.ini=whatever.ini
|
||||
```
|
||||
```
|
||||
|
||||
@@ -17,12 +17,12 @@ description: >
|
||||
|
||||
Annotations 可以放入 openAPI 的定义中:
|
||||
|
||||
- "x-kubernetes-annotation": ""
|
||||
- "x-kubernetes-label-selector": ""
|
||||
- "x-kubernetes-identity": ""
|
||||
- "x-kubernetes-object-ref-api-version": "v1",
|
||||
- "x-kubernetes-object-ref-kind": "Secret",
|
||||
- "x-kubernetes-object-ref-name-key": "name",
|
||||
- "x-kubernetes-annotation": ""
|
||||
- "x-kubernetes-label-selector": ""
|
||||
- "x-kubernetes-identity": ""
|
||||
- "x-kubernetes-object-ref-api-version": "v1",
|
||||
- "x-kubernetes-object-ref-kind": "Secret",
|
||||
- "x-kubernetes-object-ref-name-key": "name",
|
||||
|
||||
```yaml
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
|
||||
@@ -26,11 +26,11 @@ spec:
|
||||
```
|
||||
|
||||
想要将 `image` 做如下更改:
|
||||
|
||||
- 将 `postgres:8` 改为 `my-registry/my-postgres:v1`
|
||||
- 将 nginx tag 从 `1.7.9` 改为 `1.8.0`
|
||||
- 将镜像名称 `my-demo-app` 改为 `my-app`
|
||||
- 将 alpine 的 tag `3.7` 改为 digest 值
|
||||
|
||||
- 将 `postgres:8` 改为 `my-registry/my-postgres:v1`
|
||||
- 将 nginx tag 从 `1.7.9` 改为 `1.8.0`
|
||||
- 将镜像名称 `my-demo-app` 改为 `my-app`
|
||||
- 将 alpine 的 tag `3.7` 改为 digest 值
|
||||
|
||||
只需在 *kustomization* 中添加以下内容:
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ description: >
|
||||
[strategic merge]: /kustomize/zh/api-reference/glossary#patchstrategicmerge
|
||||
[JSON]: /kustomize/zh/api-reference/glossary#patchjson6902
|
||||
|
||||
|
||||
Patches 在资源上添加或覆盖字段,Kustomization 使用 `patches` 字段来提供该功能。
|
||||
|
||||
`patches` 字段包含要按指定顺序应用的 patch 列表。
|
||||
|
||||
@@ -23,6 +23,7 @@ patchesStrategicMerge:
|
||||
```
|
||||
|
||||
patch 内容也可以是一个inline string:
|
||||
|
||||
```yaml
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
@@ -31,9 +31,10 @@ replicas:
|
||||
该字段内容为列表,所以可以同时修改许多资源。
|
||||
|
||||
由于这个声明无法设置 `kind:` 或 `group:`,所以他只能匹配如下资源中的一种:
|
||||
|
||||
- `Deployment`
|
||||
- `ReplicationController`
|
||||
- `ReplicaSet`
|
||||
- `StatefulSet`
|
||||
|
||||
对于更复杂的用例,请使用 patch 。
|
||||
对于更复杂的用例,请使用 patch 。
|
||||
|
||||
@@ -7,6 +7,7 @@ description: >
|
||||
---
|
||||
|
||||
该条目可以是指向本地目录的相对路径,也可以是指向远程仓库中的目录的 URL,例如:
|
||||
|
||||
```yaml
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
@@ -10,13 +10,13 @@ Initial release after move from github.com/kubernetes/kubectl to github.com/kube
|
||||
|
||||
History
|
||||
|
||||
* May 2018: v1.0 after move to github.com/kubernetes-sigs/kubectl
|
||||
* May 2018: v1.0 after move to github.com/kubernetes-sigs/kubectl
|
||||
from github.com/kubernetes/kubectl.
|
||||
Has kustomization file, bases, overlays, basic transforms.
|
||||
* Apr 2018: s/kinflate/kustomize/, s/manifest/kustomization/
|
||||
* Oct 2017: s/kexpand/kinflate/
|
||||
* Sep 2017: kexpand [starts](https://github.com/kubernetes/kubectl/pull/65)
|
||||
* Apr 2018: s/kinflate/kustomize/, s/manifest/kustomization/
|
||||
* Oct 2017: s/kexpand/kinflate/
|
||||
* Sep 2017: kexpand [starts](https://github.com/kubernetes/kubectl/pull/65)
|
||||
in github.com/kubernetes/kubectl
|
||||
* Aug 2017: [DAM] authored by Brian Grant
|
||||
* Aug 2017: [DAM] authored by Brian Grant
|
||||
|
||||
[DAM]: https://docs.google.com/document/d/1cLPGweVEYrVqQvBLJg6sxV-TrE5Rm2MNOBA_cxZP2WU
|
||||
|
||||
@@ -151,7 +151,7 @@ path or URL to a kustomization directory in the
|
||||
![pruning dead branches][imgPruning]
|
||||
|
||||
_Alpha_
|
||||
|
||||
|
||||
Users can add an `inventory` stanza to their
|
||||
kustomization file, to add a special _inventory
|
||||
object_ to the `build` result.
|
||||
@@ -164,10 +164,9 @@ orphaned cluster resources.
|
||||
For more information see the
|
||||
[kustomize inventory object documentation].
|
||||
|
||||
|
||||
## Field changes / deprecations
|
||||
|
||||
### `resources` expanded, `bases` deprecated
|
||||
### `resources` expanded, `bases` deprecated
|
||||
|
||||
The `resources` field has been generalized; it now
|
||||
accepts what formerly could only be specified in
|
||||
@@ -235,7 +234,7 @@ or transform a generator or a transformer (see
|
||||
|
||||
The common task of patching a deployment to edit
|
||||
the number of replicas is now made easier
|
||||
with the new [replicas](/kustomize/api-reference/kustomization/replicas) field.
|
||||
with the new [replicas](/kustomize/api-reference/kustomization/replicas) field.
|
||||
|
||||
### `envs` field
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ floor on a stable API for [plugin] developers
|
||||
(both _Go_ plugin developers and _exec_ plugin
|
||||
developers who happen to use Go).
|
||||
|
||||
### Why so soon after v2.1.0?
|
||||
### Why so soon after v2.1.0
|
||||
|
||||
[semantic versioning]: https://semver.org
|
||||
[Go modules doc]: https://github.com/golang/go/wiki/Modules#releasing-modules-v2-or-higher
|
||||
@@ -70,6 +70,3 @@ Aside - the set of kustomize packages outside
|
||||
by package use, this API surface must shrink.
|
||||
Such shrinkage will trigger a major version
|
||||
increment.
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ description: >
|
||||
---
|
||||
|
||||
## Extended patches
|
||||
|
||||
Since this version, Kustomize allows applying one patch to multiple resources. This works for both Strategic Merge Patch and JSON Patch. Take a look at [patch multiple objects](https://github.com/kubernetes-sigs/kustomize/tree/master/examples/patchMultipleObjects.md).
|
||||
|
||||
## Improved Resource Matching
|
||||
@@ -52,7 +53,6 @@ spec:
|
||||
value: PRODVALUE
|
||||
```
|
||||
|
||||
|
||||
### Variable resolution improvement
|
||||
|
||||
It is possible to add namespace field to the variable declaration. In the following example,
|
||||
@@ -87,7 +87,8 @@ vars:
|
||||
### Simultaneous change of names and namespaces
|
||||
|
||||
Kustomize is now able to deal with simultaneous changes of name and namespace.
|
||||
Special attention has been paid the handling of:
|
||||
Special attention has been paid the handling of:
|
||||
|
||||
- ClusterRoleBinding/RoleBinding "subjects" field,
|
||||
- ValidatingWebhookConfiguration "webhooks" field.
|
||||
|
||||
@@ -106,7 +107,7 @@ resources:
|
||||
...
|
||||
```
|
||||
|
||||
### Resource and Kustomize Context matching.
|
||||
### Resource and Kustomize Context matching
|
||||
|
||||
Kustomize is now able to support more aggregation patterns.
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ description: >
|
||||
---
|
||||
|
||||
## Inline Patch
|
||||
|
||||
Since this version, Kustomize allows inline patches in all three of `patchesStrategicMerge`, `patchesJson6902` and `patches`. Take a look at [inline patch](https://github.com/kubernetes-sigs/kustomize/tree/master/examples/examples/inlinePatch.md).
|
||||
|
||||
## New Subcommand
|
||||
@@ -14,11 +15,13 @@ Since this version, Kustomize allows inline patches in all three of `patchesStra
|
||||
Since this version, one can create a kustomization.yaml file in a directory through a `create` subcommand.
|
||||
|
||||
Create a new overlay from the base ../base
|
||||
|
||||
```
|
||||
kustomize create --resources ../base
|
||||
```
|
||||
|
||||
Create a new kustomization detecing resources in the current directory
|
||||
|
||||
```
|
||||
kustomize create --autodetect
|
||||
```
|
||||
@@ -30,5 +33,5 @@ kustomize create --autodetect --recursive
|
||||
```
|
||||
|
||||
### New Example Generator
|
||||
A new example generator of using go-getter to download resources is added. Take a look at [go-getter generator](https://github.com/kubernetes-sigs/kustomize/tree/master/examples/goGetterGeneratorPlugin.md).
|
||||
|
||||
A new example generator of using go-getter to download resources is added. Take a look at [go-getter generator](https://github.com/kubernetes-sigs/kustomize/tree/master/examples/goGetterGeneratorPlugin.md).
|
||||
|
||||
@@ -9,10 +9,10 @@ description: >
|
||||
|
||||
[versioning policy documentation]: /site/content/en/faq/versioningPolicy.md
|
||||
[release process documentation]: /releasing
|
||||
|
||||
|
||||
## Summary of changes
|
||||
|
||||
### First release of the Go API-only module.
|
||||
### First release of the Go API-only module
|
||||
|
||||
Many of the PRs since the last vrelease were
|
||||
around restructuring the _sigs.k8s.io/kustomize_
|
||||
@@ -43,7 +43,6 @@ any other client.
|
||||
The new semver-able API will begin with `v4.0.0` (not
|
||||
yet released) and be a clean break with `v3` etc.
|
||||
|
||||
|
||||
### Change log since v3.2.0
|
||||
|
||||
```
|
||||
|
||||
@@ -14,10 +14,10 @@ description: >
|
||||
File issues as desired, but if you've found a problem
|
||||
with how `kustomize build` works, please report
|
||||
|
||||
* the output of `kustomize version`,
|
||||
* the input (the content of `kustomization.yaml`
|
||||
* the output of `kustomize version`,
|
||||
* the input (the content of `kustomization.yaml`
|
||||
and any files it refers to),
|
||||
* the expected YAML output.
|
||||
* the expected YAML output.
|
||||
|
||||
## If you have `go` installed
|
||||
|
||||
@@ -26,7 +26,7 @@ package] for specifying a kustomization's input and the
|
||||
expected output.
|
||||
|
||||
Copy one of those tests, e.g. this [reusable custom
|
||||
transformer test], to a new test file in the
|
||||
transformer test], to a new test file in the
|
||||
krusty package.
|
||||
|
||||
Insert the inputs you want to use, and run it as
|
||||
|
||||
@@ -21,5 +21,3 @@ If you are interested in contributing towards Kustomize or getting more involved
|
||||
- join the [mailing list] and reach out
|
||||
- join the [slack channel] and reach out
|
||||
- attend one of the [bi-weekly meetings] (alternating Wednesdays at 9:00am Pacific Time)
|
||||
|
||||
|
||||
|
||||
@@ -79,4 +79,3 @@ Changes must be pushed to the fork's **master branch** to be served as the fork'
|
||||
4. Commit and push the changes to the *remote fork's* **master branch**
|
||||
5. After a few minutes, the docs should be served from the fork's GitHub Page
|
||||
- e.g. [https://pwittrock.github.io/kustomize/](https://pwittrock.github.io/kustomize/)
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@ description: >
|
||||
[eschewed feature list]: https://kubernetes-sigs.github.io/kustomize/faq/eschewedfeatures/
|
||||
[kind/feature]: https://github.com/kubernetes-sigs/kustomize/labels/kind%2Ffeature
|
||||
|
||||
|
||||
Following is the process for proposing a new Kustomize feature:
|
||||
|
||||
1. Check the [eschewed feature list] to see if the feature has already been proposed
|
||||
|
||||
@@ -48,7 +48,7 @@ Call stack when running `kustomize build`, with links to code.
|
||||
* Iterate all generators
|
||||
* [runTransfomers](https://github.com/kubernetes-sigs/kustomize/blob/c7d78970fb86782dbdded3a93944b774f826071f/api/internal/target/kusttarget.go#L274)
|
||||
* [configureBuiltinTransformers](https://github.com/kubernetes-sigs/kustomize/blob/c7d78970fb86782dbdded3a93944b774f826071f/api/internal/target/kusttarget_configplugin.go#L44)
|
||||
* PatchStrategicMergeTransformer
|
||||
* PatchStrategicMergeTransformer
|
||||
* PatchTransformer
|
||||
* NamespaceTransformer
|
||||
* PrefixSuffixTransformer
|
||||
@@ -62,4 +62,4 @@ Call stack when running `kustomize build`, with links to code.
|
||||
* The following steps must be done last, not as part of the recursion implicit in AccumulateTarget.
|
||||
* [addHashesToNames](https://github.com/kubernetes-sigs/kustomize/blob/c7d78970fb86782dbdded3a93944b774f826071f/api/internal/target/kusttarget.go#L153)
|
||||
* [FixBackReferences](https://github.com/kubernetes-sigs/kustomize/blob/c7d78970fb86782dbdded3a93944b774f826071f/api/internal/accumulator/resaccumulator.go#L160): Given that names have changed (prefixs/suffixes added), fix all the back references to those names.
|
||||
* [ResolveVars](https://github.com/kubernetes-sigs/kustomize/blob/c7d78970fb86782dbdded3a93944b774f826071f/api/internal/accumulator/resaccumulator.go#L141)
|
||||
* [ResolveVars](https://github.com/kubernetes-sigs/kustomize/blob/c7d78970fb86782dbdded3a93944b774f826071f/api/internal/accumulator/resaccumulator.go#L141)
|
||||
|
||||
@@ -9,34 +9,38 @@ description: >
|
||||
|
||||
This is the PowerShell script to run all go tests for Kustomize on a windows based platform which mimics /build/pre-commit.sh
|
||||
|
||||
## Pre-Reqs:
|
||||
- PowerShell installed
|
||||
- PowerShell Core is supported
|
||||
- go installed
|
||||
- golangci-lint installed
|
||||
- mdrip installed
|
||||
## Pre-Reqs
|
||||
|
||||
- PowerShell installed
|
||||
- PowerShell Core is supported
|
||||
- go installed
|
||||
- golangci-lint installed
|
||||
- mdrip installed
|
||||
|
||||
This script should output to the current console and return an exit code if all tests are successful(0) or any failed(1).
|
||||
|
||||
### If you are tryin to run these tests locally you can follow these instructions.
|
||||
### If you are tryin to run these tests locally you can follow these instructions
|
||||
|
||||
Assume:
|
||||
- Running a stock Windows 10 system
|
||||
- Local Admin rights.
|
||||
- You can open [PowerShell as administrator](http://lmgtfy.com/?iie=1&q=How+to+open+powershell+as+administrator)
|
||||
- You should be knowledgeable enough to pull source for packages into your GO ```src``` directory
|
||||
- Yes, this means you also need to know a bit about **git** usually
|
||||
Assume:
|
||||
|
||||
- Running a stock Windows 10 system
|
||||
- Local Admin rights.
|
||||
- You can open [PowerShell as administrator](http://lmgtfy.com/?iie=1&q=How+to+open+powershell+as+administrator)
|
||||
- You should be knowledgeable enough to pull source for packages into your GO ```src``` directory
|
||||
- Yes, this means you also need to know a bit about **git** usually
|
||||
|
||||
#### Step 1 - Install Go
|
||||
- [Install Go](https://golang.org/dl/) - please use the msi
|
||||
- If you use chocolatey - it's using the zip not msi and assumptions on where go is located are made for you.
|
||||
|
||||
- [Install Go](https://golang.org/dl/) - please use the msi
|
||||
- If you use chocolatey - it's using the zip not msi and assumptions on where go is located are made for you.
|
||||
|
||||
#### Step 2 - Install Go Packages
|
||||
- Open new PowerShell Administrative window
|
||||
- Install golangci-lint
|
||||
- ```go get -u github.com/golangci/golangci-lint/cmd/golangci-lint```
|
||||
- Install mdrip
|
||||
- ```go get github.com/monopole/mdrip```
|
||||
|
||||
- Open new PowerShell Administrative window
|
||||
- Install golangci-lint
|
||||
- ```go get -u github.com/golangci/golangci-lint/cmd/golangci-lint```
|
||||
- Install mdrip
|
||||
- ```go get github.com/monopole/mdrip```
|
||||
|
||||
You should now be able to issue these commands and see comparable responses
|
||||
|
||||
@@ -51,6 +55,7 @@ Usage: C:\_go\bin\mdrip.exe {fileName}...
|
||||
```
|
||||
|
||||
#### Step 3 - Get Source and Test
|
||||
|
||||
- In your GoRoot src
|
||||
- ```Example: C:\_go\src```
|
||||
- Navigate to the Kustomize `travis` directory
|
||||
|
||||
@@ -40,7 +40,7 @@ kustomize build --load_restrictor none $target
|
||||
|
||||
Example: [#1319](https://github.com/kubernetes-sigs/kustomize/issues/1319), [#1322](https://github.com/kubernetes-sigs/kustomize/issues/1322), [#1347](https://github.com/kubernetes-sigs/kustomize/issues/1347) and etc.
|
||||
|
||||
The fields transformed by kustomize is configured explicitly in [defaultconfig](https://github.com/kubernetes-sigs/kustomize/tree/master/api/konfig/builtinpluginconsts/defaultconfig.go). The configuration itself can be customized by including `configurations` in `kustomization.yaml`, e.g.
|
||||
The fields transformed by kustomize is configured explicitly in [defaultconfig](https://github.com/kubernetes-sigs/kustomize/tree/master/api/konfig/builtinpluginconsts/defaultconfig.go). The configuration itself can be customized by including `configurations` in `kustomization.yaml`, e.g.
|
||||
|
||||
```yaml
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
|
||||
@@ -51,7 +51,7 @@ knowledge of the k8s API, and YAML or JSON syntax.
|
||||
Most edits performed by kustomize can be expressed as
|
||||
[JSON patches] or [SMP patches].
|
||||
Those can be verbose, so common patches,
|
||||
like adding labels or annotatations, get dedicated
|
||||
like adding labels or annotatations, get dedicated
|
||||
transformer plugins - `LabelTransformer`,
|
||||
`AnnotationsTransformer`, etc.
|
||||
These accept relatively simple YAML configuration
|
||||
@@ -69,7 +69,7 @@ informed error messages if inputs are invalid.
|
||||
|
||||
_Unstructured edits_, edits that don't limit
|
||||
themselves to a syntax or object structure,
|
||||
come in many forms. A common one in the
|
||||
come in many forms. A common one in the
|
||||
configuration domain is the template or
|
||||
parameterization approach.
|
||||
|
||||
@@ -93,7 +93,7 @@ kustomize eschews parameterization, because
|
||||
- The input becomes [unintelligible] as the project
|
||||
scales in any number of dimensions (resource
|
||||
count, cluster count, environment count, etc.)
|
||||
|
||||
|
||||
Kustomizations are meant to be sharable and stackable.
|
||||
Imagine tracing down a problem rooted in a
|
||||
clever set of stacked regexp replacements
|
||||
@@ -132,7 +132,6 @@ kustomize edit set image nginx:$MY_NGINX_VERSION
|
||||
as part of some encapsulating work flow executed before
|
||||
`kustomize build`.
|
||||
|
||||
|
||||
## Globs in kustomization files
|
||||
|
||||
`kustomize` supports the best practice of storing one's
|
||||
|
||||
@@ -118,10 +118,8 @@ itself is an API client requiring this module.
|
||||
|
||||
The clients and API will evolve independently.
|
||||
|
||||
|
||||
## Kustomization File Versioning
|
||||
|
||||
|
||||
The kustomization file is a struct that is part of
|
||||
the kustomize Go API (the `sigs.k8s.io/kustomize`
|
||||
module), but it also evolves as a k8s API object -
|
||||
|
||||
@@ -51,6 +51,7 @@ description: >
|
||||
> ```
|
||||
|
||||
也可以在 [kubectl-v1.14.0] 版,使用 ```kubectl``` 命令发布你的 [variants] 。
|
||||
>
|
||||
> ```
|
||||
> kubectl apply -k ~/ldap/overlays/staging
|
||||
> kubectl apply -k ~/ldap/overlays/production
|
||||
|
||||
@@ -45,6 +45,7 @@ description: >
|
||||
> ```
|
||||
|
||||
也可以在 [kubectl-v1.14.0] 版,使用 ```kubectl``` 命令发布你的 [variants] 。
|
||||
>
|
||||
> ```bash
|
||||
> kubectl apply -k ~/ldap/overlays/staging
|
||||
> kubectl apply -k ~/ldap/overlays/production
|
||||
|
||||
@@ -16,8 +16,8 @@ Kustomize 提供一个插件框架,允许用户开发自己的 _生成器_ 和
|
||||
|
||||
[12-factor]: https://12factor.net
|
||||
|
||||
* _generator_ 插件生成 k8s 资源,比如 [helm chart inflator] 是一个 generator 插件,基于少量自由变量生成一个 [12-factor] 应用所包含的全部组件 deployment,service,scaler,ingress 等)也是一个 generator 插件。
|
||||
* _transformer_ 插件转化(修改)k8s 资源,比如可能会执行对特殊容器命令行的编辑,或为其他内置转换器(`namePrefix`、`commonLabels` 等)无法转换的内容提供转换。
|
||||
* _generator_ 插件生成 k8s 资源,比如 [helm chart inflator] 是一个 generator 插件,基于少量自由变量生成一个 [12-factor] 应用所包含的全部组件 deployment,service,scaler,ingress 等)也是一个 generator 插件。
|
||||
* _transformer_ 插件转化(修改)k8s 资源,比如可能会执行对特殊容器命令行的编辑,或为其他内置转换器(`namePrefix`、`commonLabels` 等)无法转换的内容提供转换。
|
||||
|
||||
## `kustomization.yaml` 的格式
|
||||
|
||||
@@ -42,7 +42,6 @@ Kustomize 提供一个插件框架,允许用户开发自己的 _生成器_ 和
|
||||
|
||||
从磁盘上读取 YAML 文件,kustomization 的路径或 URL 会触发 kustomization 的运行。由此产生的每个的对象都会被 kustomize 进一步解析为 _plugin configuration_ 对象。
|
||||
|
||||
|
||||
## 配置
|
||||
|
||||
kustomization 文件可以包含如下内容:
|
||||
@@ -149,10 +148,10 @@ _exec 插件_ 是一个可以在命令行中接收参数可执行文件,该参
|
||||
|
||||
#### 示例
|
||||
|
||||
* [helm chart inflator] - helm chart inflates 生成器。
|
||||
* [bashed config map] - 使用 bash 生成十分简单的 configMap。
|
||||
* [sed transformer] - 使用插件来定义非结构化的编辑。
|
||||
* [hashicorp go-getter] - 下载 kustomize layes 并通过构建它来生成资源。
|
||||
* [helm chart inflator] - helm chart inflates 生成器。
|
||||
* [bashed config map] - 使用 bash 生成十分简单的 configMap。
|
||||
* [sed transformer] - 使用插件来定义非结构化的编辑。
|
||||
* [hashicorp go-getter] - 下载 kustomize layes 并通过构建它来生成资源。
|
||||
|
||||
生成器插件无需在 `stdin` 上输入任何东西,就会将生成的资源输出到 `stdout`。
|
||||
|
||||
@@ -173,6 +172,7 @@ kustomize 会使用 exec 插件适配器,为 `stdin` 提供的资源,并获
|
||||
如果此注释被设置在不受哈希转换器支持的资源上,将导致构建将失败。
|
||||
|
||||
示例:
|
||||
|
||||
```yaml
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
@@ -181,7 +181,7 @@ metadata:
|
||||
annotations:
|
||||
kustomize.config.k8s.io/needs-hash: "true"
|
||||
data:
|
||||
foo: bar
|
||||
foo: bar
|
||||
```
|
||||
|
||||
**`kustomize.config.k8s.io/behavior`**
|
||||
@@ -189,6 +189,7 @@ data:
|
||||
`behavior` 注释为当资源发生冲突时插件的处理方式,有效值包括:"create"、"merge "和 "replace",默认为 "create"。
|
||||
|
||||
示例:
|
||||
|
||||
```yaml
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
@@ -197,7 +198,7 @@ metadata:
|
||||
annotations:
|
||||
kustomize.config.k8s.io/behavior: "merge"
|
||||
data:
|
||||
foo: bar
|
||||
foo: bar
|
||||
```
|
||||
|
||||
### Go 插件
|
||||
@@ -216,8 +217,8 @@ kustomize 的一个 Go 插件看起来是这样的:
|
||||
> package main
|
||||
>
|
||||
> import (
|
||||
> "sigs.k8s.io/kustomize/api/ifc"
|
||||
> "sigs.k8s.io/kustomize/api/resmap"
|
||||
> "sigs.k8s.io/kustomize/api/ifc"
|
||||
> "sigs.k8s.io/kustomize/api/resmap"
|
||||
> ...
|
||||
> )
|
||||
>
|
||||
@@ -247,12 +248,12 @@ kustomize 的一个 Go 插件看起来是这样的:
|
||||
|
||||
#### 示例
|
||||
|
||||
* [service generator] - 使用 name 和 port 参数生成一个 service。
|
||||
* [string prefixer] - 使用 `metadata/name` 值作为前缀。这个特殊的示例是为了展示插件的转化行为。详见 `target` 包中的 `TestTransformedTransformers` 测试。
|
||||
* [date prefixer] - 将当前日期作为前缀添加到资源名称上,这是一个用于修改刚才提到的字符串前缀插件的简单示例。
|
||||
* [secret generator] - 从 toy 数据库生成 secret。
|
||||
* [sops encoded secrets] - 一个更复杂的 secret 生成器。
|
||||
* [All the builtin plugins](https://github.com/kubernetes-sigs/kustomize/tree/master/plugin/builtin).
|
||||
* [service generator] - 使用 name 和 port 参数生成一个 service。
|
||||
* [string prefixer] - 使用 `metadata/name` 值作为前缀。这个特殊的示例是为了展示插件的转化行为。详见 `target` 包中的 `TestTransformedTransformers` 测试。
|
||||
* [date prefixer] - 将当前日期作为前缀添加到资源名称上,这是一个用于修改刚才提到的字符串前缀插件的简单示例。
|
||||
* [secret generator] - 从 toy 数据库生成 secret。
|
||||
* [sops encoded secrets] - 一个更复杂的 secret 生成器。
|
||||
* [All the builtin plugins](https://github.com/kubernetes-sigs/kustomize/tree/master/plugin/builtin).
|
||||
用户自制的插件与内置插件是一样的。
|
||||
|
||||
Go 插件既可以是生成器,也可以是转化器。`Generate` 方法将在 `Transform` 方法运行之前与所有其他生成器一起运行。
|
||||
|
||||
@@ -50,6 +50,7 @@ commonAnnotations:
|
||||
> FieldSpecs \[\][config.FieldSpec]
|
||||
|
||||
#### Example
|
||||
>
|
||||
> ```yaml
|
||||
> apiVersion: builtin
|
||||
> kind: AnnotationsTransformer
|
||||
@@ -63,8 +64,6 @@ commonAnnotations:
|
||||
> create: true
|
||||
> ```
|
||||
|
||||
|
||||
|
||||
## _ConfigMapGenerator_
|
||||
|
||||
### 使用 `kustomization.yaml`
|
||||
@@ -94,7 +93,7 @@ configMapGenerator:
|
||||
- application.properties
|
||||
- more.properties
|
||||
- name: my-java-server-env-vars
|
||||
literals:
|
||||
literals:
|
||||
- JAVA_HOME=/opt/java/jdk
|
||||
- JAVA_TOOL_OPTIONS=-agentlib:hprof
|
||||
options:
|
||||
@@ -129,6 +128,7 @@ configMapGenerator:
|
||||
> [types.ConfigMapArgs]
|
||||
|
||||
#### Example
|
||||
>
|
||||
> ```yaml
|
||||
> apiVersion: builtin
|
||||
> kind: ConfigMapGenerator
|
||||
@@ -142,7 +142,6 @@ configMapGenerator:
|
||||
> - VEGETABLE=carrot
|
||||
> ```
|
||||
|
||||
|
||||
## _ImageTagTransformer_
|
||||
|
||||
### 使用 `kustomization.yaml`
|
||||
@@ -164,11 +163,11 @@ containers:
|
||||
```
|
||||
|
||||
想要将 `image` 做如下更改:
|
||||
|
||||
- 将 `postgres:8` 改为 `my-registry/my-postgres:v1`
|
||||
- 将 nginx tag 从 `1.7.9` 改为 `1.8.0`
|
||||
- 将镜像名称 `my-demo-app` 改为 `my-app`
|
||||
- 将 alpine 的 tag `3.7` 改为 digest 值
|
||||
|
||||
- 将 `postgres:8` 改为 `my-registry/my-postgres:v1`
|
||||
- 将 nginx tag 从 `1.7.9` 改为 `1.8.0`
|
||||
- 将镜像名称 `my-demo-app` 改为 `my-app`
|
||||
- 将 alpine 的 tag `3.7` 改为 digest 值
|
||||
|
||||
只需在 *kustomization* 中添加以下内容:
|
||||
|
||||
@@ -194,6 +193,7 @@ images:
|
||||
> FieldSpecs \[\][config.FieldSpec]
|
||||
|
||||
#### Example
|
||||
>
|
||||
> ```yaml
|
||||
> apiVersion: builtin
|
||||
> kind: ImageTagTransformer
|
||||
@@ -204,8 +204,6 @@ images:
|
||||
> newTag: v2
|
||||
> ```
|
||||
|
||||
|
||||
|
||||
## _LabelTransformer_
|
||||
|
||||
### 使用 `kustomization.yaml`
|
||||
@@ -230,6 +228,7 @@ commonLabels:
|
||||
> FieldSpecs \[\][config.FieldSpec]
|
||||
|
||||
#### Example
|
||||
>
|
||||
> ```yaml
|
||||
> apiVersion: builtin
|
||||
> kind: LabelTransformer
|
||||
@@ -264,6 +263,7 @@ namespace: my-namespace
|
||||
> FieldSpecs \[\][config.FieldSpec]
|
||||
|
||||
#### Example
|
||||
>
|
||||
> ```yaml
|
||||
> apiVersion: builtin
|
||||
> kind: NamespaceTransformer
|
||||
@@ -345,6 +345,7 @@ patchesJson6902:
|
||||
### 使用插件
|
||||
|
||||
#### Arguments
|
||||
|
||||
> Target [types.PatchTarget]
|
||||
>
|
||||
> Path string
|
||||
@@ -352,6 +353,7 @@ patchesJson6902:
|
||||
> JsonOp string
|
||||
|
||||
#### Example
|
||||
>
|
||||
> ```yaml
|
||||
> apiVersion: builtin
|
||||
> kind: PatchJson6902Transformer
|
||||
@@ -385,6 +387,7 @@ patchesStrategicMerge:
|
||||
```
|
||||
|
||||
patch 内容也可以是一个inline string:
|
||||
|
||||
```yaml
|
||||
patchesStrategicMerge:
|
||||
- |-
|
||||
@@ -411,6 +414,7 @@ patchesStrategicMerge:
|
||||
> Patches string
|
||||
|
||||
#### Example
|
||||
>
|
||||
> ```yaml
|
||||
> apiVersion: builtin
|
||||
> kind: PatchStrategicMergeTransformer
|
||||
@@ -420,7 +424,6 @@ patchesStrategicMerge:
|
||||
> - patch.yaml
|
||||
> ```
|
||||
|
||||
|
||||
## _PatchTransformer_
|
||||
|
||||
### 使用 `kustomization.yaml`
|
||||
@@ -460,9 +463,10 @@ is equivalent to `^myapp$`。
|
||||
>
|
||||
> Patch string
|
||||
>
|
||||
> Target \*[types.Selector]
|
||||
> Target \*[types.Selector]
|
||||
|
||||
#### Example
|
||||
>
|
||||
> ```yaml
|
||||
> apiVersion: builtin
|
||||
> kind: PatchTransformer
|
||||
@@ -502,6 +506,7 @@ nameSuffix: -v2
|
||||
> FieldSpecs \[\][config.FieldSpec]
|
||||
|
||||
#### Example
|
||||
>
|
||||
> ```yaml
|
||||
> apiVersion: builtin
|
||||
> kind: PrefixSuffixTransformer
|
||||
@@ -542,6 +547,7 @@ replicas:
|
||||
该字段内容为列表,所以可以同时修改许多资源。
|
||||
|
||||
由于这个声明无法设置 `kind:` 或 `group:`,所以他只能匹配如下资源中的一种:
|
||||
|
||||
- `Deployment`
|
||||
- `ReplicationController`
|
||||
- `ReplicaSet`
|
||||
@@ -558,6 +564,7 @@ replicas:
|
||||
> FieldSpecs \[\][config.FieldSpec]
|
||||
|
||||
#### Example
|
||||
>
|
||||
> ```yaml
|
||||
> apiVersion: builtin
|
||||
> kind: ReplicaCountTransformer
|
||||
|
||||
@@ -15,10 +15,10 @@ description: >
|
||||
|
||||
#### 环境要求
|
||||
|
||||
* `linux`
|
||||
* `git`
|
||||
* `curl`
|
||||
* `Go 1.13`
|
||||
* `linux`
|
||||
* `git`
|
||||
* `curl`
|
||||
* `Go 1.13`
|
||||
|
||||
## 创建一个工作空间/目录
|
||||
|
||||
@@ -203,7 +203,7 @@ mv kustomize $DEMO/bin
|
||||
tree $DEMO
|
||||
```
|
||||
|
||||
## 使用插件构建 APP:
|
||||
## 使用插件构建 APP
|
||||
|
||||
```bash
|
||||
XDG_CONFIG_HOME=$DEMO $DEMO/bin/kustomize build --enable_alpha_plugins $MYAPP
|
||||
|
||||
@@ -50,7 +50,7 @@ go build -buildmode plugin \
|
||||
|
||||
为了进行比较,可以参考编写 [tensorflow plugin] 必须做的事情。
|
||||
|
||||
## 为什么支持 Go 插件?
|
||||
## 为什么支持 Go 插件
|
||||
|
||||
### 安全
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ PLUGIN_ROOT=$DEMO/kustomize/plugin
|
||||
|
||||
并在下面的命令行中临时设置 `XDG_CONFIG_HOME`。
|
||||
|
||||
### 使用什么 apiVersion 和 kind?
|
||||
### 使用什么 apiVersion 和 kind
|
||||
|
||||
在 kustomize 插件的开发时,插件代码不关心也不知道配置文件中的 `apiVersion` 或 `kind`。
|
||||
|
||||
@@ -136,9 +136,9 @@ GOPATH=$tmpGoPath go build -buildmode plugin -o ${kind}.so ${kind}.go
|
||||
|
||||
在加载失败时
|
||||
|
||||
* 确保使用相同版本的Go (_go1.13_),在相同的 `$GOOS`(_linux_)和 `$GOARCH`(_amd64_) 上构建插件,用于构建本演示中使用的 [kustomize](#安装-kustomize)。
|
||||
* 确保使用相同版本的Go (_go1.13_),在相同的 `$GOOS`(_linux_)和 `$GOARCH`(_amd64_) 上构建插件,用于构建本演示中使用的 [kustomize](#安装-kustomize)。
|
||||
|
||||
* 修改插件中的依赖文件 `go.mod` 以匹配 kustomize 使用的版本。
|
||||
* 修改插件中的依赖文件 `go.mod` 以匹配 kustomize 使用的版本。
|
||||
|
||||
缺乏工具和元数据来实现自动化,就不会有一个完整的 Go 插件生态。
|
||||
|
||||
@@ -296,7 +296,7 @@ tree $DEMO
|
||||
> └── secGenerator.yaml
|
||||
> ```
|
||||
|
||||
## 使用插件构建您的应用:
|
||||
## 使用插件构建您的应用
|
||||
|
||||
```shell
|
||||
XDG_CONFIG_HOME=$DEMO $tmpGoPath/bin/kustomize build --enable_alpha_plugins $MYAPP
|
||||
|
||||
@@ -12,5 +12,6 @@ choco install kustomize
|
||||
```
|
||||
|
||||
有关软件包管理器 chocolatey 的使用以及对之前版本的支持,请参考以下链接:
|
||||
|
||||
- [Choco Package](https://chocolatey.org/packages/kustomize)
|
||||
- [Package Source](https://github.com/kenmaglio/choco-kustomize)
|
||||
- [Package Source](https://github.com/kenmaglio/choco-kustomize)
|
||||
|
||||
Reference in New Issue
Block a user