{"id":14478,"date":"2024-04-24T10:13:45","date_gmt":"2024-04-24T02:13:45","guid":{"rendered":"https:\/\/92it.top\/?p=14478"},"modified":"2024-04-24T10:13:47","modified_gmt":"2024-04-24T02:13:47","slug":"openshift%e5%85%a5%e9%97%a8%ef%bc%9a%e5%9f%ba%e6%9c%ac%e6%a6%82%e5%bf%b5%e8%a7%a3%e6%9e%90","status":"publish","type":"post","link":"https:\/\/92it.top\/?p=14478","title":{"rendered":"Openshift\u5165\u95e8\uff1a\u57fa\u672c\u6982\u5ff5\u89e3\u6790"},"content":{"rendered":"\n<p><strong>1\u3001Project \u548c Namespace<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u5728 Kubernetes \u4e2d\u4f7f\u7528\u547d\u540d\u7a7a\u95f4\uff08Namespace\uff09\u7684\u6982\u5ff5\u6765\u5206\u9694\u8d44\u6e90 \u3002 \u5728\u540c\u4e00\u4e2a\u547d\u540d\u7a7a\u95f4\u4e2d\uff0c\u67d0\u4e00\u4e2a\u5bf9\u8c61\u7684\u540d\u79f0\u5728\u5176\u5206\u7c7b\u4e2d\u5fc5\u987b\u662f\u552f\u4e00\u7684\uff0c\u4f46\u662f\u5206\u5e03\u5728\u4e0d\u540c\u547d\u540d\u7a7a\u95f4\u4e2d\u7684\u5bf9\u8c61\u5219\u53ef\u4ee5\u540c\u540d \u3002 OpenShift \u4e2d\u7ee7\u627f\u4e86 Kubernetes\u547d\u540d\u7a7a\u95f4\u7684\u6982\u5ff5\uff0c\u800c\u4e14\u5728\u5176\u4e4b\u4e0a\u5b9a\u4e49\u4e86 Project\u5bf9\u8c61\u7684\u6982\u5ff5 \u3002\u6bcf\u4e00\u4e2a Project\u4f1a\u548c\u4e00\u4e2a Namespace\u76f8\u5173\u8054\uff0c\u751a\u81f3\u53ef\u4ee5\u7b80\u5355\u5730\u8ba4\u4e3a\uff0cProject\u5c31\u662fNamespace\u3002<\/p>\n\n\n\n<p>\u5e38\u7528\u547d\u4ee4\uff1aoc project (\u67e5\u770b\u7528\u6237\u5f53\u524d\u6240\u5728\u7684project)\u3001oc get projects (\u67e5\u770b\u6240\u6709\u9879\u76ee)\u3001oc project (\u5207\u6362\u5230\u6307\u5b9a\u9879\u76ee)<\/p>\n\n\n\n<p><strong>2\u3001Pod<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u5728 OpenShift \u4e0a\u8fd0\u884c\u7684\u5bb9\u5668\u4f1a\u88ab\u4e00\u79cd\u53eb Pod \u7684\u5bf9\u8c61\u6240\u201c\u5305\u88f9\u201d\uff0c\u7528\u6237\u4e0d\u4f1a\u76f4\u63a5\u770b\u5230 Docker \u5bb9\u5668\u672c\u8eab\u3002\u4ece\u6280\u672f\u4e0a\u6765\u8bf4\uff0c Pod\u5176\u5b9e\u4e5f\u662f\u4e00\u79cd\u7279\u6b8a\u7684\u5bb9\u5668\u3002<\/p>\n\n\n\n<p>\u5e38\u7528\u547d\u4ee4\uff1aoc get pod (\u67e5\u770b\u6240\u6709pod)\u3001oc describe pod (\u67e5\u770b\u8be5pod\u7684\u8be6\u7ec6\u4fe1\u606f)<\/p>\n\n\n\n<p>oc logs (\u67e5\u770bpod\u7684log)\u3001oc rsh (\u53ef\u4ee5\u8fdb\u5165pod\u5185\u90e8\u6267\u884c\u547d\u4ee4)<\/p>\n\n\n\n<p><strong>3\u3001Service<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u5bb9\u5668\u662f\u4e00\u4e2a\u975e\u6301\u4e45\u5316\u7684\u5bf9\u8c61\u3002\u6240\u6709\u5bf9\u5bb9\u5668\u7684\u4fee\u6539\u5728\u5bb9\u5668\u9500\u6bc1\u540e\u9ed8\u8ba4\u90fd\u4f1a\u4e22\u5931\u3002\u540c\u4e00\u4e2aDocker\u955c\u50cf\u5b9e\u4f8b\u5316\u5f62\u6210\u5bb9\u5668\u540e\uff0c\u4f1a\u6062\u590d\u5230\u8fd9\u4e2a\u955c\u50cf\u521d\u59cb\u5b9a\u4e49\u7684\u72b6\u6001\uff0c\u5e76\u4e14\u83b7\u53d6\u4e00\u4e2a\u65b0\u7684IP\u5730\u5740\u3002<\/p>\n\n\n\n<p>  \u4e3a\u4e86\u514b\u670d\u5bb9\u5668\u53d8\u5316\u5f15\u53d1\u7684\u8fde\u63a5\u4fe1\u606f\u7684\u53d8\u5316\uff0c Kubernetes \u63d0\u4f9b\u4e86\u4e00\u79cd\u53eb Service (\u670d\u52a1) \u7684\u7ec4\u4ef6\u3002\u5f53\u90e8\u7f72\u67d0\u4e2a\u5e94\u7528\u65f6\uff0c\u6211\u4eec\u4f1a\u4e3a\u8be5\u5e94\u7528\u521b\u5efa\u4e00\u4e2a Service\u5bf9\u8c61\u3002 Service\u5bf9\u8c61\u4f1a\u4e0e\u8be5\u5e94\u7528\u7684\u4e00\u4e2a\u6216\u591a\u4e2a Pod\u5173\u8054\u3002 \u540c\u65f6\u6bcf\u4e2a Service\u4f1a\u88ab\u5206\u914d\u5230\u4e00\u4e2aIP\u5730\u5740\uff0c\u8fd9\u4e2aIP\u5730\u5740\u662f\u76f8\u5bf9\u6052\u5b9a\u7684\u3002\u901a\u8fc7\u8bbf\u95ee\u8fd9\u4e2a IP \u5730\u5740\u53ca\u76f8\u5e94\u7684\u7aef\u53e3\uff08\u6216\u8005service\u57df\u540d\uff09\uff0c\u8bf7\u6c42\u5c31\u4f1a\u88ab\u8f6c\u53d1\u5230\u5bf9\u5e94 Pod \u7684\u76f8\u5e94\u7aef\u53e3\u3002<br><br>  \u6ce8\u610f\u26a0\ufe0f\uff1aService\u63d0\u4f9b\u4e86\u4e00\u4e2a\u901a\u5f80\u540e\u7aef Pod\u96c6\u7fa4\u7684\u7a33\u5b9a\u7684\u4eba\u53e3\uff0c\u4f46\u662f Service\u7684 IP\u5730\u5740\u53ea\u662f\u96c6\u7fa4\u5185\u90e8\u7684\u8282\u70b9\u53ca\u5bb9\u5668\u53ef\u89c1(\u5916\u90e8\u4e0d\u53ef\u8fbe)\u3002 \u5bf9\u4e8e\u5916\u90e8\u7684\u5e94\u7528\u6216\u8005\u7528\u6237\u6765\u8bf4\uff0c\u8fd9\u4e2a\u5730\u5740\u662f\u4e0d\u53ef\u8fbe\u7684\u3002\uff08Service\u57df\u540d\u7684\u683c\u5f0f\u662f <serv\u5de5ce name=\"\"> . <project name=\"\"> svc.cluster.local\uff09<\/project><\/serv\u5de5ce><\/p>\n\n\n\n<p>\u6d4b\u8bd5==\u300b\u901a\u8fc7oc rsh \u8fdb\u5165pod\u5185\u90e8\u6267\u884c\u547d\u4ee4\uff1acurl :\uff0c\u53ef\u4ee5\u770b\u5230\u8bbf\u95ee\u6210\u529f\u3002<\/p>\n\n\n\n<p>\u5e38\u7528\u547d\u4ee4\uff1aoc get svc (\u67e5\u770b\u5f53\u524d\u9879\u76ee\u4e0b\u7684\u6240\u6709service\u5217\u8868)<br><\/p>\n\n\n\n<p><strong>4\u3001Router \u548c Route<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u4e00\u4e2a Route \u4f1a\u4e0e\u4e00\u4e2a Service \u76f8\u5173\u8054\uff0c\u5e76\u4e14\u7ed1\u5b9a\u4e00\u4e2a\u57df\u540d(\u5916\u90e8\u53ef\u8fbe)\u3002Route\u89c4\u5219\u4f1a\u88ab Router \u52a0\u8f7d\u3002 \u5f53\u7528\u6237\u901a\u8fc7\u6307\u5b9a\u57df\u540d\u8bbf\u95ee\u5e94\u7528\u65f6\uff0c\u57df\u540d\u4f1a\u88ab\u89e3\u6790\u5e76\u6307\u5411 Router\u6240\u5728\u7684\u8ba1\u7b97\u8282\u70b9\u4e0a \u3002 Router\u83b7\u53d6\u8fd9\u4e2a\u8bf7\u6c42\uff0c\u7136\u540e\u6839\u636e Route \u89c4\u5219\u5b9a\u4e49\u8f6c\u53d1\u7ed9\u4e0e\u8fd9\u4e2a\u57df\u540d\u5bf9\u5e94\u7684Service\u3002\u7136\u540eService\u4f1a\u63a5\u7740\u505a\u4e00\u4e2aload banlance\uff0c\u8f6c\u53d1\u8bf7\u6c42\u5230\u540e\u7aef\u6240\u5173\u8054\u7684 Pod \u5bb9\u5668\u5b9e\u4f8b\u3002<\/p>\n\n\n\n<p>PS\uff1a\u5176\u5b9e Router \u7ec4\u4ef6\u5c31\u662f\u4e00\u4e2a\u8fd0\u884c\u5728\u5bb9\u5668\u5185\u7684 Haproxy\uff0c\u662f\u4e00\u4e2a\u7279\u6b8a\u5b9a\u5236\u7684 Haproxy\u3002<\/p>\n\n\n\n<p>\u5e38\u7528\u547d\u4ee4\uff1aoc get route (\u67e5\u770b\u9879\u76ee\u4e2d\u6240\u6709\u7684route)<\/p>\n\n\n\n<p><strong>5\u3001Secure\u00a0Route\uff08\u5f00\u542fHTTPS\uff09<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>Secure Route\u5176\u5b9e\u662froute\u7684\u4e00\u79cd\uff0c\u53ea\u4e0d\u8fc7\u662f\u5f00\u542f\u4e86TLS termination\u3002\u6ce8\uff1aTLS\uff08Transport Layer Security\uff09\u4f20\u8f93\u5c42\u5b89\u5168\u6027\u534f\u8bae\uff0c\u5176\u524d\u8eab\u662f\u5b89\u5168\u5957\u63a5\u5c42\uff08Secure Sockets Layer\uff0c\u7f29\u5199\u4f5cSSL\uff09\u662f\u4e00\u79cd\u5b89\u5168\u534f\u8bae\uff0c\u76ee\u7684\u662f\u4e3a\u4e92\u8054\u7f51\u901a\u4fe1\u63d0\u4f9b\u5b89\u5168\u53ca\u6570\u636e\u5b8c\u6574\u6027\u4fdd\u969c\u3002<\/p>\n\n\n\n<p>\u4e09\u79cdTLS termination type\uff1a<\/p>\n\n\n\n<p>1\u20e3\ufe0fEdge\uff1aTLS\u5728router\u4e0a\u88ab\u7ec8\u7ed3\uff0c\u7136\u540e\u975eSSL\u7f51\u7edc\u5305\u88ab\u8f6c\u53d1\u7ed9\u540e\u7aefpod\u3002\u56e0\u6b64\u9700\u8981\u5728 router \u4e0a\u5b89\u88c5 TLS \u8bc1\u4e66\u3002\u4e0d\u5b89\u88c5\u7684\u8bdd\uff0c\u4f1a\u4f7f\u7528 router \u7684\u9ed8\u8ba4\u8bc1\u4e66\u3002\uff08\u5373\u5728Route\u4e0a\u5b89\u88c5certificate\u8bc1\u4e66\uff0cpod\u5185\u90e8\u7a0b\u5e8f\u4e0d\u5b89\u88c5\u8bc1\u4e66\uff0c\u56e0\u6b64\u5916\u90e8\u662fhttps\uff0c\u5185\u90e8\u662fhttp\uff09<\/p>\n\n\n\n<p>2\u20e3\ufe0fpassthrough\uff1a\u52a0\u5bc6\u7f51\u7edc\u5305\u76f4\u63a5\u88ab\u53d1\u7ed9 pod\uff0crouter \u4e0a\u4e0d\u505aTLS \u7ec8\u7ed3\uff0c\u56e0\u6b64\u4e0d\u9700\u8981\u5728 router \u4e0a\u914d\u7f6e\u8bc1\u4e66\u6216\u5bc6\u94a5\u3002\uff08\u5373\u5728Route\u4e0a\u4e0d\u5b89\u88c5\u8bc1\u4e66\uff0c\u5728pod\u5185\u90e8\u5b89\u88c5\u8bc1\u4e66\uff0c\u56e0\u6b64\u5916\u90e8\u662fhttp\uff0c\u5185\u90e8\u662fhttps\uff09<\/p>\n\n\n\n<p>3\u20e3\ufe0fRe-encryption\uff1a\u662f edge \u7684\u4e00\u79cd\u53d8\u79cd\u3002\u9996\u5148 router \u4e0a\u4f1a\u4f7f\u7528\u4e00\u4e2a\u8bc1\u4e66\u505a TSL \u7ec8\u7ed3\uff0c\u7136\u540e\u4f7f\u7528\u53e6\u5916\u7684\u8bc1\u4e66\u518d\u8fdb\u884c\u52a0\u5bc6\uff0c\u7136\u540e\u53d1\u7ed9\u540e\u7aef pod\u3002\u56e0\u6b64\uff0c\u6574\u4e2a\u7f51\u7edc\u8def\u5f84\u90fd\u662f\u52a0\u5bc6\u7684\u3002\uff08\u5185\u5916\u90e8\u5168\u90e8https\uff09<\/p>\n\n\n\n<p>\u6ce8\u610f\u26a0\ufe0f\uff1a\u4f7f\u7528Secure Route\uff0c\u8bbf\u95ee\u8def\u5f84\u90fd\u662fhttps\u3002<\/p>\n\n\n\n<p><strong>6\u3001Persistent Storage<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u5bb9\u5668\u9ed8\u8ba4\u662f\u975e\u6301\u4e45\u5316\u7684\uff0c\u6240\u6709\u7684\u4fee\u6539\u5728\u5bb9\u5668\u9500\u6bc1\u65f6\u90fd\u4f1a\u4e22\u5931\u3002 \u4f46\u73b0\u5b9e\u662f\u4f20\u7edf\u7684\u5e94\u7528\u5927\u591a\u90fd\u662f\u6709\u72b6\u6001\u7684\uff0c\u56e0\u6b64\u8981\u6c42\u67d0\u4e9b\u5bb9\u5668\u5185\u7684\u6570\u636e\u5fc5\u987b\u6301\u4e45\u5316\uff0c\u5bb9\u5668\u4e91\u5e73\u53f0\uff08OCP\uff1aopenshift container platform\uff09\u5fc5\u987b\u4e3a\u5bb9\u5668\u63d0\u4f9b\u6301\u4e45\u5316\u50a8\u5b58( persistent storage)\u3002<\/p>\n\n\n\n<p>  OpenShift \u9664\u4e86\u652f\u6301 Docker \u6301\u4e45\u5316\u5377\u7684\u6302\u8f7d\u65b9\u5f0f\u5916\uff0c\u8fd8\u63d0\u4f9b\u4e86\u4e00\u79cd\u6301\u4e45\u5316\u4f9b\u7ed9\u6a21\u578b\uff0c\u5373 Persistent Volume (\u6301\u4e45\u5316\u5377\uff0c PV)\u53ca Persistent Volume Claim (\u6301\u4e45\u5316\u5377\u8bf7\u6c42\uff0c PVC)\u6a21\u578b\u3002<br><br>  \u5728 PV \u548c PVC \u6a21\u578b\u4e2d\uff0c\u96c6\u7fa4\u7ba1\u7406\u5458\u4f1a\u521b\u5efa\u5927\u91cf\u4e0d\u540c\u5927\u5c0f\u548c\u4e0d\u540c\u7279\u6027\u7684 PV\u3002 \u7528\u6237\u5728\u90e8\u7f72\u5e94\u7528\u65f6\uff0c\u663e\u5f0f\u58f0\u660e\u5bf9\u6301\u4e45\u5316\u7684\u9700\u6c42\uff0c\u521b\u5efa  PVC\u3002\u7528\u6237\u5728 PVC \u4e2d\u5b9a\u4e49\u6240\u9700\u5b58\u50a8\u7684\u5927\u5c0f\u3001\u8bbf\u95ee\u65b9\u5f0f(\u53ea\u8bfb\u6216\u53ef\u8bfb\u53ef\u5199;\u72ec\u5360\u6216\u5171\u4eab) \u3002OpenShift \u96c6\u7fa4\u4f1a\u81ea\u52a8\u5bfb\u627e\u7b26\u5408\u8981\u6c42\u7684 PV \u4e0e PVC \u81ea\u52a8\u5bf9\u63a5\u3002<\/p>\n\n\n\n<p>\u5e38\u7528\u547d\u4ee4\uff1aoc get pv (\u67e5\u770b\u6240\u6709\u6301\u4e45\u5316\u5377\uff0c\u9700\u8981admin\u6743\u9650)\u3001oc get pvc\uff08\u67e5\u770b\u6240\u6709\u6301\u4e45\u5316\u5377\u8bf7\u6c42\uff09<\/p>\n\n\n\n<p><strong>7\u3001Registry<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>OpenShift \u63d0\u4f9b\u4e86\u4e00\u4e2a\u5185\u90e8\u7684 Docker \u955c\u50cf\u4ed3\u5e93( Registry)\uff0c\u8be5\u955c\u50cf\u4ed3\u5e93\u7528\u4e8e\u5b58\u653e\u7528\u6237\u901a\u8fc7\u5185\u7f6e\u7684 Source to Image \u955c\u50cf\u6784\u5efa\u6d41\u7a0b\u6240\u4ea7\u751f\u7684\u955c\u50cf \u3002\u6bcf\u5f53 S2I \u5b8c\u6210\u955c\u50cf\u6784\u5efa\uff0c\u5c31\u4f1a\u5411\u5185\u90e8\u7684\u955c\u50cf\u4ed3\u5e93\u63a8\u9001\u6784\u5efa\u5b8c\u6210\u7684\u955c\u50cf \u3002<\/p>\n\n\n\n<p>Registry \u7ec4\u4ef6\u9ed8\u8ba4\u4ee5\u5bb9\u5668\u7684\u65b9\u5f0f\u63d0\u4f9b\uff0c\u56e0\u6b64\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7 oc get pod -n default \u67e5\u770b Registry \u5bb9\u5668\u7684\u72b6\u6001\u3002\u540c\u7406\uff0c\u901a\u8fc7 oc get svc -n default \u53ef\u4ee5\u67e5\u770b Registry \u5bb9\u5668\u5bf9\u5e94\u7684 Service \u4fe1\u606f\u3002<\/p>\n\n\n\n<p><strong>8\u3001Source to Image \uff08S2I\uff09<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u4e00\u4e2a\u5178\u578b\u7684 S21 \u6d41\u7a0b\u5305\u542b\u4e86\u4ee5\u4e0b\u51e0\u4e2a\u6b65\u9aa4\u3002<\/p>\n\n\n\n<p>1\u20e3\ufe0f \u7528\u6237\u8f93\u5165\u6e90\u4ee3\u7801\u4ed3\u5e93\u7684\u5730\u5740\u3002<\/p>\n\n\n\n<p>2\u20e3\ufe0f \u7528\u6237\u9009\u62e9 S2I \u6784\u5efa\u7684\u57fa\u7840\u955c\u50cf(\u53c8\u79f0\u4e3a Builder \u955c\u50cf)\u3002 Builder\u955c\u50cf\u4e2d\u5305\u542b\u4e86\u64cd\u4f5c\u7cfb\u7edf\u3001\u7f16\u7a0b\u8bed\u8a00\u3001\u6846\u67b6\u7b49\u5e94\u7528\u6240\u9700\u7684\u8f6f\u4ef6\u53ca\u914d\u7f6e\u3002 OpenShift \u9ed8\u8ba4\u63d0\u4f9b\u4e86\u591a\u79cd\u7f16\u7a0b\u8bed\u8a00\u7684 Builder \u955c\u50cf\uff0c\u5982 Java\u3001 PHP\u3001 Ruby\u3001 Python\u3001 Perl\u7b49\u3002 \u7528\u6237\u4e5f\u53ef\u4ee5\u6839\u636e\u81ea\u8eab\u9700\u6c42\u5b9a\u5236\u81ea\u5df1\u7684 Builder\u955c\u50cf\uff0c\u5e76\u53d1\u5e03\u5230\u670d\u52a1\u76ee\u5f55\u4e2d\u4f9b\u7528\u6237\u9009\u7528 \u3002<\/p>\n\n\n\n<p>3\u20e3\ufe0f \u7528\u6237\u6216\u7cfb\u7edf\u89e6\u53d1 S2I \u6784\u5efa \u3002 OpenShift \u5c06\u5b9e\u4f8b\u5316 S2I \u6784\u5efa\u6267\u884c\u5668 \u3002<\/p>\n\n\n\n<p>4\u20e3\ufe0f S2I \u6784\u5efa\u6267\u884c\u5668\u5c06\u4ece\u7528\u6237\u6307\u5b9a\u7684\u4ee3\u7801\u4ed3\u5e93\u4e0b\u8f7d\u6e90\u4ee3\u7801\u3002<\/p>\n\n\n\n<p>5\u20e3\ufe0f S2I \u6784\u5efa\u6267\u884c\u5668\u5b9e\u4f8b\u5316 Builder \u955c\u50cf\u3002 \u4ee3\u7801\u5c06\u4f1a\u88ab\u6ce8\u5165 Builder \u955c\u50cf\u4e2d\u3002<\/p>\n\n\n\n<p>6\u20e3\ufe0f Builder \u955c\u50cf\u5c06\u6839\u636e\u9884\u5b9a\u4e49\u7684\u903b\u8f91\u6267\u884c\u6e90\u4ee3\u7801\u7684\u7f16\u8bd1\u3001\u6784\u5efa\u5e76\u5b8c\u6210\u90e8\u7f72\u3002<\/p>\n\n\n\n<p>7\u20e3\ufe0f S2I\u6784\u5efa\u6267\u884c\u5668\u5c06\u5b8c\u6210\u64cd\u4f5c\u7684 Builder \u955c\u50cf\u53bb\u751f\u6210\u65b0\u7684 Docker \u955c\u50cf\u3002<\/p>\n\n\n\n<p>8\u20e3\ufe0f S2I\u6784\u5efa\u6267\u884c\u5668\u5c06\u65b0\u7684\u955c\u50cf\u63a8\u9001\u5230 OpenShift \u5185\u90e8\u7684\u955c\u50cf\u4ed3\u5e93\uff08Registry\uff09\u3002<\/p>\n\n\n\n<p>9\u20e3\ufe0f S2I\u6784\u5efa\u6267\u884c\u5668\u66f4\u65b0\u8be5\u6b21\u6784\u5efa\u76f8\u5173\u7684 Image Stream \u4fe1\u606f\u3002<\/p>\n\n\n\n<p>\u6ce8\uff1aS2I \u6784\u5efa\u5b8c\u6210\u540e\uff0c\u6839\u636e\u7528\u6237\u5b9a\u4e49\u7684\u90e8\u7f72\u903b\u8f91\uff0c OpenShift\u5c06\u628a\u955c\u50cf\u5b9e\u4f8b\u5316\u90e8\u7f72\u5230\u96c6\u7fa4\u4e2d \u3002 \u9664\u4e86\u63a5\u53d7\u6e90\u4ee3\u7801\u4ed3\u5e93\u5730\u5740\u4f5c\u4e3a\u8f93\u5165\u5916\uff0c S2I\u8fd8\u63a5\u53d7 Dockerfile \u4ee5\u53ca\u4e8c\u8fdb\u5236\u6587\u4ef6\u4f5c\u4e3a\u6784\u5efa\u7684\u8f93\u5165\u3002 \u7528\u6237\u751a\u81f3\u53ef\u4ee5\u5b8c\u5168\u81ea\u5b9a\u4e49\u6784\u5efa\u903b\u8f91\u6765\u6ee1\u8db3\u7279\u6b8a\u7684\u9700\u6c42\u3002<\/p>\n\n\n\n<p><strong>9\u3001Image Stream<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>   OpenShift \u5b9a\u4e49\u4e86 Image Stream \u7684\u6982\u5ff5\u6765\u7ba1\u7406\u4e00\u7ec4\u955c\u50cf\u7684\u96c6\u5408 \u3002 \u5728\u4e00\u4e2a Image Stream \u4e2d\u53ef\u4ee5\u5b9a\u4e49\u591a\u4e2a\u955c\u50cf\u540d\u79f0\u548c Tag\uff0c\u7136\u540e\u518d\u6307\u5411\u5b9e\u9645\u7684 Docker\u955c\u50cf\u3002\u901a\u8fc7 oc get \/ describe is \u547d\u4ee4\u6765\u67e5\u770b Image Stream \u4fe1\u606f\u3002<\/p>\n\n\n\n<p><strong>10\u3001\u955c\u50cf\u6784\u5efa\uff1aBuild Config \u4e0e Build<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>  Build Config \u7528\u4e8e\u6307\u5bfc\u5e94\u7528\u6784\u5efa\u8fc7\u7a0b\uff0c\u5305\u62ec\u6e90\u7801\u4f4d\u7f6e\u3001\u6784\u5efa\u7b56\u7565\u3001\u6784\u5efa\u89e6\u53d1\u914d\u7f6e\u7b49\u3002\u901a\u8fc7 oc get bc \u53ef\u4ee5\u67e5\u770b\u6240\u6709\u7684 build config \u4fe1\u606f\u3002\u5982\u679c\u60f3\u8fdb\u4e00\u6b65\u83b7\u53d6\u67d0\u4e2a Build Config \u7684\u5177\u4f53\u914d\u7f6e\u4fe1\u606f\u53ef\u4f7f\u7528 oc get bc -o yaml \u547d\u4ee4\u3002<\/p>\n\n\n\n<p>   Build Config \u53ea\u662f\u9759\u6001\u7684\u914d\u7f6e\u4fe1\u606f \u3002 OpenShift \u6839\u636e\u8fd9\u4e2a\u9759\u6001\u7684\u914d\u7f6e\u4fe1\u606f\u53ef\u4ee5\u89e6\u53d1\u591a\u6b21\u5b9e\u9645\u7684\u6784\u5efa\u5b9e\u4f8b\uff0c\u6784\u5efa\u7684\u5b9e\u4f8b\u79f0\u4e3a Build\u3002 \u4e00\u4e2a Build Config \u53ef\u4ee5\u88ab\u591a\u6b21\u89e6\u53d1\uff0c \u751f\u6210\u591a\u4e2aBuild\u3002\u901a\u8fc7 oc get build \u547d\u4ee4\uff0c\u53ef\u4ee5\u67e5\u770b\u751f\u6210\u7684 build \u5217\u8868\u3002\u6267\u884c oc logs build\/<build-name> \u547d\u4ee4\uff0c\u53ef\u4ee5\u67e5\u770b\u672c\u6b21 build \u7684\u8be6\u7ec6\u4fe1\u606f\u3002\u5982\u679c\u60f3\u6267\u884c\u4e00\u6b21\u65b0\u7684\u6784\u5efa\uff0c\u53ef\u4f7f\u7528 oc new-build <svc-name> \u547d\u4ee4\u3002<\/svc-name><\/build-name><\/p>\n\n\n\n<p><strong>11\u3001\u955c\u50cf\u90e8\u7f72\uff1aDeployment Config \u4e0e Deploy<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>  Deployment Config \u63cf\u8ff0\u4e86\u955c\u50cf\u90e8\u7f72\u7684\u53c2\u6570\u548c\u8981\u6c42\u3002\u901a\u8fc7 oc get dc \u547d\u4ee4\u53ef\u4ee5\u67e5\u770b\u9879\u76ee\u4e2d\u7684 Deployment Config \u5217\u8868\u3002\u6267\u884c oc get dc -o yaml \u547d\u4ee4\uff0c\u53ef\u4ee5\u67e5\u770b\u8be5 DeploymentConfig \u7684\u8be6\u7ec6\u5b9a\u4e49 \u3002\u5728 Deployment Config \u4e2d\u4f1a\u5b9a\u4e49 Trigger (\u89e6\u53d1\u5668)\uff0c\u4f7f\u90e8\u7f72\u5728\u67d0\u4e9b\u7279\u5b9a\u6761\u4ef6\u4e0b\u81ea\u52a8\u89e6\u53d1\uff0c\u5982 S2I \u5b8c\u6210\u65f6\u3002<\/p>\n\n\n\n<p>  \u6bcf\u4e2a Deployment Config \u53ef\u4ee5\u88ab\u591a\u6b21\u89e6\u53d1\uff0c\u6bcf\u4e00\u6b21\u89e6\u53d1\u79f0\u4e3a\u4e00\u4e2a Deploy\u3002 \u6bcf\u4e00\u6b21 Deploy \u90fd\u4f1a\u751f\u6210\u4e00\u4e2a Replication Controller \u5bf9\u8c61\uff0c\u7528\u4ee5\u76d1\u63a7\u5bb9\u5668\u7684\u72b6\u6001\u3002 Replication Controller (\u590d\u5236\u63a7\u5236\u5668)\u662f Kubernetes \u4e2d\u7684\u4e00\u4e2a\u7ec4\u4ef6\uff0c\u5176\u8d1f\u8d23\u76d1\u63a7\u5bb9\u5668\u7684\u5b9e\u9645\u6570\u91cf\u3002\u901a\u8fc7 oc get rc \u53ef\u4ee5\u67e5\u770b Replication Controller \u5217\u8868\u3002<\/p>\n\n\n\n<p>Openshift \u7684\u66f4\u65b0\u90e8\u7f72\u7b56\u7565\u6709 Rolling \u548c Recreate \u4e24\u79cd\u3002<\/p>\n\n\n\n<p>1\u20e3\ufe0f Rolling\uff08\u6eda\u52a8\u66f4\u65b0\uff09\u662f\u6307 Openshift \u5728\u90e8\u7f72\u65f6\uff0c\u4f1a\u7b49\u4e00\u5b9a\u6570\u91cf\u7684\u65b0\u7248\u672c\u5bb9\u5668\u5b9e\u4f8b\u542f\u52a8\u5b8c\u6bd5\u540e\uff0c\u5728\u7ec8\u7ed3\u4e00\u5b9a\u6570\u91cf\u7684\u8001\u7248\u672c\u5bb9\u5668\u5b9e\u4f8b\uff0c\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\u5bf9\u5bb9\u5668\u96c6\u7fa4\u4e2d\u7684\u5b9e\u4f8b\u8fdb\u884c\u9010\u4e00\u66ff\u6362\u66f4\u65b0\u3002\u8fd9\u79cd\u65b9\u5f0f\u53ef\u4ee5\u4fdd\u8bc1\u5e94\u7528\u5728\u66f4\u65b0\u53d1\u5e03\u7684\u8fc7\u7a0b\u4e2d\u4e0d\u4f1a\u51fa\u73b0\u670d\u52a1\u4e2d\u65ad\u3002<\/p>\n\n\n\n<p>2\u20e3\ufe0f Recreate\uff08\u91cd\u65b0\u521b\u5efa\uff09\u662f\u6307\u5728\u66f4\u65b0\u65f6\u5c06\u6240\u6709\u8001\u5bb9\u5668\u5e94\u7528\u5148\u505c\u6b62\uff0c\u7136\u540e\u518d\u542f\u52a8\u4e00\u6279\u65b0\u7248\u672c\u7684\u5bb9\u5668\u5b9e\u4f8b\u3002<\/p>\n\n\n\n<p><strong>12\u3001Replication Controller<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u5728 OpenShift \u4e2d\uff0c\u6bcf\u4e00\u4e2a\u90e8\u7f72\u7684\u5e94\u7528\u7684\u5bb9\u5668\u5b9e\u4f8b\u6570\u91cf\u5728\u5176 Deployment Config \u4e2d\u5b9a\u4e49\u3002\u5b9e\u9645\u90e8\u7f72\u65f6\uff0cOpenShift \u4e3a\u6bcf\u6b21\u7684\u90e8\u7f72\u5b9e\u4f8b\u5316\u4e00\u4e2a Replication Controller\uff0c\u5e76\u5c06\u8be5\u6570\u503c\u4f20\u9012\u7ed9\u76f8\u5173\u8054\u7684 Replication Controller\u3002 Replication Controller\u662f Kubernetes \u7684\u4e00\u4e2a\u7ec4\u4ef6\uff0c\u5176\u8d1f\u8d23\u7ef4\u62a4\u5bb9\u5668\u5b9e\u4f8b\u7684\u6570\u91cf \u3002<\/p>\n\n\n\n<p>\u53ef\u4ee5\u901a\u8fc7 oc scale dc &#8211;replicas=n \u547d\u4ee4\u6765\u5c06\u8be5 service \u5e94\u7528\u5f39\u6027\u4f38\u7f29\u4e3a n \u4e2a\u5b9e\u4f8b\u3002<\/p>\n\n\n\n<p><strong>\u5176\u4ed6<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>oc login\/logout \u767b\u5f55\/\u767b\u51faOCP<\/p>\n\n\n\n<p>\u8f6c\u8f7d\uff1a<a href=\"https:\/\/blog.csdn.net\/qq_37771475\/article\/details\/102851578\">https:\/\/blog.csdn.net\/qq_37771475\/article\/details\/102851578<\/a><br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001Project \u548c Namespace \u5728 Kubernetes \u4e2d\u4f7f\u7528\u547d\u540d\u7a7a\u95f4\uff08Namespace\uff09\u7684\u6982 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29,22],"tags":[],"_links":{"self":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/14478"}],"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=14478"}],"version-history":[{"count":5,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/14478\/revisions"}],"predecessor-version":[{"id":14483,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/14478\/revisions\/14483"}],"wp:attachment":[{"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=14478"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=14478"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=14478"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}