mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-06-25 15:54:43 +00:00
Changed sync tappers to start only when sync tappers config is true (#562)
This commit is contained in:
parent
2da7c0f0ed
commit
15895d5947
@ -131,6 +131,10 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if config.Config.SyncTappers {
|
||||||
|
startSyncingTappers()
|
||||||
|
}
|
||||||
|
|
||||||
hostApi(outputItemsChannel)
|
hostApi(outputItemsChannel)
|
||||||
} else if *harsReaderMode {
|
} else if *harsReaderMode {
|
||||||
outputItemsChannel := make(chan *tapApi.OutputChannelItem, 1000)
|
outputItemsChannel := make(chan *tapApi.OutputChannelItem, 1000)
|
||||||
@ -260,20 +264,6 @@ func hostApi(socketHarOutputChannel chan<- *tapApi.OutputChannelItem) {
|
|||||||
routes.StatusRoutes(app)
|
routes.StatusRoutes(app)
|
||||||
routes.NotFoundRoute(app)
|
routes.NotFoundRoute(app)
|
||||||
|
|
||||||
if config.Config.DaemonMode {
|
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
|
||||||
defer cancel()
|
|
||||||
|
|
||||||
kubernetesProvider, err := kubernetes.NewProviderInCluster()
|
|
||||||
if err != nil {
|
|
||||||
logger.Log.Fatalf("error creating k8s provider: %+v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, err := startMizuTapperSyncer(ctx, kubernetesProvider); err != nil {
|
|
||||||
logger.Log.Fatalf("error initializing tapper syncer: %+v", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
utils.StartServer(app)
|
utils.StartServer(app)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -461,6 +451,20 @@ func handleIncomingMessageAsTapper(socketConnection *websocket.Conn) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func startSyncingTappers() {
|
||||||
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
kubernetesProvider, err := kubernetes.NewProviderInCluster()
|
||||||
|
if err != nil {
|
||||||
|
logger.Log.Fatalf("error creating k8s provider: %+v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err := startMizuTapperSyncer(ctx, kubernetesProvider); err != nil {
|
||||||
|
logger.Log.Fatalf("error initializing tapper syncer: %+v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func startMizuTapperSyncer(ctx context.Context, provider *kubernetes.Provider) (*kubernetes.MizuTapperSyncer, error) {
|
func startMizuTapperSyncer(ctx context.Context, provider *kubernetes.Provider) (*kubernetes.MizuTapperSyncer, error) {
|
||||||
tapperSyncer, err := kubernetes.CreateAndStartMizuTapperSyncer(ctx, provider, kubernetes.TapperSyncerConfig{
|
tapperSyncer, err := kubernetes.CreateAndStartMizuTapperSyncer(ctx, provider, kubernetes.TapperSyncerConfig{
|
||||||
TargetNamespaces: config.Config.TargetNamespaces,
|
TargetNamespaces: config.Config.TargetNamespaces,
|
||||||
|
@ -56,6 +56,6 @@ func getDefaultConfig() (*shared.MizuAgentConfig, error) {
|
|||||||
TapTargetRegex: *regex,
|
TapTargetRegex: *regex,
|
||||||
MaxDBSizeBytes: defaultMaxDatabaseSizeBytes,
|
MaxDBSizeBytes: defaultMaxDatabaseSizeBytes,
|
||||||
AgentDatabasePath: DefaultDatabasePath,
|
AgentDatabasePath: DefaultDatabasePath,
|
||||||
DaemonMode: false,
|
SyncTappers: false,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func HealthCheck(c *gin.Context) {
|
func HealthCheck(c *gin.Context) {
|
||||||
if config.Config.DaemonMode {
|
if config.Config.SyncTappers {
|
||||||
if providers.ExpectedTapperAmount != providers.TappersCount {
|
if providers.ExpectedTapperAmount != providers.TappersCount {
|
||||||
c.JSON(http.StatusInternalServerError, fmt.Sprintf("expecting more tappers than are actually connected (%d expected, %d connected)", providers.ExpectedTapperAmount, providers.TappersCount))
|
c.JSON(http.StatusInternalServerError, fmt.Sprintf("expecting more tappers than are actually connected (%d expected, %d connected)", providers.ExpectedTapperAmount, providers.TappersCount))
|
||||||
return
|
return
|
||||||
|
@ -392,7 +392,6 @@ func getMizuAgentConfig(targetNamespaces []string, mizuApiFilteringOptions *api.
|
|||||||
config := shared.MizuAgentConfig{
|
config := shared.MizuAgentConfig{
|
||||||
TapTargetRegex: *serializableRegex,
|
TapTargetRegex: *serializableRegex,
|
||||||
MaxDBSizeBytes: Config.Tap.MaxEntriesDBSizeBytes(),
|
MaxDBSizeBytes: Config.Tap.MaxEntriesDBSizeBytes(),
|
||||||
DaemonMode: Config.Tap.DaemonMode,
|
|
||||||
TargetNamespaces: targetNamespaces,
|
TargetNamespaces: targetNamespaces,
|
||||||
AgentImage: Config.AgentImage,
|
AgentImage: Config.AgentImage,
|
||||||
PullPolicy: Config.ImagePullPolicyStr,
|
PullPolicy: Config.ImagePullPolicyStr,
|
||||||
@ -403,6 +402,7 @@ func getMizuAgentConfig(targetNamespaces []string, mizuApiFilteringOptions *api.
|
|||||||
MizuApiFilteringOptions: *mizuApiFilteringOptions,
|
MizuApiFilteringOptions: *mizuApiFilteringOptions,
|
||||||
AgentDatabasePath: shared.DataDirPath,
|
AgentDatabasePath: shared.DataDirPath,
|
||||||
Istio: Config.Tap.Istio,
|
Istio: Config.Tap.Istio,
|
||||||
|
SyncTappers: Config.Tap.DaemonMode,
|
||||||
}
|
}
|
||||||
return &config, nil
|
return &config, nil
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,6 @@ type Resources struct {
|
|||||||
type MizuAgentConfig struct {
|
type MizuAgentConfig struct {
|
||||||
TapTargetRegex api.SerializableRegexp `json:"tapTargetRegex"`
|
TapTargetRegex api.SerializableRegexp `json:"tapTargetRegex"`
|
||||||
MaxDBSizeBytes int64 `json:"maxDBSizeBytes"`
|
MaxDBSizeBytes int64 `json:"maxDBSizeBytes"`
|
||||||
DaemonMode bool `json:"daemonMode"`
|
|
||||||
TargetNamespaces []string `json:"targetNamespaces"`
|
TargetNamespaces []string `json:"targetNamespaces"`
|
||||||
AgentImage string `json:"agentImage"`
|
AgentImage string `json:"agentImage"`
|
||||||
PullPolicy string `json:"pullPolicy"`
|
PullPolicy string `json:"pullPolicy"`
|
||||||
@ -47,6 +46,7 @@ type MizuAgentConfig struct {
|
|||||||
MizuApiFilteringOptions api.TrafficFilteringOptions `json:"mizuApiFilteringOptions"`
|
MizuApiFilteringOptions api.TrafficFilteringOptions `json:"mizuApiFilteringOptions"`
|
||||||
AgentDatabasePath string `json:"agentDatabasePath"`
|
AgentDatabasePath string `json:"agentDatabasePath"`
|
||||||
Istio bool `json:"istio"`
|
Istio bool `json:"istio"`
|
||||||
|
SyncTappers bool `json:"syncTappers"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type WebSocketMessageMetadata struct {
|
type WebSocketMessageMetadata struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user