mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-05-17 18:25:26 +00:00
1075 lines
34 KiB
HTML
1075 lines
34 KiB
HTML
<!doctype html>
|
|
<html lang="en" class="no-js">
|
|
<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.68.3" />
|
|
|
|
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
|
|
|
|
|
|
|
|
<link rel="shortcut icon" href="/favicons/favicon.ico" >
|
|
<link rel="apple-touch-icon" href="/kustomize/favicons/apple-touch-icon-180x180.png" sizes="180x180">
|
|
<link rel="icon" type="image/png" href="/kustomize/favicons/favicon-16x16.png" sizes="16x16">
|
|
<link rel="icon" type="image/png" href="/kustomize/favicons/favicon-32x32.png" sizes="32x32">
|
|
<link rel="icon" type="image/png" href="/kustomize/favicons/android-36x36.png" sizes="36x36">
|
|
<link rel="icon" type="image/png" href="/kustomize/favicons/android-48x48.png" sizes="48x48">
|
|
<link rel="icon" type="image/png" href="/kustomize/favicons/android-72x72.png" sizes="72x72">
|
|
<link rel="icon" type="image/png" href="/kustomize/favicons/android-96x96.png" sizes="96x96">
|
|
<link rel="icon" type="image/png" href="/kustomize/favicons/android-144x144.png" sizes="144x144">
|
|
<link rel="icon" type="image/png" href="/kustomize/favicons/android-192x192.png" sizes="192x192">
|
|
|
|
<title>Builtin Plugins | Kustomize</title><meta property="og:title" content="Builtin Plugins" />
|
|
<meta property="og:description" content="Builtin Plugins
|
|
" />
|
|
<meta property="og:type" content="article" />
|
|
<meta property="og:url" content="https://kubernetes-sigs.github.io/kustomize/guides/plugins/builtins/" />
|
|
<meta property="article:modified_time" content="2020-06-15T13:39:13+08:00" /><meta property="og:site_name" content="Kustomize" />
|
|
<meta itemprop="name" content="Builtin Plugins">
|
|
<meta itemprop="description" content="Builtin Plugins
|
|
">
|
|
<meta itemprop="dateModified" content="2020-06-15T13:39:13+08:00" />
|
|
<meta itemprop="wordCount" content="1560">
|
|
|
|
|
|
|
|
<meta itemprop="keywords" content="" /><meta name="twitter:card" content="summary"/>
|
|
<meta name="twitter:title" content="Builtin Plugins"/>
|
|
<meta name="twitter:description" content="Builtin Plugins
|
|
"/>
|
|
|
|
|
|
|
|
|
|
|
|
<link rel="preload" href="/kustomize/scss/main.min.818a933df0186c907f1faea6730835dd5fa01c3b53af36bb68396dc80a2d3c45.css" as="style">
|
|
<link href="/kustomize/scss/main.min.818a933df0186c907f1faea6730835dd5fa01c3b53af36bb68396dc80a2d3c45.css" rel="stylesheet" integrity="">
|
|
|
|
|
|
<script
|
|
src="https://code.jquery.com/jquery-3.3.1.min.js"
|
|
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
|
|
crossorigin="anonymous"></script>
|
|
|
|
|
|
|
|
<link rel="stylesheet" type="text/css" href="https://kubernetes-sigs.github.io/kustomize//css/asciinema-player.css" />
|
|
|
|
<title>Builtin Plugins | Kustomize</title>
|
|
</head>
|
|
<body class="td-page">
|
|
<header>
|
|
|
|
<nav class="js-navbar-scroll navbar navbar-expand navbar-dark flex-column flex-md-row td-navbar">
|
|
<a class="navbar-brand" href="/kustomize/">
|
|
<span class="navbar-logo"></span><span class="text-uppercase font-weight-bold">Kustomize</span>
|
|
</a>
|
|
<div class="td-navbar-nav-scroll ml-md-auto" id="main_navbar">
|
|
<ul class="navbar-nav mt-2 mt-lg-0">
|
|
|
|
|
|
<li class="nav-item mr-4 mb-2 mb-lg-0">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<a class="nav-link" href="/kustomize/installation/" ><span>Installation</span></a>
|
|
</li>
|
|
|
|
<li class="nav-item mr-4 mb-2 mb-lg-0">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<a class="nav-link active" href="/kustomize/guides/" ><span class="active">Guides</span></a>
|
|
</li>
|
|
|
|
<li class="nav-item mr-4 mb-2 mb-lg-0">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<a class="nav-link" href="/kustomize/api-reference/" ><span>API Reference</span></a>
|
|
</li>
|
|
|
|
<li class="nav-item mr-4 mb-2 mb-lg-0">
|
|
|
|
|
|
|
|
|
|
<a class="nav-link" href="https://github.com/kubernetes-sigs/kustomize/tree/master/examples" target="_blank" ><span>Example</span></a>
|
|
</li>
|
|
|
|
<li class="nav-item mr-4 mb-2 mb-lg-0">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<a class="nav-link" href="/kustomize/faq/" ><span>FAQ</span></a>
|
|
</li>
|
|
|
|
<li class="nav-item mr-4 mb-2 mb-lg-0">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<a class="nav-link" href="/kustomize/blog/" ><span>Blog</span></a>
|
|
</li>
|
|
|
|
<li class="nav-item mr-4 mb-2 mb-lg-0">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<a class="nav-link" href="/kustomize/contributing/" ><span>Contributing</span></a>
|
|
</li>
|
|
|
|
|
|
|
|
<li class="nav-item dropdown d-none d-lg-block">
|
|
|
|
|
|
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
|
English
|
|
</a>
|
|
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
|
|
|
|
<a class="dropdown-item" href="/kustomize/zh/guides/plugins/builtins/">简体中文</a>
|
|
|
|
</div>
|
|
</li>
|
|
|
|
</ul>
|
|
</div>
|
|
<div class="navbar-nav d-none d-lg-block">
|
|
</div>
|
|
</nav>
|
|
|
|
</header>
|
|
<div class="container-fluid td-outer">
|
|
<div class="td-main">
|
|
<div class="row flex-xl-nowrap">
|
|
<div class="col-12 col-md-3 col-xl-2 td-sidebar d-print-none">
|
|
|
|
|
|
|
|
|
|
|
|
<div id="td-sidebar-menu" class="td-sidebar__inner">
|
|
|
|
<form class="td-sidebar__search d-flex align-items-center">
|
|
|
|
|
|
<button class="btn btn-link td-sidebar__toggle d-md-none p-0 ml-3 fas fa-bars" type="button" data-toggle="collapse" data-target="#td-section-nav" aria-controls="td-docs-nav" aria-expanded="false" aria-label="Toggle section navigation">
|
|
</button>
|
|
</form>
|
|
|
|
<nav class="collapse td-sidebar-nav pt-2 pl-4" id="td-section-nav">
|
|
|
|
<div class="nav-item dropdown d-block d-lg-none">
|
|
|
|
|
|
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
|
English
|
|
</a>
|
|
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
|
|
|
|
<a class="dropdown-item" href="/kustomize/zh/guides/plugins/builtins/">简体中文</a>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<ul class="td-sidebar-nav__section pr-md-3">
|
|
<li class="td-sidebar-nav__section-title">
|
|
<a href="/kustomize/guides/" class="align-left pl-0 pr-2 td-sidebar-link td-sidebar-link__section">Guides</a>
|
|
</li>
|
|
<ul>
|
|
<li class="collapse show" id="kustomizeguides">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<ul class="td-sidebar-nav__section pr-md-3">
|
|
<li class="td-sidebar-nav__section-title">
|
|
<a href="/kustomize/guides/bespoke/" class="align-left pl-0 pr-2 collapsed td-sidebar-link td-sidebar-link__section">Bespoke Application</a>
|
|
</li>
|
|
<ul>
|
|
<li class="collapse " id="kustomizeguidesbespoke">
|
|
|
|
|
|
|
|
</li>
|
|
</ul>
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<ul class="td-sidebar-nav__section pr-md-3">
|
|
<li class="td-sidebar-nav__section-title">
|
|
<a href="/kustomize/guides/offtheshelf/" class="align-left pl-0 pr-2 collapsed td-sidebar-link td-sidebar-link__section">Off The Shelf Application</a>
|
|
</li>
|
|
<ul>
|
|
<li class="collapse " id="kustomizeguidesofftheshelf">
|
|
|
|
|
|
|
|
</li>
|
|
</ul>
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<ul class="td-sidebar-nav__section pr-md-3">
|
|
<li class="td-sidebar-nav__section-title">
|
|
<a href="/kustomize/guides/plugins/" class="align-left pl-0 pr-2 active td-sidebar-link td-sidebar-link__section">Kustomize Plugins</a>
|
|
</li>
|
|
<ul>
|
|
<li class="collapse show" id="kustomizeguidesplugins">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<a class="td-sidebar-link td-sidebar-link__page active" id="m-kustomizeguidespluginsbuiltins" href="/kustomize/guides/plugins/builtins/">Builtin Plugins</a>
|
|
|
|
|
|
|
|
|
|
|
|
<a class="td-sidebar-link td-sidebar-link__page " id="m-kustomizeguidespluginsexecpluginguidedexample" href="/kustomize/guides/plugins/execpluginguidedexample/">Exec plugin on linux</a>
|
|
|
|
|
|
|
|
|
|
|
|
<a class="td-sidebar-link td-sidebar-link__page " id="m-kustomizeguidespluginsgoplugincaveats" href="/kustomize/guides/plugins/goplugincaveats/">Go plugin Caveats</a>
|
|
|
|
|
|
|
|
|
|
|
|
<a class="td-sidebar-link td-sidebar-link__page " id="m-kustomizeguidespluginsgopluginguidedexample" href="/kustomize/guides/plugins/gopluginguidedexample/">Go plugin example</a>
|
|
|
|
|
|
</li>
|
|
</ul>
|
|
</ul>
|
|
|
|
|
|
|
|
</li>
|
|
</ul>
|
|
</ul>
|
|
|
|
</nav>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
<div class="d-none d-xl-block col-xl-2 td-toc d-print-none">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="td-page-meta ml-2 pb-1 pt-2 mb-0">
|
|
|
|
|
|
|
|
|
|
|
|
<a href="https://github.com/kubernetes-sigs/kustomize/edit/master/site/content/en/guides/plugins/builtins.md" target="_blank"><i class="fa fa-edit fa-fw"></i> Edit this page</a>
|
|
<a href="https://github.com/kubernetes-sigs/kustomize/issues/new?title=Builtin%20Plugins" target="_blank"><i class="fab fa-github fa-fw"></i> Create documentation issue</a>
|
|
|
|
|
|
<a href="https://github.com/kubernetes-sigs/kustomize/issues/new" target="_blank"><i class="fas fa-tasks fa-fw"></i> Create project issue</a>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<nav id="TableOfContents">
|
|
<ul>
|
|
<li><a href="#_annotationtransformer_"><em>AnnotationTransformer</em></a>
|
|
<ul>
|
|
<li><a href="#usage-via-kustomizationyaml">Usage via <code>kustomization.yaml</code></a></li>
|
|
<li><a href="#usage-via-plugin">Usage via plugin</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#_configmapgenerator_"><em>ConfigMapGenerator</em></a>
|
|
<ul>
|
|
<li><a href="#usage-via-kustomizationyaml-1">Usage via <code>kustomization.yaml</code></a></li>
|
|
<li><a href="#usage-via-plugin-1">Usage via plugin</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#_imagetagtransformer_"><em>ImageTagTransformer</em></a>
|
|
<ul>
|
|
<li><a href="#usage-via-kustomizationyaml-2">Usage via <code>kustomization.yaml</code></a></li>
|
|
<li><a href="#usage-via-plugin-2">Usage via plugin</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#_labeltransformer_"><em>LabelTransformer</em></a>
|
|
<ul>
|
|
<li><a href="#usage-via-kustomizationyaml-3">Usage via <code>kustomization.yaml</code></a></li>
|
|
<li><a href="#usage-via-plugin-3">Usage via plugin</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#_namespacetransformer_"><em>NamespaceTransformer</em></a>
|
|
<ul>
|
|
<li><a href="#usage-via-kustomizationyaml-4">Usage via <code>kustomization.yaml</code></a></li>
|
|
<li><a href="#usage-via-plugin-4">Usage via plugin</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#_patchesjson6902_"><em>PatchesJson6902</em></a>
|
|
<ul>
|
|
<li><a href="#usage-via-kustomizationyaml-5">Usage via <code>kustomization.yaml</code></a></li>
|
|
<li><a href="#usage-via-plugin-5">Usage via plugin</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#_patchesstrategicmerge_"><em>PatchesStrategicMerge</em></a>
|
|
<ul>
|
|
<li><a href="#usage-via-kustomizationyaml-6">Usage via <code>kustomization.yaml</code></a></li>
|
|
<li><a href="#usage-via-plugin-6">Usage via plugin</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#_patchtransformer_"><em>PatchTransformer</em></a>
|
|
<ul>
|
|
<li><a href="#usage-via-kustomizationyaml-7">Usage via <code>kustomization.yaml</code></a></li>
|
|
<li><a href="#usage-via-plugin-7">Usage via plugin</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#_prefixsuffixtransformer_"><em>PrefixSuffixTransformer</em></a>
|
|
<ul>
|
|
<li><a href="#usage-via-kustomizationyaml-8">Usage via <code>kustomization.yaml</code></a></li>
|
|
<li><a href="#usage-via-plugin-8">Usage via plugin</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#_replicacounttransformer_"><em>ReplicaCountTransformer</em></a>
|
|
<ul>
|
|
<li><a href="#usage-via-kustomizationyaml-9">Usage via <code>kustomization.yaml</code></a></li>
|
|
<li><a href="#usage-via-plugin-9">Usage via plugin</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#_secretgenerator_"><em>SecretGenerator</em></a>
|
|
<ul>
|
|
<li><a href="#usage-via-kustomizationyaml-10">Usage via <code>kustomization.yaml</code></a></li>
|
|
<li><a href="#usage-via-plugin-10">Usage via plugin</a></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</nav>
|
|
|
|
|
|
|
|
</div>
|
|
<main class="col-12 col-md-9 col-xl-8 pl-md-5" role="main">
|
|
|
|
|
|
|
|
<nav aria-label="breadcrumb" class="d-none d-md-block d-print-none">
|
|
<ol class="breadcrumb spb-1">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<li class="breadcrumb-item" >
|
|
<a href="https://kubernetes-sigs.github.io/kustomize/guides/">Guides</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
<li class="breadcrumb-item" >
|
|
<a href="https://kubernetes-sigs.github.io/kustomize/guides/plugins/">Kustomize Plugins</a>
|
|
</li>
|
|
|
|
|
|
|
|
|
|
<li class="breadcrumb-item active" aria-current="page">
|
|
<a href="https://kubernetes-sigs.github.io/kustomize/guides/plugins/builtins/">Builtin Plugins</a>
|
|
</li>
|
|
|
|
</ol>
|
|
</nav >
|
|
|
|
|
|
<div class="td-content">
|
|
<h1>Builtin Plugins</h1>
|
|
<div class="lead">Builtin Plugins</div>
|
|
<h1 id="builtin-plugins">Builtin Plugins</h1>
|
|
<p>A list of kustomize’s builtin plugins - both
|
|
generators and transformers.</p>
|
|
<p>For each plugin, an example is given for</p>
|
|
<ul>
|
|
<li>
|
|
<p>implicitly triggering
|
|
the plugin via a dedicated kustomization
|
|
file field (e.g. the <code>AnnotationsTransformer</code> is
|
|
triggered by the <code>commonAnnotations</code> field).</p>
|
|
</li>
|
|
<li>
|
|
<p>explicitly triggering the plugin
|
|
via the <code>generators</code> or <code>transformers</code> field
|
|
(by providing a config file specifying the
|
|
plugin).</p>
|
|
</li>
|
|
</ul>
|
|
<p>The former method is convenient but limited in
|
|
power as most of the plugins arguments must
|
|
be defaulted. The latter method allows for
|
|
complete plugin argument specification.</p>
|
|
<h2 id="_annotationtransformer_"><em>AnnotationTransformer</em></h2>
|
|
<h3 id="usage-via-kustomizationyaml">Usage via <code>kustomization.yaml</code></h3>
|
|
<h4 id="field-name-commonannotations">field name: <code>commonAnnotations</code></h4>
|
|
<p>Adds annotions (non-identifying metadata) to add
|
|
all resources. Like labels, these are key value
|
|
pairs.</p>
|
|
<pre><code>commonAnnotations:
|
|
oncallPager: 800-555-1212
|
|
</code></pre><h3 id="usage-via-plugin">Usage via plugin</h3>
|
|
<h4 id="arguments">Arguments</h4>
|
|
<blockquote>
|
|
<p>Annotations map[string]string</p>
|
|
<p>FieldSpecs []<a href="https://github.com/kubernetes-sigs/kustomize/tree/master/api/types/fieldspec.go">config.FieldSpec</a></p>
|
|
</blockquote>
|
|
<h4 id="example">Example</h4>
|
|
<blockquote>
|
|
<pre><code>apiVersion: builtin
|
|
kind: AnnotationsTransformer
|
|
metadata:
|
|
name: not-important-to-example
|
|
annotations:
|
|
app: myApp
|
|
greeting/morning: a string with blanks
|
|
fieldSpecs:
|
|
- path: metadata/annotations
|
|
create: true
|
|
</code></pre></blockquote>
|
|
<h2 id="_configmapgenerator_"><em>ConfigMapGenerator</em></h2>
|
|
<h3 id="usage-via-kustomizationyaml-1">Usage via <code>kustomization.yaml</code></h3>
|
|
<h4 id="field-name-configmapgenerator">field name: <code>configMapGenerator</code></h4>
|
|
<p>Each entry in this list results in the creation of
|
|
one ConfigMap resource (it’s a generator of n maps).</p>
|
|
<p>The example below creates three ConfigMaps. One with the names and contents of
|
|
the given files, one with key/value as data, and a third which sets an
|
|
annotation and label via <code>options</code> for that single ConfigMap.</p>
|
|
<p>Each configMapGenerator item accepts a parameter of
|
|
<code>behavior: [create|replace|merge]</code>.
|
|
This allows an overlay to modify or
|
|
replace an existing configMap from the parent.</p>
|
|
<p>Also, each entry has an <code>options</code> field, that has the
|
|
same subfields as the kustomization file’s <code>generatorOptions</code> field.</p>
|
|
<p>This <code>options</code> field allows one to add labels and/or
|
|
annotations to the generated instance, or to individually
|
|
disable the name suffix hash for that instance.
|
|
Labels and annotations added here will not be overwritten
|
|
by the global options associated with the kustomization
|
|
file <code>generatorOptions</code> field. However, due to how
|
|
booleans behave, if the global <code>generatorOptions</code> field
|
|
specifies <code>disableNameSuffixHash: true</code>, this will
|
|
trump any attempt to locally override it.</p>
|
|
<pre><code># These labels are added to all configmaps and secrets.
|
|
generatorOptions:
|
|
labels:
|
|
fruit: apple
|
|
|
|
configMapGenerator:
|
|
- name: my-java-server-props
|
|
behavior: merge
|
|
files:
|
|
- application.properties
|
|
- more.properties
|
|
- name: my-java-server-env-vars
|
|
literals:
|
|
- JAVA_HOME=/opt/java/jdk
|
|
- JAVA_TOOL_OPTIONS=-agentlib:hprof
|
|
options:
|
|
disableNameSuffixHash: true
|
|
labels:
|
|
pet: dog
|
|
- name: dashboards
|
|
files:
|
|
- mydashboard.json
|
|
options:
|
|
annotations:
|
|
dashboard: "1"
|
|
labels:
|
|
app.kubernetes.io/name: "app1"
|
|
</code></pre><p>It is also possible to
|
|
<a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#define-the-key-to-use-when-creating-a-configmap-from-a-file">define a key</a>
|
|
to set a name different than the filename.</p>
|
|
<p>The example below creates a ConfigMap
|
|
with the name of file as <code>myFileName.ini</code>
|
|
while the <em>actual</em> filename from which the
|
|
configmap is created is <code>whatever.ini</code>.</p>
|
|
<pre><code>configMapGenerator:
|
|
- name: app-whatever
|
|
files:
|
|
- myFileName.ini=whatever.ini
|
|
</code></pre><h3 id="usage-via-plugin-1">Usage via plugin</h3>
|
|
<h4 id="arguments-1">Arguments</h4>
|
|
<blockquote>
|
|
<p><a href="https://github.com/kubernetes-sigs/kustomize/tree/master/api/types/configmapargs.go">types.ConfigMapArgs</a></p>
|
|
</blockquote>
|
|
<h4 id="example-1">Example</h4>
|
|
<blockquote>
|
|
<pre><code>apiVersion: builtin
|
|
kind: ConfigMapGenerator
|
|
metadata:
|
|
name: mymap
|
|
envs:
|
|
- devops.env
|
|
- uxteam.env
|
|
literals:
|
|
- FRUIT=apple
|
|
- VEGETABLE=carrot
|
|
</code></pre></blockquote>
|
|
<h2 id="_imagetagtransformer_"><em>ImageTagTransformer</em></h2>
|
|
<h3 id="usage-via-kustomizationyaml-2">Usage via <code>kustomization.yaml</code></h3>
|
|
<h4 id="field-name-images">field name: <code>images</code></h4>
|
|
<p>Images modify the name, tags and/or digest for images
|
|
without creating patches. E.g. Given this
|
|
kubernetes Deployment fragment:</p>
|
|
<pre><code>containers:
|
|
- name: mypostgresdb
|
|
image: postgres:8
|
|
- name: nginxapp
|
|
image: nginx:1.7.9
|
|
- name: myapp
|
|
image: my-demo-app:latest
|
|
- name: alpine-app
|
|
image: alpine:3.7
|
|
</code></pre><p>one can change the <code>image</code> in the following ways:</p>
|
|
<ul>
|
|
<li><code>postgres:8</code> to <code>my-registry/my-postgres:v1</code>,</li>
|
|
<li>nginx tag <code>1.7.9</code> to <code>1.8.0</code>,</li>
|
|
<li>image name <code>my-demo-app</code> to <code>my-app</code>,</li>
|
|
<li>alpine’s tag <code>3.7</code> to a digest value</li>
|
|
</ul>
|
|
<p>all with the following <em>kustomization</em>:</p>
|
|
<pre><code>images:
|
|
- name: postgres
|
|
newName: my-registry/my-postgres
|
|
newTag: v1
|
|
- name: nginx
|
|
newTag: 1.8.0
|
|
- name: my-demo-app
|
|
newName: my-app
|
|
- name: alpine
|
|
digest: sha256:24a0c4b4a4c0eb97a1aabb8e29f18e917d05abfe1b7a7c07857230879ce7d3d3
|
|
</code></pre><h3 id="usage-via-plugin-2">Usage via plugin</h3>
|
|
<h4 id="arguments-2">Arguments</h4>
|
|
<blockquote>
|
|
<p>ImageTag <a href="https://github.com/kubernetes-sigs/kustomize/tree/master/api/types/image.go">image.Image</a></p>
|
|
<p>FieldSpecs []<a href="https://github.com/kubernetes-sigs/kustomize/tree/master/api/types/fieldspec.go">config.FieldSpec</a></p>
|
|
</blockquote>
|
|
<h4 id="example-2">Example</h4>
|
|
<blockquote>
|
|
<pre><code>apiVersion: builtin
|
|
kind: ImageTagTransformer
|
|
metadata:
|
|
name: not-important-to-example
|
|
imageTag:
|
|
name: nginx
|
|
newTag: v2
|
|
</code></pre></blockquote>
|
|
<h2 id="_labeltransformer_"><em>LabelTransformer</em></h2>
|
|
<h3 id="usage-via-kustomizationyaml-3">Usage via <code>kustomization.yaml</code></h3>
|
|
<h4 id="field-name-commonlabels">field name: <code>commonLabels</code></h4>
|
|
<p>Adds labels to all resources and selectors</p>
|
|
<pre><code>commonLabels:
|
|
someName: someValue
|
|
owner: alice
|
|
app: bingo
|
|
</code></pre><h3 id="usage-via-plugin-3">Usage via plugin</h3>
|
|
<h4 id="arguments-3">Arguments</h4>
|
|
<blockquote>
|
|
<p>Labels map[string]string</p>
|
|
<p>FieldSpecs []<a href="https://github.com/kubernetes-sigs/kustomize/tree/master/api/types/fieldspec.go">config.FieldSpec</a></p>
|
|
</blockquote>
|
|
<h4 id="example-3">Example</h4>
|
|
<blockquote>
|
|
<pre><code>apiVersion: builtin
|
|
kind: LabelTransformer
|
|
metadata:
|
|
name: not-important-to-example
|
|
labels:
|
|
app: myApp
|
|
env: production
|
|
fieldSpecs:
|
|
- path: metadata/labels
|
|
create: true
|
|
</code></pre></blockquote>
|
|
<h2 id="_namespacetransformer_"><em>NamespaceTransformer</em></h2>
|
|
<h3 id="usage-via-kustomizationyaml-4">Usage via <code>kustomization.yaml</code></h3>
|
|
<h4 id="field-name-namespace">field name: <code>namespace</code></h4>
|
|
<p>Adds namespace to all resources</p>
|
|
<pre><code>namespace: my-namespace
|
|
</code></pre><h3 id="usage-via-plugin-4">Usage via plugin</h3>
|
|
<h4 id="arguments-4">Arguments</h4>
|
|
<blockquote>
|
|
<p><a href="https://github.com/kubernetes-sigs/kustomize/tree/master/api/types/objectmeta.go">types.ObjectMeta</a></p>
|
|
<p>FieldSpecs []<a href="https://github.com/kubernetes-sigs/kustomize/tree/master/api/types/fieldspec.go">config.FieldSpec</a></p>
|
|
</blockquote>
|
|
<h4 id="example-4">Example</h4>
|
|
<blockquote>
|
|
<pre><code>apiVersion: builtin
|
|
kind: NamespaceTransformer
|
|
metadata:
|
|
name: not-important-to-example
|
|
namespace: test
|
|
fieldSpecs:
|
|
- path: metadata/namespace
|
|
create: true
|
|
- path: subjects
|
|
kind: RoleBinding
|
|
group: rbac.authorization.k8s.io
|
|
- path: subjects
|
|
kind: ClusterRoleBinding
|
|
group: rbac.authorization.k8s.io
|
|
</code></pre></blockquote>
|
|
<h2 id="_patchesjson6902_"><em>PatchesJson6902</em></h2>
|
|
<h3 id="usage-via-kustomizationyaml-5">Usage via <code>kustomization.yaml</code></h3>
|
|
<h4 id="field-name-patchesjson6902">field name: <code>patchesJson6902</code></h4>
|
|
<p>Each entry in this list should resolve to
|
|
a kubernetes object and a JSON patch that will be applied
|
|
to the object.
|
|
The JSON patch is documented at <a href="https://tools.ietf.org/html/rfc6902">https://tools.ietf.org/html/rfc6902</a></p>
|
|
<p>target field points to a kubernetes object within the same kustomization
|
|
by the object’s group, version, kind, name and namespace.
|
|
path field is a relative file path of a JSON patch file.
|
|
The content in this patch file can be either in JSON format as</p>
|
|
<pre><code> [
|
|
{"op": "add", "path": "/some/new/path", "value": "value"},
|
|
{"op": "replace", "path": "/some/existing/path", "value": "new value"}
|
|
]
|
|
</code></pre><p>or in YAML format as</p>
|
|
<pre><code>- op: add
|
|
path: /some/new/path
|
|
value: value
|
|
- op: replace
|
|
path: /some/existing/path
|
|
value: new value
|
|
</code></pre><pre><code>patchesJson6902:
|
|
- target:
|
|
version: v1
|
|
kind: Deployment
|
|
name: my-deployment
|
|
path: add_init_container.yaml
|
|
- target:
|
|
version: v1
|
|
kind: Service
|
|
name: my-service
|
|
path: add_service_annotation.yaml
|
|
</code></pre><p>The patch content can be an inline string as well:</p>
|
|
<pre><code>patchesJson6902:
|
|
- target:
|
|
version: v1
|
|
kind: Deployment
|
|
name: my-deployment
|
|
patch: |-
|
|
- op: add
|
|
path: /some/new/path
|
|
value: value
|
|
- op: replace
|
|
path: /some/existing/path
|
|
value: "new value"
|
|
</code></pre><h3 id="usage-via-plugin-5">Usage via plugin</h3>
|
|
<h4 id="arguments-5">Arguments</h4>
|
|
<blockquote>
|
|
<p>Target <a href="https://github.com/kubernetes-sigs/kustomize/tree/master/api/types/patchtarget.go">types.PatchTarget</a></p>
|
|
<p>Path string</p>
|
|
<p>JsonOp string</p>
|
|
</blockquote>
|
|
<h4 id="example-5">Example</h4>
|
|
<blockquote>
|
|
<pre><code>apiVersion: builtin
|
|
kind: PatchJson6902Transformer
|
|
metadata:
|
|
name: not-important-to-example
|
|
target:
|
|
group: apps
|
|
version: v1
|
|
kind: Deployment
|
|
name: my-deploy
|
|
path: jsonpatch.json
|
|
</code></pre></blockquote>
|
|
<h2 id="_patchesstrategicmerge_"><em>PatchesStrategicMerge</em></h2>
|
|
<h3 id="usage-via-kustomizationyaml-6">Usage via <code>kustomization.yaml</code></h3>
|
|
<h4 id="field-name-patchesstrategicmerge">field name: <code>patchesStrategicMerge</code></h4>
|
|
<p>Each entry in this list should be either a relative
|
|
file path or an inline content
|
|
resolving to a partial or complete resource
|
|
definition.</p>
|
|
<p>The names in these (possibly partial) resource
|
|
files must match names already loaded via the
|
|
<code>resources</code> field. These entries are used to
|
|
<em>patch</em> (modify) the known resources.</p>
|
|
<p>Small patches that do one thing are best, e.g. modify
|
|
a memory request/limit, change an env var in a
|
|
ConfigMap, etc. Small patches are easy to review and
|
|
easy to mix together in overlays.</p>
|
|
<pre><code>patchesStrategicMerge:
|
|
- service_port_8888.yaml
|
|
- deployment_increase_replicas.yaml
|
|
- deployment_increase_memory.yaml
|
|
</code></pre><p>The patch content can be a inline string as well.</p>
|
|
<pre><code>patchesStrategicMerge:
|
|
- |-
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: nginx
|
|
spec:
|
|
template:
|
|
spec:
|
|
containers:
|
|
- name: nginx
|
|
image: nignx:latest
|
|
</code></pre><p>Note that kustomize does not support more than one patch
|
|
for the same object that contain a <em>delete</em> directive. To remove
|
|
several fields / slice elements from an object create a single
|
|
patch that performs all the needed deletions.</p>
|
|
<h3 id="usage-via-plugin-6">Usage via plugin</h3>
|
|
<h4 id="arguments-6">Arguments</h4>
|
|
<blockquote>
|
|
<p>Paths []<a href="https://github.com/kubernetes-sigs/kustomize/tree/master/api/types/patchstrategicmerge.go">types.PatchStrategicMerge</a></p>
|
|
<p>Patches string</p>
|
|
</blockquote>
|
|
<h4 id="example-6">Example</h4>
|
|
<blockquote>
|
|
<pre><code>apiVersion: builtin
|
|
kind: PatchStrategicMergeTransformer
|
|
metadata:
|
|
name: not-important-to-example
|
|
paths:
|
|
- patch.yaml
|
|
</code></pre></blockquote>
|
|
<h2 id="_patchtransformer_"><em>PatchTransformer</em></h2>
|
|
<h3 id="usage-via-kustomizationyaml-7">Usage via <code>kustomization.yaml</code></h3>
|
|
<h4 id="field-name-patches">field name: <code>patches</code></h4>
|
|
<p>Each entry in this list should resolve to an Patch
|
|
object, which includes a patch and a target selector.
|
|
The patch can be either a strategic merge patch or a
|
|
JSON patch. it can be either a patch file or an inline
|
|
string. The target selects
|
|
resources by group, version, kind, name, namespace,
|
|
labelSelector and annotationSelector. A resource
|
|
which matches all the specified fields is selected
|
|
to apply the patch.</p>
|
|
<pre><code>patches:
|
|
- path: patch.yaml
|
|
target:
|
|
group: apps
|
|
version: v1
|
|
kind: Deployment
|
|
name: deploy.*
|
|
labelSelector: "env=dev"
|
|
annotationSelector: "zone=west"
|
|
- patch: |-
|
|
- op: replace
|
|
path: /some/existing/path
|
|
value: new value
|
|
target:
|
|
kind: MyKind
|
|
labelSelector: "env=dev"
|
|
</code></pre><p>The <code>name</code> and <code>namespace</code> fields of the patch target selector are
|
|
automatically anchored regular expressions. This means that the value <code>myapp</code>
|
|
is equivalent to <code>^myapp$</code>.</p>
|
|
<h3 id="usage-via-plugin-7">Usage via plugin</h3>
|
|
<h4 id="arguments-7">Arguments</h4>
|
|
<blockquote>
|
|
<p>Path string</p>
|
|
<p>Patch string</p>
|
|
<p>Target *<a href="https://github.com/kubernetes-sigs/kustomize/tree/master/api/types/selector.go">types.Selector</a></p>
|
|
</blockquote>
|
|
<h4 id="example-7">Example</h4>
|
|
<blockquote>
|
|
<pre><code>apiVersion: builtin
|
|
kind: PatchTransformer
|
|
metadata:
|
|
name: not-important-to-example
|
|
patch: '[{"op": "replace", "path": "/spec/template/spec/containers/0/image", "value": "nginx:latest"}]'
|
|
target:
|
|
name: .*Deploy
|
|
kind: Deployment
|
|
</code></pre></blockquote>
|
|
<h2 id="_prefixsuffixtransformer_"><em>PrefixSuffixTransformer</em></h2>
|
|
<h3 id="usage-via-kustomizationyaml-8">Usage via <code>kustomization.yaml</code></h3>
|
|
<h4 id="field-names-nameprefix-namesuffix">field names: <code>namePrefix</code>, <code>nameSuffix</code></h4>
|
|
<p>Prepends or postfixes the value to the names
|
|
of all resources.</p>
|
|
<p>E.g. a deployment named <code>wordpress</code> could
|
|
become <code>alices-wordpress</code> or <code>wordpress-v2</code>
|
|
or <code>alices-wordpress-v2</code>.</p>
|
|
<pre><code>namePrefix: alices-
|
|
nameSuffix: -v2
|
|
</code></pre><p>The suffix is appended before the content hash if
|
|
the resource type is ConfigMap or Secret.</p>
|
|
<h3 id="usage-via-plugin-8">Usage via plugin</h3>
|
|
<h4 id="arguments-8">Arguments</h4>
|
|
<blockquote>
|
|
<p>Prefix string</p>
|
|
<p>Suffix string</p>
|
|
<p>FieldSpecs []<a href="https://github.com/kubernetes-sigs/kustomize/tree/master/api/types/fieldspec.go">config.FieldSpec</a></p>
|
|
</blockquote>
|
|
<h4 id="example-8">Example</h4>
|
|
<blockquote>
|
|
<pre><code>apiVersion: builtin
|
|
kind: PrefixSuffixTransformer
|
|
metadata:
|
|
name: not-important-to-example
|
|
prefix: baked-
|
|
suffix: -pie
|
|
fieldSpecs:
|
|
- path: metadata/name
|
|
</code></pre></blockquote>
|
|
<h2 id="_replicacounttransformer_"><em>ReplicaCountTransformer</em></h2>
|
|
<h3 id="usage-via-kustomizationyaml-9">Usage via <code>kustomization.yaml</code></h3>
|
|
<h4 id="field-name-replicas">field name: <code>replicas</code></h4>
|
|
<p>Replicas modified the number of replicas for a resource.</p>
|
|
<p>E.g. Given this kubernetes Deployment fragment:</p>
|
|
<pre><code>kind: Deployment
|
|
metadata:
|
|
name: deployment-name
|
|
spec:
|
|
replicas: 3
|
|
</code></pre><p>one can change the number of replicas to 5
|
|
by adding the following to your kustomization:</p>
|
|
<pre><code>replicas:
|
|
- name: deployment-name
|
|
count: 5
|
|
</code></pre><p>This field accepts a list, so many resources can
|
|
be modified at the same time.</p>
|
|
<p>As this declaration does not take in a <code>kind:</code> nor a <code>group:</code>
|
|
it will match any <code>group</code> and <code>kind</code> that has a matching name and
|
|
that is one of:</p>
|
|
<ul>
|
|
<li><code>Deployment</code></li>
|
|
<li><code>ReplicationController</code></li>
|
|
<li><code>ReplicaSet</code></li>
|
|
<li><code>StatefulSet</code></li>
|
|
</ul>
|
|
<p>For more complex use cases, revert to using a patch.</p>
|
|
<h3 id="usage-via-plugin-9">Usage via plugin</h3>
|
|
<h4 id="arguments-9">Arguments</h4>
|
|
<blockquote>
|
|
<p>Replica <a href="https://github.com/kubernetes-sigs/kustomize/tree/master/api/types/replica.go">types.Replica</a></p>
|
|
<p>FieldSpecs []<a href="https://github.com/kubernetes-sigs/kustomize/tree/master/api/types/fieldspec.go">config.FieldSpec</a></p>
|
|
</blockquote>
|
|
<h4 id="example-9">Example</h4>
|
|
<blockquote>
|
|
<pre><code>apiVersion: builtin
|
|
kind: ReplicaCountTransformer
|
|
metadata:
|
|
name: not-important-to-example
|
|
replica:
|
|
name: myapp
|
|
count: 23
|
|
fieldSpecs:
|
|
- path: spec/replicas
|
|
create: true
|
|
kind: Deployment
|
|
- path: spec/replicas
|
|
create: true
|
|
kind: ReplicationController
|
|
</code></pre></blockquote>
|
|
<h2 id="_secretgenerator_"><em>SecretGenerator</em></h2>
|
|
<h3 id="usage-via-kustomizationyaml-10">Usage via <code>kustomization.yaml</code></h3>
|
|
<h4 id="field-name-secretgenerator">field name: <code>secretGenerator</code></h4>
|
|
<p>Each entry in the argument list
|
|
results in the creation of
|
|
one Secret resource
|
|
(it’s a generator of n secrets).</p>
|
|
<p>This works like the <code>configMapGenerator</code> field
|
|
described above.</p>
|
|
<pre><code>secretGenerator:
|
|
- name: app-tls
|
|
files:
|
|
- secret/tls.cert
|
|
- secret/tls.key
|
|
type: "kubernetes.io/tls"
|
|
- name: app-tls-namespaced
|
|
# you can define a namespace to generate
|
|
# a secret in, defaults to: "default"
|
|
namespace: apps
|
|
files:
|
|
- tls.crt=catsecret/tls.cert
|
|
- tls.key=secret/tls.key
|
|
type: "kubernetes.io/tls"
|
|
- name: env_file_secret
|
|
envs:
|
|
- env.txt
|
|
type: Opaque
|
|
- name: secret-with-annotation
|
|
files:
|
|
- app-config.yaml
|
|
type: Opaque
|
|
options:
|
|
annotations:
|
|
app_config: "true"
|
|
labels:
|
|
app.kubernetes.io/name: "app2"
|
|
</code></pre><h3 id="usage-via-plugin-10">Usage via plugin</h3>
|
|
<h4 id="arguments-10">Arguments</h4>
|
|
<blockquote>
|
|
<p><a href="https://github.com/kubernetes-sigs/kustomize/tree/master/api/types/objectmeta.go">types.ObjectMeta</a></p>
|
|
<p><a href="https://github.com/kubernetes-sigs/kustomize/tree/master/api/types/secretargs.go">types.SecretArgs</a></p>
|
|
</blockquote>
|
|
<h4 id="example-10">Example</h4>
|
|
<blockquote>
|
|
<pre><code>apiVersion: builtin
|
|
kind: SecretGenerator
|
|
metadata:
|
|
name: my-secret
|
|
namespace: whatever
|
|
behavior: merge
|
|
envs:
|
|
- a.env
|
|
- b.env
|
|
files:
|
|
- obscure=longsecret.txt
|
|
literals:
|
|
- FRUIT=apple
|
|
- VEGETABLE=carrot
|
|
</code></pre></blockquote>
|
|
|
|
|
|
|
|
<div class="text-muted mt-5 pt-3 border-top">Last modified June 15, 2020: <a href="https://github.com/kubernetes-sigs/kustomize/commit/518147c129f831913d33226cf17068d0d4270f41">add zh docsy (518147c1)</a>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</main>
|
|
</div>
|
|
</div>
|
|
|
|
<footer class="bg-dark py-5 row d-print-none">
|
|
<div class="container-fluid mx-sm-5">
|
|
<div class="row">
|
|
<div class="col-6 col-sm-4 text-xs-center order-sm-2">
|
|
|
|
|
|
|
|
<ul class="list-inline mb-0">
|
|
|
|
<li class="list-inline-item mx-2 h3" data-toggle="tooltip" data-placement="top" title="User mailing list" aria-label="User mailing list">
|
|
<a class="text-white" target="_blank" href="https://groups.google.com/forum/#!forum/kubernetes-sig-cli">
|
|
<i class="fa fa-envelope"></i>
|
|
</a>
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
</div>
|
|
<div class="col-6 col-sm-4 text-right text-xs-center order-sm-3">
|
|
|
|
|
|
|
|
<ul class="list-inline mb-0">
|
|
|
|
<li class="list-inline-item mx-2 h3" data-toggle="tooltip" data-placement="top" title="GitHub" aria-label="GitHub">
|
|
<a class="text-white" target="_blank" href="https://github.com/kubernetes-sigs/kustomize">
|
|
<i class="fab fa-github"></i>
|
|
</a>
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
</div>
|
|
<div class="col-12 col-sm-4 text-center py-2 order-sm-2">
|
|
<small class="text-white">© 2020 Kubernetes Authors All Rights Reserved</small>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</footer>
|
|
|
|
|
|
</div>
|
|
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
|
|
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<script src="/kustomize/js/main.min.35b203b3c2114e187f6e4bbf0903c511aaaac5535186321e3b5e364656b6de0c.js" integrity="sha256-NbIDs8IRThh/bku/CQPFEaqqxVNRhjIeO142Rla23gw=" crossorigin="anonymous"></script>
|
|
|
|
|
|
|
|
<script src="https://kubernetes-sigs.github.io/kustomize//js/asciinema-player.js"></script>
|
|
|
|
|
|
</body>
|
|
</html> |