我得到了:
0/3 nodes are available: 3 node(s) didn't have free ports for the requested pod ports.
尝试在同一k8s节点上运行多个jenkins从站。
每个pod都公开了相同的端口,这使得不可能在同一节点上运行2个相同的pod。
我有一个带有负载均衡器的服务-但它不能解决问题。
是否有可能创建一个服务,该服务将为创建的每个吊舱生成随机端口?
谢谢!
编辑: 这是配置的服务:
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "jnlp",
"namespace": "default",
"selfLink": "/api/v1/namespaces/default/services/jnlp",
"uid": "345230eb-5078-11e9-959a-1690183aeeb4",
"resourceVersion": "90390",
"creationTimestamp": "2019-03-27T10:08:01Z",
"annotations": {.....}
},
"spec": {
"ports": [
{
"name": "ssh",
"protocol": "TCP",
"port": 22,
"targetPort": 22,
"nodePort": 32417
}
],
"selector": {
"app": "jnlp"
},
"clusterIP": "....",
"type": "LoadBalancer",
"sessionAffinity": "None",
"externalTrafficPolicy": "Cluster"
},
"status": {
"loadBalancer": {
"ingress": [
{
"ip": "......"
}
]
}
}
}
jenkins配置:
podTemplate(label: slave,
containers: [
containerTemplate(name: 'mongodb',
image: mongo_image,
ttyEnabled: true,
ports: [portMapping(name: 'mongo', containerPort: 27017, hostPort: 27017)],
),
containerTemplate(name: 'elasticsearch',
image: elastic_image,
ttyEnabled: true,
ports: [portMapping(name: 'elastic', containerPort: 9200, hostPort: 9200)],
),
containerTemplate(name: 'jnlp',
image: "******:${CONTAINER_TAG}",
command: 'jenkins-slave',
alwaysPullImage: true,
privileged: true,
label: 'jnlp',
envVars: [
envVar(key: 'HOME', value: "${JENKINS_HOME}"),
])
],
imagePullSecrets: ['*******'],
podRetention: always()
)
答案 0 :(得分:0)
您不能让多个Pod使用相同的nodePort
,因为这是您将绑定到Pod的实际计算机上的端口。由于您使用的是负载平衡器,因此我看不到为什么需要使用nodePorts。如果您绝对不需要使用nodePorts,只需将其从服务中删除即可。