Select 其他 POD 不存在的节点
Select node where the other POD does not exist
我有两个节点
gke-1789571565414321321-a3ec9151-node-q0cz
gke-98798532417432432421-a3ec9151-node-q0cz
我有两个要部署的 ReplicationController 2 pods, xxx & yyy.
我想要的:如果 xxx
部署在其中一个 node
上,yyy
应该部署到另一个。
我通过 spec.nodeName
属性.
实现了这个
是否有通用的方法来避免指示特定节点?
xxx:
{
"apiVersion": "v1",
"kind": "ReplicationController",
"metadata": {
"name": "xxx",
"labels": { "name" : "xxx" }
},
"spec": {
"replicas": 1,
"selector": {
"name":"xxx"
},
"template": {
"metadata": {
"labels": {
"name":"xxx"
}
},
"spec": {
"containers": [
//...
],
"nodeName" : "gke-1789571565414321321-a3ec9151-node-q0cz"
}
}
}
}
yyy:
{
"apiVersion": "v1",
"kind": "ReplicationController",
"metadata": {
"name": "yyy",
"labels": { "name" : "yyy" }
},
"spec": {
"replicas": 1,
"selector": {
"name":"yyy"
},
"template": {
"metadata": {
"labels": {
"name":"yyy"
}
},
"spec": {
"containers": [
//...
],
"nodeName" : "gke-98798532417432432421-a3ec9151-node-q0cz"
}
}
}
}
您正在寻找的功能称为 "anti-affinity",尚未实现(但在 design doc in github). Until then, you can force the pods to be spread by assigning a constraint that can only be met once per node, such as a host port (see Allow only one pod of a type on a node in Kubernetes 中有描述)。
我有两个节点
gke-1789571565414321321-a3ec9151-node-q0cz
gke-98798532417432432421-a3ec9151-node-q0cz
我有两个要部署的 ReplicationController 2 pods, xxx & yyy.
我想要的:如果 xxx
部署在其中一个 node
上,yyy
应该部署到另一个。
我通过 spec.nodeName
属性.
是否有通用的方法来避免指示特定节点?
xxx:
{
"apiVersion": "v1",
"kind": "ReplicationController",
"metadata": {
"name": "xxx",
"labels": { "name" : "xxx" }
},
"spec": {
"replicas": 1,
"selector": {
"name":"xxx"
},
"template": {
"metadata": {
"labels": {
"name":"xxx"
}
},
"spec": {
"containers": [
//...
],
"nodeName" : "gke-1789571565414321321-a3ec9151-node-q0cz"
}
}
}
}
yyy:
{
"apiVersion": "v1",
"kind": "ReplicationController",
"metadata": {
"name": "yyy",
"labels": { "name" : "yyy" }
},
"spec": {
"replicas": 1,
"selector": {
"name":"yyy"
},
"template": {
"metadata": {
"labels": {
"name":"yyy"
}
},
"spec": {
"containers": [
//...
],
"nodeName" : "gke-98798532417432432421-a3ec9151-node-q0cz"
}
}
}
}
您正在寻找的功能称为 "anti-affinity",尚未实现(但在 design doc in github). Until then, you can force the pods to be spread by assigning a constraint that can only be met once per node, such as a host port (see Allow only one pod of a type on a node in Kubernetes 中有描述)。