41 Deploying New Releases
41 Deploying New Releases
41 Deploying New Releases
In this lesson, we will go through the Kubernetes deployment de nition and will create a deployment.
Just as we are not supposed to create Pods directly but using other controllers
like ReplicaSet, we are not supposed to create ReplicaSets either. Kubernetes
Deployments will create them for us. If you’re wondering why is this so? You’ll
have to wait a little while longer to find out.
First, we’ll create a few Deployments and, once we are familiar with the
process and the outcomes, it’ll become obvious why they are better at
managing ReplicaSets than we are.
cat deploy/go-demo-2-db.yml
apiVersion: apps/v1
kind: Deployment
metadata:
name: go-demo-2-db
spec:
selector:
matchLabels:
type: db
service: go-demo-2
template:
metadata:
labels:
type: db
service: go-demo-2
vendor: MongoLabs
spec:
containers:
- name: db
image: mongo:3.3
ports:
- containerPort: 28017
Since, in this case, both the Deployment and the ReplicaSet are the same, you
might be wondering what the advantage of using one over the other is.
kubectl create \
-f deploy/go-demo-2-db.yml \
--record
kubectl get -f deploy/go-demo-2-db.yml
...
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal ScalingReplicaSet 2m deployment-controller Scaled up replica set go-demo-2-db-75fb
From the Events section, we can observe that the Deployment created a
ReplicaSet. Or, to be more precise, that it scaled it. That is interesting.
All three objects were created, and you might be wondering why we created
the Deployment at all. You might think that we’d have the same result if we
created a ReplicaSet directly. You’d be right.
Deployment and its cascading effect that creates a ReplicaSet and, through it, Pods
In the next lesson, we will go through the sequential breakdown of the process
of creating deployment.