public List<String> getExposedPorts(ServiceSpec serviceSpec, boolean includeAgentPorts) throws HyscaleException {
        List<Port> servicePorts = serviceSpec.get(HyscaleSpecFields.ports, new TypeReference<>() {
        });
        List<String> exposedPorts = CollectionUtils.isEmpty(servicePorts) ? new ArrayList<>() :
                servicePorts.stream().map(port -> defaultPortsBuilder.updatePortProtocol(port).getPort()).collect(Collectors.toList());
        if (includeAgentPorts) {
            List<Agent> agents = serviceSpec.get(HyscaleSpecFields.agents, new TypeReference<>() {
            });
            if (!CollectionUtils.isEmpty(agents)) {
                agents.stream().filter(each -> each.getPorts() != null).forEach(agent ->
                        agent.getPorts().forEach(port ->
                                exposedPorts.add(defaultPortsBuilder.updatePortProtocol(port).getPort())));
            }
        }
        return exposedPorts;
    }
This class provides a list of Exposed Ports from
the service spec provided.
workflow-controller/controller-service/src/main/java/io/hyscale/controller/provider/PortsProvider.java