{"id":66,"date":"2020-10-22T10:09:42","date_gmt":"2020-10-22T02:09:42","guid":{"rendered":"https:\/\/www.db2go.net\/?p=66"},"modified":"2020-10-22T10:12:19","modified_gmt":"2020-10-22T02:12:19","slug":"%e7%94%a8%e4%b8%80%e4%b8%aayaml%e7%a4%ba%e4%be%8bpod%e7%9a%84%e7%94%a8%e6%b3%95","status":"publish","type":"post","link":"https:\/\/www.db2go.net\/?p=66","title":{"rendered":"\u7528\u4e00\u4e2ayaml\u793a\u4f8bpod\u7684\u7528\u6cd5"},"content":{"rendered":"<pre><code class=\"language-yaml line-numbers\">apiVersion: v1\nkind: Pod\nmetadata:\n  name: stop-apps\nspec:\n  initContainers:\n  - name: init\n    image: busybox\n    imagePullPolicy : IfNotPresent\n    command: ['sh', '-c', ' echo \"df -h &gt; \/root\/running\/yes.txt\" &gt; \/tmp\/app-a.sh;chmod +x \/tmp\/app-a.sh' ]\n    volumeMounts:\n    - name: app-running-volume\n      mountPath: \/tmp\n  containers:\n  - name: myapps\n    image: centos:7.5.1804\n    imagePullPolicy: IfNotPresent\n    command: ['sh', '-c',' \/root\/running\/app-a.sh; sleep 3600; ']\n    volumeMounts:\n    - name: app-running-volume\n      mountPath: \/root\/running\n    - name: app-logs-volume\n      mountPath: \/root\/logs\n    lifecycle:\n      postStart:\n        exec:\n          command: [\"bash\", \"-c\", \"echo begin &gt;&gt; \/root\/logs\/message\"]\n      preStop:\n        exec:\n          command: [\"bash\", \"-c\", \"echo Bye &gt;&gt; \/root\/logs\/message\"]\n  volumes:\n  - name: app-running-volume\n    hostPath:\n      path: \/tmp\/running\n      type: Directory\n  - name: app-logs-volume\n    hostPath:\n      path: \/tmp\/logs\n      type: Directory\n  nodeSelector:\n    kubernetes.io\/hostname: host-192-168-3-124\n<\/code><\/pre>\n<ul>\n<li>\u5b89\u88c5: init container<\/li>\n<li>\u542f\u52a8: \u94a9\u5b50postStart<\/li>\n<li>\u505c\u6b62: \u94a9\u5b50prestop<\/li>\n<li>\u5378\u8f7d: \u94a9\u5b50prestop<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>apiVersion: v1 kind: Pod metadata: name: stop-apps spec&hellip;<\/p>\n <a href=\"https:\/\/www.db2go.net\/?p=66\" title=\"\u7528\u4e00\u4e2ayaml\u793a\u4f8bpod\u7684\u7528\u6cd5\" class=\"entry-more-link\"><span>Read More<\/span> <span class=\"screen-reader-text\">\u7528\u4e00\u4e2ayaml\u793a\u4f8bpod\u7684\u7528\u6cd5<\/span><\/a>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"Layout":"","footnotes":""},"categories":[3],"tags":[],"class_list":["entry","author-suredandan","post-66","post","type-post","status-publish","format-standard","category-k8s"],"views":1409,"_links":{"self":[{"href":"https:\/\/www.db2go.net\/index.php?rest_route=\/wp\/v2\/posts\/66","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.db2go.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.db2go.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.db2go.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.db2go.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=66"}],"version-history":[{"count":1,"href":"https:\/\/www.db2go.net\/index.php?rest_route=\/wp\/v2\/posts\/66\/revisions"}],"predecessor-version":[{"id":67,"href":"https:\/\/www.db2go.net\/index.php?rest_route=\/wp\/v2\/posts\/66\/revisions\/67"}],"wp:attachment":[{"href":"https:\/\/www.db2go.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=66"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.db2go.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=66"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.db2go.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=66"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}