{"id":968,"date":"2020-08-24T12:29:53","date_gmt":"2020-08-24T12:29:53","guid":{"rendered":"https:\/\/blog.samarthya.me\/wps\/?p=968"},"modified":"2020-08-24T12:29:55","modified_gmt":"2020-08-24T12:29:55","slug":"deployments-k8s","status":"publish","type":"post","link":"https:\/\/blog.samarthya.me\/wps\/2020\/08\/24\/deployments-k8s\/","title":{"rendered":"Deployments: K8S"},"content":{"rendered":"\n<p>A declarative way of maintaining the desired state.<\/p>\n\n\n\n<p>Continuing my example from the last blog<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>--- # Pod deployment\napiVersion: apps\/v1\nkind: Deployment\nmetadata:\n  name: go-server-deployment\nspec:\n  replicas: 2\n  selector:\n    matchLabels:\n      app: my-go-server\n  template:\n    metadata:\n      labels:\n        app: my-go-server\n    spec:\n      containers:\n        - name: go-server\n          image: samarthya\/epserver:2.0\n          resources:\n            limits:\n              memory: \"256Mi\"\n              cpu: \"1024m\"\n          env:\n            - name: SERVERPORT\n              value: \"9090\"\n          ports:\n            - containerPort: 9090\n# Reference - https:\/\/kubernetes.io\/docs\/concepts\/workloads\/controllers\/deployment\/\n<\/code><\/pre>\n\n\n\n<p>In my deployment, I have two replicas configured, which can be increased to three using the command like the one below.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>k scale deployment\/go-server-deployment --replicas=3<\/code><\/pre>\n\n\n\n<p>If I wish rollout a change for all pods, which can be conveniently managed via deployments it is as easy as issuing a single command.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>k set image deployment\/go-server-deployment go-server=samarthya\/epserver:1.0 --record=true<\/code><\/pre>\n\n\n\n<p>History is also maintained<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>k rollout history deployment go-server-deployment \nREVISION  CHANGE-CAUSE\n1         &lt;none>\n2         k set image deployment\/go-server-deployment go-server=samarthya\/epserver:2.0 --record=true<\/code><\/pre>\n\n\n\n<p>Other command that you can issue for rollout are as under<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Available Commands:\n  history     View rollout history\n  pause       Mark the provided resource as paused\n  restart     Restart a resource\n  resume      Resume a paused resource\n  status      Show the status of the rollout\n  undo        Undo a previous rollout\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>k rollout undo<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">References<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>https:\/\/kubernetes.io\/docs\/concepts\/workloads\/controllers\/deployment\/#creating-a-deployment<\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>A declarative way of maintaining the desired state. Continuing my example from the last blog In my deployment, I have two replicas configured, which can be increased to three using the command like the one below. If I wish rollout a change for all pods, which can be conveniently managed via deployments it is as [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":970,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"image","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[34],"tags":[99,18],"class_list":["post-968","post","type-post","status-publish","format-image","has-post-thumbnail","hentry","category-technical","tag-deployments","tag-k8s","post_format-post-format-image"],"_links":{"self":[{"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/posts\/968","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/comments?post=968"}],"version-history":[{"count":0,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/posts\/968\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/media\/970"}],"wp:attachment":[{"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/media?parent=968"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/categories?post=968"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/tags?post=968"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}