mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-07-02 19:15:40 +00:00
⚡ Create Worker(s) before Hub and reduce the grace periods
This commit is contained in:
parent
7312addb65
commit
384f62f94f
@ -409,26 +409,6 @@ func postHubStarted(ctx context.Context, kubernetesProvider *kubernetes.Provider
|
|||||||
"/echo",
|
"/echo",
|
||||||
)
|
)
|
||||||
|
|
||||||
// Create workers
|
|
||||||
err := kubernetes.CreateWorkers(
|
|
||||||
kubernetesProvider,
|
|
||||||
state.selfServiceAccountExists,
|
|
||||||
ctx,
|
|
||||||
config.Config.SelfNamespace,
|
|
||||||
config.Config.Tap.Resources.Worker,
|
|
||||||
config.Config.ImagePullPolicy(),
|
|
||||||
config.Config.ImagePullSecrets(),
|
|
||||||
config.Config.Tap.ServiceMesh,
|
|
||||||
config.Config.Tap.Tls,
|
|
||||||
config.Config.Tap.Debug,
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
log.Error().Err(err).Send()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Grace period
|
|
||||||
time.Sleep(time.Second)
|
|
||||||
|
|
||||||
// Storage limit
|
// Storage limit
|
||||||
connector.PostStorageLimitToHub(config.Config.Tap.StorageLimitBytes())
|
connector.PostStorageLimitToHub(config.Config.Tap.StorageLimitBytes())
|
||||||
|
|
||||||
@ -443,8 +423,7 @@ func postHubStarted(ctx context.Context, kubernetesProvider *kubernetes.Provider
|
|||||||
// Scripting
|
// Scripting
|
||||||
connector.PostConsts(config.Config.Scripting.Consts)
|
connector.PostConsts(config.Config.Scripting.Consts)
|
||||||
|
|
||||||
var scripts []*misc.Script
|
scripts, err := config.Config.Scripting.GetScripts()
|
||||||
scripts, err = config.Config.Scripting.GetScripts()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Send()
|
log.Error().Err(err).Send()
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ type Connector struct {
|
|||||||
|
|
||||||
const DefaultRetries = 3
|
const DefaultRetries = 3
|
||||||
const DefaultTimeout = 2 * time.Second
|
const DefaultTimeout = 2 * time.Second
|
||||||
|
const DefaultSleep = 100 * time.Millisecond
|
||||||
|
|
||||||
func NewConnector(url string, retries int, timeout time.Duration) *Connector {
|
func NewConnector(url string, retries int, timeout time.Duration) *Connector {
|
||||||
return &Connector{
|
return &Connector{
|
||||||
@ -45,7 +46,7 @@ func (connector *Connector) TestConnection(path string) error {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
retriesLeft -= 1
|
retriesLeft -= 1
|
||||||
time.Sleep(time.Second)
|
time.Sleep(5 * DefaultSleep)
|
||||||
}
|
}
|
||||||
|
|
||||||
if retriesLeft == 0 {
|
if retriesLeft == 0 {
|
||||||
@ -81,7 +82,7 @@ func (connector *Connector) PostWorkerPodToHub(pod *v1.Pod) {
|
|||||||
ok = true
|
ok = true
|
||||||
log.Info().Interface("worker-pod", pod).Msg("Reported worker pod to Hub:")
|
log.Info().Interface("worker-pod", pod).Msg("Reported worker pod to Hub:")
|
||||||
}
|
}
|
||||||
time.Sleep(time.Second)
|
time.Sleep(DefaultSleep)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -111,7 +112,7 @@ func (connector *Connector) PostStorageLimitToHub(limit int64) {
|
|||||||
ok = true
|
ok = true
|
||||||
log.Info().Int("limit", int(limit)).Msg("Reported storage limit to Hub:")
|
log.Info().Int("limit", int(limit)).Msg("Reported storage limit to Hub:")
|
||||||
}
|
}
|
||||||
time.Sleep(time.Second)
|
time.Sleep(DefaultSleep)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -144,7 +145,7 @@ func (connector *Connector) PostRegexToHub(regex string, namespaces []string) {
|
|||||||
ok = true
|
ok = true
|
||||||
log.Info().Str("regex", regex).Strs("namespaces", namespaces).Msg("Reported pod regex to Hub:")
|
log.Info().Str("regex", regex).Strs("namespaces", namespaces).Msg("Reported pod regex to Hub:")
|
||||||
}
|
}
|
||||||
time.Sleep(time.Second)
|
time.Sleep(DefaultSleep)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -175,7 +176,7 @@ func (connector *Connector) PostLicense(license string) {
|
|||||||
ok = true
|
ok = true
|
||||||
log.Info().Str("license", license).Msg("Reported license to Hub:")
|
log.Info().Str("license", license).Msg("Reported license to Hub:")
|
||||||
}
|
}
|
||||||
time.Sleep(time.Second)
|
time.Sleep(DefaultSleep)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -202,7 +203,7 @@ func (connector *Connector) PostConsts(consts map[string]interface{}) {
|
|||||||
ok = true
|
ok = true
|
||||||
log.Info().Interface("consts", consts).Msg("Reported constants to Hub:")
|
log.Info().Interface("consts", consts).Msg("Reported constants to Hub:")
|
||||||
}
|
}
|
||||||
time.Sleep(time.Second)
|
time.Sleep(DefaultSleep)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -241,7 +242,7 @@ func (connector *Connector) PostScript(script *misc.Script) (index int64, err er
|
|||||||
|
|
||||||
log.Info().Int("index", int(index)).Interface("script", script).Msg("Created script on Hub:")
|
log.Info().Int("index", int(index)).Interface("script", script).Msg("Created script on Hub:")
|
||||||
}
|
}
|
||||||
time.Sleep(time.Second)
|
time.Sleep(DefaultSleep)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,7 +284,7 @@ func (connector *Connector) PutScript(script *misc.Script, index int64) (err err
|
|||||||
ok = true
|
ok = true
|
||||||
log.Info().Int("index", int(index)).Interface("script", script).Msg("Updated script on Hub:")
|
log.Info().Int("index", int(index)).Interface("script", script).Msg("Updated script on Hub:")
|
||||||
}
|
}
|
||||||
time.Sleep(time.Second)
|
time.Sleep(DefaultSleep)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -321,7 +322,7 @@ func (connector *Connector) DeleteScript(index int64) (err error) {
|
|||||||
ok = true
|
ok = true
|
||||||
log.Info().Int("index", int(index)).Msg("Deleted script on Hub:")
|
log.Info().Int("index", int(index)).Msg("Deleted script on Hub:")
|
||||||
}
|
}
|
||||||
time.Sleep(time.Second)
|
time.Sleep(DefaultSleep)
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
@ -343,6 +344,6 @@ func (connector *Connector) PostScriptDone() {
|
|||||||
ok = true
|
ok = true
|
||||||
log.Info().Msg("Reported POST script done to Hub:")
|
log.Info().Msg("Reported POST script done to Hub:")
|
||||||
}
|
}
|
||||||
time.Sleep(time.Second)
|
time.Sleep(DefaultSleep)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,23 @@ func CreateHubResources(ctx context.Context, kubernetesProvider *kubernetes.Prov
|
|||||||
serviceAccountName = ""
|
serviceAccountName = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create workers
|
||||||
|
err = kubernetes.CreateWorkers(
|
||||||
|
kubernetesProvider,
|
||||||
|
selfServiceAccountExists,
|
||||||
|
ctx,
|
||||||
|
config.Config.SelfNamespace,
|
||||||
|
config.Config.Tap.Resources.Worker,
|
||||||
|
config.Config.ImagePullPolicy(),
|
||||||
|
config.Config.ImagePullSecrets(),
|
||||||
|
config.Config.Tap.ServiceMesh,
|
||||||
|
config.Config.Tap.Tls,
|
||||||
|
config.Config.Tap.Debug,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
log.Error().Err(err).Send()
|
||||||
|
}
|
||||||
|
|
||||||
opts := &kubernetes.PodOptions{
|
opts := &kubernetes.PodOptions{
|
||||||
Namespace: selfNamespace,
|
Namespace: selfNamespace,
|
||||||
PodName: kubernetes.HubPodName,
|
PodName: kubernetes.HubPodName,
|
||||||
|
Loading…
Reference in New Issue
Block a user