Skip to main content

kubernetes deployment summary and commands

Rolling updates:
suppose one the updates resulted in some error and we would like to roll back the changes.
or may want to pause the environment, make the changes and resume so that the changes are rolled out together

How do we create a deployment file
everything will be same as replicaset in the yml file except that the kind now will be Deployment

commands
kubectl create -f deployment-ymlFile

kubectl get deployments

kubectl get replicaset (deployment automatically creates replicaset)

kubectl get pods

to see all the created objects at once
kubectl get all
apiVersion: apps/v1

kind: Deployment

metadata:
  name: myapp-deployment
  labels:
    name: myapp
    type: front-end

spec:
  template:
    metadata:
      name: myapp-pod
      labels:
        app: myapp
        type: front-end
    spec:
      containers:
        - name: nginx-controller
          image: nginx
  replicas: 3
  selector:
    matchLabels:
      type: front-end

in most of the cases we will not be creating pod  definition or replica set file and would be directly creating the deployment file


Rollout and versioning in deployment

when we create a deployment it triggers a rollout, a new rollout creates a new deployment revision.
When container version is updated, a new rollour is triggerd and a new deployment revision is created named revision2.
This helps us keep track of changes made to our deployment and enables us to roll back to previous version of the deployment  if required.

we can see the rollout status by
kubectl rolllout status deployment/<name of the deployment>

to see the history and revision of rollout
kubectl rollout history deplyment/<name of deployment>

Deployment strategy

1. Recreate strategy
 delete all  the existing once and deploy the new one
problem: system will inaccessible to users the while the system is down
(this is not the default )

2.  Rolling Update
in this, we take down the existing once one by one. This way the system never goes down and the upgrade is seamless.


How to apply the changes

Kubectl apply
kubectl apply -f deployment-definition

by setting image
kubectl set image deployment/myapp-dep \nginx= nginx:1.9.1
the only problem is that doing it this way will result in the deployment file having a different definition

to see the history of deployment we can use, in this we can find the strategy used
kubectl describe deployment

undo update 
kubectl rollout undo deployment/myapp-deployment

 perform deplyment only with image name and no definition file

kubectl run nginx --image=nginx

summary of deployment commands

create
kubectl create -f deployment deployment-definition.yml

get
kubectl get deployments

update
kubectl apply -f deployment-definition.yml
kubectl set image deployment/myapp-deployment nginx=nginx:1.9.1

status
kubectl rollout status deployment/myapp-deployment

kubectl rollout history deployment/myapp-deployment

rollback
 kubectl rollout undo deployment/myapp-deployment

in the history command if you want to see the CHANGE-CAUSE , for this we will have to issue a record command when we create cluster
eg.
kubectl create -f deployment-definition.yml --record



Comments

Popular posts from this blog

opening multiple ports tunnels ngrok in ubuntu

Location for the config yml file /home/example/.ngrok2/ngrok.yml content of config file authtoken: 4nq9771bPxe8ctg7LKr_2ClH7Y15Zqe4bWLWF9p tunnels: app-foo: addr: 80 proto: http host_header: app-foo.dev app-bar: addr: 80 proto: http host_header: app-bar.dev how to start ngrok with considering the config file: ngrok start --all

rename field in elastic Search

https://qiita.com/tkprof/items/e50368eb1473497a16d0 How to Rename an Elasticsearch field from columns: - {name: xxx, type: double} to columns: - {name: yyy, type: double} Pipeline API and reindex create a new Pipeline API : Rename Processor PUT _ingest/pipeline/pipeline_rename_xxx { "description" : "rename xxx", "processors" : [ { "rename": { "field": "xxx", "target_field": "yyy" } } ] } { "acknowledged": true } then reindex POST _reindex { "source": { "index": "source" }, "dest": { "index": "dest", "pipeline": "pipeline_rename_xxx" } }

Sumeru enterprise tiger privacy policy

Sumeru Enterprise Tiger Business Solutions Pvt. Ltd. Data Privacy Policy At Sumeru Enterprise Tiger Business Solutions Pvt. Ltd. we are committed to providing you with digitalization software products and services to meet your needs. Our commitment includes protecting personally identifiable information we obtain about you when you register to use one of our websites or become our customer (“Personal Information”). We want to earn your trust by providing strict safeguards to protect your Personal Information. This Policy applies to members, customers, former customers, users, and applicants. In the course of our business activities, Sumeru Enterprise Tiger Business Solutions Pvt. Ltd. collects, processes, and shares Personal Information. Indian law gives individuals the right to limit some but not all sharing. This Policy explains what Personal Information we collect, process, and share. We describe how we do so, and why. The Policy also describes your rights to access a...