{"id":397275,"date":"2024-06-29T13:21:14","date_gmt":"2024-06-29T13:21:14","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=397275"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=397275","title":{"rendered":"<span>\u041a\u0430\u043a \u0431\u044b\u0441\u0442\u0440\u043e \u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c YAML-\u0444\u0430\u0439\u043b\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e kubectl<\/span>"},"content":{"rendered":"<div><!--[--><img loading=\"lazy\" decoding=\"async\" height=\"1\" src=\"https:\/\/vk.com\/rtrg?p=VK-RTRG-541074-aOhpd&amp;event=habr_k8s\" style=\"display:none;\" width=\"1\"><img loading=\"lazy\" decoding=\"async\" height=\"1\" src=\"https:\/\/vk.com\/rtrg?p=VK-RTRG-541074-aOhpd&amp;event=habr_devops\" style=\"display:none;\" width=\"1\"><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/za\/cv\/au\/zacvaujcxhxytxjpa58z43ukf-e.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/za\/cv\/au\/zacvaujcxhxytxjpa58z43ukf-e.jpeg\" data-blurred=\"true\"\/><\/p>\n<p>  \u041f\u0435\u0440\u0432\u043e\u0435, \u0447\u0442\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0432 \u0433\u043e\u043b\u043e\u0432\u0443, \u043a\u043e\u0433\u0434\u0430 \u0440\u0435\u0447\u044c \u0438\u0434\u0451\u0442 \u043f\u0440\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 YAML-\u0444\u0430\u0439\u043b\u043e\u0432 \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u00a0<code>sed<\/code>,\u00a0<code>awk<\/code>\u00a0\u0438\u043b\u0438\u00a0<code>perl<\/code>\u00a0\u0438 \u0442.\u043f. \u041d\u043e \u0435\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e Kubectl\u00a0<code>patch<\/code>, \u0434\u0435\u043b\u043e \u043f\u043e\u0439\u0434\u0451\u0442 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0449\u0435. \u041a\u043e\u043c\u0430\u043d\u0434\u0430 <a href=\"https:\/\/mcs.mail.ru\/?utm_source=habr&amp;utm_medium=media&amp;utm_campaign=yaml-update\">VK Cloud<\/a> \u043f\u0435\u0440\u0435\u0432\u0435\u043b\u0430 \u0441\u0442\u0430\u0442\u044c\u044e \u043e \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f YAML-\u0444\u0430\u0439\u043b\u043e\u0432.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0435\u043f\u043b\u0438\u043a \u0432\u00a0\u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0439 \u043d\u0438\u0436\u0435 <code>spec<\/code>, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0432\u0435\u0440\u0441\u0438\u044e \u043e\u0431\u0440\u0430\u0437\u0430 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 Nginx. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u043e\u043a, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0440\u0443\u0433\u0438\u0435 \u043e\u043f\u0446\u0438\u0438 \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u0440\u0435\u043b\u0435\u0432\u0430\u043d\u0442\u043d\u044b.<\/p>\n<pre><code class=\"nginx\">apiVersion: apps\/v1 kind: Deployment metadata: \u00a0 name: nginx-deployment spec: \u00a0 selector: \u00a0 \u00a0 matchLabels: \u00a0 \u00a0 \u00a0 app: nginx \u00a0 replicas: 2 # tells deployment to run 2 pods matching the template \u00a0 template: \u00a0 \u00a0 metadata: \u00a0 \u00a0 \u00a0 labels: \u00a0 \u00a0 \u00a0 \u00a0 app: nginx \u00a0 \u00a0 spec: \u00a0 \u00a0 \u00a0 containers: \u00a0 \u00a0 \u00a0 - name: nginx \u00a0 \u00a0 \u00a0 \u00a0 image: nginx:1.14.2 \u00a0 \u00a0 \u00a0 \u00a0 ports: \u00a0 \u00a0 \u00a0 \u00a0 - containerPort: 80<\/code><\/pre>\n<p>  \u041f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u0444\u0430\u0439\u043b<br \/>  <code><a href=\"https:\/\/k8s.io\/examples\/application\/deployment.yaml\">kubectl apply -f https:\/\/k8s.io\/examples\/application\/deployment.yaml<\/a>.<\/code><\/p>\n<p>  \u041b\u043e\u043a\u0430\u043b\u044c\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0430\u0439\u043b \u0441 \u0438\u043c\u0435\u043d\u0435\u043c\u00a0patch.yaml\u00a0\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u044b\u043c:<\/p>\n<pre><code class=\"nginx\">spec: \u00a0 selector: \u00a0 \u00a0 matchLabels: \u00a0 \u00a0 \u00a0 app: nginx \u00a0 replicas: 3 # Update the number replicas from 2 to 3 \u00a0 template: \u00a0 \u00a0 metadata: \u00a0 \u00a0 \u00a0 labels: \u00a0 \u00a0 \u00a0 \u00a0 app: nginx \u00a0 \u00a0 spec: \u00a0 \u00a0 \u00a0 containers: \u00a0 \u00a0 \u00a0 - name: nginx \u00a0 \u00a0 \u00a0 \u00a0 image: nginx:1.16.1 # Update the version of nginx from 1.14.2 to 1.16.1 \u00a0 \u00a0 \u00a0 \u00a0 ports: \u00a0 \u00a0 \u00a0 \u00a0 - containerPort: 80<\/code><\/pre>\n<p>  \u0418\u0441\u043f\u0440\u0430\u0432\u0438\u043c <code>deployment<\/code>\u00a0\u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u044b:<\/p>\n<pre><code class=\"plaintext\">kubectl patch deployment\/nginx-deployment --patch \"$(cat patch.yaml)\"<\/code><\/pre>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435\u00a0<code>deployment.apps\/nginx-deployment patched.<\/code>, \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b:<\/p>\n<pre><code class=\"nginx\">Kubectl get deployments  # NAME\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 READY \u00a0 UP-TO-DATE \u00a0 AVAILABLE \u00a0 AGE #nginx-deployment\u00a0 \u00a0 \u00a0 3\/3 \u00a0 \u00a0 3\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 3 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 3hkubectl get deployment nginx-deployment -o yaml<\/code><\/pre>\n<p>  \u041d\u0430\u0447\u0438\u043d\u0430\u0439\u0442\u0435 \u0438\u0441\u043a\u0430\u0442\u044c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0443\u044e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0432\u044b \u0437\u0430\u043c\u0435\u043d\u0438\u043b\u0438:  <\/p>\n<pre><code class=\"nginx\">kubectl.kubernetes.io\/last-applied-configuration: | \u00a0 \u00a0 \u00a0 {\"apiVersion\":\"apps\/v1\",\"kind\":\"Deployment\",\"metadata\":{\"annotations\":{},\"name\":\"nginx-deployment\",\"namespace\":\"default\"},\"spec\":{\"replicas\":2,\"selector\":{\"matchLabels\":{\"app\":\"nginx\"}},\"template\":{\"metadata\":{\"labels\":{\"app\":\"nginx\"}},\"spec\":{\"containers\":[{\"image\":\"nginx:1.14.2\",\"name\":\"nginx\",\"ports\":[{\"containerPort\":80}]}]}}}}<\/code><\/pre>\n<p>  <\/p>\n<blockquote><p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 <a href=\"https:\/\/mcs.mail.ru\/containers\/?utm_source=habr&amp;utm_medium=media&amp;utm_campaign=yaml-update\">Kubernetes as a Service \u043d\u0430 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435 VK Cloud<\/a>. \u041c\u044b \u0434\u0430\u0435\u043c \u043d\u043e\u0432\u044b\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c 3000 \u0431\u043e\u043d\u0443\u0441\u043d\u044b\u0445 \u0440\u0443\u0431\u043b\u0435\u0439 \u043d\u0430 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u0438\u043b\u0438 \u043b\u044e\u0431\u044b\u0445 \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432.<\/p><\/blockquote>\n<h2>Stay tuned<\/h2>\n<p>  \u041f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0439\u0442\u0435\u0441\u044c \u043a \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c-\u043a\u0430\u043d\u0430\u043b\u0443 <a href=\"https:\/\/t.me\/+cWY7eMrhzNVmMmQy\">\u00ab\u0412\u043e\u043a\u0440\u0443\u0433 Kubernetes\u00bb<\/a>, \u0447\u0442\u043e\u0431\u044b \u0431\u044b\u0442\u044c \u0432 \u043a\u0443\u0440\u0441\u0435 \u043d\u043e\u0432\u043e\u0441\u0442\u0435\u0439 \u0438\u0437 \u043c\u0438\u0440\u0430 K8s! <\/p>\n<p>  \u0420\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0435 \u0434\u0430\u0439\u0434\u0436\u0435\u0441\u0442\u044b, \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0441\u0442\u0430\u0442\u044c\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0430\u043d\u043e\u043d\u0441\u044b \u043a\u043e\u043d\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u0439 \u0438 \u0432\u0435\u0431\u0438\u043d\u0430\u0440\u043e\u0432.<br \/>  <a href=\"https:\/\/t.me\/+cWY7eMrhzNVmMmQy\">t.me\/+cWY7eMrhzNVmMmQy<\/a><\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/722488\/\"> https:\/\/habr.com\/ru\/articles\/722488\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><img loading=\"lazy\" decoding=\"async\" height=\"1\" src=\"https:\/\/vk.com\/rtrg?p=VK-RTRG-541074-aOhpd&amp;event=habr_k8s\" style=\"display:none;\" width=\"1\"><img loading=\"lazy\" decoding=\"async\" height=\"1\" src=\"https:\/\/vk.com\/rtrg?p=VK-RTRG-541074-aOhpd&amp;event=habr_devops\" style=\"display:none;\" width=\"1\"><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/za\/cv\/au\/zacvaujcxhxytxjpa58z43ukf-e.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/za\/cv\/au\/zacvaujcxhxytxjpa58z43ukf-e.jpeg\" data-blurred=\"true\"\/><\/p>\n<p>  \u041f\u0435\u0440\u0432\u043e\u0435, \u0447\u0442\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0432 \u0433\u043e\u043b\u043e\u0432\u0443, \u043a\u043e\u0433\u0434\u0430 \u0440\u0435\u0447\u044c \u0438\u0434\u0451\u0442 \u043f\u0440\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 YAML-\u0444\u0430\u0439\u043b\u043e\u0432 \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u00a0<code>sed<\/code>,\u00a0<code>awk<\/code>\u00a0\u0438\u043b\u0438\u00a0<code>perl<\/code>\u00a0\u0438 \u0442.\u043f. \u041d\u043e \u0435\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e Kubectl\u00a0<code>patch<\/code>, \u0434\u0435\u043b\u043e \u043f\u043e\u0439\u0434\u0451\u0442 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0449\u0435. \u041a\u043e\u043c\u0430\u043d\u0434\u0430 <a href=\"https:\/\/mcs.mail.ru\/?utm_source=habr&amp;utm_medium=media&amp;utm_campaign=yaml-update\">VK Cloud<\/a> \u043f\u0435\u0440\u0435\u0432\u0435\u043b\u0430 \u0441\u0442\u0430\u0442\u044c\u044e \u043e \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f YAML-\u0444\u0430\u0439\u043b\u043e\u0432.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-397275","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/397275","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=397275"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/397275\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=397275"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=397275"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=397275"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}