-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
Suggestion
Some use cases require to add extraPortMapping between the container and the host. This is typically the case when we install an ingress controller exposing routes: argocd.localtest.me:8443, argocd.127.0.0.1.nip.io, etc
Kind supports such an option using
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
image: "kindest/node:v1.31.4"
labels:
ingress-ready: "true"
extraPortMappings:
- containerPort: 443
hostPort: 8443
protocol: TCP
...
Implementation: https://github.com/kubernetes-sigs/kind/blob/5f59a835fa1da606f7709ef51827467f53f8f091/pkg/cluster/internal/providers/podman/provision.go#L100
Such a feature is offered by the Generic TestContainer but protected !!!
// https://github.com/testcontainers/testcontainers-java/blob/main/core/src/main/java/org/testcontainers/containers/GenericContainer.java#L1130-L1148
/**
* Add a container port that should be bound to a fixed port on the docker host.
* <p>
* Note that this method is protected scope to discourage use, as clashes or instability are more likely when
* using fixed port mappings. If you need to use this method from a test, please use {@link FixedHostPortGenericContainer}
* instead of GenericContainer.
*
* @param hostPort
* @param containerPort
* @param protocol
*/
protected void addFixedExposedPort(int hostPort, int containerPort, InternetProtocol protocol) {
ExposedPort exposedPort = new ExposedPort(
containerPort,
com.github.dockerjava.api.model.InternetProtocol.parse(protocol.name())
);
PortBinding portBinding = new PortBinding(Ports.Binding.bindPort(hostPort), exposedPort);
this.containerDef.addPortBindings(portBinding);
}
Metadata
Metadata
Assignees
Labels
No labels