@@ -10,7 +10,7 @@ in subdirectories.
10
10
This is a common pattern.
11
11
The ` cue ` tooling has been optimized for this use case.
12
12
13
- In this tutorial we will address the folowing topics:
13
+ In this tutorial we will address the following topics:
14
14
15
15
1 . convert the given YAML files to CUE
16
16
1 . hoist common patterns to parent directories
@@ -99,7 +99,7 @@ Many of the files contain more than one Kubernetes object.
99
99
Moreover, we are creating a single configuration that contains all objects
100
100
of all files.
101
101
We need to organize all Kubernetes objects such that each is individually
102
- identifyable within a single configuration.
102
+ identifiable within a single configuration.
103
103
We do so by defining a different struct for each type putting each object
104
104
in this respective struct keyed by its name.
105
105
This allows objects of different types to share the same name,
@@ -464,14 +464,14 @@ $ cue fmt
464
464
```
465
465
466
466
The common configuration has been factored out into ` _spec ` .
467
- We introducded ` _name ` to aid both specifying and referring
467
+ We introduced ` _name ` to aid both specifying and referring
468
468
to the name of an object.
469
469
For completeness, we added ` configMap ` as a top-level entry.
470
470
471
471
Note that we have not yet removed the old definition of deployment.
472
472
This is fine.
473
473
As it is equivalent to the new one, unifying them will have no effect.
474
- We leave its removal as an excersize to the reader.
474
+ We leave its removal as an exercise to the reader.
475
475
476
476
Next we observe that all deployments, stateful sets and daemon sets have
477
477
an accompanying service which shares many of the same fields.
@@ -505,8 +505,8 @@ $ cue fmt
505
505
```
506
506
507
507
This example introduces a few new concepts.
508
- Open-ended lists are indicated with an elipsis (` ... ` ).
509
- The value following an elipsis is unified with any subsequent elements and
508
+ Open-ended lists are indicated with an ellipsis (` ... ` ).
509
+ The value following an ellipsis is unified with any subsequent elements and
510
510
defines the "type", or template, for additional list elements.
511
511
512
512
The ` Port ` declaration is an alias.
@@ -515,7 +515,7 @@ They can be used to make shadowed fields visible within nested scopes or,
515
515
in this case, to reduce boilerplate without introducing new fields.
516
516
517
517
Finally, this example introduces list and field comprehensions.
518
- List comprehensions are analoguous to list comprehensions found in other
518
+ List comprehensions are analogous to list comprehensions found in other
519
519
languages.
520
520
Field comprehensions allow inserting fields in structs.
521
521
In this case, the field comprehension adds a namesake service for any
@@ -524,7 +524,7 @@ Field comprehensions can also be used to add a field conditionally.
524
524
525
525
526
526
Specifying the ` targetPort ` is not necessary, but since many files define it,
527
- defining it here will allow those defintitions to be removed
527
+ defining it here will allow those definitions to be removed
528
528
using ` cue trim ` .
529
529
We add an option ` _export ` for ports defined in containers to specify whether
530
530
to include them in the service and explicitly set this to false
@@ -558,14 +558,14 @@ $ cue trim ./...
558
558
$ find . | grep kube.cue | xargs wc | tail -1
559
559
1129 2270 22073 total
560
560
```
561
- This is after removing the rewriten and now redundant deployment definition.
561
+ This is after removing the rewritten and now redundant deployment definition.
562
562
563
563
We shaved off almost another 100 lines, even after adding the template.
564
564
You can verify that the service definitions are now gone in most of the files.
565
565
What remains is either some additional configuration, or inconsistencies that
566
566
should probably be cleaned up.
567
567
568
- But we have another trick up our sleave .
568
+ But we have another trick up our sleeve .
569
569
With the ` -s ` or ` --simplify ` option we can tell ` trim ` or ` fmt ` to collapse
570
570
structs with a single element onto a single line. For instance:
571
571
@@ -650,10 +650,10 @@ $ find . | grep kube.cue | xargs wc | tail -1
650
650
931 2052 19624 total
651
651
```
652
652
653
- Antoher 40 lines removed.
653
+ Another 40 lines removed.
654
654
We may have gotten used to larger reductions, but at this point there is just
655
655
not much left to remove: in some of the frontend files there are only 4 lines
656
- of confiugration left.
656
+ of configuration left.
657
657
658
658
659
659
#### Directory ` kitchen `
@@ -736,7 +736,7 @@ This template definition is not ideal: the definitions are positional, so if
736
736
configurations were to define the disks in a different order, there would be
737
737
no reuse or even conflicts.
738
738
Also note that in order to deal with this restriction, almost all field values
739
- are just default values and can be overriden by instances.
739
+ are just default values and can be overridden by instances.
740
740
A better way would be define a map of volumes,
741
741
similarly to how we organized the top-level Kubernetes objects,
742
742
and then generate these two sections from this map.
@@ -765,7 +765,7 @@ We also reduced the configuration by a sizeable amount once more.
765
765
766
766
However, on closer inspection of the remaining files we see a lot of remaining
767
767
fields in the disk specifications as a result of inconsistent naming.
768
- Reducing configurations like we did in this excersize exposes inconsistencies.
768
+ Reducing configurations like we did in this exercise exposes inconsistencies.
769
769
The inconsistencies can be removed by simply deleting the overrides in the
770
770
specific configuration.
771
771
Leaving them as is gives a clear signal that a configuration is inconsistent.
@@ -774,7 +774,7 @@ Leaving them as is gives a clear signal that a configuration is inconsistent.
774
774
### Conclusion of Quick 'n Dirty tutorial
775
775
776
776
There is still some gain to be made with the other directories.
777
- At nearly a 1000-line, or 55%, reduction, we leave the rest as an excersize to
777
+ At nearly a 1000-line, or 55%, reduction, we leave the rest as an exercise to
778
778
the reader.
779
779
780
780
We have shown how CUE can be used to reduce boilerplate, enforce consistencies,
@@ -920,7 +920,7 @@ values.
920
920
The result may contain conflicts, such as our top-level ` _component ` field,
921
921
but our per-type maps of Kubernetes objects should be free of conflict
922
922
(if there is, we have a problem with Kubernetes down the line).
923
- A merge thus gives us a unfied view of all objects.
923
+ A merge thus gives us a unified view of all objects.
924
924
925
925
```
926
926
$ cue ls ./...
@@ -1010,7 +1010,7 @@ EOF
1010
1010
This command has two tasks, named ` kube ` and ` display ` .
1011
1011
The ` display ` task depends on the output of the ` kube ` task.
1012
1012
The ` cue ` tool does a static analysis of the dependencies and runs all
1013
- tasks which depencies are satisfied in parallel while blocking tasks
1013
+ tasks which dependencies are satisfied in parallel while blocking tasks
1014
1014
for which an input is missing.
1015
1015
1016
1016
```
@@ -1088,7 +1088,7 @@ In the next sections we will show how to get there.
1088
1088
1089
1089
### Outline
1090
1090
1091
- The basic premis of our configuration is to maintain two configurations,
1091
+ The basic premise of our configuration is to maintain two configurations,
1092
1092
a simple and abstract one, and one compatible with Kubernetes.
1093
1093
The Kubernetes version is automatically generated from the simple configuration.
1094
1094
Each simplified object has a ` kubernetes ` section that get gets merged into
@@ -1124,7 +1124,7 @@ Overall, the code modeling our services and the code generating the kubernetes
1124
1124
code is separated, while still allowing to inject Kubernetes-specific
1125
1125
data into our general model.
1126
1126
At the same time, we can add additional information to our model without
1127
- it ending up in the Kubernetes defintions causing it to barf.
1127
+ it ending up in the Kubernetes definitions causing it to barf.
1128
1128
1129
1129
1130
1130
### Deployment Definition
@@ -1152,7 +1152,7 @@ This also eliminates the need for `_spec`.
1152
1152
1153
1153
The next step is to pull common fields, such as ` image ` to the top level.
1154
1154
1155
- Arguments can be specied as a map.
1155
+ Arguments can be specified as a map.
1156
1156
```
1157
1157
arg <Key>: string
1158
1158
args: [ "-\(k)=\(v)" for k, v in arg ] | [...string]
@@ -1268,7 +1268,7 @@ part of this exercise.
1268
1268
That said, most CUE users will never have to resort to this level of CUE
1269
1269
to write configurations.
1270
1270
For instance, none of the files in the subdirectories contain comprehensions,
1271
- not even the template files in these directores (such as ` kitchen/kube.cue ` ).
1271
+ not even the template files in these directories (such as ` kitchen/kube.cue ` ).
1272
1272
Furthermore, none of the configuration files in any of the
1273
1273
leaf directories contain string interpolations.
1274
1274
@@ -1284,23 +1284,23 @@ $ find . | grep kube.cue | xargs wc | tail -1
1284
1284
```
1285
1285
This does not count our conversion templates.
1286
1286
Assuming that the top-level templates are reusable, and if we don't count them
1287
- for both approaches, the manual approach shaves off about anoter 150 lines.
1287
+ for both approaches, the manual approach shaves off about another 150 lines.
1288
1288
If we count the templates as well, the two approaches are roughly equal.
1289
1289
1290
1290
1291
1291
### Conclusions Manual Configuration
1292
1292
1293
1293
We have shown that we can further compact a configuration by manually
1294
1294
optimizing template files.
1295
- However, we have also shown that the manual optimizition only gives
1295
+ However, we have also shown that the manual optimization only gives
1296
1296
a marginal benefit with respect to the quick-and-dirty semi-automatic reduction.
1297
- The benefits for the manual definition largely lies in the orginazational
1297
+ The benefits for the manual definition largely lies in the organizational
1298
1298
flexibility one gets.
1299
1299
1300
1300
Manually tailoring your configurations allows creating an abstraction layer
1301
1301
between logical definitions and Kubernetes-specific definitions.
1302
1302
At the same time, CUE's order independence
1303
- makes it easy to mix in low-level Kubernetes configuration whereever it is
1303
+ makes it easy to mix in low-level Kubernetes configuration wherever it is
1304
1304
convenient and applicable.
1305
1305
1306
1306
Manual tailoring also allows us to add our own definitions without breaking
0 commit comments