{"id":15200,"date":"2024-05-22T22:49:32","date_gmt":"2024-05-22T14:49:32","guid":{"rendered":"https:\/\/92it.top\/?p=15200"},"modified":"2024-05-22T22:49:32","modified_gmt":"2024-05-22T14:49:32","slug":"%e5%85%b3%e4%ba%8eopen-shift-%e4%b8%ad%e5%ba%94%e7%94%a8%e7%ae%a1%e7%90%86%e9%83%a8%e7%bd%b2%e7%9a%84%e4%b8%80%e4%ba%9b%e7%ac%94%e8%ae%b0","status":"publish","type":"post","link":"https:\/\/92it.top\/?p=15200","title":{"rendered":"\u5173\u4e8eOpen Shift \u4e2d\u5e94\u7528\u7ba1\u7406\u90e8\u7f72\u7684\u4e00\u4e9b\u7b14\u8bb0"},"content":{"rendered":"\n<p><strong>\u5199\u5728\u524d\u9762<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u56e0\u4e3a\u53c2\u52a0\u8003\u8bd5\uff0c\u4f1a\u9646\u7eed\u5206\u4eab\u4e00\u4e9b OpenShift \u7684\u7b14\u8bb0\uff0c\u535a\u6587\u5185\u5bb9\u4e3a\u4ecb\u7ecd openshift \u4e0d\u540c\u7684\u521b\u5efa\u5e94\u7528\u7684\u65b9\u5f0f\uff0c\u5305\u62ec\uff1a<\/p>\n\n\n\n<ul>\n<li>\u57fa\u4e8e IS \u521b\u5efa\u5e94\u7528<\/li>\n\n\n\n<li>\u57fa\u4e8e\u955c\u50cf\u521b\u5efa\u5e94\u7528<\/li>\n\n\n\n<li>\u57fa\u4e8e\u6e90\u7801\u548c image \u521b\u5efa\u5e94\u7528<\/li>\n\n\n\n<li>\u57fa\u4e8e\u6e90\u7801\u548c IS \u521b\u5efa\u5e94\u7528<\/li>\n\n\n\n<li>\u57fa\u4e8e\u6a21\u677f\u521b\u5efa\u5e94\u7528<\/li>\n<\/ul>\n\n\n\n<p>\u5b66\u4e60\u73af\u5883\u4e3a openshift v3 \u7684\u7248\u672c\uff0c\u6709\u4e9b\u65e7\uff0c\u8fd9\u91cc\u5982\u679c\u4e13\u95e8\u5b66\u4e60 openshift \uff0c\u5efa\u8bae\u5b66\u4e60 v4 \u7248\u672c\u3002<\/p>\n\n\n\n<p><strong>\u5e94\u7528\u521b\u5efa<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u4e3a\u4e86\u5728 OpenShift \u4e2d\u521b\u5efa\u65b0\u5e94\u7528\u7a0b\u5e8f\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528 oc new-app \u547d\u4ee4\u521b\u5efa\u5e94\u7528\uff0c\u4f7f\u7528 &#8211;strategy \u6807\u5fd7\u6765\u6307\u5b9a\u8981\u4f7f\u7528\u7684\u6784\u5efa\u7b56\u7565\u3002\u2013strategy \u6807\u5fd7\u53ef\u4ee5\u91c7\u7528\u591a\u4e2a\u503c\uff0c\u5305\u62ec\uff1a<\/p>\n\n\n\n<ul>\n<li>docker\uff1a\u6b64\u7b56\u7565\u4ece Dockerfile \u6784\u5efa\u5e94\u7528\u7a0b\u5e8f\u3002<\/li>\n\n\n\n<li>source\uff1a\u6b64\u7b56\u7565\u4f7f\u7528 Source-to-Image (S2I) \u5de5\u5177\u4ece\u6e90\u4ee3\u7801\u6784\u5efa\u5e94\u7528\u7a0b\u5e8f\u3002<\/li>\n\n\n\n<li>pipeline\uff1a\u6b64\u7b56\u7565\u4f7f\u7528 Jenkins \u7ba1\u9053\u6784\u5efa\u5e94\u7528\u7a0b\u5e8f\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u4f7f\u7528\u4e86 &#8211;strategy=source \u6807\u5fd7\uff0c\u8fd9\u610f\u5473\u7740 OpenShift \u5c06\u4f7f\u7528 S2I \u5de5\u5177\u4ece\u6e90\u4ee3\u7801\u6784\u5efa\u5e94\u7528\u7a0b\u5e8f\u3002S2I \u662f OpenShift \u4e2d\u7684\u4e00\u4e2a\u5de5\u5177\uff0c\u5b83\u5141\u8bb8\u5f00\u53d1\u4eba\u5458\u4ece\u4ed6\u4eec\u7684\u6e90\u4ee3\u7801\u6784\u5efa\u53ef\u91cd\u73b0\u7684 Docker \u955c\u50cf\u3002S2I \u901a\u8fc7\u63d0\u4f9b\u6784\u5efa\u548c\u8fd0\u884c\u5bb9\u5668\u5e94\u7528\u7a0b\u5e8f\u7684\u6846\u67b6\u7b80\u5316\u4e86\u6784\u5efa\u955c\u50cf\u7684\u8fc7\u7a0b\u3002<\/p>\n\n\n\n<p>S2I \u7684\u5de5\u4f5c\u539f\u7406\u662f\u5c06\u60a8\u7684\u6e90\u4ee3\u7801\u4e0e\u57fa\u7840\u955c\u50cf\u7ed3\u5408\u8d77\u6765\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u955c\u50cf\uff0c\u8be5\u955c\u50cf\u53ef\u4ee5\u5728\u5bb9\u5668\u4e2d\u8fd0\u884c\u3002\u57fa\u7840\u955c\u50cf\u4e3a\u60a8\u7684\u5e94\u7528\u7a0b\u5e8f\u63d0\u4f9b\u8fd0\u884c\u65f6\u73af\u5883\uff0c\u800c\u6e90\u4ee3\u7801\u5219\u63d0\u4f9b\u5e94\u7528\u7a0b\u5e8f\u4ee3\u7801\u3002S2I \u8fd8\u5141\u8bb8\u60a8\u901a\u8fc7\u63d0\u4f9b\u53ef\u4ee5\u5728\u6784\u5efa\u8fc7\u7a0b\u4e2d\u8fd0\u884c\u7684\u811a\u672c\u6765\u81ea\u5b9a\u4e49\u6784\u5efa\u8fc7\u7a0b\u3002<\/p>\n\n\n\n<p>\u8981\u5728 OpenShift \u4e2d\u521b\u5efa S2I \u6784\u5efa\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528 oc new-app \u547d\u4ee4\u548c &#8211;strategy=source \u6807\u5fd7\u3002\u8fd9\u5c06\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u6784\u5efa\u914d\u7f6e\uff0c\u8be5\u914d\u7f6e\u4f7f\u7528 S2I \u6784\u5efa\u60a8\u7684\u5e94\u7528\u7a0b\u5e8f\u3002\u7136\u540e\uff0c\u60a8\u53ef\u4ee5\u5c06\u6e90\u4ee3\u7801\u63a8\u9001\u5230\u6784\u5efa\u914d\u7f6e\u4e2d\uff0cOpenShift \u5c06\u81ea\u52a8\u4e3a\u60a8\u6784\u5efa\u4e00\u4e2a\u65b0\u7684\u955c\u50cf\u3002<\/p>\n\n\n\n<p>\u4ee5\u4e0b\u662f\u4f7f\u7528 oc new-app \u547d\u4ee4\u5728 OpenShift \u4e2d\u521b\u5efa S2I \u6784\u5efa\u7684\u793a\u4f8b\uff1a<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"600\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-541-1024x600.png\" alt=\"\" class=\"wp-image-15202\" style=\"width:484px;height:auto\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-541-1024x600.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-541-300x176.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-541-768x450.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-541-1536x900.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-541-830x487.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-541-230x135.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-541-350x205.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-541-480x281.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2024\/05\/image-541.png 1600w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n<p><strong>\u57fa\u4e8e IS \u521b\u5efa\u5e94\u7528<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\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=mysql   -i  mysql:latest  -e  MYSQL_ROOT_PASSWORD=redhat   <\/pre>\n\n\n\n<p>\u4f7f\u7528 <code>-i, --image-stream<\/code> \u6307\u5b9a IS \u7684\u955c\u50cf\u4f4d\u7f6e<\/p>\n\n\n\n<p>\u8981\u5728 OpenShift \u4e0a\u521b\u5efa\u4e00\u4e2a\u57fa\u4e8e ImageStream (IS) \u7684\u5e94\u7528\uff0c\u53ef\u4ee5\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u8fdb\u884c\u64cd\u4f5c\uff1a<\/p>\n\n\n\n<ul>\n<li>1.\u521b\u5efa\u4e00\u4e2a\u65b0\u9879\u76ee\u6216\u9009\u62e9\u4e00\u4e2a\u73b0\u6709\u9879\u76ee\u3002<\/li>\n\n\n\n<li>2.\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa\u4e00\u4e2a ImageStream\uff1a<\/li>\n<\/ul>\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=\"\">  # \u8fd9\u5c06\u5728\u5f53\u524d\u9879\u76ee\u4e2d\u521b\u5efa\u4e00\u4e2a\u6307\u5b9a\u540d\u79f0\u7684\u65b0 ImageStream\u3002\n   oc create is &lt;imagestream-name><\/pre>\n\n\n\n<ul>\n<li>3.\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u5c06\u955c\u50cf\u5bfc\u5165 ImageStream\uff1a<\/li>\n<\/ul>\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=\"\">   #\u8fd9\u5c06\u4ece\u6307\u5b9a\u7684 URL \u5bfc\u5165\u955c\u50cf\u5230 ImageStream \u4e2d\u3002\n   oc import-image &lt;imagestream-name> --from=&lt;image-url> --confirm\n<\/pre>\n\n\n\n<ul>\n<li>4.\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa\u4e00\u4e2a\u65b0\u5e94\u7528\uff1a<\/li>\n<\/ul>\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 -i &lt;imagestream-name><\/pre>\n\n\n\n<p>\u8fd9\u5c06\u521b\u5efa\u4e00\u4e2a\u57fa\u4e8e ImageStream \u7684\u65b0\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n\n\n\n<p>\u5728\u6b64\u8fc7\u7a0b\u4e2d\uff0c\u5c06\u81ea\u52a8\u751f\u6210\u591a\u4e2a API \u8d44\u6e90\u5bf9\u8c61\uff0c\u5305\u62ec\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=\"\">ImageStream\nImageStreamTag\nDeploymentConfig\nDeployment\nReplicationcontroller\nReplicaset\nService\nRoute(\u8def\u7531\u5bf9\u8c61\u9700\u8981\u624b\u52a8\u521b\u5efa)<\/pre>\n\n\n\n<p>\u5f53\u955c\u50cf\u88ab\u5bfc\u5165 ImageStream \u65f6\uff0c\u5c06\u521b\u5efa ImageStream \u548c ImageStreamTag \u8d44\u6e90\u3002\u5f53\u521b\u5efa\u65b0\u5e94\u7528\u7a0b\u5e8f\u65f6\uff0c\u5c06\u521b\u5efa DeploymentConfig\u3001Service \u548c Route \u8d44\u6e90\u3002<\/p>\n\n\n\n<p>\u8fd9\u91cc\u6211\u4eec\u770b\u4e00\u4e2a Demo\uff0c\u521b\u5efa\u4e00\u4e2a ImageStream\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=\"\">\u250c\u2500\u2500[root@vms16.liruilongs.github.io]-[~]\n\u2514\u2500$   oc create is myimagestream\nimagestream.image.openshift.io\/myimagestream created\n<\/pre>\n\n\n\n<p>\u5c06\u955c\u50cf\u5bfc\u5165 ImageStream\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=\"\">\u250c\u2500\u2500[root@vms16.liruilongs.github.io]-[~]\n\u2514\u2500$   oc import-image myimagestream --from=docker.io\/nginx --confirm\nimagestream.image.openshift.io\/myimagestream imported\n\nName:                   myimagestream\nNamespace:              myproject\nCreated:                14 seconds ago\nLabels:                 &lt;none>\nAnnotations:            openshift.io\/image.dockerRepositoryCheck=2023-04-16T03:21:19Z\nDocker Pull Spec:       172.30.1.1:5000\/myproject\/myimagestream\nImage Lookup:           local=false\nUnique Images:          1\nTags:                   1\n\nlatest\n  tagged from docker.io\/nginx\n\n  * docker.io\/nginx@sha256:f2fee5c7194cbbfb9d2711fa5de094c797a42a51aa42b0c8ee8ca31547c872b1\n      Less than a second ago\n\nImage Name:     myimagestream:latest\nDocker Image:   docker.io\/nginx@sha256:f2fee5c7194cbbfb9d2711fa5de094c797a42a51aa42b0c8ee8ca31547c872b1\nName:           sha256:f2fee5c7194cbbfb9d2711fa5de094c797a42a51aa42b0c8ee8ca31547c872b1\nCreated:        Less than a second ago\nAnnotations:    image.openshift.io\/dockerLayersOrder=ascending\nImage Size:     57.01MB in 6 layers\nLayers:         31.42MB sha256:26c5c85e47da3022f1bdb9a112103646c5c29517d757e95426f16e4bd9533405\n                25.58MB sha256:4f3256bdf66bf00bcec08043e67a80981428f0e0de12f963eac3c753b14d101d\n                626B    sha256:2019c71d56550b97ce01e0b6ef8e971fec705186f2927d2cb109ac3e18edb0ac\n                958B    sha256:8c767bdbc9aedd4bbf276c6f28aad18251cceacb768967c5702974ae1eac23cd\n                773B    sha256:78e14bb05fd35b58587cd0c5ca2c2eb12b15031633ec30daa21c0ea3d2bb2a15\n                1.406kB sha256:75576236abf5959ff23b741ed8c4786e244155b9265db5e6ecda9d8261de529f\nImage Created:  3 days ago\nAuthor:         &lt;none>\nArch:           amd64\nEntrypoint:     \/docker-entrypoint.sh\nCommand:        nginx -g daemon off;\nWorking Dir:    &lt;none>\nUser:           &lt;none>\nExposes Ports:  80\/tcp\nDocker Labels:  maintainer=NGINX Docker Maintainers &lt;docker-maint@nginx.com>\nEnvironment:    PATH=\/usr\/local\/sbin:\/usr\/local\/bin:\/usr\/sbin:\/usr\/bin:\/sbin:\/bin\n                NGINX_VERSION=1.23.4\n                NJS_VERSION=0.7.11\n                PKG_RELEASE=1~bullseye\n<\/pre>\n\n\n\n<p>\u57fa\u4e8e ImageStream \u521b\u5efa\u4e00\u4e2a\u65b0\u5e94\u7528\u7a0b\u5e8f\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=\"\">\u250c\u2500\u2500[root@vms16.liruilongs.github.io]-[~]\n\u2514\u2500$   oc new-app myimagestream\n--> Found image 6efc10a (3 days old) in image stream \"myproject\/myimagestream\" under tag \"latest\" for \"myimagestream\"\n\n    * This image will be deployed in deployment config \"myimagestream\"\n    * Port 80\/tcp will be load balanced by service \"myimagestream\"\n      * Other containers can access this service through the hostname \"myimagestream\"\n    * WARNING: Image \"myproject\/myimagestream:latest\" runs as the 'root' user which may not be permitted by your cluster administrator\n\n--> Creating resources ...\n    deploymentconfig.apps.openshift.io \"myimagestream\" created\n    service \"myimagestream\" created\n--> Success\n    Application is not exposed. You can expose services to the outside world by executing one or more of the commands below:\n     'oc expose svc\/myimagestream'\n    Run 'oc status' to view your app.\n<\/pre>\n\n\n\n<p>\u9ed8\u8ba4\u751f\u6210\u7684\u8d44\u6e90\uff0c\u53ef\u4ee5\u770b\u5230\u901a\u8fc7 IS \u521b\u5efa\u5e94\u7528\u4f1a\u751f\u6210<\/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=\"\">\u250c\u2500\u2500[root@vms16.liruilongs.github.io]-[~]\n\u2514\u2500$oc get all\nNAME                         READY     STATUS              RESTARTS   AGE\npod\/myimagestream-1-9gfgs    0\/1       ContainerCreating   0          23s\npod\/myimagestream-1-deploy   1\/1       Running             0          24s\n\nNAME                                    DESIRED   CURRENT   READY     AGE\nreplicationcontroller\/myimagestream-1   1         1         0         24s\n\nNAME                    TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)   AGE\nservice\/myimagestream   ClusterIP   172.30.226.178   &lt;none>        80\/TCP    24s\n\nNAME                      DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE\ndeployment.apps\/testpod   0         0         0            0           322d\n\nNAME                                 DESIRED   CURRENT   READY     AGE\nreplicaset.apps\/testpod-6fd8cb8d9f   0         0         0         322d\n\nNAME                                               REVISION   DESIRED   CURRENT   TRIGGERED BY\ndeploymentconfig.apps.openshift.io\/myimagestream   1          1         1         config,image(myimagestream:latest)\n\nNAME                                           DOCKER REPO                               TAGS      UPDATED\nimagestream.image.openshift.io\/myimagestream   172.30.1.1:5000\/myproject\/myimagestream   latest    46 seconds ago\n\u250c\u2500\u2500[root@vms16.liruilongs.github.io]-[~]\n\u2514\u2500$\n<\/pre>\n\n\n\n<p><strong>\u57fa\u4e8e\u955c\u50cf\u521b\u5efa\u5e94\u7528<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\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 --docker-image=registry.lab.example.com\/openshift\/hello-openshift --name=hello   <\/pre>\n\n\n\n<p>\u5728 OpenShift \u4e0a\u57fa\u4e8e Docker \u955c\u50cf\u521b\u5efa\u5e94\u7528\uff0c\u53ef\u4ee5\u4f7f\u7528oc new-app\u547d\u4ee4\u3002\u8be5\u547d\u4ee4\u5c06\u57fa\u4e8e\u63d0\u4f9b\u7684 Docker \u955c\u50cf\u521b\u5efa\u65b0\u7684\u5e94\u7528\u7a0b\u5e8f\u548c\u6784\u5efa\u914d\u7f6e\u3002<\/p>\n\n\n\n<p>\u5728\u521b\u5efa\u8fc7\u7a0b\u4e2d\uff0cOpenShift \u5c06\u81ea\u52a8\u751f\u6210\u591a\u4e2a API \u8d44\u6e90\u5bf9\u8c61\uff0c\u5305\u62ec<\/p>\n\n\n\n<ul>\n<li>DeploymentConfig<\/li>\n\n\n\n<li>ImageStream<\/li>\n\n\n\n<li>Replicationcontroller<\/li>\n\n\n\n<li><\/li>\n\n\n\n<li>router(\u8def\u7531\u9700\u8981\u81ea\u5df1\u521b\u5efa)<\/li>\n<\/ul>\n\n\n\n<p>\u8fd9\u4e9b\u5bf9\u8c61\u7528\u4e8e\u7ba1\u7406\u5e94\u7528\u7a0b\u5e8f\u53ca\u5176\u76f8\u5173\u8d44\u6e90\u3002<\/p>\n\n\n\n<p>\u770b\u4e00\u4e2aDemo<\/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=\"\">[root@master ~]# oc project samples\nNow using project \"samples\" on server \"https:\/\/master.lab.example.com:443\".\n<\/pre>\n\n\n\n<p>\u5728\u521b\u5efa\u7684\u9879\u76ee\u4e0b\u901a\u8fc7\u955c\u50cf\u6784\u5efa\u5e94\u7528<\/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=\"\">[root@master ~]# oc new-app --docker-image=registry.lab.example.com\/openshift\/hello-openshift --name=greeter\n--> Found Docker image 7af3297 (4 years old) from registry.lab.example.com for \"registry.lab.example.com\/openshift\/hello-openshift\"\n\n    * An image stream will be created as \"greeter:latest\" that will track this image\n    * This image will be deployed in deployment config \"greeter\"\n    * Ports 8080\/tcp, 8888\/tcp will be load balanced by service \"greeter\"\n      * Other containers can access this service through the hostname \"greeter\"\n\n--> Creating resources ...\n    imagestream \"greeter\" created\n    deploymentconfig \"greeter\" created\n    service \"greeter\" created\n--> Success\n    Application is not exposed. You can expose services to the outside world by executing one or more of the commands below:\n     'oc expose svc\/greeter'\n    Run 'oc status' to view your app.\n<\/pre>\n\n\n\n<p>\u67e5\u770b\u521b\u5efa\u8fc7\u7a0b<\/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=\"\">[root@master ~]# oc status\nIn project samples on server https:\/\/master.lab.example.com:443\n\nsvc\/greeter - 172.30.106.99 ports 8080, 8888\n  dc\/greeter deploys istag\/greeter:latest\n    deployment #1 deployed 9 seconds ago - 1 pod\n\n\n2 infos identified, use 'oc status -v' to see details.\n[root@master ~]# oc status -v\nIn project samples on server https:\/\/master.lab.example.com:443\n\nsvc\/greeter - 172.30.106.99 ports 8080, 8888\n  dc\/greeter deploys istag\/greeter:latest\n    deployment #1 deployed about a minute ago - 1 pod\n\nInfo:\n  * dc\/greeter has no readiness probe to verify pods are ready to accept traffic or ensure deployment is successful.\n    try: oc set probe dc\/greeter --readiness ...\n  * dc\/greeter has no liveness probe to verify pods are still running.\n    try: oc set probe dc\/greeter --liveness ...\n\nView details with 'oc describe &lt;resource>\/&lt;name>' or list everything with 'oc get all'.\n<\/pre>\n\n\n\n<p>\u67e5\u770b\u901a\u955c\u50cf\u76f4\u63a5\u6784\u5efa\u751f\u6210\u7684 API \u8d44\u6e90\u5bf9\u8c61<\/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=\"\">[root@master ~]# oc get all\nNAME                        REVISION   DESIRED   CURRENT   TRIGGERED BY\ndeploymentconfigs\/greeter   1          1         1         config,image(greeter:latest)\n\nNAME                   DOCKER REPO                                        TAGS      UPDATED\nimagestreams\/greeter   docker-registry.default.svc:5000\/samples\/greeter   latest    About a minute ago\n\nNAME                 READY     STATUS    RESTARTS   AGE\npo\/greeter-1-gm5qg   1\/1       Running   0          1m\n\nNAME           DESIRED   CURRENT   READY     AGE\nrc\/greeter-1   1         1         1         1m\n\nNAME          TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)             AGE\nsvc\/greeter   ClusterIP   172.30.106.99   &lt;none>        8080\/TCP,8888\/TCP   1m\n[root@master ~]#\n<\/pre>\n\n\n\n<p>\u6709\u4e9b\u8def\u7531\u53ef\u80fd\u9700\u8981 TSL \u7b49<\/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=\"\">[root@master ~]# .\/gencert.sh greeter.apps.lab.example.com\nGenerating a private key...\nGenerating RSA private key, 2048 bit long modulus\n............................................................................................+++\n....................+++\ne is 65537 (0x10001)\n\nGenerating a CSR...\n\nGenerating a certificate...\nSignature ok\nsubject=\/C=US\/ST=NC\/L=Raleigh\/O=RedHat\/OU=RHT\/CN=greeter.apps.lab.example.com\nGetting Private key\n\nDONE.\n\n<\/pre>\n\n\n\n<p>\u521b\u5efa\u4e00\u4e2a\u652f\u6301 https \u7684\u8def\u7531<\/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=\"\">[root@master ~]# oc get svc\nNAME      TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)             AGE\ngreeter   ClusterIP   172.30.106.99   &lt;none>        8080\/TCP,8888\/TCP   6m\n[root@master ~]# oc create route edge --service=greeter  --hostname=greeter.apps.lab.example.com --key=greeter.apps.lab.example.com.key --cert=greeter.apps.lab.example.com.crt\nroute \"greeter\" created\n[root@master ~]# oc get route\nNAME      HOST\/PORT                      PATH      SERVICES   PORT       TERMINATION   WILDCARD\ngreeter   greeter.apps.lab.example.com             greeter    8080-tcp   edge          None\n[root@master ~]# curl greeter.apps.lab.example.com\n<\/pre>\n\n\n\n<p>\u751f\u6210\u8bc1\u4e66\u6587\u4ef6<\/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=\"\">[root@master ~]# cat gencert.sh\n#!\/bin\/bash\n\necho \"Generating a private key...\"\nopenssl genrsa -out $1.key 2048\necho\n\necho \"Generating a CSR...\"\nopenssl req -new -key $1.key -out $1.csr -subj \"\/C=US\/ST=NC\/L=Raleigh\/O=RedHat\/OU=RHT\/CN=$1\"\necho\n\necho \"Generating a certificate...\"\nopenssl x509 -req -days 366 -in $1.csr -signkey $1.key -out $1.crt\necho\necho  \"DONE.\"\necho\n[root@master ~]#\n<\/pre>\n\n\n\n<p><strong>\u57fa\u4e8e\u6e90\u7801\u548c image \u521b\u5efa\u5e94\u7528<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\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=\"\">[root@master ~]# oc new-app registry.lab.example.com\/rhscl\/php-70-rhel7~http:\/\/services.lab.example.com\n\/php-helloworld\n--> Found Docker image c101534 (5 years old) from registry.lab.example.com for \"registry.lab.example.com\/rhscl\/php-70-rhel7\"\n\n    Apache 2.4 with PHP 7.0\n    -----------------------\n    PHP 7.0 available as docker container is a base platform for building and running various PHP 7.0 applications and frameworks. PHP is an HTML-embedded scripting language. PHP attempts to make it easy for developers to write dynamically generated web pages. PHP also offers built-in database integration for several commercial and non-commercial database management systems, so writing a database-enabled webpage with PHP is fairly simple. The most common use of PHP coding is probably as a replacement for CGI scripts.\n\n    Tags: builder, php, php70, rh-php70\n\n    * An image stream will be created as \"php-70-rhel7:latest\" that will track the source image\n    * A source build using source code from http:\/\/services.lab.example.com\/php-helloworld will be created\n      * The resulting image will be pushed to image stream \"php-helloworld:latest\"\n      * Every time \"php-70-rhel7:latest\" changes a new build will be triggered\n    * This image will be deployed in deployment config \"php-helloworld\"\n    * Port 8080\/tcp will be load balanced by service \"php-helloworld\"\n      * Other containers can access this service through the hostname \"php-helloworld\"\n\n--> Creating resources ...\n    imagestream \"php-70-rhel7\" created\n    imagestream \"php-helloworld\" created\n    buildconfig \"php-helloworld\" created\n    deploymentconfig \"php-helloworld\" created\n    service \"php-helloworld\" created\n--> Success\n    Build scheduled, use 'oc logs -f bc\/php-helloworld' to track its progress.\n    Application is not exposed. You can expose services to the outside world by executing one or more of the commands below:\n     'oc expose svc\/php-helloworld'\n    Run 'oc status' to view your app.\n[root@master ~]# oc logs -f bc\/php-helloworld\nCloning \"http:\/\/services.lab.example.com\/php-helloworld\" ...\n        Commit: 6d61e75647124d02aa761f994532ef29eae46f8e (Establish remote repository)\n        Author: root &lt;root@services.lab.example.com>\n        Date:   Thu Aug 9 11:33:29 2018 -0700\n---> Installing application source...\n\nPushing image docker-registry.default.svc:5000\/rome\/php-helloworld:latest ...\nPushed 0\/6 layers, 1% complete\nPushed 1\/6 layers, 25% complete\nPushed 2\/6 layers, 42% complete\nPushed 3\/6 layers, 59% complete\nPushed 4\/6 layers, 81% complete\nPushed 5\/6 layers, 100% complete\nPushed 6\/6 layers, 100% complete\nPush successful\n[root@master ~]#\n<\/pre>\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=\"\">[root@master ~]# oc get all\nNAME                               REVISION   DESIRED   CURRENT   TRIGGERED BY\ndeploymentconfigs\/php-helloworld   1          1         1         config,image(php-helloworld:latest)\n\nNAME                          TYPE      FROM      LATEST\nbuildconfigs\/php-helloworld   Source    Git       1\n\nNAME                      TYPE      FROM          STATUS     STARTED         DURATION\nbuilds\/php-helloworld-1   Source    Git@6d61e75   Complete   2 minutes ago   1m12s\n\nNAME                          DOCKER REPO                                            TAGS      UPDATED\nimagestreams\/php-70-rhel7     docker-registry.default.svc:5000\/rome\/php-70-rhel7     latest    2 minutes ago\nimagestreams\/php-helloworld   docker-registry.default.svc:5000\/rome\/php-helloworld   latest    About a minute ago\n\nNAME                        READY     STATUS      RESTARTS   AGE\npo\/php-helloworld-1-8hvvn   1\/1       Running     0          1m\npo\/php-helloworld-1-build   0\/1       Completed   0          2m\n\nNAME                  DESIRED   CURRENT   READY     AGE\nrc\/php-helloworld-1   1         1         1         1m\n\nNAME                 TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)    AGE\nsvc\/php-helloworld   ClusterIP   172.30.69.166   &lt;none>        8080\/TCP   2m\n[root@master ~]#\n<\/pre>\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=\"\">[root@master ~]# oc expose svc\/php-helloworld  --hostname=hellophp.apps.lab.example.com\nroute \"php-helloworld\" exposed\n[root@master ~]# oc get route\nNAME             HOST\/PORT                       PATH      SERVICES         PORT       TERMINATION   WILDCARD\nphp-helloworld   hellophp.apps.lab.example.com             php-helloworld   8080-tcp                 None\n[root@master ~]# curl hellophp.apps.lab.example.com\nHello, World! php version is 7.0.10\n[root@master ~]#\n<\/pre>\n\n\n\n<p>\u6301\u7eed\u6784\u5efa<\/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=\"\">[root@master php-helloworld]# oc start-build php-helloworld\nbuild \"php-helloworld-2\" started\n[root@master php-helloworld]# oc get dc\nNAME             REVISION   DESIRED   CURRENT   TRIGGERED BY\nphp-helloworld   2          1         0         config,image(php-helloworld:latest)\n[root@master php-helloworld]# oc get build\nNAME               TYPE      FROM          STATUS     STARTED          DURATION\nphp-helloworld-1   Source    Git@6d61e75   Complete   10 minutes ago   1m12s\nphp-helloworld-2   Source    Git@2210bc1   Complete   15 seconds ago   8s\n<\/pre>\n\n\n\n<p><strong>\u57fa\u4e8e\u6e90\u7801\u548c IS \u521b\u5efa\u5e94\u7528<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\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=hello    -i    php:7.0    http:\/\/registry.lab.example.com\/scaling   <\/pre>\n\n\n\n<p>\u8fd9\u91cc\u5b9e\u9645\u4e0a\u548c\u4e0a\u9762\u7684\u4e00\u6837\uff0c\u4e0d\u518d\u8bf4\u660e<\/p>\n\n\n\n<p><strong>\u57fa\u4e8e\u6a21\u677f\u521b\u5efa\u5e94\u7528<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\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    --template=ruby-helloworld-sample    --param=MYSQL_USER=admin $    oc    new-app    --file=.\/example\/myapp\/template.json    --param=MYSQL_USER=admi n  <\/pre>\n\n\n\n<p>\u4ee5\u4e0b\u662f\u4f7f\u7528\u6a21\u677f\u5728OpenShift\u4e2d\u521b\u5efa\u5e94\u7528\u7684\u6b65\u9aa4\uff1a<\/p>\n\n\n\n<ul>\n<li>\u4f7f\u7528 oc login \u547d\u4ee4\u767b\u5f55\u5230\u60a8\u7684OpenShift\u96c6\u7fa4\u3002<\/li>\n\n\n\n<li>\u4f7f\u7528 oc new-project \u547d\u4ee4\u521b\u5efa\u4e00\u4e2a\u65b0\u9879\u76ee\u3002<\/li>\n\n\n\n<li>\u4f7f\u7528 oc get templates -n openshift \u547d\u4ee4\u6d4f\u89c8\u53ef\u7528\u7684\u6a21\u677f\u3002<\/li>\n\n\n\n<li>\u9009\u62e9\u9002\u5408\u60a8\u9700\u6c42\u7684\u6a21\u677f\uff0c\u4f7f\u7528 oc new-app \u547d\u4ee4\u521b\u5efa\u4e00\u4e2a\u5e94\u7528\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528 -p \u6807\u5fd7\u6307\u5b9a\u6a21\u677f\u540d\u79f0\u548c\u4efb\u4f55\u53c2\u6570\u503c\u3002<\/li>\n\n\n\n<li>\u4f7f\u7528 oc get pods \u547d\u4ee4\u76d1\u89c6\u90e8\u7f72\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u5f53\u60a8\u4ece\u6a21\u677f\u521b\u5efa\u5e94\u7528\u65f6\uff0cOpenShift\u4f1a\u521b\u5efa\u591a\u4e2a\u8d44\u6e90\u5bf9\u8c61\uff0c\u5305\u62ecDeploymentConfig\u3001Service\u3001Route\u548cImageStream\u3002\u8fd9\u4e9b\u5bf9\u8c61\u4e00\u8d77\u5de5\u4f5c\uff0c\u4ee5\u90e8\u7f72\u548c\u516c\u5f00\u60a8\u7684\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n\n\n\n<p>DeploymentConfig\u5bf9\u8c61\u5b9a\u4e49\u4e86\u5e94\u7528\u7a0b\u5e8f\u7684\u90e8\u7f72\u65b9\u5f0f\uff0c\u5305\u62ec\u526f\u672c\u6570\u3001\u8981\u4f7f\u7528\u7684\u5bb9\u5668\u6620\u50cf\u4ee5\u53ca\u4efb\u4f55\u73af\u5883\u53d8\u91cf\u6216\u5377\u6302\u8f7d\u3002Service\u5bf9\u8c61\u4e3a\u60a8\u7684\u5e94\u7528\u7a0b\u5e8f\u63d0\u4f9b\u7a33\u5b9a\u7684IP\u5730\u5740\u548cDNS\u540d\u79f0\uff0c\u5141\u8bb8\u5176\u4ed6\u670d\u52a1\u4e0e\u5176\u901a\u4fe1\u3002Route\u5bf9\u8c61\u5c06\u60a8\u7684\u5e94\u7528\u7a0b\u5e8f\u516c\u5f00\u7ed9\u5916\u90e8\u4e16\u754c\uff0c\u63d0\u4f9b\u7528\u6237\u53ef\u4ee5\u8bbf\u95ee\u7684URL\u3002\u6700\u540e\uff0cImageStream\u5bf9\u8c61\u8ddf\u8e2a\u5e94\u7528\u7a0b\u5e8f\u4f7f\u7528\u7684\u5bb9\u5668\u6620\u50cf\uff0c\u5141\u8bb8\u60a8\u56de\u6eda\u5230\u4ee5\u524d\u7684\u7248\u672c(\u5982\u679c\u9700\u8981)\u3002<\/p>\n\n\n\n<p>\u4e00\u4e2a \u6a21\u677f yaml \u6587\u4ef6 Demo<\/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=\"\">\n[root@master ~]# cat gogs-temp.yaml\nkind: Template\napiVersion: v1\nmetadata:\n  annotations:\n    description: The Gogs git server (https:\/\/gogs.io\/)\n    tags: instant-app,gogs,go,golang\n  name: gogs\nobjects:\n- kind: PersistentVolume\n  apiVersion: v1\n  metadata:\n    name: gogs-postgres-data\n  spec:\n    capacity:\n      storage: 2Gi\n    accessModes:\n    - ReadWriteMany\n    nfs:\n      path: \/exports\/gogs-postgres-data\n      server: services.lab.example.com\n    persistentVolumeReclaimPolicy: Recycle\n\n- kind: PersistentVolume\n  apiVersion: v1\n  metadata:\n    name: gogs-data\n  spec:\n    capacity:\n      storage: 1Gi\n    accessModes:\n    - ReadWriteMany\n    nfs:\n      path: \/exports\/gogs-data\n      server: services.lab.example.com\n    persistentVolumeReclaimPolicy: Recycle\n\n- kind: ServiceAccount\n  apiVersion: v1\n  metadata:\n    creationTimestamp: null\n    labels:\n      app: ${APPLICATION_NAME}\n    name: ${APPLICATION_NAME}\n- kind: Service\n  apiVersion: v1\n  metadata:\n    annotations:\n      description: Exposes the database server\n    name: ${APPLICATION_NAME}-postgresql\n    labels:\n      app: ${APPLICATION_NAME}\n  spec:\n    ports:\n    - name: postgresql\n      port: 5432\n      targetPort: 5432\n    selector:\n      name: ${APPLICATION_NAME}-postgresql\n- kind: DeploymentConfig\n  apiVersion: v1\n  metadata:\n    annotations:\n      description: Defines how to deploy the database\n    name: ${APPLICATION_NAME}-postgresql\n    labels:\n      app: ${APPLICATION_NAME}\n  spec:\n    replicas: 1\n    selector:\n      name: ${APPLICATION_NAME}-postgresql\n    strategy:\n      type: Recreate\n    template:\n      metadata:\n        labels:\n          name: ${APPLICATION_NAME}-postgresql\n        name: ${APPLICATION_NAME}-postgresql\n      spec:\n        serviceAccountName: ${APPLICATION_NAME}\n        containers:\n        - env:\n          - name: POSTGRESQL_USER\n            value: ${DATABASE_USER}\n          - name: POSTGRESQL_PASSWORD\n            value: ${DATABASE_PASSWORD}\n          - name: POSTGRESQL_DATABASE\n            value: ${DATABASE_NAME}\n          - name: POSTGRESQL_MAX_CONNECTIONS\n            value: ${DATABASE_MAX_CONNECTIONS}\n          - name: POSTGRESQL_SHARED_BUFFERS\n            value: ${DATABASE_SHARED_BUFFERS}\n          - name: POSTGRESQL_ADMIN_PASSWORD\n            value: ${DATABASE_ADMIN_PASSWORD}\n          image: ' '\n          livenessProbe:\n            initialDelaySeconds: 30\n            tcpSocket:\n              port: 5432\n            timeoutSeconds: 1\n            failureThreshold: 10\n            periodSeconds: 20\n          name: postgresql\n          ports:\n          - containerPort: 5432\n          readinessProbe:\n            exec:\n              command:\n              - \/bin\/sh\n              - -i\n              - -c\n              - psql -h 127.0.0.1 -U ${POSTGRESQL_USER} -q -d ${POSTGRESQL_DATABASE} -c 'SELECT 1'\n            initialDelaySeconds: 5\n            timeoutSeconds: 1\n            failureThreshold: 10\n          resources:\n            limits:\n              memory: 512Mi\n          volumeMounts:\n          - mountPath: \/var\/lib\/pgsql\/data\n            name: gogs-postgres-data\n        volumes:\n        - name: gogs-postgres-data\n          persistentVolumeClaim:\n            claimName: gogs-postgres-data\n    triggers:\n    - imageChangeParams:\n        automatic: true\n        containerNames:\n        - postgresql\n        from:\n          kind: ImageStreamTag\n          name: postgresql:9.5\n          namespace: openshift\n      type: ImageChange\n    - type: ConfigChange\n- kind: Service\n  apiVersion: v1\n  metadata:\n    annotations:\n      description: The Gogs server's http port\n      service.alpha.openshift.io\/dependencies: '[{\"name\":\"${APPLICATION_NAME}-postgresql\",\"namespace\":\"\",\"kind\":\"Service\"}]'\n    labels:\n      app: ${APPLICATION_NAME}\n    name: ${APPLICATION_NAME}\n  spec:\n    ports:\n    - name: 3000-tcp\n      port: 3000\n      protocol: TCP\n      targetPort: 3000\n    selector:\n      app: ${APPLICATION_NAME}\n      deploymentconfig: ${APPLICATION_NAME}\n    sessionAffinity: None\n    type: ClusterIP\n  status:\n    loadBalancer: {}\n- kind: Route\n  apiVersion: v1\n  id: ${APPLICATION_NAME}-http\n  metadata:\n    annotations:\n      description: Route for application's http service.\n    labels:\n      app: ${APPLICATION_NAME}\n    name: ${APPLICATION_NAME}\n  spec:\n    host: ${HOSTNAME}\n    to:\n      name: ${APPLICATION_NAME}\n- kind: DeploymentConfig\n  apiVersion: v1\n  metadata:\n    labels:\n      app: ${APPLICATION_NAME}\n    name: ${APPLICATION_NAME}\n  spec:\n    replicas: 1\n    selector:\n      app: ${APPLICATION_NAME}\n      deploymentconfig: ${APPLICATION_NAME}\n    strategy:\n      resources: {}\n      rollingParams:\n        intervalSeconds: 1\n        maxSurge: 25%\n        maxUnavailable: 25%\n        timeoutSeconds: 600\n        updatePeriodSeconds: 1\n      type: Rolling\n    template:\n      metadata:\n        creationTimestamp: null\n        labels:\n          app: ${APPLICATION_NAME}\n          deploymentconfig: ${APPLICATION_NAME}\n      spec:\n        serviceAccountName: ${APPLICATION_NAME}\n        containers:\n        - image: \" \"\n          imagePullPolicy: Always\n          name: ${APPLICATION_NAME}\n          ports:\n          - containerPort: 3000\n            protocol: TCP\n          resources: {}\n          terminationMessagePath: \/dev\/termination-log\n          volumeMounts:\n          - name: gogs-data\n            mountPath: \/opt\/gogs\/data\n          - name: gogs-config\n            mountPath: \/etc\/gogs\/conf\n          readinessProbe:\n              httpGet:\n                path: \/\n                port: 3000\n                scheme: HTTP\n              initialDelaySeconds: 3\n              timeoutSeconds: 1\n              periodSeconds: 20\n              successThreshold: 1\n              failureThreshold: 10\n          livenessProbe:\n              httpGet:\n                path: \/\n                port: 3000\n                scheme: HTTP\n              initialDelaySeconds: 20\n              timeoutSeconds: 1\n              periodSeconds: 10\n              successThreshold: 1\n              failureThreshold: 10\n        dnsPolicy: ClusterFirst\n        restartPolicy: Always\n        securityContext: {}\n        terminationGracePeriodSeconds: 30\n        volumes:\n        - name: gogs-data\n          persistentVolumeClaim:\n            claimName: gogs-data\n        - name: gogs-config\n          configMap:\n            name: gogs-config\n            items:\n              - key: app.ini\n                path: app.ini\n    test: false\n    triggers:\n    - type: ConfigChange\n    - imageChangeParams:\n        automatic: true\n        containerNames:\n        - ${APPLICATION_NAME}\n        from:\n          kind: ImageStreamTag\n          name: ${APPLICATION_NAME}:${GOGS_VERSION}\n      type: ImageChange\n- kind: ImageStream\n  apiVersion: v1\n  metadata:\n    labels:\n      app: ${APPLICATION_NAME}\n    name: ${APPLICATION_NAME}\n  spec:\n    tags:\n    - name: \"${GOGS_VERSION}\"\n      from:\n        kind: DockerImage\n        name: services.lab.example.com\/openshiftdemos\/gogs:0.9.97\n      importPolicy: {\n            \"insecure\":true\n         }\n      annotations:\n        description: The Gogs git server docker image\n        tags: gogs,go,golang\n        version: \"${GOGS_VERSION}\"\n- kind: PersistentVolumeClaim\n  apiVersion: v1\n  metadata:\n    name: gogs-data\n    labels:\n      app: ${APPLICATION_NAME}\n  spec:\n    accessModes:\n      - ReadWriteMany\n    resources:\n      requests:\n        storage: ${GOGS_VOLUME_CAPACITY}\n- kind: PersistentVolumeClaim\n  apiVersion: v1\n  metadata:\n    name: gogs-postgres-data\n    labels:\n      app: ${APPLICATION_NAME}\n  spec:\n    accessModes:\n      - ReadWriteMany\n    resources:\n      requests:\n        storage: ${DB_VOLUME_CAPACITY}\n- kind: ConfigMap\n  apiVersion: v1\n  metadata:\n    name: gogs-config\n    labels:\n      app: ${APPLICATION_NAME}\n  data:\n    app.ini: |\n      RUN_MODE = prod\n      RUN_USER = gogs\n\n      [database]\n      DB_TYPE  = postgres\n      HOST     = ${APPLICATION_NAME}-postgresql:5432\n      NAME     = ${DATABASE_NAME}\n      USER     = ${DATABASE_USER}\n      PASSWD   = ${DATABASE_PASSWORD}\n\n      [repository]\n      ROOT = \/opt\/gogs\/data\/repositories\n\n      [server]\n      ROOT_URL=http:\/\/${HOSTNAME}\n      SSH_DOMAIN=${HOSTNAME}\n\n      [security]\n      INSTALL_LOCK = ${INSTALL_LOCK}\n\n      [service]\n      ENABLE_CAPTCHA = false\n\n      [webhook]\n      SKIP_TLS_VERIFY = ${SKIP_TLS_VERIFY}\nparameters:\n- description: The name for the application.\n  name: APPLICATION_NAME\n  required: true\n  value: gogs\n- description: 'Custom hostname for http service route.  Leave blank for default hostname, e.g.: &lt;application-name>-&lt;project>.&lt;default-domain-suffix>'\n  name: HOSTNAME\n  required: true\n- description: Volume space available for data, e.g. 512Mi, 2Gi\n  name: GOGS_VOLUME_CAPACITY\n  required: true\n  value: 1Gi\n- description: Volume space available for postregs data, e.g. 512Mi, 2Gi\n  name: DB_VOLUME_CAPACITY\n  required: true\n  value: 2Gi\n- displayName: Database Username\n  from: gogs\n  value: gogs\n  name: DATABASE_USER\n- displayName: Database Password\n  from: '[a-zA-Z0-9]{8}'\n  value: gogs\n  name: DATABASE_PASSWORD\n- displayName: Database Name\n  name: DATABASE_NAME\n  value: gogs\n- displayName: Database Admin Password\n  from: '[a-zA-Z0-9]{8}'\n  generate: expression\n  name: DATABASE_ADMIN_PASSWORD\n- displayName: Maximum Database Connections\n  name: DATABASE_MAX_CONNECTIONS\n  value: \"100\"\n- displayName: Shared Buffer Amount\n  name: DATABASE_SHARED_BUFFERS\n  value: 12MB\n- name: GOGS_VERSION\n  displayName: Gogs Version\n  description: 'Version of the Gogs container image to be used (check the available version https:\/\/hub.docker.com\/r\/openshiftdemos\/gogs\/tags)'\n  value: \"0.9.97\"\n  required: true\n- name: INSTALL_LOCK\n  displayName: Installation lock\n  description: 'If set to true, installation (\/install) page will be disabled. Set to false if you want to run the installation wizard via web'\n  value: \"true\"\n- name: SKIP_TLS_VERIFY\n  displayName: Skip TLS verification on webhooks\n  description: Skip TLS verification on webhooks. Enable with caution!\n  value: \"false\"\n[root@master ~]# gogs-temp.yaml\n<\/pre>\n\n\n\n<p>\u901a\u8fc7 yaml \u6587\u4ef6\u521b\u5efa \u6a21\u677f<\/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=\"\">[root@master ~]# oc apply -f gogs-temp.yaml -n openshift\ntemplate \"gogs\" created\n<\/pre>\n\n\n\n<p>\u901a\u8fc7\u6a21\u677f\u8fd0\u884c\u5e94\u7528<\/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=\"\">[root@master ~]# oc new-app --template=gogs  --param=HOSTNAME=gogs.apps.lab.example.com\n--> Deploying template \"openshift\/gogs\" to project ditto\n\n     gogs\n     ---------\n     The Gogs git server (https:\/\/gogs.io\/)\n\n     * With parameters:\n        * APPLICATION_NAME=gogs\n        * HOSTNAME=gogs.apps.lab.example.com\n        * GOGS_VOLUME_CAPACITY=1Gi\n        * DB_VOLUME_CAPACITY=2Gi\n        * Database Username=gogs\n        * Database Password=gogs\n        * Database Name=gogs\n        * Database Admin Password=iaHaUYMy # generated\n        * Maximum Database Connections=100\n        * Shared Buffer Amount=12MB\n        * Gogs Version=0.9.97\n        * Installation lock=true\n        * Skip TLS verification on webhooks=false\n\n--> Creating resources ...\n    persistentvolume \"gogs-postgres-data\" created\n    persistentvolume \"gogs-data\" created\n    serviceaccount \"gogs\" created\n    service \"gogs-postgresql\" created\n    deploymentconfig \"gogs-postgresql\" created\n    service \"gogs\" created\n    route \"gogs\" created\n    deploymentconfig \"gogs\" created\n    imagestream \"gogs\" created\n    persistentvolumeclaim \"gogs-data\" created\n    persistentvolumeclaim \"gogs-postgres-data\" created\n    configmap \"gogs-config\" created\n--> Success\n    Access your application via route 'gogs.apps.lab.example.com'\n    Run 'oc status' to view your app.\n[root@master ~]#\n<\/pre>\n\n\n\n<p>\u67e5\u770b\u6240\u6709\u8d44\u6e90<\/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=\"\">[root@master ~]# oc get all\nNAME                                REVISION   DESIRED   CURRENT   TRIGGERED BY\ndeploymentconfigs\/gogs              0          1         0         config,image(gogs:0.9.97)\ndeploymentconfigs\/gogs-postgresql   1          1         1         config,image(postgresql:9.2)\n\nNAME                DOCKER REPO                                   TAGS      UPDATED\nimagestreams\/gogs   docker-registry.default.svc:5000\/ditto\/gogs   0.9.97\n\nNAME          HOST\/PORT                   PATH      SERVICES   PORT      TERMINATION   WILDCARD\nroutes\/gogs   gogs.apps.lab.example.com             gogs       &lt;all>                   None\n\nNAME                          READY     STATUS    RESTARTS   AGE\npo\/gogs-postgresql-1-9rjb2    0\/1       Running   0          30s\npo\/gogs-postgresql-1-deploy   1\/1       Running   0          33s\n\nNAME                   DESIRED   CURRENT   READY     AGE\nrc\/gogs-postgresql-1   1         1         0         33s\n\nNAME                  TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)    AGE\nsvc\/gogs              ClusterIP   172.30.4.106     &lt;none>        3000\/TCP   33s\nsvc\/gogs-postgresql   ClusterIP   172.30.127.172   &lt;none>        5432\/TCP   34s\n[root@master ~]#\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5199\u5728\u524d\u9762 \u56e0\u4e3a\u53c2\u52a0\u8003\u8bd5\uff0c\u4f1a\u9646\u7eed\u5206\u4eab\u4e00\u4e9b OpenShift \u7684\u7b14\u8bb0\uff0c\u535a\u6587\u5185\u5bb9\u4e3a\u4ecb\u7ecd openshift \u4e0d\u540c\u7684 [&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\/15200"}],"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=15200"}],"version-history":[{"count":1,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/15200\/revisions"}],"predecessor-version":[{"id":15203,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/15200\/revisions\/15203"}],"wp:attachment":[{"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=15200"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=15200"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=15200"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}