Lorenz Brun | dd8c80e | 2019-10-07 16:19:49 +0200 | [diff] [blame] | 1 | // 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 Bazanski | 77cb6c5 | 2020-12-19 00:09:22 +0100 | [diff] [blame] | 17 | package node |
Hendrik Hofstadt | 0d7c91e | 2019-10-23 21:44:47 +0200 | [diff] [blame] | 18 | |
Lorenz Brun | 9e7961b | 2021-12-15 18:47:31 +0100 | [diff] [blame] | 19 | import "strconv" |
| 20 | |
Serge Bazanski | 52304a8 | 2021-10-29 16:56:18 +0200 | [diff] [blame] | 21 | // Port is a TCP and/or UDP port number reserved for and used by Metropolis |
| 22 | // node code. |
| 23 | type Port uint16 |
| 24 | |
Serge Bazanski | 77cb6c5 | 2020-12-19 00:09:22 +0100 | [diff] [blame] | 25 | const ( |
Serge Bazanski | 52304a8 | 2021-10-29 16:56:18 +0200 | [diff] [blame] | 26 | // 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 |
| 37 | // KubernetesAPIPort is the TCP port on which the Kubernetes API is |
| 38 | // exposed. |
| 39 | KubernetesAPIPort Port = 6443 |
Lorenz Brun | cc078df | 2021-12-23 11:51:55 +0100 | [diff] [blame] | 40 | // KubernetesAPIWrappedPort is the TCP port on which the Metropolis |
| 41 | // authenticating proxy for the Kubernetes API is exposed. |
| 42 | KubernetesAPIWrappedPort Port = 6444 |
Serge Bazanski | 6fdca3f | 2023-03-20 17:47:07 +0100 | [diff] [blame] | 43 | // KubernetesWorkerLocalAPIPort is the TCP port on which Kubernetes worker nodes |
| 44 | // run a loadbalancer to access the cluster's API servers before cluster |
| 45 | // networking is available. This port is only bound to 127.0.0.1. |
| 46 | KubernetesWorkerLocalAPIPort Port = 6445 |
Serge Bazanski | 52304a8 | 2021-10-29 16:56:18 +0200 | [diff] [blame] | 47 | // DebuggerPort is the port on which the delve debugger runs (on debug |
| 48 | // builds only). Not to be confused with DebugServicePort. |
| 49 | DebuggerPort Port = 2345 |
Serge Bazanski | 77cb6c5 | 2020-12-19 00:09:22 +0100 | [diff] [blame] | 50 | ) |
Serge Bazanski | 52304a8 | 2021-10-29 16:56:18 +0200 | [diff] [blame] | 51 | |
| 52 | func (p Port) String() string { |
| 53 | switch p { |
| 54 | case CuratorServicePort: |
| 55 | return "curator" |
| 56 | case ConsensusPort: |
| 57 | return "consensus" |
| 58 | case DebugServicePort: |
| 59 | return "debug" |
| 60 | case WireGuardPort: |
| 61 | return "wireguard" |
| 62 | case KubernetesAPIPort: |
| 63 | return "kubernetes-api" |
Serge Bazanski | 6fdca3f | 2023-03-20 17:47:07 +0100 | [diff] [blame] | 64 | case KubernetesWorkerLocalAPIPort: |
| 65 | return "kubernetes-worker-local-api" |
Lorenz Brun | cc078df | 2021-12-23 11:51:55 +0100 | [diff] [blame] | 66 | case KubernetesAPIWrappedPort: |
| 67 | return "kubernetes-api-wrapped" |
Serge Bazanski | 52304a8 | 2021-10-29 16:56:18 +0200 | [diff] [blame] | 68 | case DebuggerPort: |
| 69 | return "delve" |
| 70 | } |
| 71 | return "unknown" |
| 72 | } |
Lorenz Brun | 9e7961b | 2021-12-15 18:47:31 +0100 | [diff] [blame] | 73 | |
| 74 | func (p Port) PortString() string { |
| 75 | return strconv.Itoa(int(p)) |
| 76 | } |