问题
I want to run multiple instances of same pod in the same node in the Kubernetes. I am using a wildfly docker image for this. When running more than one pod in the same node, I am getting port conflict exception.
2020-11-30 15:53:17,079 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
("core-service" => "management"),
("management-interface" => "http-interface")
]) - failure description: {"WFLYCTL0080: Failed services" => {"org.wildfly.management.http.extensible" => "java.net.BindException: Address already in use /0.0.0.0:9990"}}
2020-11-30 15:53:17,259 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
("subsystem" => "undertow"),
("server" => "default-server"),
("http-listener" => "default")
]) - failure description: {"WFLYCTL0080: Failed services" => {"org.wildfly.undertow.listener.default" => "Address already in use /0.0.0.0:9575"}}
2020-11-30 15:53:17,260 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
("subsystem" => "undertow"),
("server" => "default-server"),
("https-listener" => "https")
]) - failure description: {"WFLYCTL0080: Failed services" => {"org.wildfly.undertow.listener.https" => "Address already in use /0.0.0.0:8553"}}
2020-11-30 15:53:17,262 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([
("core-service" => "management"),
("management-interface" => "http-interface")
]) - failure description: {"WFLYCTL0080: Failed services" => {"org.wildfly.management.http.extensible" => "java.net.BindException: Address already in use /0.0.0.0:9990"}}
2020-11-30 15:53:17,399 INFO [org.jboss.as.server.deployment] (MSC service thread 1-1) WFLYSRV0028: Stopped deployment demo.war (runtime-name: demo.war) in 133ms
2020-11-30 15:53:17,416 ERROR [org.jboss.as.server] (ServerService Thread Pool -- 44) WFLYSRV0021: Deploy of deployment "demo.war" was rolled back with the following fai
lure message: undefined
So how can i bypass this issue and run multiple instances without port conflits??
回答1:
Ports of different pods may collide only if you use hostPort
or hostNetwork
. Otherwise, you shouldn't encounter any issues while running multiple identical pods in the same node.
You can just try to run the following commands. Your Wildfly pods should run without any issues because the ports they use are inside the containers.
kubectl run wildfly --image=jboss/wildfly
kubectl run wildfly-2 --image=jboss/wildfly
kubectl run wildfly-3 --image=jboss/wildfly
If you need to use hostPort
or hostNetwork
(which is not recommended), then you're on your own here, and you need to "orchestrate" ports on your own.
来源:https://stackoverflow.com/questions/65084667/multiple-instance-of-same-pod-in-same-node-kubernetes