...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
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
key | description |
---|---|
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
|
Steps to deploying an application
- Create a deployment similar to the one shown above
- execute the command kubectl apply -f <deployment yaml file>
- kubectl expose deployment nginx-deployment --type=LoadBalancer --port=8080