{"id":10035,"date":"2023-03-21T21:06:39","date_gmt":"2023-03-21T13:06:39","guid":{"rendered":"http:\/\/123.57.164.21\/?p=10035"},"modified":"2023-03-21T21:06:39","modified_gmt":"2023-03-21T13:06:39","slug":"openshift-4-hands-on-lab-%e4%bd%bf%e7%94%a8%e6%8c%81%e4%b9%85%e5%8c%96%e5%ad%98%e5%82%a8","status":"publish","type":"post","link":"https:\/\/92it.top\/?p=10035","title":{"rendered":"OpenShift 4 Hands-on Lab \u4f7f\u7528\u6301\u4e45\u5316\u5b58\u50a8"},"content":{"rendered":"\n<p><strong>OpenShift\u652f\u6301\u7684\u5b58\u50a8\u7684\u8bbf\u95ee\u80fd\u529b<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\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-178-1024x660.png\" alt=\"\" class=\"wp-image-10036\" width=\"547\" height=\"352\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-178-1024x660.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-178-300x193.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-178-768x495.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-178-1536x990.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-178-830x535.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-178-230x148.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-178-350x226.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-178-480x309.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-178.png 1548w\" sizes=\"(max-width: 547px) 100vw, 547px\" \/><\/figure><\/div>\n\n\n\n<p><strong>\u901a\u8fc7PVC\u4f7f\u7528\u5b58\u50a8<\/strong><\/p>\n\n\n\n<p>1.\u7528\u4e00\u822c\u7528\u6237\u65b0\u5efa\u4e00\u4e2a\u540d\u4e3aUSER-ID-pv\u7684\u9879\u76ee\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=\"\">$ export USER_ID=YOUR-USER-ID\n$ oc new-project ${USER_ID}-pv\n<\/pre>\n\n\n\n<p>2.\u6267\u884c\u4ee5\u4e0b\u4efb\u4e00\u4e2a\u547d\u4ee4\u521b\u5efa\u6d4b\u8bd5\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 -l app=image-uploader --image-stream=php --code=https:\/\/github.com\/liuxiaoyu-git\/image-uploader.git -n ${USER_ID}-pv\n$ oc new-app -l app=image-uploader php~https:\/\/github.com\/liuxiaoyu-git\/image-uploader.git -n ${USER_ID}-pv\n$ oc new-app -l app=image-uploader https:\/\/github.com\/liuxiaoyu-git\/image-uploader.git -n ${USER_ID}-pv\n<\/pre>\n\n\n\n<p>3.\u4e3a\u5e94\u7528\u751f\u6210route\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">oc expose svc image-uploader -n ${USER_ID}-pv<\/pre>\n\n\n\n<p>4.\u6253\u5f00image-uploader\u7684route\u5bf9\u5e94\u5730\u5740\uff0c\u7136\u540e\u4e0a\u4f20\u4e00\u4e2aJPG\/GIF\/PNG\u683c\u5f0f\u7684\u56fe\u7247\u6587\u4ef6\u3002\u786e\u8ba4\u53ef\u4ee5\u67e5\u770b\u5230\u4e0a\u4f20\u7684\u56fe\u7247\u7684\u7f29\u7565\u56fe\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-179-1024x756.png\" alt=\"\" class=\"wp-image-10037\" width=\"470\" height=\"347\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-179-1024x756.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-179-300x221.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-179-768x567.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-179-830x613.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-179-230x170.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-179-350x258.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-179-480x354.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-179.png 1436w\" sizes=\"(max-width: 470px) 100vw, 470px\" \/><\/figure><\/div>\n\n\n\n<p>5.\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u5c06\u90e8\u7f72\u7684Pod\u6269\u5c55\u4e3a2\u4e2a\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ oc scale dc image-uploader --replicas=2 -n ${USER_ID}-pv<\/pre>\n\n\n\n<p>6.\u7531\u4e8e\u76f8\u540c\u6d4f\u89c8\u5668\u901a\u5e38\u90fd\u662f\u5171\u4eabSession\u7684\uff0c\u56e0\u6b64\u9700\u8981\u7528\u53e6\u5916\u4e00\u6b3e\u6d4f\u89c8\u5668\u6253\u5f00image-uploader\u7684route\u5bf9\u5e94\u94fe\u63a5\u3002\u6b64\u65f6\u4f1a\u53d1\u73b0\u65b0\u7684\u6d4f\u89c8\u5668\u4e2d\u770b\u4e0d\u5230\u56fe\u7247\u7f29\u7565\u56fe\uff0c\u800c\u539f\u6709\u6d4f\u89c8\u5668\u53ef\u770b\u5230\u56fe\u7247\u7f29\u7565\u56fe\u3002\u5728\u65b0\u7684\u6d4f\u89c8\u5668\u4e2d\u4e0a\u4f20\u53e6\u4e00\u4e2a\u56fe\u7247\uff0c\u4f1a\u53d1\u73b0\u4e24\u5404\u6d4f\u89c8\u5668\u770b\u5230\u7684\u662f\u4e0d\u540c\u56fe\u7247\uff0c\u8fd9\u8bf4\u660e\u6b64\u65f6\u5e94\u7528\u4f7f\u7528\u7684\u662f\u6bcf\u4e2aPod\u7684\u672c\u5730\u5b58\u50a8\u4fdd\u5b58\u7684\u56fe\u7247\u3002<\/p>\n\n\n\n<p>7.\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u67e5\u770bPod\u7684\u540d\u79f0<\/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 pod -n ${USER_ID}-pv\nNAME                      READY   STATUS      RESTARTS   AGE\nimage-uploader-1-build    0\/1     Completed   0          23m\nimage-uploader-1-d8c5s    1\/1     Running     0          21m\nimage-uploader-1-deploy   0\/1     Completed   0          21m\nimage-uploader-1-zq65k    1\/1     Running     0          21m\n<\/pre>\n\n\n\n<p><br>8.\u7136\u540e\u5220\u9664image-uploader\u5e94\u7528\u7684\u8fd92\u4e2apod\u3002\u7a0d\u540e\u518d\u6b21\u67e5\u770bPod\uff0c\u6b64\u65f6\u53ef\u53d1\u73b0OpenShift\u53c8\u521b\u5efa\u4e862\u4e2a\u65b0\u7684Pod\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 delete pods -l app=image-uploader -n ${USER_ID}-pv\n$ oc get pod\nNAME                     READY   STATUS    RESTARTS   AGE\nimage-uploader-1-5s72r   1\/1     Running   0          91s\nimage-uploader-1-88trb   1\/1     Running   0          93s\n<\/pre>\n\n\n\n<p>9.\u7528\u4e24\u4e2a\u6d4f\u89c8\u5668\u5206\u522b\u6253\u5f00image-uploader\u5e94\u7528route\u94fe\u63a5\uff0c\u4f1a\u53d1\u73b0\u56fe\u7247\u5168\u6ca1\u6709\u4e86\u3002\u8fd9\u8bf4\u660ePod\u88ab\u5220\u9664\u540e\uff0c\u5176\u5185\u90e8\u7684\u56fe\u7247\u4f1a\u968f\u4e4b\u4e22\u5931\u3002<\/p>\n\n\n\n<p>10.\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u67e5\u770bOpenShift\u914d\u7f6e\u7684StorgaClass\uff08\u4e0b\u9762\u662f\u5728\u5df2\u7ecf\u914d\u7f6e\u597d\u7684AWS gp2\u5b58\u50a8\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 get storageclass -n ${USER_ID}-pv\nNAME            PROVISIONER             AGE\ngp2 (default)   kubernetes.io\/aws-ebs   42h<\/pre>\n\n\n\n<p>11.\u5207\u6362\u5230\u7ed9\u7528\u6237\u7684Administrator\u89c6\u56fe\uff0c\u7136\u540e\u901a\u8fc7Storage->Persistent Volume Claims\u4e2d\u8fdb\u5165Create Persistent Volume Claim\u9875\u9762\uff0c\u6309\u4e0b\u9762\u914d\u7f6e\u521b\u5efa\u4e00\u4e2aPersistent Volume Claim\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=\"\">Name: USER-ID-pvc\nAccess Mode: Single User(RWO)\nSize: 1GiB<\/pre>\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-180-1024x615.png\" alt=\"\" class=\"wp-image-10038\" width=\"545\" height=\"327\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-180-1024x615.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-180-300x180.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-180-768x461.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-180-830x498.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-180-230x138.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-180-350x210.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-180-480x288.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-180.png 1506w\" sizes=\"(max-width: 545px) 100vw, 545px\" \/><\/figure><\/div>\n\n\n\n<p>12.\u4ece\u83dc\u5355\u8fdb\u5165Workloads->Deployment Configs\u4e2dimage-uploader\u7684\u914d\u7f6e\u9875\u9762\uff0c\u7136\u540e\u8fdb\u5165\u53f3\u4e0a\u65b9\u7684Action->Add Storage\u3002<\/p>\n\n\n\n<p>13.\u5728Add Storage\u9875\u9762\u4e2d\u4e3aUse existing claim\u9009\u62e9\u524d\u9762\u521b\u5efa\u7684USER-ID-pv\uff0c\u7136\u540e\u5c06Mount Path\u8bbe\u4e3a\u2018\/opt\/app-root\/src\/uploads\u2019\uff0c\u7136\u540e\u70b9\u51fbSave\u6309\u94ae\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-181-1024x618.png\" alt=\"\" class=\"wp-image-10039\" width=\"457\" height=\"275\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-181-1024x618.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-181-300x181.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-181-768x463.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-181-830x501.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-181-230x139.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-181-350x211.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-181-480x290.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-181.png 1502w\" sizes=\"(max-width: 457px) 100vw, 457px\" \/><\/figure><\/div>\n\n\n\n<p>14.\u6b64\u65f6\u9875\u9762\u8df3\u8f6c\u5230image-uploader\u7684Delployment Config\uff0c\u53ef\u4ee5\u770b\u5230OpenShift\u4f1a\u81ea\u52a8\u91cd\u65b0\u90e8\u7f72\u8be5\u5e94\u7528\uff0c\u901a\u8fc7\u6eda\u52a8\u5347\u7ea7\u7684\u65b9\u5f0f\u75282\u4e2a\u65b0Pod\u8fd0\u884cimage-uploader\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-182-1024x634.png\" alt=\"\" class=\"wp-image-10041\" width=\"459\" height=\"284\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-182-1024x634.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-182-300x186.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-182-768x475.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-182-830x514.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-182-230x142.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-182-350x217.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-182-480x297.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-182.png 1474w\" sizes=\"(max-width: 459px) 100vw, 459px\" \/><\/figure><\/div>\n\n\n\n<p>15.\u5728\u5b8c\u6210\u540e\u65b0\u7684\u90e8\u7f72\u540e\u518d\u6b21\u7528\u4e00\u4e2a\u6d4f\u89c8\u5668\u8bbf\u95ee\u8be5\u5e94\u7528\u5bf9\u5e94\u7684route\u94fe\u63a5\uff0c\u4e0a\u4f20\u6587\u4ef6\u540e\uff0c\u7136\u540e\u4f7f\u7528\u53e6\u4e00\u6b3e\u6d4f\u89c8\u5668\u5e94\u8be5\u53ef\u4e5f\u80fd\u770b\u5230\u4e0a\u4f20\u7684\u56fe\u7247\u3002<\/p>\n\n\n\n<p>16.\u518d\u901a\u8fc7\uff088\uff09\u5220\u96642\u4e2aPod\uff0cOpenShift\u4f1a\u81ea\u52a8\u65b0\u5efa2\u4e2apod\u3002\u901a\u8fc7\u6d4f\u89c8\u5668\u8bbf\u95ee\u5e94\u7528\uff0c\u53d1\u73b0\u8fd8\u53ef\u770b\u5230\u4ee5\u524d\u4e0a\u4f20\u7684\u56fe\u7247\u3002<\/p>\n\n\n\n<p>17.\u5728OpenShift\u63a7\u5236\u53f0\u5206\u522b\u8fdb\u51652\u4e2aPod\u7684Terminal\u67e5\u770b\/opt\/app-root\/src\/uploads\u76ee\u5f55\uff0c\u53ef\u770b\u5230\u521a\u521a\u4e0a\u4f20\u7684\u56fe\u7247\u3002\u8fd9\u8bf4\u660e2\u4e2apod\u90fd\u4f7f\u7528\u4e86\u76f8\u540c\u7684storage\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>OpenShift\u652f\u6301\u7684\u5b58\u50a8\u7684\u8bbf\u95ee\u80fd\u529b \u901a\u8fc7PVC\u4f7f\u7528\u5b58\u50a8 1.\u7528\u4e00\u822c\u7528\u6237\u65b0\u5efa\u4e00\u4e2a\u540d\u4e3aUSER-ID-pv\u7684\u9879 [&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\/10035"}],"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=10035"}],"version-history":[{"count":2,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/10035\/revisions"}],"predecessor-version":[{"id":10042,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/10035\/revisions\/10042"}],"wp:attachment":[{"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10035"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10035"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10035"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}