我在我的kind: Deployment文件中有两个yaml文件--主文件
apiVersion: apps/v1
kind: Deployment
metadata:
name: accounts-management-service
labels:
app: accounts-management-service
spec:
replicas: $($env:WEB_REPLICAS)
selector:
matchLabels:
app: accounts-management-service
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 20%
maxUnavailable: 10%
progressDeadlineSeconds: 3600
template:
metadata:
labels:
app: accounts-management-service
spec:
containers:
- image: registry$(GetHash).azurecr.io/$(GetContext 'ApplicationContainerName')
name: accounts-management-service
command: ["npm"]
args: ["run", "start:production:web"]
resources:
requests:
memory: "500Mi"
cpu: "1000m"
limits:
memory: "4096Mi"
cpu: "1001m"
env:
- name: CONFIG_DEPLOYMENT_UNIT
value: $(GetContext 'DeploymentUnit')
- name: NODE_ENV
value: $(GetContext 'DeploymentUnit')
- name: TENANT
value: "$(GetContext 'DeploymentUnit' | Format -NoHyphens)$(GetContext 'Cluster')"
- name: ROLE
value: $(GetContext 'Cluster')
ports:
- containerPort: 1337
protocol: TCP
volumeMounts:
- name: secret-agent
mountPath: /var/run/secret-agent
readinessProbe:
httpGet:
path: /v0.1/status
port: 1337
successThreshold: 2
failureThreshold: 3
initialDelaySeconds: 60
periodSeconds: 10
livenessProbe:
httpGet:
path: /v0.1/status_without_db
port: 1337
failureThreshold: 3
initialDelaySeconds: 60
periodSeconds: 30
volumes:
- name: secret-agent
hostPath:
path: /var/run/secret-agent
type: DirectoryOrCreate第二个
# second
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: accounts-management-service-second
labels:
app: accounts-management-service-second
spec:
replicas: $($env:second_REPLICAS)
selector:
matchLabels:
app: accounts-management-service-second
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 10%
maxUnavailable: 10%
template:
metadata:
labels:
app: accounts-management-service-second
spec:
containers:
- image: registry$(GetHash).azurecr.io/$(GetContext 'ApplicationContainerName')
name: accounts-management-service-second
command: ["npm"]
args: ["run", "start:production:second"]
resources:
requests:
memory: "500Mi"
cpu: "250m"
limits:
memory: "8192Mi"
cpu: "1001m"
env:
- name: CONFIG_DEPLOYMENT_UNIT
value: $(GetContext 'DeploymentUnit')
- name: NODE_ENV
value: $(GetContext 'DeploymentUnit')
- name: TENANT
value: "$(GetContext 'DeploymentUnit' | Format -NoHyphens)$(GetContext 'Cluster')"
- name: ROLE
value: $(GetContext 'Cluster')
ports:
- containerPort: 1337
protocol: TCP
volumeMounts:
- name: secret-agent
mountPath: /var/run/secret-agent
readinessProbe:
httpGet:
path: /status
port: 1337
initialDelaySeconds: 60
periodSeconds: 10
livenessProbe:
httpGet:
path: /status
port: 1337
initialDelaySeconds: 60
periodSeconds: 10
volumes:
- name: secret-agent
hostPath:
path: /var/run/secret-agent
type: DirectoryOrCreate它们都指向相同的卷路径。我是库伯内特斯的新手,我正在努力理解豆荚创造和两个kind: Deployment之间的关系。如果有人能解释这一点,那就太好了。我希望这属于允许提出问题的类别。
发布于 2021-06-29 07:25:43
对于配置的任何工作负载,部署管理副本计数。
后台部署使用Replicasets或ReplicationController。
因此,如果您在部署中拥有所需的副本1,则将通过部署来管理它。
部署持续检查所需的副本和可伸缩副本(如果已经进行缩放)。
建议实现上述的扩展,HPA将通知部署,以便将副本、扩展到3-4等。
描述部署中所需的状态,Deployment以受控速率将实际状态更改为所需状态。您可以定义部署来创建新的ReplicaSets,或者删除现有的部署,并在新的部署中采用它们的所有资源。
在部署过程中,如果您正在更新豆荚或容器,那么您可以将策略配置为更新,这样理想情况下,它们会一个接一个地下降,然后出现一个新的容器。
因此,在此过程中出现的停机时间较少,此策略在部署级别上进行管理和配置。
示例
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 20%
maxUnavailable: 10%另外,两个部署意味着在YAML中配置了两种不同类型的应用程序或微服务或工作负载。每个微服务配置一个。
如果你有任何问题,可以随意在评论中添加问题。
发布于 2021-06-29 07:19:43
基本上,部署可以通过部署规范部分和.spec.template.spec部分中定义的标签来查找它们管理的豆荚。
部署检查是否运行与所提供的标签匹配的荚,同时确定可用的副本计数是否为所需的副本计数。
如果需要计数>可用计数,DeploymentController将根据模板部分创建一个新的pod (实际上,部署控制一个ReplicaSet,后者反过来控制吊舱,但这是您真正需要的额外知识)。但是,部署不只是基于模板创建和删除吊舱。如果部署所在的名称空间中已经运行了与您在部署中指定的标签相匹配的荚,那么它将把这个荚计算为部署的一部分,并指向可用的副本。
希望这能澄清您对部署的理解。
发布于 2021-06-29 07:25:26
如果您想知道由指定的部署创建了哪些荚,可以使用kubectl get pods命令和--selector选项来筛选这些荚。
您在部署模板中定义的标签是app=accounts-management-service和app=accounts-management-service-second,您可以通过以下方法找出这些吊舱:
$ kubectl get pods --selector=app=accounts-management-service
$ kubectl get pods --selector=app=accounts-management-service-secondhttps://stackoverflow.com/questions/68173852
复制相似问题