/** * Find the the qualfied container port of the target service * Uses java annotations first or returns the container port. * * @param service * The target service. * @param qualifiers * The set of qualifiers. * * @return Returns the resolved containerPort of '0' as a fallback. */ private static int getContainerPort(Service service, Annotation... qualifiers) { for (Annotation q : qualifiers) { if (q instanceof Port) { Port port = (Port) q; if (port.value() > 0) { return port.value(); } } } ServicePort servicePort = findQualifiedServicePort(service, qualifiers); if (servicePort != null) { return servicePort.getTargetPort().getIntVal(); } return 0; }
/** * Find the the qualfied container port of the target service * Uses java annotations first or returns the container port. * * @param service * The target service. * @param qualifiers * The set of qualifiers. * * @return Returns the resolved containerPort of '0' as a fallback. */ private static int getContainerPort(Service service, Annotation... qualifiers) { for (Annotation q : qualifiers) { if (q instanceof Port) { Port port = (Port) q; if (port.value() > 0) { return port.value(); } } } ServicePort servicePort = findQualifiedServicePort(service, qualifiers); if (servicePort != null) { return servicePort.getTargetPort().getIntVal(); } return 0; }
private int resolvePort(Service service) { final Pod pod = getRandomPod(client, service.getMetadata().getName(), namespace); final ServicePort servicePort = (service.getSpec() != null && service.getSpec().getPorts() != null) ? service.getSpec().getPorts().get(0) : null; final int containerPort = servicePort != null ? servicePort.getTargetPort().getIntVal() : 0; return portForward(pod.getMetadata().getName(), containerPort, namespace); }
private int resolvePort(Service service) { final Pod pod = getRandomPod(client, service.getMetadata().getName(), namespace); final ServicePort servicePort = (service.getSpec() != null && service.getSpec().getPorts() != null) ? service.getSpec().getPorts().get(0) : null; final int containerPort = servicePort != null ? servicePort.getTargetPort().getIntVal() : 0; return portForward(pod.getMetadata().getName(), containerPort, namespace); }