mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-09-20 09:39:14 +00:00
WIP
This commit is contained in:
@@ -111,7 +111,7 @@ func (provider *Provider) CreateMizuAggregatorPod(ctx context.Context, namespace
|
||||
return provider.clientSet.CoreV1().Pods(namespace).Create(ctx, pod, metav1.CreateOptions{})
|
||||
}
|
||||
|
||||
func (provider *Provider) CreateService(ctx context.Context, namespace string, serviceName string, appLabelValue string) (*core.Service, error) {
|
||||
func (provider *Provider) CreateService(ctx context.Context, namespace string, serviceName string, appLabelValue string, serviceType string) (*core.Service, error) {
|
||||
service := core.Service{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: serviceName,
|
||||
@@ -119,7 +119,7 @@ func (provider *Provider) CreateService(ctx context.Context, namespace string, s
|
||||
},
|
||||
Spec: core.ServiceSpec{
|
||||
Ports: []core.ServicePort{{TargetPort: intstr.FromInt(8899), Port: 80}},
|
||||
Type: core.ServiceTypeClusterIP,
|
||||
Type: core.ServiceType(serviceType),
|
||||
Selector: map[string]string{"app": appLabelValue},
|
||||
},
|
||||
}
|
||||
|
31
cli/kubernetes/proxy.go
Normal file
31
cli/kubernetes/proxy.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package kubernetes
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"k8s.io/kubectl/pkg/proxy"
|
||||
)
|
||||
|
||||
func StartProxy(ctx context.Context, kubernetesProvider *Provider, mizuPort uint16, mizuNamespace string, mizuServiceName string) error {
|
||||
server, err := proxy.NewServer("", "/", "", nil, &kubernetesProvider.clientConfig, 0)
|
||||
|
||||
l, err := server.Listen("0.0.0.0", int(mizuPort))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
go func() {
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
err := l.Close()
|
||||
if err != nil {
|
||||
fmt.Printf("Error stopping proxy network handler %v", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
}()
|
||||
fmt.Printf("Mizu is available at http://localhost:%d/api/v1/namespaces/%s/services/%s:80/proxy", mizuPort, mizuNamespace, mizuServiceName)
|
||||
return server.ServeOnListener(l)
|
||||
}
|
Reference in New Issue
Block a user