Skip to content

Commit

Permalink
propagate log level into kube-router
Browse files Browse the repository at this point in the history
Init klog v2 with the same V level set for logrus so that the verbosity level is correct in kube-router.
  • Loading branch information
thomasferrandiz committed Apr 18, 2023
1 parent 257fa2c commit 348d15c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/agent/netpol/netpol.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ package netpol

import (
"context"
"flag"
"runtime"
"strconv"
"strings"
"sync"

Expand All @@ -19,13 +21,15 @@ import (
"github.com/cloudnativelabs/kube-router/v2/pkg/options"
"github.com/cloudnativelabs/kube-router/v2/pkg/utils"
"github.com/coreos/go-iptables/iptables"
"github.com/k3s-io/k3s/pkg/cli/cmds"
"github.com/k3s-io/k3s/pkg/daemons/config"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
v1core "k8s.io/api/core/v1"
"k8s.io/client-go/informers"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/klog/v2"
)

// Run creates and starts a new instance of the kube-router network policy controller
Expand Down Expand Up @@ -126,6 +130,10 @@ func Run(ctx context.Context, nodeConfig *config.Node) error {
wg.Add(1)
go hc.RunCheck(healthCh, stopCh, &wg)

//init klog v2 which is used by kube-router
klog.InitFlags(nil)
flag.Set("v", strconv.Itoa(cmds.LogConfig.VLevel))

npc, err := netpol.NewNetworkPolicyController(client, krConfig, podInformer, npInformer, nsInformer, &sync.Mutex{},
iptablesCmdHandlers, ipSetHandlers)
if err != nil {
Expand Down

0 comments on commit 348d15c

Please sign in to comment.