mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-08-06 11:05:08 +00:00
⚡ Pass every config through environment variables and don't make HTTP calls in first tap
command
This commit is contained in:
parent
26d75da588
commit
5ce10b626f
@ -331,6 +331,11 @@ func pcap(tarPath string) {
|
|||||||
connector = connect.NewConnector(kubernetes.GetLocalhostOnPort(config.Config.Tap.Proxy.Hub.SrcPort), connect.DefaultRetries, connect.DefaultTimeout)
|
connector = connect.NewConnector(kubernetes.GetLocalhostOnPort(config.Config.Tap.Proxy.Hub.SrcPort), connect.DefaultRetries, connect.DefaultTimeout)
|
||||||
connector.PostWorkerPodToHub(workerPod)
|
connector.PostWorkerPodToHub(workerPod)
|
||||||
|
|
||||||
|
// License
|
||||||
|
if config.Config.License != "" {
|
||||||
|
connector.PostLicense(config.Config.License)
|
||||||
|
}
|
||||||
|
|
||||||
log.Info().
|
log.Info().
|
||||||
Str("url", kubernetes.GetLocalhostOnPort(config.Config.Tap.Proxy.Hub.SrcPort)).
|
Str("url", kubernetes.GetLocalhostOnPort(config.Config.Tap.Proxy.Hub.SrcPort)).
|
||||||
Msg(fmt.Sprintf(utils.Green, "Hub is available at:"))
|
Msg(fmt.Sprintf(utils.Green, "Hub is available at:"))
|
||||||
|
@ -435,7 +435,7 @@ func postHubStarted(ctx context.Context, kubernetesProvider *kubernetes.Provider
|
|||||||
// Grace period
|
// Grace period
|
||||||
log.Info().Msg("Waiting for worker containers...")
|
log.Info().Msg("Waiting for worker containers...")
|
||||||
time.Sleep(5 * time.Second)
|
time.Sleep(5 * time.Second)
|
||||||
}
|
} else {
|
||||||
|
|
||||||
// Storage limit
|
// Storage limit
|
||||||
connector.PostStorageLimitToHub(config.Config.Tap.StorageLimitBytes())
|
connector.PostStorageLimitToHub(config.Config.Tap.StorageLimitBytes())
|
||||||
@ -464,6 +464,7 @@ func postHubStarted(ctx context.Context, kubernetesProvider *kubernetes.Provider
|
|||||||
}
|
}
|
||||||
|
|
||||||
connector.PostScriptDone()
|
connector.PostScriptDone()
|
||||||
|
}
|
||||||
|
|
||||||
if !update {
|
if !update {
|
||||||
// Hub proxy URL
|
// Hub proxy URL
|
||||||
|
@ -3,6 +3,7 @@ package kubernetes
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
@ -212,6 +213,25 @@ func (provider *Provider) BuildHubPod(opts *PodOptions) (*core.Pod, error) {
|
|||||||
command = append(command, "-debug")
|
command = append(command, "-debug")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Scripting environment variables
|
||||||
|
scriptingEnvMarshalled, err := json.Marshal(config.Config.Scripting.Env)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scripting scripts
|
||||||
|
scripts, err := config.Config.Scripting.GetScripts()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if scripts == nil {
|
||||||
|
scripts = []*misc.Script{}
|
||||||
|
}
|
||||||
|
scriptsMarshalled, err := json.Marshal(scripts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
containers := []core.Container{
|
containers := []core.Container{
|
||||||
{
|
{
|
||||||
Name: opts.PodName,
|
Name: opts.PodName,
|
||||||
@ -245,6 +265,14 @@ func (provider *Provider) BuildHubPod(opts *PodOptions) (*core.Pod, error) {
|
|||||||
Name: "LICENSE",
|
Name: "LICENSE",
|
||||||
Value: "",
|
Value: "",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "SCRIPTING_ENV",
|
||||||
|
Value: string(scriptingEnvMarshalled),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "SCRIPTING_SCRIPTS",
|
||||||
|
Value: string(scriptsMarshalled),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user