Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Version History

« Previous Version 2 Next »

A Deployment is the artefact that is used to describe the end state of a POD.  It is usually written in YAML and would look something like this

YAML Deployment File
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.9.1
        ports:
        - containerPort: 80

Key to the above YAML file

keydescription
metadata:Key/value pairs that can be used in search and configuration operation, the above example name is the label, nginx-deployment is the value.  When viewed in the dashboard nginx-deployment is a label that will be a clickable field.  From the dashboard, look at the Overview or Deployments view, you will see the deployment name "nginx-deployment", adjacent to this value is the label app:nginx.  
spec:The specification
replicas:The number of PODs in the cluster
spec:/selector:/matchLabels:

A series of labels that can be used in search and configuration operations, in the above example app is the label, nginx is the value.

From the dashboard, look at the Overview or Deployments view, you will see the deployment name "nginx-deployment", select the deployment name and the deployment details will be shown.  Within the details you will the selector value.

spec:/template:/spec:/containers:

Use this section to specify the container details

  • name - the container name
  • image - path to image (default is docker but can be url other repos such as googles)
  • ports:/containerPort - the host port the application exposes itself out to the world (docker run -p <host port>:<container port>)

Steps to deploying an application

  1. Create a deployment similar to the one shown above
  2. execute the command kubectl apply -f <deployment yaml file>
  3. kubectl expose deployment nginx-deployment --type=LoadBalancer --port=8080


  • No labels