[Kubernetes] Run, Expose, and Create Generators

[Kubernetes] Run, Expose, and Create Generators

  • 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 defaults as a starting point
    • Generators are "opinionated default"
  • Generator Examples
    • Using dry-run with yaml output we can see the generators
      • kubectl create deployment test --image nginx --dry-run -o yaml
      • Job的restartPolicy是Never,kubectl create job test --image nginx --dry-run -o yaml
      • kubectl expose deployment/test --port 80 --dry-run -o yaml, You need create a deployment before it works( kubectl create deployment test --image nginx )
    • End