This is an old revision of the document!
Overview
Deployments, finally we have reached to the last major object in Kubernetes. Deployments take everything we have being doing so far and encapusaltes it. What I mean is the following:
Of course you can have more than 1 pod in replica set. Yes, it is replica set when under Deployment, not replication controller. But the purpose is the same.
So let's create our Deployment now:
Configuration
To create a deployment again we have two ways:
- Iterative - With kubectl create and so on
- Declarative - Using YML / JSON file, I will be using this one.
As I am bored with the iterative way, let's clean our env and create a deployment. I won't delete my service as I will use it later.
Create Deployment (Declarative)
First, let's create our YML file:
Create Deployment YML file
apiVersion: apps/v1 kind: Deployment metadata: name: hello-deploy spec: replicas: 10 selector: matchLabels: app: hello-date template: metadata: labels: app: hello-date spec: containers: - name: hello-pod image: andonovj/httpserverdemo:latest ports: - containerPort: 1234
Bare in mind that the deployment have been moved from extensions/v1beta1 → apps/v1 and forward :) Also a little syntax changes compared to the old one, but nothing serious.
Once we have the YAML file, we can continue as follows:
Create deployment
ubuntu@k8s-master:~$ kubectl create -f deploy.yml deployment.apps/hello-deploy created ubuntu@k8s-master:~$ kubectl get deploy NAME READY UP-TO-DATE AVAILABLE AGE hello-deploy 1/10 10 1 26s ubuntu@k8s-master:~$ kubectl describe deploy Name: hello-deploy Namespace: default CreationTimestamp: Sat, 02 May 2020 15:54:34 +0000 Labels: <none> Annotations: deployment.kubernetes.io/revision: 1 Selector: app=hello-date Replicas: 10 desired | 10 updated | 10 total | 10 available | 0 unavailable StrategyType: RollingUpdate MinReadySeconds: 0 RollingUpdateStrategy: 25% max unavailable, 25% max surge Pod Template: Labels: app=hello-date Containers: hello-pod: Image: andonovj/httpserverdemo:latest Port: 1234/TCP Host Port: 0/TCP Environment: <none> Mounts: <none> Volumes: <none> Conditions: Type Status Reason ---- ------ ------ Available True MinimumReplicasAvailable Progressing True NewReplicaSetAvailable OldReplicaSets: <none> NewReplicaSet: hello-deploy-6cd458494 (10/10 replicas created) Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal ScalingReplicaSet 8m59s deployment-controller Scaled up replica set hello-deploy-6cd458494 to 10
Again, we can check if our app is working:
Replica Sets
As already mentioned, deployments operate with Replicat Sets, NOT replication Controllers. Eventhough that is a new objects, it inherits a lot of stuff from the replication controller. You can check the Replica sets, almost the same as the replication controller and notice that we don't have Replication Controllers anymore…after I have deleted them in the past of course.
Check Replica Sets
ubuntu@k8s-master:~$ kubectl get rs NAME DESIRED CURRENT READY AGE hello-deploy-6cd458494 10 10 10 11m ubuntu@k8s-master:~$ kubectl get rc No resources found in default namespace. ubuntu@k8s-master:~$