Kubernetes Management Techniques

Run, Create and Expose Generators

    These commands use helper templates called "generators"
    Every resource in Kubernetes has a specification or "spec"
    kubectl create deployment sample --image nginx --dry-run -o yaml
    You can output those templates with --dry-run -o yaml
    You can use those YAML default as a starting point for your own templates
    Generators are "opinionated defaults"
1
apiVersion: apps/v1
2
kind: Deployment
3
metadata:
4
creationTimestamp: null
5
labels:
6
app: sample
7
name: sample
8
spec:
9
replicas: 1
10
selector:
11
matchLabels:
12
app: sample
13
strategy: {}
14
template:
15
metadata:
16
creationTimestamp: null
17
labels:
18
app: sample
19
spec:
20
containers:
21
- image: nginx
22
name: nginx
23
resources: {}
24
status: {}
Copied!

Three Management Approaches

    Imperative commands: run, expose, scale, edit, create deployment
      best for dev / learning / personal projects
      easy to learn, hardest to manage over time
    Imperative objects: create -f file.yml, replace -f file.yml, delete -f file.yml
      good for prod of small environments, single file per command
      store your changes in git-based yaml files
      hard to automate
    Declarative objects: apply -f file.yaml or dir\, diff
      best for prod, easier to automate
      harder to understand and predict changes
    Most important rule:
      don't mix these three approaches
Last modified 1yr ago