kustomize.yaml becomes kustomization.yaml

This commit is contained in:
Jeffrey Regan
2018-04-17 11:16:49 -07:00
parent 428e980eb5
commit 897def7483
5 changed files with 52 additions and 55 deletions

View File

@@ -57,7 +57,7 @@ Expecting something like:
> └── base
> ├── configMap.yaml
> ├── deployment.yaml
> ├── kustomize.yaml
> ├── kustomization.yaml
> ├── LICENSE
> ├── README.md
> └── service.yaml
@@ -81,7 +81,7 @@ The `base` directory has a [kustomization] file:
<!-- @showKustomization @test -->
```
BASE=$DEMO_HOME/base
more $BASE/kustomize.yaml
more $BASE/kustomization.yaml
```
Run `kustomize` on the base to emit customized resources
@@ -100,7 +100,7 @@ label_ applied to all resources:
<!-- @addLabel @test -->
```
sed -i 's/app: hello/app: my-hello/' \
$BASE/kustomize.yaml
$BASE/kustomization.yaml
```
See the effect:
@@ -132,12 +132,12 @@ defining a new name prefix, and some different labels.
<!-- @makeStagingKustomization @test -->
```
cat <<'EOF' >$OVERLAYS/staging/kustomize.yaml
cat <<'EOF' >$OVERLAYS/staging/kustomization.yaml
namePrefix: staging-
labelsToAdd:
commonLabels:
instance: staging
org: acmeCorporation
annotationsToAdd:
commonAnnotations:
note: Hello, I am staging!
bases:
- ../../base
@@ -173,12 +173,12 @@ with a different name prefix and labels.
<!-- @makeProductionKustomization @test -->
```
cat <<EOF >$OVERLAYS/production/kustomize.yaml
cat <<EOF >$OVERLAYS/production/kustomization.yaml
namePrefix: production-
labelsToAdd:
commonLabels:
instance: production
org: acmeCorporation
annotationsToAdd:
commonAnnotations:
note: Hello, I am production!
bases:
- ../../base
@@ -231,16 +231,16 @@ Expecting something like:
> ├── base
> │   ├── configMap.yaml
> │   ├── deployment.yaml
> │   ├── kustomize.yaml
> │   ├── kustomization.yaml
> │   ├── LICENSE
> │   ├── README.md
> │   └── service.yaml
> └── overlays
> ├── production
> │   ├── deployment.yaml
> │   └── kustomize.yaml
> │   └── kustomization.yaml
> └── staging
> ├── kustomize.yaml
> ├── kustomization.yaml
> └── map.yaml
> ```
@@ -373,7 +373,7 @@ kustomize build $OVERLAYS/staging |\
The configMap name is prefixed by _staging-_, per the
`namePrefix` field in
`$OVERLAYS/staging/kustomize.yaml`.
`$OVERLAYS/staging/kustomization.yaml`.
The suffix to the configMap name is generated from a
hash of the maps content - in this case the name suffix

View File

@@ -30,16 +30,16 @@ done
```
### Initialize kustomize.yaml
### Initialize kustomization.yaml
The `kustomize` program gets its instructions from
a file called `kustomize.yaml`.
a file called `kustomization.yaml`.
Start this file:
<!-- @kustomizeYaml @test -->
```
touch $DEMO_HOME/kustomize.yaml
touch $DEMO_HOME/kustomization.yaml
```
### Add the resources
@@ -52,10 +52,10 @@ kustomize edit add resource secret.yaml
kustomize edit add resource service.yaml
kustomize edit add resource deployment.yaml
cat kustomize.yaml
cat kustomization.yaml
```
`kustomize.yaml`'s resources section should contain:
`kustomization.yaml`'s resources section should contain:
> ```
> resources:
@@ -76,10 +76,10 @@ cd $DEMO_HOME
kustomize edit set nameprefix 'prod-'
cat kustomize.yaml
cat kustomization.yaml
```
`kustomize.yaml` should have updated value of namePrefix field:
`kustomization.yaml` should have updated value of namePrefix field:
> ```
> namePrefix: prod-
@@ -128,15 +128,13 @@ We want resources in production environment to have
certain labels so that we can query them by label
selector.
`kustomize` does not have `set label` command to add
label, but we can edit `kustomize.yaml` file under
`prod` directory and add the production labels under
`labelsToAdd` fields as highlighted below.
`kustomize` does not have `edit set label` command to add
a label, but one can always edit `kustomization.yaml` directly:
<!-- @customizeLabels @test -->
```
sed -i 's/app: helloworld/app: prod/' \
$DEMO_HOME/kustomize.yaml
$DEMO_HOME/kustomization.yaml
```
At this point, running `kustomize build` will
@@ -170,11 +168,11 @@ spec:
EOF
```
Add the patch file to `kustomize.yaml`:
Add the patch file to `kustomization.yaml`:
<!-- @specifyPatch @test -->
```
cat <<'EOF' >> $DEMO_HOME/kustomize.yaml
cat <<'EOF' >> $DEMO_HOME/kustomization.yaml
patches:
- persistent-disk.yaml
EOF
@@ -187,7 +185,7 @@ Lets break this down:
in deployment.yaml
- Then we added `persistent-disk.yaml` to list of
`patches` in `kustomize.yaml`. `kustomize build`
`patches` in `kustomization.yaml`. `kustomize build`
will apply this patch to the deployment resource with
the name `mysql` as defined in the patch.

View File

@@ -31,16 +31,16 @@ for f in service deployment; do \
done
```
### Initialize kustomize.yaml
### Initialize kustomization.yaml
The `kustomize` program gets its instructions from
a file called `kustomize.yaml`.
a file called `kustomization.yaml`.
Start this file:
<!-- @kustomizeYaml @test -->
```
touch $DEMO_HOME/kustomize.yaml
touch $DEMO_HOME/kustomization.yaml
```
### Add the resources
@@ -52,10 +52,10 @@ cd $DEMO_HOME
kustomize edit add resource service.yaml
kustomize edit add resource deployment.yaml
cat kustomize.yaml
cat kustomization.yaml
```
`kustomize.yaml`'s resources section should contain:
`kustomization.yaml`'s resources section should contain:
> ```
> resources:
@@ -71,10 +71,10 @@ cd $DEMO_HOME
wget -q $CONTENT/example-springboot/master/application.properties
kustomize edit add configmap demo-configmap --from-file application.properties
cat kustomize.yaml
cat kustomization.yaml
```
`kustomize.yaml`'s configMapGenerator section should contain:
`kustomization.yaml`'s configMapGenerator section should contain:
> ```
> configMapGenerator:
@@ -111,7 +111,7 @@ spec:
value: prod
EOF
cat <<EOF >>$DEMO_HOME/kustomize.yaml
cat <<EOF >>$DEMO_HOME/kustomization.yaml
patches:
- patch.yaml
EOF
@@ -125,10 +125,10 @@ EOF
kustomize edit add configmap demo-configmap --from-file application-prod.properties
cat kustomize.yaml
cat kustomization.yaml
```
`kustomize.yaml`'s configMapGenerator section should contain:
`kustomization.yaml`'s configMapGenerator section should contain:
> ```
> configMapGenerator:
> - files:
@@ -149,14 +149,14 @@ cd $DEMO_HOME
kustomize edit set nameprefix 'prod-'
cat kustomize.yaml
cat kustomization.yaml
```
`kustomize.yaml` should have updated value of namePrefix field:
`kustomization.yaml` should have updated value of namePrefix field:
> ```
> namePrefix: prod-
> annotationsToAdd:
> commonAnnotations:
> note: This is a example annotation
> ```
@@ -204,14 +204,12 @@ certain labels so that we can query them by label
selector.
`kustomize` does not have `edit set label` command to add
label, but we can edit `kustomize.yaml` file under
`prod` directory and add the production labels under
`labelsToAdd` fields as highlighted below.
a label, but one can always edit `kustomization.yaml` directly:
<!-- @customizeLabels @test -->
```
sed -i 's/app: helloworld/app: prod/' \
$DEMO_HOME/kustomize.yaml
$DEMO_HOME/kustomization.yaml
```
At this point, running `kustomize build` will
@@ -301,18 +299,18 @@ The output contains
### Add patches
Currently `kustomize` doesn't provide a command to add a file as a patch, but we can edit the file `kustomize.yaml` to
Currently `kustomize` doesn't provide a command to add a file as a patch, but we can edit the file `kustomization.yaml` to
include this patch.
<!-- @addPatch @test -->
```
mv $DEMO_HOME/kustomize.yaml $DEMO_HOME/tmp.yaml
mv $DEMO_HOME/kustomization.yaml $DEMO_HOME/tmp.yaml
sed '/patches:$/{N;s/- patch.yaml/- patch.yaml\n- memorylimit_patch.yaml\n- healthcheck_patch.yaml/}' \
$DEMO_HOME/tmp.yaml >& $DEMO_HOME/kustomize.yaml
$DEMO_HOME/tmp.yaml >& $DEMO_HOME/kustomization.yaml
```
`kustomize.yaml` should have patches field:
`kustomization.yaml` should have patches field:
> ```
> patches

View File

@@ -122,15 +122,16 @@ an [overlay] to a [base].
## kustomization
A _kustomization_ is a file called `kustomize.yaml` that
A _kustomization_ is a file called `kustomization.yaml` that
describes a configuration consumable by [kustomize].
Here's an [example](kustomize.yaml).
Here's an [example](kustomization.yaml).
A kustomization contains fields falling into these categories:
* Immediate customization instructions -
_namePrefix_, _labelsToAdd_, etc.
* Immediate customization declarations, e.g.
_namePrefix_, _commonLabels_, etc.
* Resource _generators_ for configmaps and secrets.
* References to _external files_ in these categories:
* [resources] - completely specified k8s API objects,
@@ -166,7 +167,7 @@ E.g. one might create a github repository like this:
> ```
> github.com/username/someapp/
> kustomize.yaml
> kustomization.yaml
> deployment.yaml
> configmap.yaml
> README.md
@@ -252,7 +253,7 @@ The _target_ is the argument to `build`, e.g.:
`$target` must be a path to a directory that
immediately contains a file called
`kustomize.yaml` (i.e. a [kustomization]).
`kustomization.yaml` (i.e. a [kustomization]).
The target contains, or refers to, all the information
needed to create customized resources to send to the