blob: ded18154ad9a6c4860950e9a2e6a040247c6fa61 [file] [log] [blame]
Lorenz Brundd8c80e2019-10-07 16:19:49 +02001// Copyright 2020 The Monogon Project Authors.
2//
3// SPDX-License-Identifier: Apache-2.0
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16
Serge Bazanski77cb6c52020-12-19 00:09:22 +010017package node
Hendrik Hofstadt0d7c91e2019-10-23 21:44:47 +020018
Tim Windelschmidt03000772023-07-03 02:19:28 +020019import (
20 "strconv"
21)
Lorenz Brun9e7961b2021-12-15 18:47:31 +010022
Serge Bazanski52304a82021-10-29 16:56:18 +020023// Port is a TCP and/or UDP port number reserved for and used by Metropolis
24// node code.
25type Port uint16
26
Serge Bazanski77cb6c52020-12-19 00:09:22 +010027const (
Serge Bazanski52304a82021-10-29 16:56:18 +020028 // CuratorServicePort is the TCP port on which the Curator listens for gRPC
29 // calls and services Management/AAA/Curator RPCs.
30 CuratorServicePort Port = 7835
31 // ConsensusPort is the TCP port on which etcd listens for peer traffic.
32 ConsensusPort Port = 7834
33 // DebugServicePort is the TCP port on which the debug service serves gRPC
34 // traffic. This is only available in debug builds.
35 DebugServicePort Port = 7837
36 // WireGuardPort is the UDP port on which the Wireguard Kubernetes network
37 // overlay listens for incoming peer traffic.
38 WireGuardPort Port = 7838
Tim Windelschmidtec2906a2024-03-27 01:36:43 +010039 // NodeManagementPort is the TCP port on which the node-local management service
Serge Bazanskib40c0082023-03-29 14:28:04 +020040 // serves gRPC traffic for NodeManagement.
Tim Windelschmidtec2906a2024-03-27 01:36:43 +010041 NodeManagementPort Port = 7839
Serge Bazanski54e212a2023-06-14 13:45:11 +020042 // MetricsPort is the TCP port on which the Metrics Service exports
43 // Prometheus-compatible metrics for this node, secured using TLS and the
44 // Cluster/Node certificates.
45 MetricsPort Port = 7840
46 // MetricsNodeListenerPort is the TCP port on which the Prometheus node_exporter
47 // runs, bound to 127.0.0.1. The Metrics Service proxies traffic to it from the
48 // public MetricsPort.
49 MetricsNodeListenerPort Port = 7841
Tim Windelschmidtc37a8862023-07-19 16:33:21 +020050 // MetricsEtcdListenerPort is the TCP port on which the etcd exporter
Tim Windelschmidtf64f1972023-07-28 00:00:50 +000051 // runs, bound to 127.0.0.1. The metrics service proxies traffic to it from the
Tim Windelschmidtc37a8862023-07-19 16:33:21 +020052 // public MetricsPort.
53 MetricsEtcdListenerPort Port = 7842
Tim Windelschmidtf64f1972023-07-28 00:00:50 +000054 // MetricsKubeSchedulerListenerPort is the TCP port on which the proxy for
55 // the kube-scheduler runs, bound to 127.0.0.1. The metrics service proxies
56 // traffic to it from the public MetricsPort.
57 MetricsKubeSchedulerListenerPort Port = 7843
58 // MetricsKubeControllerManagerListenerPort is the TCP port on which the
59 // proxy for the controller-manager runs, bound to 127.0.0.1. The metrics
60 // service proxies traffic to it from the public MetricsPort.
61 MetricsKubeControllerManagerListenerPort Port = 7844
Tim Windelschmidt600e2eb2023-11-21 05:29:14 +010062 // MetricsKubeAPIServerListenerPort is the TCP port on which the
63 // proxy for the api-server runs, bound to 127.0.0.1. The metrics
Lorenz Brun4b42c8a2023-11-19 07:02:51 +010064 // service proxies traffic to it from the public MetricsPort.
65 MetricsKubeAPIServerListenerPort Port = 7845
Tim Windelschmidt3bdb5fc2024-03-14 18:47:35 +010066 // MetricsContainerdListenerPort is the TCP port on which the
67 // containerd metrics endpoint, bound to 127.0.0.1, is exposed.
68 MetricsContainerdListenerPort Port = 7846
Serge Bazanski52304a82021-10-29 16:56:18 +020069 // KubernetesAPIPort is the TCP port on which the Kubernetes API is
70 // exposed.
71 KubernetesAPIPort Port = 6443
Lorenz Bruncc078df2021-12-23 11:51:55 +010072 // KubernetesAPIWrappedPort is the TCP port on which the Metropolis
73 // authenticating proxy for the Kubernetes API is exposed.
74 KubernetesAPIWrappedPort Port = 6444
Serge Bazanski6fdca3f2023-03-20 17:47:07 +010075 // KubernetesWorkerLocalAPIPort is the TCP port on which Kubernetes worker nodes
76 // run a loadbalancer to access the cluster's API servers before cluster
77 // networking is available. This port is only bound to 127.0.0.1.
78 KubernetesWorkerLocalAPIPort Port = 6445
Serge Bazanski52304a82021-10-29 16:56:18 +020079 // DebuggerPort is the port on which the delve debugger runs (on debug
80 // builds only). Not to be confused with DebugServicePort.
81 DebuggerPort Port = 2345
Serge Bazanski77cb6c52020-12-19 00:09:22 +010082)
Serge Bazanski52304a82021-10-29 16:56:18 +020083
Tim Windelschmidt03000772023-07-03 02:19:28 +020084var SystemPorts = []Port{
85 CuratorServicePort,
86 ConsensusPort,
87 DebugServicePort,
88 WireGuardPort,
Tim Windelschmidtec2906a2024-03-27 01:36:43 +010089 NodeManagementPort,
Tim Windelschmidt03000772023-07-03 02:19:28 +020090 MetricsPort,
91 MetricsNodeListenerPort,
Tim Windelschmidtc37a8862023-07-19 16:33:21 +020092 MetricsEtcdListenerPort,
Tim Windelschmidt03000772023-07-03 02:19:28 +020093 KubernetesAPIPort,
94 KubernetesAPIWrappedPort,
95 KubernetesWorkerLocalAPIPort,
96 DebuggerPort,
97}
98
Serge Bazanski52304a82021-10-29 16:56:18 +020099func (p Port) String() string {
100 switch p {
101 case CuratorServicePort:
102 return "curator"
103 case ConsensusPort:
104 return "consensus"
105 case DebugServicePort:
106 return "debug"
107 case WireGuardPort:
108 return "wireguard"
Tim Windelschmidtec2906a2024-03-27 01:36:43 +0100109 case NodeManagementPort:
Serge Bazanskib40c0082023-03-29 14:28:04 +0200110 return "node-mgmt"
Serge Bazanski52304a82021-10-29 16:56:18 +0200111 case KubernetesAPIPort:
112 return "kubernetes-api"
Serge Bazanski6fdca3f2023-03-20 17:47:07 +0100113 case KubernetesWorkerLocalAPIPort:
114 return "kubernetes-worker-local-api"
Lorenz Bruncc078df2021-12-23 11:51:55 +0100115 case KubernetesAPIWrappedPort:
116 return "kubernetes-api-wrapped"
Serge Bazanski52304a82021-10-29 16:56:18 +0200117 case DebuggerPort:
118 return "delve"
119 }
120 return "unknown"
121}
Lorenz Brun9e7961b2021-12-15 18:47:31 +0100122
123func (p Port) PortString() string {
124 return strconv.Itoa(int(p))
125}