using net.JoinHostPort to generate a network address
Signed-off-by: guoyao <1015105054@qq.com>
This commit is contained in:
parent
4705587037
commit
d563b179cd
|
@ -3,8 +3,9 @@ package app
|
|||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"net"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"k8s.io/client-go/discovery"
|
||||
|
@ -77,7 +78,7 @@ func Run(ctx context.Context, opts *options.Options) error {
|
|||
LeaderElectionID: opts.LeaderElection.ResourceName,
|
||||
LeaderElectionNamespace: opts.LeaderElection.ResourceNamespace,
|
||||
LeaderElectionResourceLock: opts.LeaderElection.ResourceLock,
|
||||
HealthProbeBindAddress: fmt.Sprintf("%s:%d", opts.BindAddress, opts.SecurePort),
|
||||
HealthProbeBindAddress: net.JoinHostPort(opts.BindAddress, strconv.Itoa(opts.SecurePort)),
|
||||
LivenessEndpointName: "/healthz",
|
||||
})
|
||||
if err != nil {
|
||||
|
|
|
@ -4,8 +4,10 @@ import (
|
|||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
|
@ -45,7 +47,7 @@ func NewSchedulerEstimatorCommand(ctx context.Context) *cobra.Command {
|
|||
|
||||
func run(ctx context.Context, opts *options.Options) error {
|
||||
klog.Infof("karmada-scheduler-estimator version: %s", version.Get())
|
||||
go serveHealthz(fmt.Sprintf("%s:%d", opts.BindAddress, opts.SecurePort))
|
||||
go serveHealthz(net.JoinHostPort(opts.BindAddress, strconv.Itoa(opts.SecurePort)))
|
||||
|
||||
restConfig, err := clientcmd.BuildConfigFromFlags(opts.Master, opts.KubeConfig)
|
||||
if err != nil {
|
||||
|
|
|
@ -4,8 +4,10 @@ import (
|
|||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
|
@ -60,7 +62,7 @@ func NewSchedulerCommand(stopChan <-chan struct{}) *cobra.Command {
|
|||
|
||||
func run(opts *options.Options, stopChan <-chan struct{}) error {
|
||||
klog.Infof("karmada-scheduler version: %s", version.Get())
|
||||
go serveHealthzAndMetrics(fmt.Sprintf("%s:%d", opts.BindAddress, opts.SecurePort))
|
||||
go serveHealthzAndMetrics(net.JoinHostPort(opts.BindAddress, strconv.Itoa(opts.SecurePort)))
|
||||
|
||||
restConfig, err := clientcmd.BuildConfigFromFlags(opts.Master, opts.KubeConfig)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue