четвер, 16 листопада 2023 р.

Kubernetes. 3 Deployment 3. Creating Deployment. Quick Way

 apiVersion: apps/v1
kind: Deployment
metadata:
  creationTimestamp: null
  labels:
    app: easy-peasy
  name: easy-peasy
spec:
  replicas: 5
  selector:
    matchLabels:
      app: easy-peasy
  strategy: {}
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: easy-peasy
    spec:
      containers:
      - command:
        - sleep
        - infinity
        image: busybox:1.34
        name: busybox
        resources: {}
status: {}

 

Please inspect following command:


kubectl create deployment --help


Create a deployment with the specified name.


Aliases:

deployment, deploy


Examples:

  # Create a deployment named my-dep that runs the busybox image.

  kubectl create deployment my-dep --image=busybox:1.34

  

  # Create a deployment with command

  kubectl create deployment my-dep --image=busybox -- date

  

  # Create a deployment named my-dep that runs the nginx image with 3 replicas.

  kubectl create deployment my-dep --image=nginx --replicas=3

  

  # Create a deployment named my-dep that runs the busybox image and expose port 5701.

  kubectl create deployment my-dep --image=busybox --port=5701


Options:

      --allow-missing-template-keys=true: If true, ignore any errors in templates when a field or

map key is missing in the template. Only applies to golang and jsonpath output formats.

      --dry-run='none': Must be "none", "server", or "client". If client strategy, only print the

object that would be sent, without sending it. If server strategy, submit server-side request

without persisting the resource.

      --field-manager='kubectl-create': Name of the manager used to track field ownership.

      --image=[]: Image names to run.

  -o, --output='': Output format. One of:

json|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|jsonpath-as-json|jsonpath-file.

      --port=-1: The port that this container exposes.

  -r, --replicas=1: Number of replicas to create. Default is 1.

      --save-config=false: If true, the configuration of current object will be saved in its

annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to

perform kubectl apply on this object in the future.

      --template='': Template string or path to template file to use when -o=go-template,

-o=go-template-file. The template format is golang templates

[http://golang.org/pkg/text/template/#pkg-overview].

      --validate=true: If true, use a schema to validate the input before sending it


Usage:

  kubectl create deployment NAME --image=image -- [COMMAND] [args...] [options]


Use "kubectl options" for a list of global command-line options (applies to all commands).


Task:


Inspect the details listed above, add necessary options to kubectl create deploy command to produce following deployment configuration:


    Name: easy-peasy

    Image: busybox:1.34

    Replicas: 5

    Command: sleep infinity


Take into Account:


To generate Deployment manifest you should use the same command with these options:


    --dry-run=client

    -o yaml


    Make sure you use these options before command part (-- ...)


Documentation:


    https://kubernetes.io/docs/concepts/workloads/controllers/deployment/

    https://cloud.google.com/kubernetes-engine/docs/concepts/deployment


Check Report


easy-peasy deployment:


✓ created


✓ image is ok


✓ replicas set to correct value


✓ all pods are up


✓ command is ok


Score: 100


 

Немає коментарів:

Дописати коментар