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 (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"k8s.io/client-go/discovery"
|
"k8s.io/client-go/discovery"
|
||||||
|
@ -77,7 +78,7 @@ func Run(ctx context.Context, opts *options.Options) error {
|
||||||
LeaderElectionID: opts.LeaderElection.ResourceName,
|
LeaderElectionID: opts.LeaderElection.ResourceName,
|
||||||
LeaderElectionNamespace: opts.LeaderElection.ResourceNamespace,
|
LeaderElectionNamespace: opts.LeaderElection.ResourceNamespace,
|
||||||
LeaderElectionResourceLock: opts.LeaderElection.ResourceLock,
|
LeaderElectionResourceLock: opts.LeaderElection.ResourceLock,
|
||||||
HealthProbeBindAddress: fmt.Sprintf("%s:%d", opts.BindAddress, opts.SecurePort),
|
HealthProbeBindAddress: net.JoinHostPort(opts.BindAddress, strconv.Itoa(opts.SecurePort)),
|
||||||
LivenessEndpointName: "/healthz",
|
LivenessEndpointName: "/healthz",
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -4,8 +4,10 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"k8s.io/client-go/kubernetes"
|
"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 {
|
func run(ctx context.Context, opts *options.Options) error {
|
||||||
klog.Infof("karmada-scheduler-estimator version: %s", version.Get())
|
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)
|
restConfig, err := clientcmd.BuildConfigFromFlags(opts.Master, opts.KubeConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -4,8 +4,10 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
"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 {
|
func run(opts *options.Options, stopChan <-chan struct{}) error {
|
||||||
klog.Infof("karmada-scheduler version: %s", version.Get())
|
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)
|
restConfig, err := clientcmd.BuildConfigFromFlags(opts.Master, opts.KubeConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue