Skip to content

Commit

Permalink
feat: allow defining http server and api server ports separately
Browse files Browse the repository at this point in the history
This should provide flexibility in case if running on `hostNetwork` and
want a different port and still keep compatibility with
`loadbalancer`/`ingress` setups.

Signed-off-by: Artem Chernyshev <artem.chernyshev@talos-systems.com>
(cherry picked from commit 0511d78)
  • Loading branch information
Unix4ever authored and smira committed Dec 9, 2021
1 parent 31ecffb commit ce626cf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/sidero-controller-manager/config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ spec:
- --metrics-bind-addr=127.0.0.1:8080
- --api-endpoint=${SIDERO_CONTROLLER_MANAGER_API_ENDPOINT:=-}
- --api-port=${SIDERO_CONTROLLER_MANAGER_API_PORT:=8081}
- --http-port=${SIDERO_CONTROLLER_MANAGER_CONTAINER_API_PORT:=8081}
- --extra-agent-kernel-args=${SIDERO_CONTROLLER_MANAGER_EXTRA_AGENT_KERNEL_ARGS:=-}
- --boot-from-disk-method=${SIDERO_CONTROLLER_MANAGER_BOOT_FROM_DISK_METHOD:=ipxe-exit}
- --auto-accept-servers=${SIDERO_CONTROLLER_MANAGER_AUTO_ACCEPT_SERVERS:=false}
Expand All @@ -65,7 +66,7 @@ spec:
containerPort: 69
protocol: UDP
- name: http
containerPort: ${SIDERO_CONTROLLER_MANAGER_API_PORT:=8081}
containerPort: ${SIDERO_CONTROLLER_MANAGER_CONTAINER_API_PORT:=8081}
protocol: TCP
env:
- name: API_ENDPOINT
Expand Down
4 changes: 3 additions & 1 deletion app/sidero-controller-manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func main() {
metricsAddr string
apiEndpoint string
apiPort int
httpPort int
extraAgentKernelArgs string
bootFromDiskMethod string
enableLeaderElection bool
Expand All @@ -84,6 +85,7 @@ func main() {

flag.StringVar(&apiEndpoint, "api-endpoint", "", "The endpoint (hostname or IP address) Sidero can be reached at from the servers.")
flag.IntVar(&apiPort, "api-port", 8081, "The TCP port Sidero components can be reached at from the servers.")
flag.IntVar(&httpPort, "http-port", 8081, "The TCP port Sidero controller manager HTTP server is running.")
flag.StringVar(&metricsAddr, "metrics-bind-addr", ":8081", "The address the metric endpoint binds to.")
flag.StringVar(&extraAgentKernelArgs, "extra-agent-kernel-args", "", "A comma delimited list of key-value pairs to be added to the agent environment kernel parameters.")
flag.StringVar(&bootFromDiskMethod, "boot-from-disk-method", string(ipxe.BootIPXEExit), "Default method to use to boot server from disk if it hits iPXE endpoint after install.")
Expand Down Expand Up @@ -292,7 +294,7 @@ func main() {
httpMux.ServeHTTP(w, req)
})

err := http.ListenAndServe(fmt.Sprintf(":%d", apiPort), h2c.NewHandler(grpcHandler, h2s))
err := http.ListenAndServe(fmt.Sprintf(":%d", httpPort), h2c.NewHandler(grpcHandler, h2s))
if err != nil {
setupLog.Error(err, "problem running HTTP server")
}
Expand Down

0 comments on commit ce626cf

Please sign in to comment.