{"id":10021,"date":"2023-03-21T20:32:16","date_gmt":"2023-03-21T12:32:16","guid":{"rendered":"http:\/\/123.57.164.21\/?p=10021"},"modified":"2023-03-21T20:34:08","modified_gmt":"2023-03-21T12:34:08","slug":"openshift-hands-on-lab1-%e5%a4%9a%e7%a7%8d%e6%96%b9%e6%b3%95%e9%83%a8%e7%bd%b2%e8%bf%90%e8%a1%8c%e5%ba%94%e7%94%a8","status":"publish","type":"post","link":"https:\/\/92it.top\/?p=10021","title":{"rendered":"OpenShift Hands-on Lab &#8211; \u591a\u79cd\u65b9\u6cd5\u90e8\u7f72\u8fd0\u884c\u5e94\u7528"},"content":{"rendered":"\n<p><strong>\u5e94\u7528\u662f\u5982\u4f55\u90e8\u7f72\u5230OpenShift\u4e0a\u7684<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>OpenShift\u662f\u4f01\u4e1a\u7ea7\u5bb9\u5668\u5e73\u53f0\uff0c\u5728OpenShift\u7684\u5e94\u7528\u5fc5\u987b\u662f\u5bb9\u5668\uff08Container\uff09\u5f62\u6001\u8fd0\u884c\u7684\uff0c\u56e0\u6b64\u53ef\u4ee5\u8bf4\u90e8\u7f72\u5e94\u7528\u5c31\u662f\u90e8\u7f72\u5e94\u7528\u5bb9\u5668\u3002\u6211\u4eec\u77e5\u9053\u6240\u6709\u8fd0\u884c\u7684\u5bb9\u5668\u90fd\u662f\u6765\u81ea\u955c\u50cf\uff08Image\uff09\uff0c\u4eceOpenShift\u7684\u89d2\u5ea6\u770b\u955c\u50cf\u5206\u4e3a\u4e24\u7c7b\uff1a\u5373\u57fa\u7840\u955c\u50cf\uff08Base Image\uff0c\u4e5f\u53ebBuilder Image\u3002\u5b83\u53ea\u5305\u62ec\u8fd0\u884c\u5e94\u7528\u6240\u9700\u7684\u57fa\u7840\u73af\u5883\uff0c\u4f8b\u5982Tomcat\u955c\u50cf\u4e2d\u53ea\u5305\u62ec\u4e00\u4e2a\u6807\u51c6\u7684Tomcat\u73af\u5883\uff09\u548c\u5e94\u7528\u955c\u50cf\uff08App Image &#8211; \u5305\u62ec\u4e86\u5e94\u7528\u5305\u548c\u6240\u6709\u4f9d\u8d56\u7684\u8fd0\u884c\u73af\u5883\uff09\u3002\u4e24\u8005\u7684\u5173\u7cfb\u5927\u81f4\u662f\u201c\u57fa\u7840\u955c\u50cf + \u5e94\u7528\u5305 + \u5e94\u7528\u4f9d\u8d56\u5305 = \u5e94\u7528\u955c\u50cf\u201d\uff0c\u5176\u4e2d\u201c\u5e94\u7528\u5305\u201d\u53c8\u8fdb\u4e00\u6b65\u662f\u7531\u201c\u5e94\u7528\u4ee3\u7801\u201d\u901a\u8fc7\u7f16\u8bd1\u3001\u6253\u5305\u800c\u751f\u6210\u7684\u7ed3\u679c\uff0c\u800c\u201c\u5e94\u7528\u4f9d\u8d56\u5305\u201d\u6307\u7684\u662f\u5e94\u7528\u8fd0\u884c\u6240\u4f9d\u8d56\u7684\u6587\u4ef6\uff0c\u4f8b\u5982\u4e00\u4e2aSpring Boot\u5e94\u7528\u8fd0\u884c\u6240\u4f9d\u8d56\u5404\u79cdJAR\u5305\u3002<\/p>\n\n\n\n<p>\u6839\u636e\u5e94\u7528\u8d44\u6e90\u5f53\u524d\u7684\u5f62\u6001\uff0c\u5728OpenShift\u4e0a\u4e3b\u8981\u6709\u51e0\u79cd\u90e8\u7f72\u5e94\u7528\u7684\u65b9\u5f0f\uff1a<\/p>\n\n\n\n<ul><li>\u90e8\u7f72\u5e94\u7528\u955c\u50cf\uff1a\u76f4\u63a5\u90e8\u7f72\u6700\u7ec8\u7684\u5e94\u7528\u955c\u50cf\u3002\u6b64\u8fc7\u7a0b\u9002\u5408\u7528\u5728\u751f\u4ea7\u73af\u5883\uff0c\u56e0\u4e3a\u6b64\u65f6\u7684\u5e94\u7528\u955c\u50cf\u5df2\u662f\u7ecf\u8fc7\u5168\u9762\u6d4b\u8bd5\u9a8c\u8bc1\u7684\uff0c\u8be5\u955c\u50cf\u4e2d\u5305\u62ec\u53ef\u5e94\u7528\u6240\u9700\u8981\u7684\u6240\u6709\u8d44\u6e90\u3002\u7531\u4e8e\u90e8\u7f72\u8fc7\u7a0b\u4e2d\u4e0d\u4f1a\u518d\u52a8\u6001\u4e0b\u8f7d\u4efb\u4f55\u5e94\u7528\u4f9d\u8d56\u5305\uff0c\u56e0\u6b64\u53ef\u76f4\u63a5\u5728\u79bb\u7ebf\u73af\u5883\u4e2d\u90e8\u7f72\uff0c\u90e8\u7f72\u540e\u53ef\u76f4\u63a5\u8fd0\u884c\u3002<\/li><\/ul>\n\n\n\n<ul><li>\u90e8\u7f72\u5e94\u7528\u4ee3\u7801\uff1aOpenShift\u63d0\u4f9b\u4e86\u4e00\u79cd\u79f0\u4e3aSource 2 Image\uff08S2I\uff09\u5de5\u5177\uff0c\u5229\u7528\u5b83\u53ef\u4ee5\u76f4\u63a5\u4ee5\u5e94\u7528\u4ee3\u7801\u4e3a\u6e90\u90e8\u7f72\u5e94\u7528\u3002\u5728\u6b64\u8fc7\u7a0b\u4e2dS2I\u4f1a\u81ea\u52a8\u4e0b\u8f7d\u5e94\u7528\u6240\u9700\u4f9d\u8d56\u5305\uff0c\u7136\u540e\u7f16\u8bd1\u5e76\u6253\u5305\u5e94\u7528\uff0c\u6700\u540e\u5c06\u5e94\u7528\u5305\u3001\u5e94\u7528\u4f9d\u8d56\u5305\u548c\u57fa\u7840\u955c\u50cf\u6253\u5305\u6210\u5e94\u7528\u955c\u50cf\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u5728OpenShift\u8fd0\u884c\u8be5\u5e94\u7528\u955c\u50cf\u4e86\u3002\u7531\u4e8e\u53ef\u4ee5\u5c06\u5e94\u7528\u4ee3\u7801\u81ea\u52a8\u7ecf\u8fc7\u4e00\u7cfb\u5217\u8fc7\u7a0b\u53d8\u4e3a\u53ef\u8fd0\u884c\u7684\u5e94\u7528\u955c\u50cf\uff0c\u56e0\u6b64\u6b64\u8fc7\u7a0b\u975e\u5e38\u9002\u5408\u7528\u5728\u5e94\u7528\u5f00\u53d1\u6d4b\u8bd5\u9636\u6bb5\u3002\u5c24\u5176\u662f\u914d\u5408\u5f00\u53d1\u5de5\u5177\uff0c\u53ef\u4ee5\u5c06\u5e94\u7528\u4ee3\u7801\u90e8\u7f72\u5230OpenShift\u4e0a\u8fdb\u884c\u6d4b\u8bd5\u3002<\/li><li>\u90e8\u7f72\u5e94\u7528\u5305\uff1a\u7c7b\u4f3c\u90e8\u7f72\u65b9\u5f0f2\uff0c\u53ea\u4e0d\u8fc7S2I\u5de5\u5177\u662f\u4ece\u5e94\u7528\u5305\u5f00\u59cb\u90e8\u7f72\u8fc7\u7a0b\u7684\u3002<\/li><li>\u90e8\u7f72Dockerfile\u8d44\u6e90\uff1aOpenShift\u4f1a\u5148\u6839\u636eDockerfile\u5b9a\u4e49\u6784\u5efa\u5e94\u7528\u5bb9\u5668\u955c\u50cf\uff0c\u7136\u540e\u518d\u5c06\u751f\u6210\u7684\u5bb9\u5668\u955c\u50cf\u63a8\u9001\u5230\u5185\u90e8\u7684Image Registry\uff0cOpenShift\u7136\u540e\u518d\u90e8\u7f72\u8be5\u955c\u50cf\u3002<\/li><\/ul>\n\n\n\n<p>\u4e0b\u9762\u6211\u4eec\u5206\u522b\u4ecb\u7ecd\u4e0a\u8ff0\u90e8\u7f72\u5e94\u7528\u7684\u64cd\u4f5c\u8fc7\u7a0b\u3002<\/p>\n\n\n\n<p><strong>\u90e8\u7f72\u5e94\u7528\u955c\u50cf<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>1.\u6253\u5f00\u6d4f\u89c8\u5668\u6253\u5f00<strong>OCP_MASTER_URL<\/strong>\u9875\u9762\uff0c\u7136\u540e\u7528<strong>USER_ID<\/strong>\u7528\u6237\u767b\u5f55\u8fdb\u5165OpenShift\u63a7\u5236\u53f0\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-170-1024x495.png\" alt=\"\" class=\"wp-image-10023\" width=\"555\" height=\"268\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-170-1024x495.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-170-300x145.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-170-768x371.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-170-830x401.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-170-230x111.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-170-350x169.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-170-480x232.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-170.png 1498w\" sizes=\"(max-width: 555px) 100vw, 555px\" \/><\/figure><\/div>\n\n\n\n<p>2.\u5728\u767b\u5f55\u540e\u7684\u5207\u6362\u5230&#8221;<strong>\u5f00\u53d1\u8005<\/strong>&#8220;\u89c6\u56fe\uff0c\u7136\u540e\u8fdb\u5165\u201c<strong>\u62d3\u6251<\/strong>\u201d\u9875\u9762\u3002\u5148\u70b9\u51fb\u201c<strong>\u9879\u76ee\uff1a\u6240\u6709\u9879\u76ee<\/strong>\u201c\u53f3\u4fa7\u4e0b\u62c9\uff0c\u7136\u540e\u9009\u4e2d\u201d<strong>\u521b\u5efa\u9879\u76ee<\/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-171-1024x504.png\" alt=\"\" class=\"wp-image-10024\" width=\"574\" height=\"282\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-171-1024x504.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-171-300x148.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-171-768x378.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-171-830x408.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-171-230x113.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-171-350x172.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-171-480x236.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-171.png 1488w\" sizes=\"(max-width: 574px) 100vw, 574px\" \/><\/figure><\/div>\n\n\n\n<p>3.\u5728Create Project\u7a97\u53e3\u4e2d\u586b\u5199\u201c<strong>USER-ID-parksmap<\/strong>\u201d\u4f5c\u4e3a\u540d\u79f0\uff0c\u7136\u540e\u70b9\u51fb\u201c<strong>\u521b\u5efa<\/strong>\u201d\u6309\u94ae\uff0c\u9879\u76ee\u5373\u521b\u5efa\u6210\u529f\u3002<\/p>\n\n\n\n<p>4.\u70b9\u51fb\u9875\u9762\u5de6\u4fa7\u201c<strong>+\u6dfb\u52a0<\/strong>\u201d\u83dc\u5355\uff0c\u7136\u540e\u70b9\u51fb\u201c<strong>\u5bb9\u5668\u955c\u50cf<\/strong>\u201d\u3002<\/p>\n\n\n\n<p>5.\u5728\u201c<strong>\u90e8\u7f72\u955c\u50cf<\/strong>\u201d\u9875\u9762\u4e2d\u4e3a\u201c<strong>\u6765\u81ea\u5916\u90e8\u5bb9\u5668\u955c\u50cf\u4ed3\u5e93\u7684\u955c\u50cf\u540d\u79f0<\/strong>\u201d\u63d0\u4f9b\u4ee5\u4e0b\u4fe1\u606f\uff0c\u7136\u540e\u56de\u8f66\u3002<br>openshiftroadshow\/parksmap<\/p>\n\n\n\n<p>6.\u5728\u8bc6\u522b\u51fa\u955c\u50cf\u540e\u70b9\u51fb\u9875\u9762\u4e0b\u65b9\u7684\u201c<strong>\u521b\u5efa<\/strong>\u201d\u6309\u94ae\uff0cOpenShift\u4f1a\u5f00\u59cb\u90e8\u7f72\u6b64\u955c\u50cf\uff0c\u7a0d\u540e\u9875\u9762\u5c06\u663e\u793a\u4e0b\u56fe\u201c<strong>\u62d3\u6251<\/strong>\u201d\u754c\u9762\u3002\u5f53\u90e8\u7f72\u6210\u529f\u90e8\u7f72\u540e\uff0c\u5916\u5708\u4f1a\u53d8\u6210\u6df1\u84dd\u8272\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-172-1024x546.png\" alt=\"\" class=\"wp-image-10025\" width=\"602\" height=\"320\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-172-1024x546.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-172-300x160.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-172-768x410.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-172-830x443.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-172-230x123.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-172-350x187.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-172-480x256.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-172.png 1496w\" sizes=\"(max-width: 602px) 100vw, 602px\" \/><\/figure><\/div>\n\n\n\n<p>7.\u5c06\u9f20\u6807\u653e\u5728\u4e0a\u56feparksmap\u56fe\u6807\u7684\u53f3\u4e0a\u65b9\u7684\u7bad\u5934\u5904\uff08\u4f1a\u5f39\u51fa\u7684\u201c<strong>\u6253\u5f00URI<\/strong>\u201d\u7684\u63d0\u793a\uff09\uff0c\u7136\u540e\u70b9\u51fb\u7bad\u5934\u3002\u6b64\u65f6\u4f1a\u5f39\u51fa\u4e00\u4e2a\u65b0\u9875\u9762\u663e\u793a\u521a\u521a\u90e8\u7f72\u597d\u7684\u5e94\u7528\u3002<\/p>\n\n\n\n<p>8.\u56de\u5230OpenShift\u63a7\u5236\u53f0\uff0c\u70b9\u51fbparksmap\u56fe\u6807\uff0c\u53f3\u4fa7\u4f1a\u6ed1\u51fa\u76f8\u5173Deployment\u4fe1\u606f\u3002\u5176\u4e2d\u201c<strong>\u8def\u7531<\/strong>\u201d\uff08Route\uff09\u5c31\u662f\u4e0a\u4e00\u6b65\u7684\u201c<strong>URI<\/strong>\u201d\uff0c\u5373\u5e94\u7528\u8bbf\u95ee\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-173-1024x597.png\" alt=\"\" class=\"wp-image-10026\" width=\"611\" height=\"355\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-173-1024x597.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-173-300x175.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-173-768x448.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-173-830x484.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-173-230x134.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-173-350x204.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-173-480x280.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-173.png 1482w\" sizes=\"(max-width: 611px) 100vw, 611px\" \/><\/figure><\/div>\n\n\n\n<p>9.\u70b9\u51fb\u4e0a\u56fe\u7684Pod\u5b9e\u4f8b\u540d\u94fe\u63a5\uff0c\u5c06\u663e\u793a\u8be5Pod\u7684\u9875\u9762\u3002\u53ef\u4ee5\u8fdb\u5165\u201c<strong>\u6307\u6807<\/strong>\u201d\u76d1\u63a7\u8be5Pod\u7684\u8fd0\u884c\u8d44\u6e90\uff0c\u89c1\u4e0b\u56fe\uff08\u53ea\u6709\u5b89\u88c5\u4e86OpenShift\u7684Metric\u529f\u80fd\u624d\u80fd\u663e\u793a\u51fa\u6570\u636e\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-174-1024x591.png\" alt=\"\" class=\"wp-image-10027\" width=\"579\" height=\"333\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-174-1024x591.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-174-300x173.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-174-768x443.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-174-830x479.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-174-230x133.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-174-350x202.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-174-480x277.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-174.png 1472w\" sizes=\"(max-width: 579px) 100vw, 579px\" \/><\/figure><\/div>\n\n\n\n<p>10.\u8fdb\u5165\u201c<strong>\u65e5\u5fd7<\/strong>\u201d\uff0c\u67e5\u770bPod\u4e2d\u5bb9\u5668\u7684\u65e5\u5fd7\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-175-1024x619.png\" alt=\"\" class=\"wp-image-10028\" width=\"570\" height=\"344\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-175-1024x619.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-175-300x181.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-175-768x464.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-175-830x502.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-175-230x139.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-175-350x212.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-175-480x290.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-175.png 1466w\" sizes=\"(max-width: 570px) 100vw, 570px\" \/><\/figure><\/div>\n\n\n\n<p>11.\u56de\u5230\u201c<strong>\u62d3\u6251<\/strong>\u201d\u9875\u9762\uff0c\u67e5\u770bparksmap\u90e8\u7f72\u7684\u201c<strong>\u8be6\u60c5<\/strong>\u201d\u4e00\u680f\uff0c\u53ef\u4ee5\u901a\u8fc7\u70b9\u51fbpod\u53f3\u4fa7\u7684\u5411\u4e0a\u7ebf\u7bad\u5934\u589e\u52a0pod\u7684\u6570\u91cf\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-176-1024x655.png\" alt=\"\" class=\"wp-image-10029\" width=\"549\" height=\"351\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-176-1024x655.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-176-300x192.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-176-768x491.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-176-830x531.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-176-230x147.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-176-350x224.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-176-480x307.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-176.png 1508w\" sizes=\"(max-width: 549px) 100vw, 549px\" \/><\/figure><\/div>\n\n\n\n<p>12.\u5728\u547d\u4ee4\u7ec8\u7aef\u4e2d\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u767b\u5f55OpenShift\uff0c\u7136\u540e\u67e5\u770b\u9879\u76ee\u4e2d\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 login OCP_API_URL -u USER-ID -p USER-PW\n$ oc get pod -n USER-ID-parksmap\nNAME                      READY   STATUS      RESTARTS   AGE\nparksmap-1-2w9mf          1\/1     Running     0          4h10m\nparksmap-1-ph8j2          1\/1     Running     0          178m<\/pre>\n\n\n\n<p><strong>\u90e8\u7f72\u5e94\u7528\u4ee3\u7801<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>1.\u901a\u8fc7OpenShift\u63a7\u5236\u53f0\u521b\u5efa\u4e00\u4e2a\u65b0\u9879\u76eeUSER-ID-cakephp\u3002<\/p>\n\n\n\n<p>2.\u70b9\u51fbOpenShift\u63a7\u5236\u53f0\u5de6\u4fa7\u7684\u201c<strong>+\u6dfb\u52a0<\/strong>\u201d\uff0c\u7136\u540e\u5728\u9875\u9762\u53f3\u4fa7\u70b9\u51fb\u201c<strong>\u4eceGit<\/strong>\u201d\u3002<\/p>\n\n\n\n<p>3.\u5728\u201c<strong>\u4ece Git \u5bfc\u5165<\/strong>\u201d\u9875\u9762\u4e2d\uff0c\u5c06\u201c<strong>Git Repo URL<\/strong>\u201d\u680f\u8bbe\u4e3a\u201c<strong>https:\/\/github.com\/sclorg\/cakephp-ex.git<\/strong>\u201d\u3002<\/p>\n\n\n\n<p>4.\u5728\u201c\u6784\u5efa\u5668\u201d\u533a\u57df\u9009\u4e2d\u201c<strong>PHP<\/strong>\u201d\uff0c\u5176\u5b83\u90fd\u63a5\u53d7\u7f3a\u7701\u5373\u53ef\uff0c\u6700\u540e\u70b9\u51fb\u4e0b\u65b9\u7684\u201c<strong>\u521b\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-177-1024x516.png\" alt=\"\" class=\"wp-image-10031\" width=\"519\" height=\"261\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-177-1024x516.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-177-300x151.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-177-768x387.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-177-830x418.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-177-230x116.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-177-350x176.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-177-480x242.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/03\/image-177.png 1476w\" sizes=\"(max-width: 519px) 100vw, 519px\" \/><\/figure><\/div>\n\n\n\n<p>5.\u4f9d\u6b21\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u901a\u8fc7\u65e5\u5fd7\u67e5\u770b\u6784\u5efa\uff08Build\uff09\u5e94\u7528\u7684\u60c5\u51b5\u3002\u53ef\u4ee5\u4eceBuild\u7684\u65e5\u5fd7\u4e2d\u770b\u5230OpenShift\u4f1a\u5148\u4eceGitHub\u4e0a\u4e0b\u8f7d\u5e94\u7528\u4ee3\u7801\uff0c\u7136\u540e\u6839\u636edockerfile\u7684\u5b9a\u4e49\u6b65\u9aa4\u5c06\u5e94\u7528\u4ee3\u7801\u548cBuilder Image\u6253\u5305\uff0c\u5728\u8fd9\u4e2a\u8fc7\u7a0b\u4e2d\u4f1a\u4e0b\u8f7d\u8fd0\u884cphp\u5e94\u7528\u6240\u4f9d\u8d56\u7684\u6587\u4ef6\u5305\u3002\u6700\u540e\u5c06\u751f\u6210\u7684App Image\u63a8\u9001\u5230OpenShift\u5185\u90e8\u7684Image Registry\u3002\u53ef\u4ee5\u901a\u8fc7image-registry.openshift-image-registry.svc:5000\/user1-parksmap\/cakephp-ex-git\u8bbf\u95ee\u5230\u8be5App 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 get build -n USER-ID-cakephp\nNAME               TYPE     FROM          STATUS     STARTED       DURATION\ncakephp-ex-git-1   Source   Git@133cb8b   Complete   3 hours ago   1m45s\n$ oc logs -f build\/cakephp-ex-git-1 -n USER-ID-cakephp\nCloning \"https:\/\/github.com\/sclorg\/cakephp-ex.git\" ...\n        Commit: 133cb8b0b9a79944b1620acf17fe9f07825e0b68 (Get rid off EOL php version)\n        Author: Petr \"Stone\" Hracek &lt;phracek@redhat.com>\n        Date:   Thu Jan 2 09:48:33 2020 +0100\nCaching blobs under \"\/var\/cache\/blobs\".\nGetting image source signatures\nCopying blob sha256:1cd26fbb2b2181a18c41ece85dff8b293e399e50dc3abe227b1940450bf6298b\nCopying blob sha256:4fbc3bafa3d4400bb97a733c1fe12f2f99bf38b9d5b913d5034f29798739654d\nCopying blob sha256:707235ac60367dff674607b0be2e18a83daea6dc2c8fb7330dbf7de29baf094b\nCopying blob sha256:0453406be68523ccc82999f84fffc57af64e00d9be0b75169c642c952b9bf7bc\n... \n...\n######\u4ee5\u4e0b\u7701\u7565N\u884c\n...\n...\nPushing image image-registry.openshift-image-registry.svc:5000\/user1-cakephp\/cakephp-ex-git:latest ...\nGetting image source signatures\nCopying blob sha256:5fc6b6797fe6bcbd34f4ea77d1d4b4918e49a68d51fa3c2340a7c98837368661\nCopying blob sha256:0453406be68523ccc82999f84fffc57af64e00d9be0b75169c642c952b9bf7bc\nCopying blob sha256:4fbc3bafa3d4400bb97a733c1fe12f2f99bf38b9d5b913d5034f29798739654d\nCopying blob sha256:1cd26fbb2b2181a18c41ece85dff8b293e399e50dc3abe227b1940450bf6298b\nCopying blob sha256:707235ac60367dff674607b0be2e18a83daea6dc2c8fb7330dbf7de29baf094b\nCopying blob sha256:34971b2d1eb98e410c2802e6bb3a7f499f9c5bff1b870ed329089ecdb21cf856\nCopying config sha256:b77051c0a30366462c246e26211394487bb638f0c3648aacaaca553824c056dc\nWriting manifest to image destination\nStoring signatures\nSuccessfully pushed image-registry.openshift-image-registry.svc:5000\/user1-parksmap\/cakephp-ex-git@sha256:a90e60a420a64b30c6382cb3e7685e1023a3242311745a9e38679c742b4ea9df\nPush successful\n<\/pre>\n\n\n\n<p>6.\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b\u90e8\u7f72\u8fdb\u5ea6\u3002\u5f53\u4e3a\u4ee5\u4e0b\u72b6\u6001\u65f6\u8bf4\u660e\u5e94\u7528\u5df2\u7ecf\u90e8\u7f72\u597d\u3002\u5176\u4e2dcakephp-ex-git-1-build\u8d1f\u8d23\u4e0b\u8f7d\u5e94\u7528\u4ee3\u7801\u548c\u5176\u4f9d\u8d56\u7684\u6587\u4ef6\uff0c\u7136\u540e\u5c06\u5176\u548c\u201c\u6784\u5efa\u5668\u955c\u50cf\u201d\uff08Builder Image\uff09\u6253\u5305\u6210\u201c\u5e94\u7528\u955c\u50cf\u201d\uff08App Image\uff09\uff0c\u800ccakephp-ex-git-1-deploy\u8d1f\u8d23\u5c06App Image\u90e8\u7f72\u5230OpenShift\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 get pod -n USER-ID-cakephp\nNAME                              READY   STATUS      RESTARTS   AGE\ncakephp-ex-git-1-build            0\/1     Completed   0          23m\ncakephp-ex-git-8586668995-m99ld   1\/1     Running     0          22m\n<\/pre>\n\n\n\n<p><br>7.\u67e5\u770b\u8bbf\u95ee\u5e94\u7528\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 get route -n USER-ID-cakephp\nNAME             HOST\/PORT                                                                                  PATH   SERVICES         PORT       TERMINATION   WILDCARD\ncakephp-ex-git   cakephp-ex-git-user1-parksmap.apps.cluster-beijing-c70a.beijing-c70a.example.opentlc.com \n<\/pre>\n\n\n\n<p>8.\u7528\u6d4f\u89c8\u5668\u6253\u5f00Route\u7684HOST\u5730\u5740\u5373\u53ef\u8bbf\u95ee\u5e94\u7528\u3002<\/p>\n\n\n\n<p><strong>\u90e8\u7f72\u5e94\u7528\u5305<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>1.\u5148\u521b\u5efaUSER-ID-war\u9879\u76ee\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ oc new-project USER-ID-mywar<\/pre>\n\n\n\n<p>2.\u4ee5\u4e0b\u53ef\u4ee5\u4efb\u9009\u4e00\u79cd\u65b9\u5f0f\u6267\u884c\uff1a\u53ef\u4ee5\u76f4\u63a5\u90e8\u7f72\u5728GitHub\u4e0a\u7684war\uff08\u6587\u4ef6\u540d\u5fc5\u987b\u662fROOT.war\uff09\uff0c\u4e5f\u53ef\u5148\u5c06war\u6587\u4ef6\u4e0b\u8f7d\u5230\u672c\u5730\uff0c\u7136\u540e\u518d\u90e8\u7f72\u3002<\/p>\n\n\n\n<p>\u65b9\u6cd51\uff1a\u76f4\u63a5\u90e8\u7f72\u5728GitHub\u4e0a\u7684ROOT.war\uff0c\u7136\u540e\u67e5\u770bBuild\u65e5\u5fd7\u3002<strong>\u6ce8\u610f<\/strong>\uff1a\u5728Build\u65e5\u5fd7\u4e2d\u53ef\u4ee5\u770b\u5230\u5c06ROOT.war\u590d\u5236\u5230\u76f8\u5173\u76ee\u5f55\u4e2d\uff0c\u7136\u540e\u751f\u6210App Image\u5e76\u63a8\u9001\u5230OpenShift\u5185\u90e8\u7684Registry\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 new-app --name=mywar jboss-webserver31-tomcat8-openshift:1.4~https:\/\/github.com\/liuxiaoyu-git\/tomcat-war -n USER-ID-mywar\n$ oc logs -f bc\/mywar -n USER-ID-mywar\n\u3002\u3002\u3002\nSTEP 8: RUN \/usr\/local\/s2i\/assemble\nCopying all war artifacts from \/tmp\/src directory into \/opt\/webserver\/webapps for later deployment...\n'\/tmp\/src\/ROOT.war' -> '\/opt\/webserver\/webapps\/ROOT.war'\nCopying all war artifacts from \/tmp\/src\/deployments directory into \/opt\/webserver\/webapps for later deployment\n\u3002\u3002\u3002\n<\/pre>\n\n\n\n<p>\u65b9\u6cd52\uff1a\u5148\u5c06ROOT.war\u6587\u4ef6\u4e0b\u8f7d\u5230\u672c\u5730\uff0c\u7136\u540e\u5728\u6307\u5b9aBuilder Image\uff08jboss-webserver31-tomcat8-openshift:1.2\uff09\u521b\u5efa\u5e94\u7528\uff0c\u6700\u540e\u518d\u6839\u636eROOT.war\u5f00\u59cb\u6784\u5efaApp Image\u3002\u6ce8\u610f\uff1a\u5728Build\u65e5\u5fd7\u4e2d\u53ef\u4ee5\u770b\u5230\u5c06ROOT.war\u590d\u5236\u5230\u76f8\u5173\u76ee\u5f55\u4e2d\uff0c\u7136\u540e\u751f\u6210App Image\u5e76\u63a8\u9001\u5230OpenShift\u5185\u90e8\u7684Registry\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=\"\">$ curl -LO https:\/\/raw.githubusercontent.com\/liuxiaoyu-git\/tomcat-war\/master\/ROOT.war\n$ oc new-app --name=mywar jboss-webserver31-tomcat8-openshift:1.4~. -n USER-ID-mywar\n$ oc start-build mywar --from-file=ROOT.war -n USER-ID-mywar\n$ oc logs -f bc\/mywar -n USER-ID-mywar\n\u3002\u3002\u3002\nSTEP 8: RUN \/usr\/local\/s2i\/assemble\nCopying all war artifacts from \/tmp\/src directory into \/opt\/webserver\/webapps for later deployment...\n'\/tmp\/src\/ROOT.war' -> '\/opt\/webserver\/webapps\/ROOT.war'\nCopying all war artifacts from \/tmp\/src\/deployments directory into \/opt\/webserver\/webapps for later deployment\n\u3002\u3002\u3002\n<\/pre>\n\n\n\n<p>3.\u7531\u4e8eOpenShift\u4e0d\u4f1a\u4e3a\u901a\u8fc7\u547d\u4ee4\u884c\u65b9\u5f0f\u521b\u5efa\u7684App\u81ea\u52a8\u521b\u5efaRoute\uff0c\u56e0\u6b64\u8fd8\u9700\u624b\u52a8\u6839\u636eService\u521b\u5efaRoute\u3002\u7136\u540e\u83b7\u5f97mywar\u7684Route\u7684\u8bbf\u95ee\u5730\u5740\uff0c\u7528\u6d4f\u89c8\u5668\u8bbf\u95ee\u5e94\u7528\u5373\u53ef\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 expose svc mywar -n USER-ID-mywar\n$ oc get route mywar -n USER-ID-mywar\nNAME    HOST\/PORT                                                                PATH   SERVICES   PORT       TERMINATION   WILDCARD\nmywar   mywar-mywar.apps.cluster-beijing-c70a.beijing-c70a.example.opentlc.com          mywar      8080-tcp   edge          None\n<\/pre>\n\n\n\n<p><strong>\u90e8\u7f72Dockerfile\u8d44\u6e90<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>OpenShift\u53ef\u4ee5\u76f4\u63a5\u90e8\u7f72Dockerfile\u8d44\u6e90\uff0c\u5176\u5b9eOpenShift\u540e\u53f0\u9700\u8981\u5148\u6839\u636eDockerfile\u6784\u5efa\u955c\u50cf\uff0c\u7136\u540e\u518d\u90e8\u7f72\u8be5\u955c\u50cf\u3002<\/p>\n\n\n\n<p>1.\u5148\u521b\u5efaUSER-ID-dockerfile\u9879\u76ee\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ oc new-project USER-ID-dockerfile<\/pre>\n\n\n\n<p>2.\u9996\u5148\u67e5\u770bDockerfile\u5185\u5bb9\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=\"\">$ curl https:\/\/raw.githubusercontent.com\/liuxiaoyu-git\/openshift-dockerfile-example\/master\/Dockerfile\nFROM bash:latest\n \nCMD [\"bash\", \"-c\", \"while true; do sleep 3; echo 'Sleep.'; done\"]\n<\/pre>\n\n\n\n<p>3.\u7136\u540e\u6839\u636eDockerfile\u521b\u5efa\u8fd0\u884c\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 --name sleep https:\/\/github.com\/liuxiaoyu-git\/openshift-dockerfile-example.git -n USER-ID-dockerfile\n$ oc logs -f bc\/sleep -n USER-ID-dockerfile\n<\/pre>\n\n\n\n<p>4.\u67e5\u770b\u8fd0\u884csleep\u7684pod\u540d\u79f0\uff0c\u7136\u540e\u67e5\u770b\u8be5pod\u7684\u65e5\u5fd7\u786e\u8ba4\u8fd0\u884c\u6b63\u5e38\uff0c\u8bc1\u660e\u5e94\u7528\u5e94\u5728\u8fd0\u884c\u4e86\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 pod -w -n USER-ID-dockerfile\nNAME                    READY   STATUS      RESTARTS   AGE\nsleep-1-build           0\/1     Completed   0          51s\nsleep-b4d7cd7fb-6mhj4   1\/1     Running     0          39s\n$ oc logs pod\/&lt;SLEEP_POD_NAME> -n USER-ID-dockerfile\nSleep\nSleep\n...\nSleep <\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5e94\u7528\u662f\u5982\u4f55\u90e8\u7f72\u5230OpenShift\u4e0a\u7684 OpenShift\u662f\u4f01\u4e1a\u7ea7\u5bb9\u5668\u5e73\u53f0\uff0c\u5728OpenShift\u7684\u5e94\u7528\u5fc5\u987b\u662f\u5bb9 [&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\/10021"}],"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=10021"}],"version-history":[{"count":5,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/10021\/revisions"}],"predecessor-version":[{"id":10034,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/10021\/revisions\/10034"}],"wp:attachment":[{"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10021"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10021"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10021"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}