{"id":10097,"date":"2023-03-22T16:13:11","date_gmt":"2023-03-22T08:13:11","guid":{"rendered":"http:\/\/123.57.164.21\/?p=10097"},"modified":"2023-03-22T16:13:11","modified_gmt":"2023-03-22T08:13:11","slug":"openshift-4-hands-on-lab-%e5%ba%94%e7%94%a8%e9%83%a8%e7%bd%b2%e5%92%8c%e5%88%87%e6%8d%a2%e7%ad%96%e7%95%a5%ef%bc%88%e8%93%9d%e7%bb%bf%e3%80%81%e9%87%91%e4%b8%9d%e9%9b%80%e5%92%8ca-b%e3%80%81%e5%9b%9e","status":"publish","type":"post","link":"https:\/\/92it.top\/?p=10097","title":{"rendered":"OpenShift 4 Hands-on Lab- \u5e94\u7528\u90e8\u7f72\u548c\u5207\u6362\u7b56\u7565\uff08\u84dd\u7eff\u3001\u91d1\u4e1d\u96c0\u548cA\/B\u3001\u56de\u6eda\uff09"},"content":{"rendered":"\n<p><strong>\u5e94\u7528\u4e0a\u7ebf\u90e8\u7f72\u7b56\u7565<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u672c\u8282\u4ecb\u7ecd\u5e94\u7528\u90e8\u7f72\u4e0a\u7ebf\u548c\u5207\u6362\u5e94\u7528\u8bbf\u95ee\u7684\u5e38\u7528\u7b56\u7565\u3002\u867d\u7136\u53ef\u4ee5\u6839\u636e\u9700\u8981\u7075\u6d3b\u4f7f\u7528\u4ee5\u4e0b\u7b56\u7565\uff0c\u4f46\u7531\u4e8e\u672c\u8282\u4f7f\u7528\u4e86\u540c\u4e00\u7ec4\u9a8c\u8bc1\u7684\u5e94\u7528\uff0c\u56e0\u6b64\u8bf7\u6309\u987a\u5e8f\u8fdb\u884c\u4e0b\u97623\u4e2aLab\u64cd\u4f5c\u3002<br>\u5728\u90e8\u7f72\u5e94\u7528\u524d\uff0c\u9700\u8981\u5c06https:\/\/github.com\/liuxiaoyu-git\/bluegreen.git\u7684\u4ee3\u7801fork\u5230\u81ea\u5df1\u7684GitHub\u8d26\u6237\u4e0b\uff0c\u4e0b\u6587\u5c06\u7528\u201cMY_GITHUB\u201d\u4ee3\u8868\u7528\u6237\u5404\u81ea\u7684GitHub\u8d26\u6237\u540d\u3002<\/p>\n\n\n\n<p><strong>\u84dd\u7eff\u90e8\u7f72<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p><br>\u84dd\u7eff\u90e8\u7f72\u662f\u6700\u5e38\u89c1\u7684\u4e00\u79cd\u4e0d\u95f4\u65ad\u7684\u5e94\u7528\u5347\u7ea7\u90e8\u7f72\u7684\u65b9\u5f0f\uff0c\u84dd\u7eff\u90e8\u7f72\u7684\u76ee\u7684\u662f\u5b89\u5168\u7a33\u5b9a\u5730\u53d1\u5e03\u65b0\u7248\u672c\u5e94\u7528\uff0c\u5e76\u5728\u5fc5\u8981\u65f6\u56de\u6eda\u3002\u84dd\u7eff\u90e8\u7f72\u7684\u7279\u70b9\u662f\u5728\u4e00\u4e2a\u65f6\u95f4\u70b9\u8bf7\u6c42\u4f1a100%\u5730\u53d1\u7ed9\u84dd\u7eff\u90e8\u7f72\u4e2d\u7684\u4e00\u4e2a\u76ee\u6807\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2023\/03\/image-219-1024x528.png\" alt=\"\" class=\"wp-image-10098\" width=\"478\" height=\"246\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-219-1024x528.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-219-300x155.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-219-768x396.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-219-830x428.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-219-230x119.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-219-350x181.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-219-480x248.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-219.png 1272w\" sizes=\"(max-width: 478px) 100vw, 478px\" \/><\/figure><\/div>\n\n\n\n<p>\u84dd\u7eff\u90e8\u7f72\u901a\u5e38\u751f\u4ea7\u73af\u5883\u9700\u8981\u4e24\u7ec4\u914d\u7f6e\uff0c\u4e00\u7ec4\u662factive\u7684\u751f\u4ea7\u73af\u5883\u7684\u914d\u7f6e\uff0c\u4e00\u7ec4\u662finactive\u7684\u914d\u7f6e\u3002\u7528\u6237\u8bbf\u95ee\u7684\u65f6\u5019\uff0c\u53ea\u8ba9\u7528\u6237\u8bbf\u95eeactive\u7684\u670d\u52a1\u5668\u96c6\u7fa4\u3002\u84dd\u8272\u73af\u5883\uff08active\uff09\u8fd0\u884c\u65e7\u7248\u672c\u5e94\u7528version1\u3002\u5f53\u8981\u5347\u7ea7\u5230version2\uff0c\u5148\u5728\u7eff\u8272\u73af\u5883\u4e2d\u90e8\u7f72\u65b0\u7248\u672c\u5e94\u7528\uff0c\u5e76\u8fdb\u884c\u6d4b\u8bd5\u3002\u5982\u679c\u6d4b\u8bd5\u6ca1\u95ee\u9898\uff0c\u5c31\u53ef\u4ee5\u628a\u8def\u7531\u6307\u5411\u7eff\u8272\u73af\u5883\u3002<\/p>\n\n\n\n<p>1.\u4f9d\u6b21\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u9996\u5148\u521b\u5efa\u9879\u76ee\uff0c\u7136\u540e\u90e8\u7f72blue\u7248\u7684\u5e94\u7528\uff0c\u5728\u6839\u636eService\u751f\u6210Route\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ oc new-project USER-ID-bluegreen\n$ oc new-app https:\/\/github.com\/MY_GITHUB\/bluegreen.git#master --name=blue -n USER-ID-bluegreen\n$ oc expose service blue --name=bluegreen -n USER-ID-bluegreen\n$ oc get route bluegreen -n USER-ID-bluegreen\nNAME        HOST\/PORT                                                                    PATH   SERVICES   PORT       TERMINATION   WILDCARD\nbluegreen   bluegreen-mywar.apps.cluster-beijing-c70a.beijing-c70a.example.opentlc.com          blue       8080-tcp                 <\/pre>\n\n\n\n<p>2.\u7528\u6d4f\u89c8\u5668\u8bbf\u95ee\u4ee5\u4e0aRoute\u5730\u5740\uff0c\u53ef\u4ee5\u770b\u5230\u4ee5\u4e0b\u663e\u793aBlue\u7684\u9875\u9762\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2023\/03\/image-220.png\" alt=\"\" class=\"wp-image-10099\" width=\"284\" height=\"213\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-220.png 572w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-220-300x226.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-220-230x173.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-220-350x263.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-220-480x361.png 480w\" sizes=\"(max-width: 284px) 100vw, 284px\" \/><\/figure><\/div>\n\n\n\n<p>3.\u90e8\u7f72Green\u7248\u7684\u5e94\u7528\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ oc new-app https:\/\/github.com\/MY_GITHUB\/bluegreen.git#green --name=green -n USER-ID-bluegreen<\/pre>\n\n\n\n<p>4.\u5c06Route\u8bbf\u95ee\u7684\u540e\u53f0\u670d\u52a1\u5207\u6362\u5230Green\u5e94\u7528\u4e0a\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ oc patch route\/bluegreen -p '{\"spec\":{\"to\":{\"name\":\"green\"}}}' -n USER-ID-bluegreen<\/pre>\n\n\n\n<p>5.\u518d\u6b21\u7528\u6d4f\u89c8\u5668\u8bbf\u95ee\u5e94\u7528\u7684Route\u5bf9\u5e94\u7684http:\/\/bluegreen-mywar.apps.cluster-beijing-c70a.beijing-c70a.example.opentlc.com\u5730\u5740\uff0c\u53ef\u4ee5\u770b\u5230\u6b64\u65f6\u663e\u793a\u7684\u5df2\u7ecf\u662fGreen\u7248\u7684\u5e94\u7528\u9875\u9762\u4e86\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2023\/03\/image-221.png\" alt=\"\" class=\"wp-image-10100\" width=\"370\" height=\"249\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-221.png 618w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-221-300x202.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-221-230x155.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-221-350x236.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-221-480x323.png 480w\" sizes=\"(max-width: 370px) 100vw, 370px\" \/><\/figure><\/div>\n\n\n\n<p><strong>\u91d1\u4e1d\u96c0\u53d1\u5e03\u548cA\/B\u6d4b\u8bd5<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u6211\u628a\u91d1\u4e1d\u96c0\u53d1\u5e03\u548cA\/B\u6d4b\u8bd5\u653e\u5728\u4e00\u8d77\uff0c\u56e0\u4e3a\u5b83\u4eec\u7684\u7279\u70b9\u90fd\u662f\u5728\u4e00\u4e2a\u65f6\u95f4\u70b9\u5141\u8bb8\u5c06\u8bf7\u6c42\u6839\u636e\u9700\u8981\u6d41\u5411\u4e0d\u540c\u7684\u76ee\u6807\uff0c\u4e0d\u8fc7\u91d1\u4e1d\u96c0\u53d1\u5e03\u548cA\/B\u6d4b\u8bd5\u6709\u4e0d\u540c\u7684\u76ee\u7684\u3002\u91d1\u4e1d\u96c0\u53d1\u5e03\u53c8\u540d\u7070\u5ea6\u53d1\u5e03\uff0c\u662f\u7528\u9010\u6b65\u8fc7\u6e21\u7684\u65b9\u6cd5\u5b9e\u73b0\u65b0\u7248\u672c\u5e94\u7528\u4e0a\u7ebf\u7684\u4e00\u79cd\u53d1\u5e03\u7b56\u7565\uff1b\u800cA\/B\u6d4b\u8bd5\u4e3b\u8981\u662f\u7528\u6765\u6d4b\u8bd5\u4e00\u4e2a\u5e94\u7528\u7684\u4e0d\u540c\u5b9e\u73b0\u7248\u672c\u7684\u5dee\u5f02\u5316\u8868\u73b0\u7684\u65b9\u6cd5\uff0c\u4f8b\u5982\u8bc4\u4f30\u4e24\u4e2a\u4e0d\u540c\u754c\u9762\u98ce\u683c\u7684\u5e94\u7528\u54ea\u4e2a\u66f4\u53d7\u7528\u6237\u7684\u6b22\u8fce\u3001\u5176\u6027\u80fd\u5dee\u5f02\u7b49\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2023\/03\/image-222-1024x226.png\" alt=\"\" class=\"wp-image-10101\" width=\"561\" height=\"124\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-222-1024x226.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-222-300x66.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-222-768x169.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-222-1536x339.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-222-830x183.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-222-230x51.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-222-350x77.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-222-480x106.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-222.png 1542w\" sizes=\"(max-width: 561px) 100vw, 561px\" \/><\/figure><\/div>\n\n\n\n<p><strong>\u901a\u8fc7\u8c03\u6574Route\u6743\u91cd\u5b9e\u73b0<\/strong><\/p>\n\n\n\n<p>1.\u6267\u884c\u547d\u4ee4\uff0c\u7f16\u8f91\u540d\u4e3abluegreen\u7684Route\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ oc edit route bluegreen -n USER-ID-bluegreen<\/pre>\n\n\n\n<p>2.\u5728\u201cspec\u201d\u533a\u57df\u7684\u201cto\u201d\u540e\u589e\u52a0\u201calternateBackends\u201d\u4e00\u6bb5\u5185\u5bb9\uff0c\u4fee\u6539\u5b8c\u201cspec\u201d\u533a\u57df\u7684\u5185\u5bb9\u5e94\u8be5\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\u3002\u3002\u3002\nspec:\n  host: YOUR-HOST\n  port:\n    targetPort: 8080-tcp\n  subdomain: \"\"\n  to:\n    kind: Service\n    name: green\n    weight: 50\n  alternateBackends:\n    - kind: Service\n      name: blue\n      weight: 50\n  wildcardPolicy: None\n  \u3002\u3002\u3002\n<\/pre>\n\n\n\n<p>3.\u4fdd\u5b58bluegreen\u7684Route\u914d\u7f6e\u540e\u6267\u884c\u547d\u4ee4\u67e5\u770bbluegreen\u7684Route\u7684blue\u548cgreen\u5404\u670950%\u7684\u673a\u4f1a\u63a5\u6536\u8bf7\u6c42\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ oc get route bluegreen -n USER-ID-bluegreen\nNAME        HOST\/PORT                                                                    PATH   SERVICES               PORT       TERMINATION   WILDCARD\nbluegreen   bluegreen-mywar.apps.cluster-beijing-c70a.beijing-c70a.example.opentlc.com          green(50%),blue(50%)   8080-tcp                 <\/pre>\n\n\n\n<p>4.\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u67e5\u770b\u7ea2\u8272\u52a0\u4eae\u7684\u5b57\u4f53\uff0c\u786e\u8ba4\u6570\u91cf\u57fa\u672c\u662f\u4e00\u6837\u7684\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ while true;do curl $(oc get route bluegreen -n USER-ID-bluegreen -o template --template '{{.spec.host}}') | grep -e green -e blue;done<\/pre>\n\n\n\n<p>5.\u5206\u522b\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u5206\u522b\u5c06blue\u548cgreen\u63a5\u6536\u8bf7\u6c42\u7684\u6bd4\u4f8b\u8bbe\u4e3a30%-70%\u4ee5\u53ca50%-50%\uff0c\u7136\u540e\u7528\uff084\uff09\u811a\u672c\u786e\u8ba4\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ oc set route-backends bluegreen --adjust blue=30% -n USER-ID-bluegreen\n$ oc set route-backends bluegreen --adjust blue=+10% -n USER-ID-bluegreen\n$ oc set route-backends bluegreen --equal -n USER-ID-bluegreen\n<\/pre>\n\n\n\n<p><strong>\u901a\u8fc7\u8c03\u6574Pod\u6570\u91cf\u5b9e\u73b0<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u8fd8\u53ef\u7528\u4e00\u4e2aService\u5bf9\u5e94\u591a\u4e2aDeployment\uff0c\u7136\u540e\u901a\u8fc7\u8c03\u6574Deployment\u4e2d\u8fd0\u884c\u7684Pod\u5b9e\u4f8b\u6570\u5b9e\u73b0\u5728\u4e0d\u540c\u7248\u672c\u7684\u5e94\u7528\u5206\u914d\u6d41\u91cf\u3002<\/p>\n\n\n\n<p>1.\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u5148\u6839\u636eApp Image\u521b\u5efaab-example\u5e94\u7528\u548c\u5bf9\u5e94\u7684Route\u8d44\u6e90\uff0c\u7136\u540e\u53ea\u4fdd\u7559\u5e94\u7528\u7684Service\u548cRoute\u914d\u7f6e\uff08\u5220\u9664Deployment\u914d\u7f6e\uff09\u3002\u518d\u6839\u636eApp Image\u521b\u5efaab-example-a\u548cab-example-b\u5e94\u7528\uff0c\u7136\u540e\u53ea\u4fdd\u7559\u5b83\u4eec\u7684Deployment\uff08\u5220\u9664Service\u914d\u7f6e\uff09\u3002\u8fd9\u6837\u5c31\u6709\u4e861\u4e2aService\u548c2\u4e2aDeployment\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ oc new-project USER-ID-ab\n$ oc new-app openshift\/deployment-example:v1 --name=ab-example --labels=ab-example=true -n USER-ID-ab\n$ oc expose svc\/ab-example --name=ab-example -n USER-ID-ab\n$ oc delete deployment\/ab-example -n USER-ID-ab\n$ oc new-app openshift\/deployment-example:v1 --name=ab-example-a --labels=ab-example=true -n USER-ID-ab\n$ oc new-app openshift\/deployment-example:v2 --name=ab-example-b --labels=ab-example=true SUBTITLE=Shard-B COLOR=red -n USER-ID-ab\n$ oc delete svc\/ab-example-a -n USER-ID-ab\n$ oc delete svc\/ab-example-b -n USER-ID-ab\n<\/pre>\n\n\n\n<p>2.\u5728OpenShift\u63a7\u5236\u53f0\u7684\u201c<strong>\u5f00\u53d1\u8005<\/strong>\u201d\u89c6\u56fe\u4e2d\u8fdb\u5165\u6b64\u9879\u76ee\u7684\u201c<strong>\u62d3\u6251<\/strong>\u201d\u83dc\u5355\uff0c\u786e\u8ba4\u6b64\u65f6\u663e\u793a\u7684\u201cab-example-a\u201d\u548c\u201cab-example-b\u201d\u4e24\u4e2aDeployment\u90fd\u6ca1\u6709\u5bf9\u5e94\u7684\u201c<strong>\u670d\u52a1<\/strong>\u201d\u548c\u201c<strong>\u8def\u7531<\/strong>\u201d\u3002\u8fd9\u662f\u7531\u4e8e\u4e0a\u4e00\u6b65\u6211\u4eec\u624b\u52a8\u5220\u9664\u4e86\u81ea\u52a8\u751f\u6210\u7684\u201c<strong>\u670d\u52a1<\/strong>\u201d\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2023\/03\/image-223-1024x463.png\" alt=\"\" class=\"wp-image-10102\" width=\"596\" height=\"269\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-223-1024x463.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-223-300x136.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-223-768x347.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-223-830x375.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-223-230x104.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-223-350x158.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-223-480x217.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-223.png 1492w\" sizes=\"(max-width: 596px) 100vw, 596px\" \/><\/figure><\/div>\n\n\n\n<p>3.\u6b64\u65f6\u540d\u4e3aab-example\u7684\u201c\u670d\u52a1\u201d\u662f\u901a\u8fc7\u201c<strong>Pod\u9009\u62e9\u5668<\/strong>\u201d\u9009\u62e9\u7528\u54ea\u4e9bPod\u5904\u7406\u8bf7\u6c42\u3002\u5728OpenShift\u63a7\u5236\u53f0\u7684\u201c<strong>\u7ba1\u7406\u5458<\/strong>\u201d\u89c6\u56fe\u4e2d\u8fdb\u5165\u201c<strong>\u7f51\u7edc<\/strong>\u201d\u7684\u2018<strong>\u670d\u52a1<\/strong>\u2019\u3002\u5728\u5217\u8868\u4e2d\u53ef\u4ee5\u770b\u5230\u201c<strong>Pod\u9009\u62e9\u5668<\/strong>\u201d\uff08\u89c1\u4e0b\u56fe\uff09\uff0c\u7136\u540e\u70b9\u51fb\u201c<strong>Pod\u9009\u62e9\u5668<\/strong>\u201d\u4e0b\u9762\u7684\u94fe\u63a5\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2023\/03\/image-224-1024x364.png\" alt=\"\" class=\"wp-image-10103\" width=\"601\" height=\"213\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-224-1024x364.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-224-300x107.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-224-768x273.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-224-830x295.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-224-230x82.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-224-350x124.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-224-480x171.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-224.png 1514w\" sizes=\"(max-width: 601px) 100vw, 601px\" \/><\/figure><\/div>\n\n\n\n<p>4.\u53ef\u4ee5\u770b\u5230\u6839\u636e\u5f53\u524d\u7684\u6761\u4ef6\uff08ab-example=true\u548cdeployment=ab-example\uff09\uff0c\u662f\u6ca1\u6709\u5bf9\u5e94\u7684Pod\u3002<\/p>\n\n\n\n<p>5.\u5982\u679c\u5220\u9664\u201cdeployment=ab-example\u201d\u6761\u4ef6\uff0c\u5c31\u53ef\u4ee5\u9009\u51fa2\u4e2aDeployment\u5b9a\u4e49\u7684Pod\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2023\/03\/image-225-1024x471.png\" alt=\"\" class=\"wp-image-10104\" width=\"625\" height=\"287\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-225-1024x471.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-225-300x138.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-225-768x353.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-225-830x382.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-225-230x106.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-225-350x161.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-225-480x221.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-225.png 1474w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><\/figure><\/div>\n\n\n\n<p>6.\u518d\u6b21\u901a\u8fc7\u201c<strong>\u7f51\u7edc<\/strong>\u201d\u7684\u201c<strong>\u670d\u52a1<\/strong>\u201d\u83dc\u5355\u8fdb\u5165ab-example\uff0c\u7136\u540e\u70b9\u51fb\u201c<strong>\u64cd\u4f5c<\/strong>\u201d\u7684\u201c<strong>\u7f16\u8f91Pod\u9009\u62e9\u5668<\/strong>\u201d\u9879\u76ee\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2023\/03\/image-226-1024x548.png\" alt=\"\" class=\"wp-image-10105\" width=\"588\" height=\"314\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-226-1024x548.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-226-300x160.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-226-768x411.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-226-830x444.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-226-230x123.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-226-350x187.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-226-480x257.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-226.png 1496w\" sizes=\"(max-width: 588px) 100vw, 588px\" \/><\/figure><\/div>\n\n\n\n<p>7.\u5728\u201c<strong>\u7f16\u8f91 Pod \u9009\u62e9\u5668<\/strong>\u201d\u5bf9\u8bdd\u6846\u4e2d\u70b9\u51fb\u201cdeployment=ab-example\u201d\u53f3\u4fa7\u5220\u6389\u56fe\u6807\uff0c\u7136\u540e\u70b9\u51fb\u201c<strong>\u4fdd\u5b58<\/strong>\u201d\u5173\u95ed\u7a97\u53e3\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2023\/03\/image-227-1024x686.png\" alt=\"\" class=\"wp-image-10106\" width=\"572\" height=\"382\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-227-1024x686.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-227-300x201.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-227-768x514.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-227-830x556.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-227-230x154.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-227-350x234.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-227-480x321.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-227.png 1422w\" sizes=\"(max-width: 572px) 100vw, 572px\" \/><\/figure><\/div>\n\n\n\n<p>8.\u6b64\u65f6\u5728ab-example\u7684\u201c<strong>\u670d\u52a1<\/strong>\u201d\u754c\u9762\u4e2d\u8fdb\u5165\u201c<strong>Pod<\/strong>\u201d\u6807\u7b7e\uff0c\u53ef\u4ee5\u770b\u5230\u8be5Service\u5df2\u7ecf\u5bf9\u5e94\u4e0a2\u4e2aPod\u4e86\uff0c\u5b83\u4eec\u5206\u522b\u7531ab-example-a\u548cab-example-b\u90e8\u7f72\u7684\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2023\/03\/image-228-1024x392.png\" alt=\"\" class=\"wp-image-10107\" width=\"624\" height=\"238\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-228-1024x392.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-228-300x115.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-228-768x294.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-228-830x317.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-228-230x88.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-228-350x134.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-228-480x184.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-228.png 1464w\" sizes=\"(max-width: 624px) 100vw, 624px\" \/><\/figure><\/div>\n\n\n\n<p>9.\u6b64\u65f6\u56de\u5230\u8fd9\u4e2a\u9879\u76ee\u7684\u201c<strong>\u5f00\u53d1\u8005<\/strong>\u201d\u89c6\u56fe\u7684\u201c<strong>\u62d3\u6251<\/strong>\u201d\u83dc\u5355\uff0c\u53ef\u4ee5\u770b\u5230\u4e0b\u56fe\uff0c\u5176\u4e2d2\u4e2aDeployment\u90fd\u5bf9\u5e94\u4e86\u76f8\u540c\u7684Service\u540d\u79f0\u548cRoute\u5730\u5740\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2023\/03\/image-229-1024x500.png\" alt=\"\" class=\"wp-image-10108\" width=\"612\" height=\"299\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-229-1024x500.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-229-300x146.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-229-768x375.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-229-830x405.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-229-230x112.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-229-350x171.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-229-480x234.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-229.png 1504w\" sizes=\"(max-width: 612px) 100vw, 612px\" \/><\/figure><\/div>\n\n\n\n<p>10.\u591a\u6b21\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u786e\u8ba4\u53ef\u4ee5\u8f6e\u6d41\u770b\u5230v1\u548cv2\u7248\u672c\u5e94\u7528\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ while true;do curl $(oc get route ab-example -n USER-ID-ab -o template --template '{{.spec.host}}') | grep -e v1 -e v2;done<\/pre>\n\n\n\n<p>11.\u5148\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u5c06\u540d\u4e3aab-example-a\u7684Deployment\u8fd0\u884c\u7684Pod\u6570\u8bbe\u4e3a0\u3002\u7136\u540e\u5728\u6267\u884c\uff089\uff09\u547d\u4ee4\uff0c\u786e\u8ba4\u53ea\u80fd\u770b\u5230v2\u7248\u672c\u5e94\u7528\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ oc scale deployment\/ab-example-a --replicas=0 -n USER-ID-ab<\/pre>\n\n\n\n<p>12.\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u5c06\u540d\u4e3aab-example-b\u7684Deployment\u8fd0\u884c\u7684Pod\u6570\u8bbe\u4e3a0\uff0c\u5c06\u540d\u4e3aab-example-a\u7684Deployment\u8fd0\u884c\u7684Pod\u6570\u8bbe\u4e3a1\u3002\u7136\u540e\u5728\u591a\u6b21\u6267\u884c\uff089\uff09\u547d\u4ee4\uff0c\u786e\u8ba4\u53ea\u80fd\u770b\u5230v1\u7248\u672c\u5e94\u7528\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ oc scale deployment\/ab-example-a --replicas=1 -n USER-ID-ab\n$ oc scale deployment\/ab-example-b --replicas=0 -n USER-ID-ab\n$ while true;do curl $(oc get route ab-example -n USER-ID-ab -o template --template '{{.spec.host}}') | grep -e v1 -e v2;done\n<\/pre>\n\n\n\n<p><strong>\u90e8\u7f72\u56de\u6eda<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u6ce8\u610f\uff1a\u56de\u6edaRollback\u53ea\u9002\u7528\u4e8e\u4f7f\u7528OpenShift\u63d0\u4f9b\u7684DeploymentConfig\u90e8\u7f72\u7684\u5e94\u7528\uff0c\u800c\u4e0d\u9002\u7528\u4e8e\u4f7f\u7528Kubernetes\u7684Deployment\u90e8\u7f72\u7684\u5e94\u7528\u3002<br>\u4e0b\u9762\u9996\u5148\u90e8\u7f72version 1\u7248\u7684blue\u5e94\u7528\uff0c\u518d\u66f4\u6539\u5e94\u7528\u5230\u65b0\u7248\u672cversion 2\u540e\u518d\u6b21\u90e8\u7f72blue\uff0c\u5f53\u53d1\u73b0\u90e8\u7f72\u540e\u7684\u65b0\u7248\u672c\u5e94\u7528\u51fa\u73b0\u95ee\u9898\uff0c\u53ef\u4ee5\u901a\u8fc7\u90e8\u7f72\u56de\u6eda\u5feb\u901f\u5207\u6362\u5230\u4ee5\u524d\u8fd0\u884c\u6b63\u5e38\u7684version 1\u7248\u672c\u5e94\u7528\u3002<\/p>\n\n\n\n<p>1.\u4f7f\u7528DeploymentConfig\u90e8\u7f72version 1\u7248\u7684blue\u5e94\u7528\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ oc new-project USER-ID-rollback\n$ oc new-app https:\/\/github.com\/MY_GITHUB\/bluegreen.git#master --name=blue --as-deployment-config -n USER-ID-rollback\n$ oc expose service blue --name=bluegreen -n USER-ID-rollback\n$ oc get route bluegreen -n USER-ID-rollback\n<\/pre>\n\n\n\n<p><br>2.\u8fdb\u5165https:\/\/github.com\/MY_GITHUB\/bluegreen.git\uff0c\u9009\u62e9requestHandlers.js\u6587\u4ef6\uff0c\u7136\u540e\u70b9\u51fbHistory\u53f3\u4fa7\u7684\u7f16\u8f91\u56fe\u6807\u3002<\/p>\n\n\n\n<p>3.\u627e\u5230\u201c\u201d\uff0c\u5728\u540e\u9762\u589e\u52a0\u201cversion 1\u201d\u7528\u6765\u505a\u7248\u672c\u8ddf\u8e2a\uff0c\u7136\u540e\u70b9\u51fb\u9875\u9762\u6700\u4e0b\u65b9\u7684Commit changes\u56fe\u6807<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">'&lt;body> version 1'+<\/pre>\n\n\n\n<p>4.\u5728OpenShift\u63a7\u5236\u53f0\u7684\u201c<strong>\u5f00\u53d1\u8005<\/strong>\u201d\u89c6\u56fe\u4e2d\u8fdb\u5165\u201c<strong>\u6784\u5efa<\/strong>\u201d\uff0c\u7136\u540e\u8fdb\u5165\u540d\u4e3a\u201c<strong>blue<\/strong>\u201d\u7684BuildConfig\uff0c\u5728\u5176\u4e2d\u67e5\u770b\u201c<strong>\u6784\u5efa<\/strong>\u201d\u680f\u76ee\u3002\u70b9\u51fb\u53f3\u4e0a\u65b9\u7684\u201c<strong>\u64cd\u4f5c<\/strong>\u201d\u4e0b\u62c9\u83dc\u5355\u4e2d\u7684\u201c<strong>\u5f00\u59cb\u6784\u5efa<\/strong>\u201d\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2023\/03\/image-230-1024x361.png\" alt=\"\" class=\"wp-image-10109\" width=\"617\" height=\"217\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-230-1024x361.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-230-300x106.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-230-768x271.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-230-830x293.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-230-230x81.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-230-350x123.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-230-480x169.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-230.png 1480w\" sizes=\"(max-width: 617px) 100vw, 617px\" \/><\/figure><\/div>\n\n\n\n<p>5.\u6b64\u65f6\u9875\u9762\u4f1a\u8f6c\u5230\u201c<strong>blue-2<\/strong>\u201d\u7684\u6784\u5efa\u754c\u9762\uff0c\u8fdb\u5165\u201c<strong>\u65e5\u5fd7<\/strong>\u201d\u680f\u76ee\u53ef\u4ee5\u770b\u5230\u6784\u5efa\u7684\u8fdb\u5ea6\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2023\/03\/image-231-1024x792.png\" alt=\"\" class=\"wp-image-10110\" width=\"637\" height=\"492\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-231-1024x792.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-231-300x232.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-231-768x594.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-231-830x642.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-231-230x178.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-231-350x271.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-231-480x371.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-231.png 1448w\" sizes=\"(max-width: 637px) 100vw, 637px\" \/><\/figure><\/div>\n\n\n\n<p>6.\u8fdb\u5165OpenShift\u63a7\u5236\u53f0\u201c<strong>\u5f00\u53d1\u8005<\/strong>\u201d\u89c6\u56fe\u7684\u201c<strong>\u62d3\u6251<\/strong>\u201d\u83dc\u5355\uff0c\u53ef\u4ee5\u770b\u5230blue\u56fe\u6807\u7684\u53d8\u5316\u8fc7\u7a0b\uff0c\u8fd9\u8bf4\u660e\u5f53\u6784\u5efa\u5b8c\u540eOpenShift\u4f1a\u81ea\u52a8\u89e6\u53d1\u90e8\u7f72\u65b0\u6784\u5efa\u7684App Image\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2023\/03\/image-232.png\" alt=\"\" class=\"wp-image-10111\" width=\"262\" height=\"337\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-232.png 446w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-232-233x300.png 233w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-232-230x296.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-232-350x450.png 350w\" sizes=\"(max-width: 262px) 100vw, 262px\" \/><\/figure><\/div>\n\n\n\n<p>7.\u9009\u4e2d\u4e0a\u56feblue\u7684\u56fe\u6807\uff0c\u7136\u540e\u5728\u53f3\u4fa7\u6ed1\u51fa\u90e8\u5206\u8fdb\u5165\u201c<strong>\u8be6\u7ec6<\/strong>\u201d\u3002\u5f53DeploymentConfig\u90e8\u7f72\u8fc7\u7a0b\u5b8c\u6210\u540e\uff0cblue\u7684\u201c<strong>\u6700\u65b0\u7248\u672c<\/strong>\u201d\u4f1a\u53d8\u4e3a2\uff08DeploymentConfig\u6bcf\u6210\u529f\u90e8\u7f72\u4e00\u6b21\uff0c\u201c<strong>\u6700\u65b0\u7248\u672c<\/strong>\u201d\u4f1a\u589e\u52a01\uff09\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2023\/03\/image-233-1024x705.png\" alt=\"\" class=\"wp-image-10112\" width=\"505\" height=\"347\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-233-1024x705.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-233-300x207.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-233-768x529.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-233-830x572.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-233-230x158.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-233-350x241.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-233-480x331.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-233.png 1498w\" sizes=\"(max-width: 505px) 100vw, 505px\" \/><\/figure><\/div>\n\n\n\n<p>8.\u7528\u547d\u4ee4\u67e5\u770bblue\u7684DeploymentConfig\u3002\u6ce8\u610f\uff0cDeploymentConfig\u6bcf\u53d8\u5316\u4e00\u6b21\uff0cREVISION\u5c31\u4f1a\u589e\u52a0\u201c1\u201d\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ oc get dc\/blue -n USER-ID-bluegreen\nNAME   REVISION   DESIRED   CURRENT   TRIGGERED BY\nblue   2          1         1         config,image(blue:latest)\n<\/pre>\n\n\n\n<p>9.\u8bbf\u95eebluegreen\u7684Route\uff0c\u4f1a\u53d1\u73b0\u9875\u9762\u4f1a\u663e\u793a\u201cversion 1\u201d<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ curl $(oc get route bluegreen -n USER-ID-rollback -o template --template '{{.spec.host}}') | grep version<\/pre>\n\n\n\n<p>10.\u91cd\u590d\u4ee5\u4e0a2-8\u64cd\u4f5c\uff0c\u5c06\u9875\u9762\u4ece\u201cversion 1\u201d\u6539\u4e3a\u201cversion 2\u201d\uff0c\u7136\u540e\u518d\u624b\u52a8\u89e6\u53d1\u4e00\u6b21\u6784\u5efa\u3002\u5728\u5b8c\u6210\u540eOpenShift\u4f1a\u81ea\u52a8\u5c06\u6784\u5efa\u7684\u6700\u65b0App Image\u90e8\u7f72\u8d77\u6765\uff0c\u6b64\u65f6\u518d\u6267\u884c\uff089\uff09\u9875\u9762\u5c31\u4f1a\u663e\u793a\u201cversion 2\u201d\u3002<\/p>\n\n\n\n<p>11.\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u5c06\u663e\u793aversion 2\u7684blue\u5e94\u7528\u9000\u56de\u5230\u4e0a\u4e00\u4e2a\u663e\u793aversion 1\u7684\u7248\u672c\u3002\u5728\u56de\u9000\u5b8c\u540e\uff0c\u7528\uff089\uff09\u6b65\u7684\u547d\u4ee4\u9a8c\u8bc1\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ oc rollout undo dc\/blue -n USER-ID-rollback \ndeployment.apps\/blue rolled back<\/pre>\n\n\n\n<p>12.\u6267\u884c\u547d\u4ee4\u67e5\u770b\u5f53\u524d\u6709\u591a\u5c11\u548cblue\u76f8\u5173\u7684Build\uff0c\u53ef\u4ee5\u770b\u6709\u4ee5\u4e0b3\u4e2a\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ oc get build -n USER-ID-rollback\nNAME     TYPE     FROM          STATUS     STARTED             DURATION\nblue-1   Source   Git@31c4e83   Complete   About an hour ago   1m14s\nblue-2   Source   Git@e7df24a   Complete   About an hour ago   1m29s\nblue-3   Source   Git@69b099b   Complete   About an hour ago   1m26s\n<\/pre>\n\n\n\n<p>13.\u67e5\u770b\u540d\u4e3a\u201cblue-2\u201d\u7684\u6784\u5efa\u751f\u6210\u7684App Image\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ oc describe build blue-2 -n USER-ID-rollback | grep 'Image Digest'\nImage Digest:   sha256:5fae117dd73f9dc28cb3228a8efc2a53cf15289bfd8224ef2163de59f4930c05<\/pre>\n\n\n\n<p>14.\u67e5\u770b\u540d\u4e3ablue\u7684ImageStream\u4fe1\u606f\uff0c\u5b83\u7528\u6765\u8ddf\u8e2ablue\u7684App Image\u3002\u901a\u8fc7\u955c\u50cf\u7b7e\u540d\u53ef\u786e\u8ba4\u6709\u5bf9\u5e94build-2\u751f\u6210\u7684App Image\uff08\u4ee5\u4e0b\u7ed3\u679c\u4ece\u4e0b\u5411\u4e0a\u7b2c2\u884c\uff09\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ oc describe is blue -n USER-ID-rollback | grep blue\nName:                   blue\nNamespace:              user1-rollback \nLabels:                 app=blue\n                        app.kubernetes.io\/component=blue\n                        app.kubernetes.io\/instance=blue\nImage Repository:       default-route-openshift-image-registry.apps.cluster-beijing-c70a.beijing-c70a.example.opentlc.com\/user1-bluegreen\/blue\n  * image-registry.openshift-image-registry.svc:5000\/user1-rollback \/blue@sha256:e7dac0f2191e385b25c39ec5bf2108c75a7d6770417551b03e5f79b1f8e989d7\n    image-registry.openshift-image-registry.svc:5000\/user1-rollback \/blue@sha256:5fae117dd73f9dc28cb3228a8efc2a53cf15289bfd8224ef2163de59f4930c05\n    image-registry.openshift-image-registry.svc:5000\/user1-rollback \/blue@sha256:085591991c22f4f76ab9ffa0f4247eb6047710b99547c7514f38168f6e25d5cd\n<\/pre>\n\n\n\n<p>15.\u6211\u4eec\u521a\u521a\u5df2\u7ecf\u5c06blue\u7684DeploymentConfig\u4f7f\u7528\u7684App Image\u7248\u672c\u56de\u9000\u5230\u4e86\u663e\u793aversion 1\u7684\u7248\u672c\u3002\u6267\u884c\u4e0b\u9762\u547d\u4ee4\u53ef\u518d\u6b21\u5c06DeploymentConfig\u56de\u9000\u5230\u6700\u540e\u4e00\u4e2a\u7248\u672c\uff08\u5373\u663e\u793aversion 2\uff09\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ oc rollback blue -n USER-ID-rollback\ndeployment.apps.openshift.io\/blue deployment #6 rolled back to blue-3\nWarning: the following images triggers were disabled: blue:latest\n  You can re-enable them with: oc set triggers dc\/blue --auto<\/pre>\n\n\n\n<p>16.\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u53ef\u5c06\u5e94\u7528\u56de\u9000\u5230\u521d\u59cb\u7248\u672c\uff08\u5373\u4e0d\u663e\u793aversion 1\u6216version 2\uff09<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ oc rollback blue --to-version=1 -n USER-ID-rollback<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5e94\u7528\u4e0a\u7ebf\u90e8\u7f72\u7b56\u7565 \u672c\u8282\u4ecb\u7ecd\u5e94\u7528\u90e8\u7f72\u4e0a\u7ebf\u548c\u5207\u6362\u5e94\u7528\u8bbf\u95ee\u7684\u5e38\u7528\u7b56\u7565\u3002\u867d\u7136\u53ef\u4ee5\u6839\u636e\u9700\u8981\u7075\u6d3b\u4f7f\u7528\u4ee5\u4e0b\u7b56\u7565\uff0c\u4f46\u7531\u4e8e\u672c\u8282\u4f7f [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22],"tags":[],"_links":{"self":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/10097"}],"collection":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10097"}],"version-history":[{"count":1,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/10097\/revisions"}],"predecessor-version":[{"id":10113,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/10097\/revisions\/10113"}],"wp:attachment":[{"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10097"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10097"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10097"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}