mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-06-27 00:29:31 +00:00
Update Makefile, version.go, and 3 more files...
This commit is contained in:
parent
cc60ad064c
commit
bc165dbbaf
@ -11,7 +11,7 @@ install:
|
|||||||
go install mizu.go
|
go install mizu.go
|
||||||
|
|
||||||
build: ## build mizu CLI binary (select platform via GOOS / GOARCH env variables)
|
build: ## build mizu CLI binary (select platform via GOOS / GOARCH env variables)
|
||||||
go build -ldflags="-X 'github.com/up9inc/mizu/cli/mizu.Version=$(COMMIT_HASH)'" -o bin/$(FOLDER)/mizu mizu.go
|
go build -ldflags="-X 'github.com/up9inc/mizu/cli/mizu.GitCommitHash=$(COMMIT_HASH)'" -o bin/$(FOLDER)/mizu mizu.go
|
||||||
|
|
||||||
build-all: ## build for all supported platforms
|
build-all: ## build for all supported platforms
|
||||||
@echo "Compiling for every OS and Platform"
|
@echo "Compiling for every OS and Platform"
|
||||||
|
@ -11,7 +11,7 @@ var versionCmd = &cobra.Command{
|
|||||||
Use: "version",
|
Use: "version",
|
||||||
Short: "Print version info",
|
Short: "Print version info",
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
fmt.Printf("mizu version %s\n", mizu.Version)
|
fmt.Printf("%s %s\n", mizu.Version, mizu.GitCommitHash)
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ func (provider *Provider) GetPods(ctx context.Context, namespace string) {
|
|||||||
fmt.Printf("There are %d pods in Namespace %s\n", len(pods.Items), namespace)
|
fmt.Printf("There are %d pods in Namespace %s\n", len(pods.Items), namespace)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (provider *Provider) CreateMizuPod(ctx context.Context, namespace string, podName string, podImage string, tappedPodNamespace string, tappedPodName string) (*core.Pod, error) {
|
func (provider *Provider) CreateMizuPod(ctx context.Context, namespace string, podName string, podImage string, tappedPodNamespace string, tappedPodName string, linkServiceAccount bool) (*core.Pod, error) {
|
||||||
tappedPod, err := provider.clientSet.CoreV1().Pods(tappedPodNamespace).Get(ctx, tappedPodName, metav1.GetOptions{})
|
tappedPod, err := provider.clientSet.CoreV1().Pods(tappedPodNamespace).Get(ctx, tappedPodName, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err.Error())
|
panic(err.Error())
|
||||||
@ -117,11 +117,14 @@ func (provider *Provider) CreateMizuPod(ctx context.Context, namespace string, p
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
ServiceAccountName: serviceAccountName,
|
|
||||||
TerminationGracePeriodSeconds: new(int64),
|
TerminationGracePeriodSeconds: new(int64),
|
||||||
NodeSelector: map[string]string{"kubernetes.io/hostname": tappedPod.Spec.NodeName},
|
NodeSelector: map[string]string{"kubernetes.io/hostname": tappedPod.Spec.NodeName},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
//pod will crash if a non existent service account name is defined in spec
|
||||||
|
if linkServiceAccount {
|
||||||
|
pod.Spec.ServiceAccountName = serviceAccountName
|
||||||
|
}
|
||||||
return provider.clientSet.CoreV1().Pods(namespace).Create(ctx, pod, metav1.CreateOptions{})
|
return provider.clientSet.CoreV1().Pods(namespace).Create(ctx, pod, metav1.CreateOptions{})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
package mizu
|
package mizu
|
||||||
|
|
||||||
var Version = "development" // this var is overridden using ldflags in makefile when building
|
var (
|
||||||
|
Version = "v0.0.1"
|
||||||
|
GitCommitHash = "" // this var is overridden using ldflags in makefile when building
|
||||||
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
MizuResourcesNamespace = "default"
|
MizuResourcesNamespace = "default"
|
||||||
|
@ -19,8 +19,8 @@ func Run(tappedPodName string) {
|
|||||||
|
|
||||||
podName := "mizu-collector"
|
podName := "mizu-collector"
|
||||||
|
|
||||||
createRBACIfNecessary(ctx, kubernetesProvider, cancel)
|
mizuServiceAccountExists := createRBACIfNecessary(ctx, kubernetesProvider)
|
||||||
go createPodAndPortForward(ctx, kubernetesProvider, cancel, podName, MizuResourcesNamespace, tappedPodName) //TODO convert this to job for built in pod ttl or have the running app handle this
|
go createPodAndPortForward(ctx, kubernetesProvider, cancel, podName, MizuResourcesNamespace, tappedPodName, mizuServiceAccountExists) //TODO convert this to job for built in pod ttl or have the running app handle this
|
||||||
waitForFinish(ctx, cancel) //block until exit signal or error
|
waitForFinish(ctx, cancel) //block until exit signal or error
|
||||||
|
|
||||||
// TODO handle incoming traffic from tapper using a channel
|
// TODO handle incoming traffic from tapper using a channel
|
||||||
@ -53,8 +53,8 @@ func watchPodsForTapping(ctx context.Context, kubernetesProvider *kubernetes.Pro
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func createPodAndPortForward(ctx context.Context, kubernetesProvider *kubernetes.Provider, cancel context.CancelFunc, podName string, namespace string, tappedPodName string) {
|
func createPodAndPortForward(ctx context.Context, kubernetesProvider *kubernetes.Provider, cancel context.CancelFunc, podName string, namespace string, tappedPodName string, linkServiceAccount bool) {
|
||||||
pod, err := kubernetesProvider.CreateMizuPod(ctx, MizuResourcesNamespace, podName, config.Configuration.MizuImage, kubernetesProvider.Namespace, tappedPodName)
|
pod, err := kubernetesProvider.CreateMizuPod(ctx, MizuResourcesNamespace, podName, config.Configuration.MizuImage, kubernetesProvider.Namespace, tappedPodName, linkServiceAccount)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("error creating pod %s", err)
|
fmt.Printf("error creating pod %s", err)
|
||||||
cancel()
|
cancel()
|
||||||
@ -102,21 +102,20 @@ func createPodAndPortForward(ctx context.Context, kubernetesProvider *kubernetes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func createRBACIfNecessary(ctx context.Context, kubernetesProvider *kubernetes.Provider, cancel context.CancelFunc) {
|
func createRBACIfNecessary(ctx context.Context, kubernetesProvider *kubernetes.Provider) bool {
|
||||||
mizuRBACExists, err := kubernetesProvider.DoesMizuRBACExist(ctx, MizuResourcesNamespace)
|
mizuRBACExists, err := kubernetesProvider.DoesMizuRBACExist(ctx, MizuResourcesNamespace)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("error checking rbac %v", err)
|
fmt.Printf("warning: could not ensure mizu rbac resources exist %v", err)
|
||||||
cancel()
|
return false
|
||||||
return
|
|
||||||
}
|
}
|
||||||
if !mizuRBACExists {
|
if !mizuRBACExists {
|
||||||
err := kubernetesProvider.CreateMizuRBAC(ctx, MizuResourcesNamespace, Version)
|
err := kubernetesProvider.CreateMizuRBAC(ctx, MizuResourcesNamespace, Version)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("error creating rbac %v", err)
|
fmt.Printf("warning: could not create mizu rbac resources %v", err)
|
||||||
cancel()
|
return false
|
||||||
return
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func waitForFinish(ctx context.Context, cancel context.CancelFunc) {
|
func waitForFinish(ctx context.Context, cancel context.CancelFunc) {
|
||||||
|
Loading…
Reference in New Issue
Block a user