Skip to content

Commit 4d11143

Browse files
authored
Merge pull request kubernetes-sigs#35 from monopole/baseOverlayNotes
Base overlay notes
2 parents 10b4c5d + 1583486 commit 4d11143

File tree

2 files changed

+57
-53
lines changed

2 files changed

+57
-53
lines changed

README.md

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
[demos]: demos/README.md
99
[imageBase]: docs/base.jpg
1010
[imageOverlay]: docs/overlay.jpg
11-
[installation]: INSTALL.md
11+
[install]: INSTALL.md
1212
[kubernetes style]: docs/glossary.md#kubernetes-style-object
1313
[kustomization]: docs/glossary.md#kustomization
1414
[overlay]: docs/glossary.md#overlay
@@ -35,67 +35,64 @@ and it's like [`sed`], in that it emits editted text.
3535
[![Build Status](https://travis-ci.org/kubernetes-sigs/kustomize.svg?branch=master)](https://travis-ci.org/kubernetes-sigs/kustomize)
3636
[![Go Report Card](https://goreportcard.com/badge/github.com/kubernetes-sigs/kustomize)](https://goreportcard.com/report/github.com/kubernetes-sigs/kustomize)
3737

38-
**Installation**:
39-
Download a binary from the [release page], or
40-
see these [installation] alternatives.
41-
42-
Be sure to try one of the tested [demos].
38+
**Installation**: Download a binary from the [release
39+
page], or see these [install] notes. Then try one of
40+
the tested [demos].
4341

4442
## Usage
4543

4644

47-
### Make a [base]
45+
### 1) Make a [kustomization] file
4846

4947
In some directory containing your YAML [resource]
5048
files (deployments, services, configmaps, etc.), create a
5149
[kustomization] file.
5250

5351
This file should declare those resources, and any
54-
common customization to apply to them, e.g. _add a
55-
common label_.
52+
customization to apply to them, e.g. _add a common
53+
label_.
5654

5755
![base image][imageBase]
5856

5957
File structure:
6058

6159
> ```
62-
> ~/yourApp
63-
> └── base
64-
> ├── deployment.yaml
65-
> ├── kustomization.yaml
66-
> └── service.yaml
60+
> ~/someApp
61+
> ├── deployment.yaml
62+
> ├── kustomization.yaml
63+
> └── service.yaml
6764
> ```
6865
69-
This is your [base]. The resources in it could be a
70-
fork of someone else's configuration. If so, you can
71-
easily rebase from the source material to capture
66+
The resources in this directory could be a fork of
67+
someone else's configuration. If so, you can easily
68+
rebase from the source material to capture
7269
improvements, because you don't modify the resources
7370
directly.
7471
7572
Generate customized YAML with:
7673
7774
```
78-
kustomize build ~/yourApp/base
75+
kustomize build ~/someApp
7976
```
8077
8178
The YAML can be directly [applied] to a cluster:
8279
8380
> ```
84-
> kustomize build ~/yourApp/base | kubectl apply -f -
81+
> kustomize build ~/someApp | kubectl apply -f -
8582
> ```
8683
8784
88-
### Create [variants] of a common base using [overlays]
85+
### 2) Create [variants] using [overlays]
8986
90-
Manage traditional [variants] of a configuration like
91-
_development_, _staging_ and _production_ using
92-
[overlays].
87+
Manage traditional [variants] of a configuration - like
88+
_development_, _staging_ and _production_ - using
89+
[overlays] that modify a common [base].
9390
9491
![overlay image][imageOverlay]
9592
9693
File structure:
9794
> ```
98-
> ~/yourApp
95+
> ~/someApp
9996
> ├── base
10097
> │   ├── deployment.yaml
10198
> │   ├── kustomization.yaml
@@ -111,21 +108,32 @@ File structure:
111108
> └── replica_count.yaml
112109
> ```
113110
114-
Store your overlays in your own repository. On disk,
115-
the overlay can reference a base in a sibling
116-
directory. This avoids trouble with nesting git
117-
repositories.
111+
Take the work from step (1) above, move it into a
112+
`someApp` subdirectory called `base`, then
113+
place overlays in a sibling directory.
114+
115+
An overlay is just another kustomization, refering to
116+
the base, and referring to patches to apply to that
117+
base.
118+
119+
This arrangement makes it easy to manage your
120+
configuration with `git`. The base could have files
121+
from an upstream repository managed by someone else.
122+
The overlays could be in a repository you own.
123+
Arranging the repo clones as siblings on disk avoids
124+
the need for git submodules (though that works fine, if
125+
you are a submodule fan).
118126
119127
Generate YAML with
120128
121129
```
122-
kustomize build ~/yourApp/overlays/production
130+
kustomize build ~/someApp/overlays/production
123131
```
124132
125133
The YAML can be directly [applied] to a cluster:
126134
127135
> ```
128-
> kustomize build ~/yourApp/overlays/production | kubectl apply -f -
136+
> kustomize build ~/someApp/overlays/production | kubectl apply -f -
129137
> ```
130138
131139
## About

docs/glossary.md

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -68,25 +68,17 @@ management in k8s.
6868

6969
A _base_ is a [target] that some [overlay] modifies.
7070

71-
Any target, including an overlay, can be a base to
71+
Any target, including an [overlay], can be a base to
7272
another target.
7373

7474
A base has no knowledge of the overlays that refer to it.
7575

76-
A base is usable in isolation, i.e. one should
77-
be able to [apply] a base to a cluster directly.
78-
7976
For simple [gitops] management, a base configuration
8077
could be the _sole content of a git repository
8178
dedicated to that purpose_. Same with [overlays].
8279
Changes in a repo could generate a build, test and
8380
deploy cycle.
8481

85-
Some of the demos for [kustomize] will break from this
86-
idiom and store all demo config files in directories
87-
_next_ to the `kustomize` code so that the code and
88-
demos can be more easily maintained by the same group
89-
of people.
9082

9183
## bespoke configuration
9284

@@ -163,9 +155,9 @@ It's often abbreviated as _k8s_.
163155
An object, expressed in a YAML or JSON file, with the
164156
[fields required] by kubernetes. Basically just a
165157
_kind_ field to identify the type, a _metadata/name_
166-
field to identify the variant, and an _apiVersion_
167-
field to identify the version (if there's more than one
168-
version).
158+
field to identify the particular instance, and an
159+
_apiVersion_ field to identify the version (if there's
160+
more than one version).
169161

170162
## kustomize
171163

@@ -210,19 +202,24 @@ An _overlay_ is a [target] that modifies (and thus
210202
depends on) another target.
211203
212204
The [kustomization] in an overlay refers to (via file
213-
path, URI or other method) _some other kustomization_,
205+
path, URI or other method) some other kustomization,
214206
known as its [base].
215207
216208
An overlay is unusable without its base.
217209
218-
An overlay supports the typical notion of a
219-
_development_, _QA_, _staging_ and _production_
220-
environment variants.
210+
An overlay may act as a base to another overlay.
211+
212+
Overlays make the most sense when there is _more than
213+
one_, because they create different [variants] of a
214+
common base - e.g. _development_, _QA_, _staging_ and
215+
_production_ environment variants.
221216
222-
The configuration of these environments is specified in
223-
individual overlays (one per environment) that all
224-
refer to a common base that holds common configuration.
225-
One configures the cluster like this:
217+
These variants use the same overall resources, and vary
218+
in relatively simple ways, e.g. the number of replicas
219+
in a deployment, the CPU to a particular pod, the data
220+
source used in a configmap, etc.
221+
222+
One configures a cluster like this:
226223
227224
> ```
228225
> kustomize build someapp/overlays/staging |\
@@ -232,10 +229,9 @@ One configures the cluster like this:
232229
> kubectl apply -f -
233230
> ```
234231
235-
Usage of the base is implicit (the overlay's kustomization
236-
points to the base).
232+
Usage of the base is implicit - the overlay's
233+
kustomization points to the base.
237234
238-
An overlay may act as a base to another overlay.
239235
240236
## package
241237

0 commit comments

Comments
 (0)