mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-12 01:14:22 +00:00
generate site
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<meta name="generator" content="Hugo 0.76.5" />
|
||||
<meta name="generator" content="Hugo 0.74.3" />
|
||||
|
||||
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
|
||||
|
||||
@@ -26,13 +26,13 @@
|
||||
<meta property="og:type" content="article" />
|
||||
<meta property="og:url" content="https://kubernetes-sigs.github.io/kustomize/zh/blog/2019/06/18/v2.1.0/" />
|
||||
<meta property="article:published_time" content="2019-06-18T00:00:00+00:00" />
|
||||
<meta property="article:modified_time" content="2020-07-16T12:57:18-07:00" /><meta property="og:site_name" content="Kustomize" />
|
||||
<meta property="article:modified_time" content="2020-11-25T21:41:27+05:30" /><meta property="og:site_name" content="Kustomize" />
|
||||
<meta itemprop="name" content="v2.1.0">
|
||||
<meta itemprop="description" content="Kustomize v2.1.0
|
||||
">
|
||||
<meta itemprop="datePublished" content="2019-06-18T00:00:00+00:00" />
|
||||
<meta itemprop="dateModified" content="2020-07-16T12:57:18-07:00" />
|
||||
<meta itemprop="wordCount" content="920">
|
||||
<meta itemprop="dateModified" content="2020-11-25T21:41:27+05:30" />
|
||||
<meta itemprop="wordCount" content="3">
|
||||
|
||||
|
||||
|
||||
@@ -46,8 +46,8 @@
|
||||
|
||||
|
||||
|
||||
<link rel="preload" href="/kustomize/scss/main.min.0084926537b5667d9dea1d1fd692923ad85f8bcab133e53e7ec8af9ce8dd2ca5.css" as="style">
|
||||
<link href="/kustomize/scss/main.min.0084926537b5667d9dea1d1fd692923ad85f8bcab133e53e7ec8af9ce8dd2ca5.css" rel="stylesheet" integrity="">
|
||||
<link rel="preload" href="/kustomize/scss/main.min.818a933df0186c907f1faea6730835dd5fa01c3b53af36bb68396dc80a2d3c45.css" as="style">
|
||||
<link href="/kustomize/scss/main.min.818a933df0186c907f1faea6730835dd5fa01c3b53af36bb68396dc80a2d3c45.css" rel="stylesheet" integrity="">
|
||||
|
||||
|
||||
<script
|
||||
@@ -320,23 +320,6 @@
|
||||
|
||||
|
||||
|
||||
<nav id="TableOfContents">
|
||||
<ul>
|
||||
<li><a href="#go-modules">Go modules</a></li>
|
||||
<li><a href="#resource-ordering">Resource ordering</a></li>
|
||||
<li><a href="#generator-and-transformer-plugins">Generator and transformer plugins</a></li>
|
||||
<li><a href="#remove-load-restrictions">Remove load restrictions</a></li>
|
||||
<li><a href="#inventory-generation-for-pruning">Inventory generation for pruning</a></li>
|
||||
<li><a href="#field-changes--deprecations">Field changes / deprecations</a>
|
||||
<ul>
|
||||
<li><a href="#resources-expanded-bases-deprecated"><code>resources</code> expanded, <code>bases</code> deprecated</a></li>
|
||||
<li><a href="#replicas-field"><code>replicas</code> field</a></li>
|
||||
<li><a href="#envs-field"><code>envs</code> field</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
@@ -352,173 +335,8 @@
|
||||
|
||||
<time datetime="2019-06-18" class="text-muted">2019年06月18日</time>
|
||||
</div>
|
||||
<p>Go modules, resource ordering respected, generator and transformer plugins, eased
|
||||
loading restrictions, the notion of inventory, eased replica count modification.
|
||||
About ~90 issues closed since <a href="https://github.com/kubernetes-sigs/kustomize/releases/tag/v1.0.9releases/tag/v2.0.3">v2.0.3</a> in ~400 commits.</p>
|
||||
<p>Download <a href="https://github.com/kubernetes-sigs/kustomize/releases/tag/v1.0.9releases/tag/v2.1.0">here</a>.</p>
|
||||
<h2 id="go-modules">Go modules</h2>
|
||||
<p><img src="/kustomize/images/goModules.png" alt="gopher with boxes"></p>
|
||||
<p>Kustomize now defines its dependencies in a top
|
||||
level <code>go.mod</code> file. This is the first step
|
||||
towards a package structure intentially exported
|
||||
as one or more <a href="https://github.com/golang/go/wiki/Modules">Go modules</a> for use in other
|
||||
programs (kubectl, kubebuilder, etc.) and in
|
||||
kustomize plugins (see below).</p>
|
||||
<h2 id="resource-ordering">Resource ordering</h2>
|
||||
<p><img src="/kustomize/images/sorted.png" alt="sort order retained"></p>
|
||||
<p>Kustomize now retains the depth-first order of
|
||||
resources as read, a frequently requested
|
||||
feature.</p>
|
||||
<p>This means resource order can be controlled
|
||||
by editting kustomization files. This is
|
||||
also vital to applying user-defined
|
||||
transformations (plugins) in a particular
|
||||
order.</p>
|
||||
<p>Nothing needs to be done to activate this;
|
||||
it happens automatically.</p>
|
||||
<p>The <code>build</code> command now accepts a <code>--reorder</code>
|
||||
flag with values <code>legacy</code> and <code>none</code>,
|
||||
with a default value of <code>legacy</code>.</p>
|
||||
<p><code>legacy</code> means apply an ordering based on
|
||||
GVK, that currently emits <code>Namespace</code> objects
|
||||
first, and <code>ValidatingWebhookConfiguration</code>
|
||||
objects last. This means that despite
|
||||
automatic retention of load order, your
|
||||
<code>build</code> output won’t change by default.</p>
|
||||
<p><code>none</code> means <em>don’t</em> reorder the resources before
|
||||
output. Specify this to see output order
|
||||
respect input order.</p>
|
||||
<h2 id="generator-and-transformer-plugins">Generator and transformer plugins</h2>
|
||||
<p><img src="/kustomize/images/plugins.png" alt="kid putting knife in electrical outlet"></p>
|
||||
<p>Since the beginning (as <code>kinflate</code> back in Sep
|
||||
2017), kustomize has read or generated resources,
|
||||
applied a series of pipelined transformation to
|
||||
them, and emitted the result to <code>stdout</code>.</p>
|
||||
<p>At that time, the only way to change the behavior
|
||||
of a generator (e.g. a secret generator), or
|
||||
change the behavior of a transformer (e.g. a name
|
||||
changer, or json patcher), was to modify source
|
||||
code and put out a release.</p>
|
||||
<p><a href="https://github.com/kubernetes-sigs/kustomize/releases/tag/v1.0.9">v1.0.9</a> introduced <a href="https://github.com/kubernetes-sigs/kustomize/tree/master/examples/generatorOptions.md">generator options</a> as a means
|
||||
to change the behavior of the only two generators
|
||||
available at the time - Secret and ConfigMap
|
||||
generators. It also introduced
|
||||
<a href="https://github.com/kubernetes-sigs/kustomize/tree/master/examples/transformerconfigs">transformer configs</a> as a way to fine tune the
|
||||
targets of transformations (e.g. to which fields
|
||||
<em>selectors</em> should be added). Most of the feature
|
||||
requests for kustomize revolve around changing the
|
||||
behavior of the builtin generators and
|
||||
transformers.</p>
|
||||
<p><a href="https://github.com/kubernetes-sigs/kustomize/releases/tag/v1.0.9releases/tag/v2.1.0">v2.1.0</a> adds an <em>alpha</em> plugin framework, that
|
||||
encourages users to write their own generators or
|
||||
transformers, <em>declaring them as kubernetes
|
||||
objects just like everything else</em>, and apply them
|
||||
as part of the <code>kustomize build</code> process.</p>
|
||||
<p>To inform the API exposed to plugins, and to
|
||||
confirm that the plugin framework can offer plugin
|
||||
authors the same capabilities as builtin
|
||||
operations, all the builtin generators and
|
||||
tranformers have been converted to plugin form
|
||||
(with one exceptions awaiting Go module
|
||||
refinements). This means that adding, say, a
|
||||
<code>secretGenerator</code> or <code>commonAnnotations</code> directive
|
||||
to your kustomization will (in <a href="https://github.com/kubernetes-sigs/kustomize/releases/tag/v1.0.9releases/tag/v2.1.0">v2.1.0</a>) trigger
|
||||
execution of
|
||||
<a href="https://github.com/kubernetes-sigs/kustomize/tree/master/plugin/builtin">code committed as a plugin</a>.</p>
|
||||
<p>For more information, see the
|
||||
<a href="plugins">kustomize plugin documentation</a>.</p>
|
||||
<h2 id="remove-load-restrictions">Remove load restrictions</h2>
|
||||
<p><img src="/kustomize/images/abandonedTrainingWheels.png" alt="removed training wheels"></p>
|
||||
<p>The following usage:</p>
|
||||
<pre><code>kustomize build --load_restrictor none $target
|
||||
</code></pre><p>allows a <code>kustomization.yaml</code> file used in this
|
||||
build to refer to files outside its own directory
|
||||
(i.e. outside its <a href="/kustomize/api-reference/glossary#kustomization-root">root</a>).</p>
|
||||
<p>This is an opt-in to suppress a security feature
|
||||
that denies this precise behavior.</p>
|
||||
<p>This feature should only be used to allow multiple
|
||||
overlays (e.g. prod, staging and dev) to share a
|
||||
patch file. To share <em>resources</em>, use a relative
|
||||
path or URL to a kustomization directory in the
|
||||
<code>resources</code> directive.</p>
|
||||
<h2 id="inventory-generation-for-pruning">Inventory generation for pruning</h2>
|
||||
<p><img src="/kustomize/images/pruning.png" alt="pruning dead branches"></p>
|
||||
<p><em>Alpha</em></p>
|
||||
<p>Users can add an <code>inventory</code> stanza to their
|
||||
kustomization file, to add a special <em>inventory
|
||||
object</em> to the <code>build</code> result.</p>
|
||||
<p>This object applies to the cluster along with
|
||||
everything else in the build result and can be
|
||||
used by other clients to intelligently <em>prune</em>
|
||||
orphaned cluster resources.</p>
|
||||
<p>For more information see the
|
||||
<a href="https://github.com/kubernetes-sigs/kustomize/tree/master/docs/inventory_object.md">kustomize inventory object documentation</a>.</p>
|
||||
<h2 id="field-changes--deprecations">Field changes / deprecations</h2>
|
||||
<h3 id="resources-expanded-bases-deprecated"><code>resources</code> expanded, <code>bases</code> deprecated</h3>
|
||||
<p>The <code>resources</code> field has been generalized; it now
|
||||
accepts what formerly could only be specified in
|
||||
the <code>bases</code> field.</p>
|
||||
<p>This change was made to allow users fine control
|
||||
over resource processing order. With a distinct
|
||||
<code>bases</code> field, bases had to be loaded separately
|
||||
from resources as a group. Now, base loading may
|
||||
be interleaved as desired with the loading of
|
||||
resource files from the current
|
||||
directory. <a href="#resource-ordering">Resource ordering</a>
|
||||
had to be respected before this feature could be
|
||||
introduced.</p>
|
||||
<p>The <code>bases</code> field is now deprecated, and will be
|
||||
deleted in some future major release. Manage the
|
||||
deprecation simply moving the arguments of the
|
||||
<code>bases</code> field to the <code>resources</code> field in the
|
||||
desired order, e.g.</p>
|
||||
<blockquote>
|
||||
<pre><code>resources:
|
||||
- someResouceFile.yaml
|
||||
- someOtherResourceFile.yaml
|
||||
bases:
|
||||
- ../../someBaseDir
|
||||
</code></pre></blockquote>
|
||||
<p>could become</p>
|
||||
<blockquote>
|
||||
<pre><code>resources:
|
||||
- someResouceFile.yaml
|
||||
- ../../someBaseDir
|
||||
- someOtherResourceFile.yaml
|
||||
</code></pre></blockquote>
|
||||
<p>The <code>kustomized edit fix</code> command will do this for
|
||||
you, though it will always put the bases at the
|
||||
end.</p>
|
||||
<p>As an aside, the <code>resources</code>, <code>generators</code> and
|
||||
<code>transformers</code> fields now all accept the same
|
||||
argument format.</p>
|
||||
<blockquote>
|
||||
<p>Each field’s argument is a <em>string list</em>,
|
||||
where each entry is either a <em>resource</em> (a
|
||||
relative path to a YAML file) or a
|
||||
<a href="/kustomize/api-reference/glossary#kustomization"><em>kustomization</em></a> (a path or URL
|
||||
pointing to a directory with a kustomization
|
||||
file). A kustomization directory used in this
|
||||
context is called a <a href="/kustomize/api-reference/glossary#base"><em>base</em></a>.</p>
|
||||
</blockquote>
|
||||
<p>The fact that the <code>generators</code> and <code>transformers</code>
|
||||
field accept <a href="/kustomize/api-reference/glossary#base">bases</a> and the fact that generator
|
||||
and transformer configuration objects are just
|
||||
normal k8s resources means that one can generate
|
||||
or transform a generator or a transformer (see
|
||||
<a href="https://github.com/kubernetes-sigs/kustomize/tree/master/api/internal/target/transformerplugin_test.go">TestTransformerTransformers</a>).</p>
|
||||
<h3 id="replicas-field"><code>replicas</code> field</h3>
|
||||
<p>The common task of patching a deployment to edit
|
||||
the number of replicas is now made easier
|
||||
with the new <a href="/kustomize/api-reference/kustomization/replicas">replicas</a> field.</p>
|
||||
<h3 id="envs-field"><code>envs</code> field</h3>
|
||||
<p>An <code>envs</code> sub-field has been added to both
|
||||
<code>configMapGenerator</code> and <code>secretGenerator</code>,
|
||||
replacing the now deprecated (and singular)
|
||||
<code>env</code> field. The new field accepts lists, just
|
||||
like its sibling fields <code>files</code> and <code>literals</code>.</p>
|
||||
<p>Optionally use <code>kustomize edit fix</code> to merge
|
||||
singular <code>env</code> field into a plural field.</p>
|
||||
<meta http-equiv="refresh" content="0; url=https://kubectl.docs.kubernetes.io/zh/blog/2019/06/18/v2.1.0/" />
|
||||
<p>Moved to <a href="https://github.com/kubernetes-sigs/cli-experimental">https://github.com/kubernetes-sigs/cli-experimental</a></p>
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user