{"id":3570,"date":"2022-02-16T22:41:01","date_gmt":"2022-02-16T14:41:01","guid":{"rendered":"\/?p=3570"},"modified":"2022-02-21T22:41:51","modified_gmt":"2022-02-21T14:41:51","slug":"15-k8s%e4%b8%ad%e7%9a%84%e4%b8%8a%e5%b1%82%e5%af%b9%e8%b1%a1-deployment","status":"publish","type":"post","link":"http:\/\/xinblog.ltd\/?p=3570","title":{"rendered":"15.K8S\u4e2d\u7684\u4e0a\u5c42\u5bf9\u8c61-Deployment"},"content":{"rendered":"<p>\u6211\u4eec\u8bf4\u4e0b\u5de5\u4f5c\u8d1f\u8f7d\u4e2d\u7684\u7b2c\u4e00\u4e2a\u4e0a\u5c42\u5bf9\u8c61-Deployment<\/p>\n<p>\u5176\u4e3aPods\u63d0\u4f9b\u4e86\u58f0\u660e\u5f0f\u7684\u66f4\u65b0\u80fd\u529b<\/p>\n<p>K8S\u5185\u90e8\u7531Controller-Manager\u7ba1\u7406\u4e86\u4e00\u4e2aDeployment-Controller,\u5176\u8d1f\u8d23\u5c06Deployment\u8fdb\u884c\u89e3\u6790,\u5e76\u4fee\u6539status \u72b6\u6001=spec\u72b6\u6001\u3002<\/p>\n<p>Deployment \u4e5f\u4e0d\u662f\u76f4\u63a5\u53bb\u7ba1\u7406Pod,\u800c\u662f\u7ba1\u7406\u4e00\u4e2a\u65b0\u7684\u4e2d\u95f4\u5bf9\u8c61,ReplicaSet,\u5173\u4e8eReplicaSet,\u6211\u4eec\u4f1a\u5728\u4e0b\u9762\u8bb2<\/p>\n<p>\u7136\u540e\u6211\u4eec\u5148\u770b\u4e0bDeployment\u7684\u4e66\u5199\u6a21\u677f<\/p>\n<p>\u4ecd\u7136\u662f\u5305\u542b\u4e94\u4e2a\u5927\u6a21\u5757<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"554\" height=\"225\" class=\"wp-image-3571\" src=\"\/wp-content\/uploads\/2022\/02\/unnamed-file-23.png\" alt=\"\u56fe\u7247\" srcset=\"http:\/\/xinblog.ltd\/wp-content\/uploads\/2022\/02\/unnamed-file-23.png 554w, http:\/\/xinblog.ltd\/wp-content\/uploads\/2022\/02\/unnamed-file-23-300x122.png 300w\" sizes=\"(max-width: 554px) 100vw, 554px\" \/><\/p>\n<p>\u90a3\u4e48\u91cd\u70b9\u5728\u4e8espec\u7684\u4e66\u5199,\u5176\u5185\u90e8\u7684\u5b57\u6bb5\u5982\u4e0b<\/p>\n<table>\n<tbody>\n<tr>\n<td>minReadySeconds\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;integer&gt;<\/p>\n<p>Minimum number of seconds for which a newly created pod should be ready<\/p>\n<p>without any of its container crashing, for it to be considered available.<\/p>\n<p>Defaults to 0 (pod will be considered available as soon as it is ready)<\/p>\n<p>paused\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;boolean&gt;<\/p>\n<p>Indicates that the deployment is paused.<\/p>\n<p>progressDeadlineSeconds\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;integer&gt;<\/p>\n<p>The maximum time in seconds for a deployment to make progress before it is<\/p>\n<p>considered to be failed. The deployment controller will continue to process<\/p>\n<p>failed deployments and a condition with a ProgressDeadlineExceeded reason<\/p>\n<p>will be surfaced in the deployment status. Note that progress will not be<\/p>\n<p>estimated during the time a deployment is paused. Defaults to 600s.<\/p>\n<p>replicas\u00a0\u00a0\u00a0\u00a0 &lt;integer&gt;<\/p>\n<p>Number of desired pods. This is a pointer to distinguish between explicit<\/p>\n<p>zero and not specified. Defaults to 1.<\/p>\n<p>revisionHistoryLimit &lt;integer&gt;<\/p>\n<p>The number of old ReplicaSets to retain to allow rollback. This is a<\/p>\n<p>pointer to distinguish between explicit zero and not specified. Defaults to<\/p>\n<p>10.<\/p>\n<p>selector\u00a0\u00a0\u00a0\u00a0 &lt;Object&gt; -required-<\/p>\n<p>Label selector for pods. Existing ReplicaSets whose pods are selected by<\/p>\n<p>this will be the ones affected by this deployment. It must match the pod<\/p>\n<p>template&#8217;s labels.<\/p>\n<p>strategy\u00a0\u00a0\u00a0\u00a0 &lt;Object&gt;<\/p>\n<p>The deployment strategy to use to replace existing pods with new ones.<\/p>\n<p>template\u00a0\u00a0\u00a0\u00a0 &lt;Object&gt; -required-<\/p>\n<p>Template describes the pods that will be created.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u6bd4\u8f83\u91cd\u70b9\u7684\u5b57\u6bb5\u6709:<\/p>\n<p>replicas\u00a0\u00a0 \u6307\u5b9a\u4e86\u526f\u672c\u6570\u91cf<\/p>\n<p>selector\u00a0 \u6307\u5b9a\u5339\u914d\u7684Pod\u6a21\u677f<\/p>\n<p>template \u58f0\u660e\u4e00\u4e2aPod\u6a21\u677f<\/p>\n<p>\u4e0a\u9762\u7684selector\u8868\u793a\u8981\u7ba1\u7406\u54ea\u4e9bPod,\u5176\u7ba1\u7406\u7684\u539f\u7406\u5728\u4e8e,\u8981\u6c42\u88ab\u7ba1\u7406\u7684Pod\u4e2d\u643a\u5e26selector\u4e2d\u58f0\u660e\u7684Label<\/p>\n<p>\u800c\u5728Deployment\u7ba1\u7406\u7684\u4e0b\u5c42,\u662f\u4e00\u4e2aReplicaSet,\u5bf9\u4e8eReplicaSet,\u6211\u4eec\u4e5f\u770b\u4e0b\u5176\u4e2d\u5305\u542b\u7684\u5b57\u6bb5<\/p>\n<table>\n<tbody>\n<tr>\n<td>\u00a0\u00a0 minReadySeconds\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;integer&gt;<\/p>\n<p>Minimum number of seconds for which a newly created pod should be ready<\/p>\n<p>without any of its container crashing, for it to be considered available.<\/p>\n<p>Defaults to 0 (pod will be considered available as soon as it is ready)<\/p>\n<p>replicas\u00a0\u00a0\u00a0\u00a0 &lt;integer&gt;<\/p>\n<p>Replicas is the number of desired replicas. This is a pointer to<\/p>\n<p>distinguish between explicit zero and unspecified. Defaults to 1. More<\/p>\n<p>info:<\/p>\n<p><a href=\"https:\/\/kubernetes.io\/docs\/concepts\/workloads\/controllers\/replicationcontroller\/#what-is-a-replicationcontroller\">https:\/\/kubernetes.io\/docs\/concepts\/workloads\/controllers\/replicationcontroller\/#what-is-a-replicationcontroller<\/a><\/p>\n<p>selector\u00a0\u00a0\u00a0\u00a0 &lt;Object&gt; -required-<\/p>\n<p>Selector is a label query over pods that should match the replica count.<\/p>\n<p>Label keys and values that must match in order to be controlled by this<\/p>\n<p>replica set. It must match the pod template&#8217;s labels. More info:<\/p>\n<p><a href=\"https:\/\/kubernetes.io\/docs\/concepts\/overview\/working-with-objects\/labels\/#label-selectors\">https:\/\/kubernetes.io\/docs\/concepts\/overview\/working-with-objects\/labels\/#label-selectors<\/a><\/p>\n<p>template\u00a0\u00a0\u00a0\u00a0 &lt;Object&gt;<\/p>\n<p>Template is the object that describes the pod that will be created if<\/p>\n<p>insufficient replicas are detected. More info:<\/p>\n<p><a href=\"https:\/\/kubernetes.io\/docs\/concepts\/workloads\/controllers\/replicationcontroller#pod-template\">https:\/\/kubernetes.io\/docs\/concepts\/workloads\/controllers\/replicationcontroller#pod-template<\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5176\u4e2d\u57fa\u672c\u548cDeployment\u4e00\u81f4,\u6700\u91cd\u8981\u7684\u662freplicas,\u8868\u793a\u7ba1\u7406\u591a\u5c11\u7684Pod.<\/p>\n<p>\u6574\u4f53\u6765\u8bf4\u7ed3\u6784\u5c31\u662f<\/p>\n<p>\u56e0\u6b64,Deployment \u5bf9 Pod\u5177\u6709\u4e86\u81ea\u6108\u80fd\u529b<\/p>\n<p>\u5982\u679c\u5bf9\u7ba1\u7406\u7684Pod\u8fdb\u884c\u4e86\u5220\u9664\u64cd\u4f5c,\u4e5f\u4f1a\u8fdb\u884c\u76f8\u5173\u7684\u518d\u542f\u52a8<\/p>\n<p>\u5176\u6b21\u662fDeployment\u4e2d,\u4e5f\u5177\u6709\u4e00\u4e2a\u65b0\u7684\u80fd\u529b,\u5c31\u662f\u6eda\u52a8\u66f4\u65b0\u7684\u80fd\u529b<\/p>\n<p>\u5173\u4e8eDeployment\u7684\u6eda\u52a8\u66f4\u65b0\u7684\u80fd\u529b,\u5229\u7528\u7684\u662fReplicaSet,\u6bcf\u6b21\u5f53Deployment\u53d1\u751f\u53d8\u5316\u7684\u65f6\u5019,\u4f1a\u751f\u6210\u4e00\u4e2a\u65b0\u7684rs,\u5229\u7528\u8fd9\u79cd\u65b9\u5f0f\u4fdd\u5b58\u4e86\u5185\u90e8\u7684Pod\u76f8\u5173\u7684\u5b9a\u4e49,\u4ece\u800c\u65b9\u4fbf\u56de\u6eda<\/p>\n<p>\u5bf9\u4e8e\u4fdd\u5b58\u7684RS\u4e2a\u6570,\u5219\u662f\u7531Deployment \u4e2d spec\u4e2drevisionHsitoryLimit\u8bbe\u7f6e\u7684<\/p>\n<p>\u65e0\u8bba\u6211\u4eec\u662f\u4fee\u6539Deployment\u7684yaml\u6587\u4ef6,\u8fd8\u662f\u76f4\u63a5\u5229\u7528kubectl set images\u547d\u4ee4<\/p>\n<p>\u90fd\u662f\u4f1a\u4ea7\u751f\u4e00\u4e2a\u65b0\u7684RS<\/p>\n<p>\u5982\u679c\u9700\u8981\u76f4\u63a5\u7684\u56de\u6eda,\u4e5f\u53ef\u4ee5\u4f7f\u7528rs,\u547d\u4ee4\u4e3a<\/p>\n<p>kubectl rollout history deployment &amp;&amp; kubectl rollout undo deployment<\/p>\n<p>\u4e0d\u8fc7\u9700\u8981\u6ce8\u610f,rollout history\u4e2d,\u5e76\u4e0d\u4f1a\u8bb0\u5f55\u4fee\u6539\u4e86\u4ec0\u4e48,\u9700\u8981\u6211\u4eec\u5728\u5e94\u7528\u547d\u4ee4\u7684\u65f6\u5019\u5229\u7528\u2014record\u6765\u8fdb\u884c\u8bb0\u5f55<\/p>\n<p>\u5982\u679c\u4e0d\u60f3\u8981\u6bcf\u6b21\u5e94\u7528\u90fd\u4ea7\u751f\u4e00\u4e2aRS,\u5219\u53ef\u4ee5\u4f7f\u7528<\/p>\n<p>kubectl rollout pause \u6682\u505c\u4ea7\u751fRS<\/p>\n<p>\u7136\u540e\u591a\u6b21\u4fee\u6539\u5b8c\u6210\u540e<\/p>\n<p>kubectl rollout resume<\/p>\n<p>\u6062\u590d\u5e76\u5e94\u7528\u66f4\u65b0,\u540c\u7406\u7684deployment\u4e2d\u7684spec\u914d\u7f6e\u9879\u6709\u4e00\u4e2apaused<\/p>\n<p>\u914d\u7f6e\u4e86\u4e4b\u540e,\u90e8\u7f72\u7684Depolyment\u4e0d\u4f1a\u4ea7\u751f\u65b0\u7684RS<\/p>\n<p>\u5269\u4e0b\u7684\u914d\u7f6e\u9879\u8bf8\u5982<\/p>\n<p>minReadySeconds \u6700\u5c0f\u7684\u51c6\u5907\u65f6\u95f4,\u5c31\u662f\u4e00\u4e2aPod\u542f\u52a8\u4e4b\u540e,\u591a\u5c11\u79d2\u540e\u624d\u4f1a\u5224\u65ad\u4ed6\u5df2\u7ecf\u53ef\u4ee5\u63d0\u4f9b\u670d\u52a1\u4e86,\u8fd9\u4e00\u70b9\u9002\u7528\u4e8ePod\u66f4\u65b0<\/p>\n<p>progressDeadlineSeconds \u6700\u8fdf\u5c31\u7eea\u65f6\u95f4<\/p>\n<p>strategy:\u63a7\u5236\u6eda\u52a8\u66f4\u65b0\u7684\u8272\u7ec7<\/p>\n<p>\u91cc\u9762\u5305\u542b\u7684\u5b57\u6bb5\u6709<\/p>\n<p>rollingUpdate type<\/p>\n<p>\u9996\u5148\u770btype\u8fd9\u4e2a\u5b57\u6bb5<\/p>\n<p>\u5176\u4e2d\u53ef\u4ee5\u914d\u7f6e\u7684\u65b9\u5f0f\u6709 Recreate\u548cRollingUpdate<\/p>\n<p>\u5982\u679c\u662f&#8221;Recreate&#8221;\u7684\u8bdd,\u5176\u5b9e\u5c31\u662f\u6bcf\u521b\u5efa\u4e00\u4e2a\u65b0\u7684,\u5c31\u5220\u53bb\u4e00\u4e2a\u8001\u7684,\u76f8\u5f53\u4e8e\u9876\u66ff<\/p>\n<p>\u800cRollingUpdate\u5c31\u662f\u548c\u4e0a\u9762\u7684rollingUpdate\u8fdb\u884c\u8054\u52a8,\u505a\u5230\u6eda\u52a8\u66f4\u65b0\u7684<\/p>\n<p>rollingUpdate\u4e2d\u53ef\u4ee5\u914d\u7f6e\u7684\u6709 maxSurge maxUnavailable<\/p>\n<p>\u4e00\u4e2a\u662f\u6bcf\u6b21\u6700\u5927\u80fd\u591f\u66f4\u65b0\u591a\u5c11\u4e2aPod,\u4e00\u4e2a\u662f\u8868\u793a\u6700\u591a\u6709\u591a\u5c11\u4e0d\u53ef\u7528<\/p>\n<p>maxSurge\u76f8\u5bf9\u597d\u7406\u89e3,\u800cmaxUnavailable\u5219\u662f\u5728\u66f4\u65b0\u8fc7\u7a0b\u4e2d,\u65b0\u7684Pod\u7684\u548c\u65e7\u7684Pod\u52a0\u4e00\u6b21\u7b49\u4e8ereplica \u51cf\u53bb maxUnavailable<\/p>\n<p>\u4e24\u8005\u7684\u914d\u7f6e\u53ef\u4ee5\u662f \u6570\u5b57,\u4e5f\u53ef\u4ee5\u662f\u767e\u5206\u6bd4<\/p>\n<p>\u8bf4\u5b8c\u4e86\u8fd9\u4e2a,\u6211\u4eec\u770b\u4e0bDeployment\u4e2d\u7684HPA,\u4e5f\u5c31\u662f\u52a8\u6001\u7684\u6269\u7f29\u5bb9<\/p>\n<p>\u5bf9\u5e94\u7684\u6587\u6863\u662f<\/p>\n<p><a href=\"https:\/\/kubernetes.io\/zh\/docs\/tasks\/run-application\/horizontal-pod-autoscale\/#scaling-policies\">https:\/\/kubernetes.io\/zh\/docs\/tasks\/run-application\/horizontal-pod-autoscale\/#scaling-policies<\/a><\/p>\n<p>\u800c\u5bf9HPA\u7684\u5f00\u542f,\u9700\u8981\u90e8\u7f72\u5bf9\u5e94\u7684Deployment<\/p>\n<p>\u9700\u8981\u5148\u5b89\u88c5\u4e00\u4e2ametrics-server<\/p>\n<p>\u5b89\u88c5\u7684\u65b9\u5f0f,\u5728github\u4e0a\u5b58\u5728<\/p>\n<p><a href=\"https:\/\/github.com\/kubernetes-sigs\/metrics-server\">https:\/\/github.com\/kubernetes-sigs\/metrics-server<\/a><\/p>\n<p>\u5bf9\u5e94\u7684\u90e8\u7f72yaml\u5982\u4e0b<\/p>\n<table>\n<tbody>\n<tr>\n<td>apiVersion: v1<\/p>\n<p>kind: ServiceAccount<\/p>\n<p>metadata:<\/p>\n<p>labels:<\/p>\n<p>k8s-app: metrics-server<\/p>\n<p>name: metrics-server<\/p>\n<p>namespace: kube-system<\/p>\n<p>&#8212;<\/p>\n<p>apiVersion: rbac.authorization.k8s.io\/v1<\/p>\n<p>kind: ClusterRole<\/p>\n<p>metadata:<\/p>\n<p>labels:<\/p>\n<p>k8s-app: metrics-server<\/p>\n<p>rbac.authorization.k8s.io\/aggregate-to-admin: &#8220;true&#8221;<\/p>\n<p>rbac.authorization.k8s.io\/aggregate-to-edit: &#8220;true&#8221;<\/p>\n<p>rbac.authorization.k8s.io\/aggregate-to-view: &#8220;true&#8221;<\/p>\n<p>name: system:aggregated-metrics-reader<\/p>\n<p>rules:<\/p>\n<p>&#8211; apiGroups:<\/p>\n<p>&#8211; metrics.k8s.io<\/p>\n<p>resources:<\/p>\n<p>&#8211; pods<\/p>\n<p>&#8211; nodes<\/p>\n<p>verbs:<\/p>\n<p>&#8211; get<\/p>\n<p>&#8211; list<\/p>\n<p>&#8211; watch<\/p>\n<p>&#8212;<\/p>\n<p>apiVersion: rbac.authorization.k8s.io\/v1<\/p>\n<p>kind: ClusterRole<\/p>\n<p>metadata:<\/p>\n<p>labels:<\/p>\n<p>k8s-app: metrics-server<\/p>\n<p>name: system:metrics-server<\/p>\n<p>rules:<\/p>\n<p>&#8211; apiGroups:<\/p>\n<p>&#8211; &#8220;&#8221;<\/p>\n<p>resources:<\/p>\n<p>&#8211; pods<\/p>\n<p>&#8211; nodes<\/p>\n<p>&#8211; nodes\/stats<\/p>\n<p>&#8211; namespaces<\/p>\n<p>&#8211; configmaps<\/p>\n<p>verbs:<\/p>\n<p>&#8211; get<\/p>\n<p>&#8211; list<\/p>\n<p>&#8211; watch<\/p>\n<p>&#8212;<\/p>\n<p>apiVersion: rbac.authorization.k8s.io\/v1<\/p>\n<p>kind: RoleBinding<\/p>\n<p>metadata:<\/p>\n<p>labels:<\/p>\n<p>k8s-app: metrics-server<\/p>\n<p>name: metrics-server-auth-reader<\/p>\n<p>namespace: kube-system<\/p>\n<p>roleRef:<\/p>\n<p>apiGroup: rbac.authorization.k8s.io<\/p>\n<p>kind: Role<\/p>\n<p>name: extension-apiserver-authentication-reader<\/p>\n<p>subjects:<\/p>\n<p>&#8211; kind: ServiceAccount<\/p>\n<p>name: metrics-server<\/p>\n<p>namespace: kube-system<\/p>\n<p>&#8212;<\/p>\n<p>apiVersion: rbac.authorization.k8s.io\/v1<\/p>\n<p>kind: ClusterRoleBinding<\/p>\n<p>metadata:<\/p>\n<p>labels:<\/p>\n<p>k8s-app: metrics-server<\/p>\n<p>name: metrics-server:system:auth-delegator<\/p>\n<p>roleRef:<\/p>\n<p>apiGroup: rbac.authorization.k8s.io<\/p>\n<p>kind: ClusterRole<\/p>\n<p>name: system:auth-delegator<\/p>\n<p>subjects:<\/p>\n<p>&#8211; kind: ServiceAccount<\/p>\n<p>name: metrics-server<\/p>\n<p>namespace: kube-system<\/p>\n<p>&#8212;<\/p>\n<p>apiVersion: rbac.authorization.k8s.io\/v1<\/p>\n<p>kind: ClusterRoleBinding<\/p>\n<p>metadata:<\/p>\n<p>labels:<\/p>\n<p>k8s-app: metrics-server<\/p>\n<p>name: system:metrics-server<\/p>\n<p>roleRef:<\/p>\n<p>apiGroup: rbac.authorization.k8s.io<\/p>\n<p>kind: ClusterRole<\/p>\n<p>name: system:metrics-server<\/p>\n<p>subjects:<\/p>\n<p>&#8211; kind: ServiceAccount<\/p>\n<p>name: metrics-server<\/p>\n<p>namespace: kube-system<\/p>\n<p>&#8212;<\/p>\n<p>apiVersion: v1<\/p>\n<p>kind: Service<\/p>\n<p>metadata:<\/p>\n<p>labels:<\/p>\n<p>k8s-app: metrics-server<\/p>\n<p>name: metrics-server<\/p>\n<p>namespace: kube-system<\/p>\n<p>spec:<\/p>\n<p>ports:<\/p>\n<p>&#8211; name: https<\/p>\n<p>port: 443<\/p>\n<p>protocol: TCP<\/p>\n<p>targetPort: https<\/p>\n<p>selector:<\/p>\n<p>k8s-app: metrics-server<\/p>\n<p>&#8212;<\/p>\n<p>apiVersion: apps\/v1<\/p>\n<p>kind: Deployment<\/p>\n<p>metadata:<\/p>\n<p>labels:<\/p>\n<p>k8s-app: metrics-server<\/p>\n<p>name: metrics-server<\/p>\n<p>namespace: kube-system<\/p>\n<p>spec:<\/p>\n<p>selector:<\/p>\n<p>matchLabels:<\/p>\n<p>k8s-app: metrics-server<\/p>\n<p>strategy:<\/p>\n<p>rollingUpdate:<\/p>\n<p>maxUnavailable: 0<\/p>\n<p>template:<\/p>\n<p>metadata:<\/p>\n<p>labels:<\/p>\n<p>k8s-app: metrics-server<\/p>\n<p>spec:<\/p>\n<p>containers:<\/p>\n<p>&#8211; args:<\/p>\n<p>&#8211; &#8211;cert-dir=\/tmp<\/p>\n<p>&#8211; &#8211;kubelet-insecure-tls<\/p>\n<p>&#8211; &#8211;secure-port=4443<\/p>\n<p>&#8211; &#8211;kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname<\/p>\n<p>&#8211; &#8211;kubelet-use-node-status-port<\/p>\n<p>image: xxxxx\/metrics-server:v0.4.3 #\u9700\u8981\u4fee\u6539\u4e3a\u53ef\u4ee5\u8bbf\u95ee\u5230\u7684image\u4ed3\u5e93<\/p>\n<p>imagePullPolicy: IfNotPresent<\/p>\n<p>livenessProbe:<\/p>\n<p>failureThreshold: 3<\/p>\n<p>httpGet:<\/p>\n<p>path: \/livez<\/p>\n<p>port: https<\/p>\n<p>scheme: HTTPS<\/p>\n<p>periodSeconds: 10<\/p>\n<p>name: metrics-server<\/p>\n<p>ports:<\/p>\n<p>&#8211; containerPort: 4443<\/p>\n<p>name: https<\/p>\n<p>protocol: TCP<\/p>\n<p>readinessProbe:<\/p>\n<p>failureThreshold: 3<\/p>\n<p>httpGet:<\/p>\n<p>path: \/readyz<\/p>\n<p>port: https<\/p>\n<p>scheme: HTTPS<\/p>\n<p>periodSeconds: 10<\/p>\n<p>securityContext:<\/p>\n<p>readOnlyRootFilesystem: true<\/p>\n<p>runAsNonRoot: true<\/p>\n<p>runAsUser: 1000<\/p>\n<p>volumeMounts:<\/p>\n<p>&#8211; mountPath: \/tmp<\/p>\n<p>name: tmp-dir<\/p>\n<p>nodeSelector:<\/p>\n<p>kubernetes.io\/os: linux<\/p>\n<p>priorityClassName: system-cluster-critical<\/p>\n<p>serviceAccountName: metrics-server<\/p>\n<p>volumes:<\/p>\n<p>&#8211; emptyDir: {}<\/p>\n<p>name: tmp-dir<\/p>\n<p>&#8212;<\/p>\n<p>apiVersion: apiregistration.k8s.io\/v1<\/p>\n<p>kind: APIService<\/p>\n<p>metadata:<\/p>\n<p>labels:<\/p>\n<p>k8s-app: metrics-server<\/p>\n<p>name: v1beta1.metrics.k8s.io<\/p>\n<p>spec:<\/p>\n<p>group: metrics.k8s.io<\/p>\n<p>groupPriorityMinimum: 100<\/p>\n<p>insecureSkipTLSVerify: true<\/p>\n<p>service:<\/p>\n<p>name: metrics-server<\/p>\n<p>namespace: kube-system<\/p>\n<p>version: v1beta1<\/p>\n<p>versionPriority: 100<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>kubectl apply\u4e4b\u540e<\/p>\n<p>\u53ef\u4ee5\u5229\u7528\u5982\u4e0b\u7684\u547d\u4ee4\u6765\u67e5\u770b\u786c\u4ef6\u4f7f\u7528\u7387<\/p>\n<p>kubectl top nodes \u2013user-protocol-buffers<\/p>\n<p>\u4e4b\u540e\u5728\u914d\u7f6e\u5e76\u90e8\u7f72\u4e86Deployment\u4e4b\u540e,\u6211\u4eec\u53ef\u4ee5\u4e66\u5199\u5bf9\u5e94\u7684hpa\u7684yaml\u6587\u4ef6\u6765\u8fdb\u884c<\/p>\n<p>\u4e00\u4e2a\u5b9e\u4f8b\u5982\u4e0b<\/p>\n<table>\n<tbody>\n<tr>\n<td>apiVersion: autoscaling\/v1<\/p>\n<p>kind: HorizontalPodAutoscaler<\/p>\n<p>metadata:<\/p>\n<p>name: php-apache #\u5143\u6570\u636e<\/p>\n<p>spec:<\/p>\n<p>maxReplicas: 10 #\u6700\u5927\u7684Replicas<\/p>\n<p>minReplicas: 1 #\u6700\u5c0f\u7684Replicas<\/p>\n<p>scaleTargetRef: #\u8981\u626b\u63cf\u7684\u5bf9\u8c61<\/p>\n<p>apiVersion: apps\/v1<\/p>\n<p>kind: Deployment<\/p>\n<p>name: php-apache<\/p>\n<p>targetCPUUtilizationPercentage: 50 #\u89e6\u53d1\u7684\u4e34\u754c\u6761\u4ef6<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u4e4b\u540ekubectl apply -f \u4e00\u4e0b\u5373\u53ef<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6211\u4eec\u8bf4\u4e0b\u5de5\u4f5c\u8d1f\u8f7d\u4e2d\u7684\u7b2c\u4e00\u4e2a\u4e0a\u5c42 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27],"tags":[],"_links":{"self":[{"href":"http:\/\/xinblog.ltd\/index.php?rest_route=\/wp\/v2\/posts\/3570"}],"collection":[{"href":"http:\/\/xinblog.ltd\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/xinblog.ltd\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/xinblog.ltd\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/xinblog.ltd\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3570"}],"version-history":[{"count":0,"href":"http:\/\/xinblog.ltd\/index.php?rest_route=\/wp\/v2\/posts\/3570\/revisions"}],"wp:attachment":[{"href":"http:\/\/xinblog.ltd\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3570"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/xinblog.ltd\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3570"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/xinblog.ltd\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3570"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}