func newFEServicePorts()

in pkg/controller/sub_controller/disaggregated_cluster/disaggregated_fe/service.go [56:92]


func newFEServicePorts(config map[string]interface{}, svcConf *dv1.ExportService) []corev1.ServicePort {
	httpPort := resource.GetPort(config, resource.HTTP_PORT)
	rpcPort := resource.GetPort(config, resource.RPC_PORT)
	queryPort := resource.GetPort(config, resource.QUERY_PORT)
	editPort := resource.GetPort(config, resource.EDIT_LOG_PORT)
	arrowFlightPort := resource.GetPort(config, resource.ARROW_FLIGHT_SQL_PORT)
	ports := []corev1.ServicePort{
		{
			Port: httpPort, TargetPort: intstr.FromInt32(httpPort), Name: resource.GetPortKey(resource.HTTP_PORT),
		}, {
			Port: rpcPort, TargetPort: intstr.FromInt32(rpcPort), Name: resource.GetPortKey(resource.RPC_PORT),
		}, {
			Port: queryPort, TargetPort: intstr.FromInt32(queryPort), Name: resource.GetPortKey(resource.QUERY_PORT),
		}, {
			Port: editPort, TargetPort: intstr.FromInt32(editPort), Name: resource.GetPortKey(resource.EDIT_LOG_PORT),
		}}

	if arrowFlightPort != -1 {
		ports = append(ports, corev1.ServicePort{
			Port: arrowFlightPort, TargetPort: intstr.FromInt32(arrowFlightPort), Name: resource.GetPortKey(resource.ARROW_FLIGHT_SQL_PORT),
		})
	}

	if svcConf == nil || svcConf.Type != corev1.ServiceTypeNodePort {
		return ports
	}

	for i, _ := range ports {
		for j, _ := range svcConf.PortMaps {
			if ports[i].Port == svcConf.PortMaps[j].TargetPort {
				ports[i].NodePort = svcConf.PortMaps[j].NodePort
			}
		}
	}

	return ports
}