blob: 440f127dd226f58142af13c54cb30c324a0e11c6 [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
Lorenz Brun9e7961b2021-12-15 18:47:31 +010019import "strconv"
20
Serge Bazanski52304a82021-10-29 16:56:18 +020021// Port is a TCP and/or UDP port number reserved for and used by Metropolis
22// node code.
23type Port uint16
24
Serge Bazanski77cb6c52020-12-19 00:09:22 +010025const (
Serge Bazanski52304a82021-10-29 16:56:18 +020026 // CuratorServicePort is the TCP port on which the Curator listens for gRPC
27 // calls and services Management/AAA/Curator RPCs.
28 CuratorServicePort Port = 7835
29 // ConsensusPort is the TCP port on which etcd listens for peer traffic.
30 ConsensusPort Port = 7834
31 // DebugServicePort is the TCP port on which the debug service serves gRPC
32 // traffic. This is only available in debug builds.
33 DebugServicePort Port = 7837
34 // WireGuardPort is the UDP port on which the Wireguard Kubernetes network
35 // overlay listens for incoming peer traffic.
36 WireGuardPort Port = 7838
Serge Bazanskib40c0082023-03-29 14:28:04 +020037 // NodeManagement is the TCP port on which the node-local management service
38 // serves gRPC traffic for NodeManagement.
39 NodeManagement Port = 7839
Serge Bazanski52304a82021-10-29 16:56:18 +020040 // KubernetesAPIPort is the TCP port on which the Kubernetes API is
41 // exposed.
42 KubernetesAPIPort Port = 6443
Lorenz Bruncc078df2021-12-23 11:51:55 +010043 // KubernetesAPIWrappedPort is the TCP port on which the Metropolis
44 // authenticating proxy for the Kubernetes API is exposed.
45 KubernetesAPIWrappedPort Port = 6444
Serge Bazanski6fdca3f2023-03-20 17:47:07 +010046 // KubernetesWorkerLocalAPIPort is the TCP port on which Kubernetes worker nodes
47 // run a loadbalancer to access the cluster's API servers before cluster
48 // networking is available. This port is only bound to 127.0.0.1.
49 KubernetesWorkerLocalAPIPort Port = 6445
Serge Bazanski52304a82021-10-29 16:56:18 +020050 // DebuggerPort is the port on which the delve debugger runs (on debug
51 // builds only). Not to be confused with DebugServicePort.
52 DebuggerPort Port = 2345
Serge Bazanski77cb6c52020-12-19 00:09:22 +010053)
Serge Bazanski52304a82021-10-29 16:56:18 +020054
55func (p Port) String() string {
56 switch p {
57 case CuratorServicePort:
58 return "curator"
59 case ConsensusPort:
60 return "consensus"
61 case DebugServicePort:
62 return "debug"
63 case WireGuardPort:
64 return "wireguard"
Serge Bazanskib40c0082023-03-29 14:28:04 +020065 case NodeManagement:
66 return "node-mgmt"
Serge Bazanski52304a82021-10-29 16:56:18 +020067 case KubernetesAPIPort:
68 return "kubernetes-api"
Serge Bazanski6fdca3f2023-03-20 17:47:07 +010069 case KubernetesWorkerLocalAPIPort:
70 return "kubernetes-worker-local-api"
Lorenz Bruncc078df2021-12-23 11:51:55 +010071 case KubernetesAPIWrappedPort:
72 return "kubernetes-api-wrapped"
Serge Bazanski52304a82021-10-29 16:56:18 +020073 case DebuggerPort:
74 return "delve"
75 }
76 return "unknown"
77}
Lorenz Brun9e7961b2021-12-15 18:47:31 +010078
79func (p Port) PortString() string {
80 return strconv.Itoa(int(p))
81}