mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-07-17 09:51:56 +00:00
✨ Add POD_REGEX
, NAMESPACES
, STORAGE_LIMIT
and LICENSE
environment variables to Hub
This commit is contained in:
parent
39d1b77045
commit
c42481deb8
@ -70,7 +70,7 @@ func tap() {
|
|||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
defer cancel() // cancel will be called when this function exits
|
defer cancel() // cancel will be called when this function exits
|
||||||
|
|
||||||
state.targetNamespaces = getNamespaces(kubernetesProvider)
|
state.targetNamespaces = kubernetesProvider.GetNamespaces()
|
||||||
|
|
||||||
if config.Config.IsNsRestrictedMode() {
|
if config.Config.IsNsRestrictedMode() {
|
||||||
if len(state.targetNamespaces) != 1 || !utils.Contains(state.targetNamespaces, config.Config.Tap.SelfNamespace) {
|
if len(state.targetNamespaces) != 1 || !utils.Contains(state.targetNamespaces, config.Config.Tap.SelfNamespace) {
|
||||||
@ -495,17 +495,3 @@ func postFrontStarted(ctx context.Context, kubernetesProvider *kubernetes.Provid
|
|||||||
utils.OpenBrowser(url)
|
utils.OpenBrowser(url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getNamespaces(kubernetesProvider *kubernetes.Provider) []string {
|
|
||||||
if config.Config.Tap.AllNamespaces {
|
|
||||||
return []string{kubernetes.K8sAllNamespaces}
|
|
||||||
} else if len(config.Config.Tap.Namespaces) > 0 {
|
|
||||||
return utils.Unique(config.Config.Tap.Namespaces)
|
|
||||||
} else {
|
|
||||||
currentNamespace, err := kubernetesProvider.CurrentNamespace()
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal().Err(err).Msg("Error getting current namespace!")
|
|
||||||
}
|
|
||||||
return []string{currentNamespace}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -74,7 +74,7 @@ type TapConfig struct {
|
|||||||
Proxy ProxyConfig `yaml:"proxy"`
|
Proxy ProxyConfig `yaml:"proxy"`
|
||||||
PodRegexStr string `yaml:"regex" default:".*"`
|
PodRegexStr string `yaml:"regex" default:".*"`
|
||||||
Namespaces []string `yaml:"namespaces"`
|
Namespaces []string `yaml:"namespaces"`
|
||||||
AllNamespaces bool `yaml:"allnamespaces" default:"false"`
|
AllNamespaces bool `yaml:"allnamespaces" default:"true"`
|
||||||
SelfNamespace string `yaml:"selfnamespace" default:"kubeshark"`
|
SelfNamespace string `yaml:"selfnamespace" default:"kubeshark"`
|
||||||
StorageLimit string `yaml:"storagelimit" default:"200MB"`
|
StorageLimit string `yaml:"storagelimit" default:"200MB"`
|
||||||
DryRun bool `yaml:"dryrun" default:"false"`
|
DryRun bool `yaml:"dryrun" default:"false"`
|
||||||
|
@ -9,12 +9,14 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/kubeshark/kubeshark/config"
|
"github.com/kubeshark/kubeshark/config"
|
||||||
"github.com/kubeshark/kubeshark/config/configStructs"
|
"github.com/kubeshark/kubeshark/config/configStructs"
|
||||||
"github.com/kubeshark/kubeshark/docker"
|
"github.com/kubeshark/kubeshark/docker"
|
||||||
"github.com/kubeshark/kubeshark/misc"
|
"github.com/kubeshark/kubeshark/misc"
|
||||||
"github.com/kubeshark/kubeshark/semver"
|
"github.com/kubeshark/kubeshark/semver"
|
||||||
|
"github.com/kubeshark/kubeshark/utils"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
auth "k8s.io/api/authorization/v1"
|
auth "k8s.io/api/authorization/v1"
|
||||||
core "k8s.io/api/core/v1"
|
core "k8s.io/api/core/v1"
|
||||||
@ -226,6 +228,24 @@ func (provider *Provider) BuildHubPod(opts *PodOptions) (*core.Pod, error) {
|
|||||||
"memory": memRequests,
|
"memory": memRequests,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Env: []core.EnvVar{
|
||||||
|
{
|
||||||
|
Name: "POD_REGEX",
|
||||||
|
Value: config.Config.Tap.PodRegexStr,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "NAMESPACES",
|
||||||
|
Value: strings.Join(provider.GetNamespaces(), ","),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "STORAGE_LIMIT",
|
||||||
|
Value: config.Config.Tap.StorageLimit,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "LICENSE",
|
||||||
|
Value: "",
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1076,6 +1096,20 @@ func (provider *Provider) GetKubernetesVersion() (*semver.SemVersion, error) {
|
|||||||
return &serverVersionSemVer, nil
|
return &serverVersionSemVer, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (provider *Provider) GetNamespaces() []string {
|
||||||
|
if config.Config.Tap.AllNamespaces {
|
||||||
|
return []string{K8sAllNamespaces}
|
||||||
|
} else if len(config.Config.Tap.Namespaces) > 0 {
|
||||||
|
return utils.Unique(config.Config.Tap.Namespaces)
|
||||||
|
} else {
|
||||||
|
currentNamespace, err := provider.CurrentNamespace()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal().Err(err).Msg("Error getting current namespace!")
|
||||||
|
}
|
||||||
|
return []string{currentNamespace}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func getClientSet(config *rest.Config) (*kubernetes.Clientset, error) {
|
func getClientSet(config *rest.Config) (*kubernetes.Clientset, error) {
|
||||||
clientSet, err := kubernetes.NewForConfig(config)
|
clientSet, err := kubernetes.NewForConfig(config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -12,6 +12,13 @@ spec:
|
|||||||
containers:
|
containers:
|
||||||
- command:
|
- command:
|
||||||
- ./hub
|
- ./hub
|
||||||
|
env:
|
||||||
|
- name: POD_REGEX
|
||||||
|
value: .*
|
||||||
|
- name: NAMESPACES
|
||||||
|
- name: STORAGE_LIMIT
|
||||||
|
value: 200MB
|
||||||
|
- name: LICENSE
|
||||||
image: docker.io/kubeshark/hub:latest
|
image: docker.io/kubeshark/hub:latest
|
||||||
imagePullPolicy: Always
|
imagePullPolicy: Always
|
||||||
name: kubeshark-hub
|
name: kubeshark-hub
|
||||||
|
Loading…
Reference in New Issue
Block a user