mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-08-10 21:02:21 +00:00
TRA-4235 Move Basenine binary into the same agent image but run it as a separate container (#702)
* TRA-4235 Revert "Move Basenine binary into a separate container" * Deploy the same agent image as a separate container for Basenine Co-authored-by: Igor Gov <iggvrv@gmail.com>
This commit is contained in:
parent
65bb338ed6
commit
7fa1a191a6
11
Dockerfile
11
Dockerfile
@ -16,7 +16,7 @@ RUN npm run build-ent
|
|||||||
### Base builder image for native builds architecture
|
### Base builder image for native builds architecture
|
||||||
FROM golang:1.16-alpine AS builder-native-base
|
FROM golang:1.16-alpine AS builder-native-base
|
||||||
ENV CGO_ENABLED=1 GOOS=linux
|
ENV CGO_ENABLED=1 GOOS=linux
|
||||||
RUN apk add libpcap-dev g++
|
RUN apk add libpcap-dev g++ perl-utils
|
||||||
|
|
||||||
|
|
||||||
### Intermediate builder image for x86-64 to x86-64 native builds
|
### Intermediate builder image for x86-64 to x86-64 native builds
|
||||||
@ -77,6 +77,13 @@ RUN go build -ldflags="-extldflags=-static -s -w \
|
|||||||
-X 'mizuserver/pkg/version.BuildTimestamp=${BUILD_TIMESTAMP}' \
|
-X 'mizuserver/pkg/version.BuildTimestamp=${BUILD_TIMESTAMP}' \
|
||||||
-X 'mizuserver/pkg/version.SemVer=${SEM_VER}'" -o mizuagent .
|
-X 'mizuserver/pkg/version.SemVer=${SEM_VER}'" -o mizuagent .
|
||||||
|
|
||||||
|
# Download Basenine executable, verify the sha1sum
|
||||||
|
ADD https://github.com/up9inc/basenine/releases/download/v0.4.13/basenine_linux_${GOARCH} ./basenine_linux_${GOARCH}
|
||||||
|
ADD https://github.com/up9inc/basenine/releases/download/v0.4.13/basenine_linux_${GOARCH}.sha256 ./basenine_linux_${GOARCH}.sha256
|
||||||
|
RUN shasum -a 256 -c basenine_linux_${GOARCH}.sha256
|
||||||
|
RUN chmod +x ./basenine_linux_${GOARCH}
|
||||||
|
RUN mv ./basenine_linux_${GOARCH} ./basenine
|
||||||
|
|
||||||
|
|
||||||
### The shipped image
|
### The shipped image
|
||||||
ARG TARGETARCH=amd64
|
ARG TARGETARCH=amd64
|
||||||
@ -85,10 +92,12 @@ FROM ${TARGETARCH}/busybox:latest
|
|||||||
# gin-gonic runs in debug mode without this
|
# gin-gonic runs in debug mode without this
|
||||||
ENV GIN_MODE=release
|
ENV GIN_MODE=release
|
||||||
|
|
||||||
|
WORKDIR /app/data/
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy binary and config files from /build to root folder of scratch container.
|
# Copy binary and config files from /build to root folder of scratch container.
|
||||||
COPY --from=builder ["/app/agent-build/mizuagent", "."]
|
COPY --from=builder ["/app/agent-build/mizuagent", "."]
|
||||||
|
COPY --from=builder ["/app/agent-build/basenine", "/usr/local/bin/basenine"]
|
||||||
COPY --from=front-end ["/app/ui-build/build", "site"]
|
COPY --from=front-end ["/app/ui-build/build", "site"]
|
||||||
COPY --from=front-end ["/app/ui-build/build-ent", "site-standalone"]
|
COPY --from=front-end ["/app/ui-build/build-ent", "site-standalone"]
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/creasty/defaults"
|
"github.com/creasty/defaults"
|
||||||
"github.com/up9inc/mizu/cli/config"
|
"github.com/up9inc/mizu/cli/config"
|
||||||
"github.com/up9inc/mizu/cli/errormessage"
|
"github.com/up9inc/mizu/cli/errormessage"
|
||||||
@ -41,7 +42,7 @@ func runMizuInstall() {
|
|||||||
|
|
||||||
if err = resources.CreateInstallMizuResources(ctx, kubernetesProvider, serializedValidationRules,
|
if err = resources.CreateInstallMizuResources(ctx, kubernetesProvider, serializedValidationRules,
|
||||||
serializedContract, serializedMizuConfig, config.Config.IsNsRestrictedMode(),
|
serializedContract, serializedMizuConfig, config.Config.IsNsRestrictedMode(),
|
||||||
config.Config.MizuResourcesNamespace, config.Config.AgentImage, config.Config.BasenineImage,
|
config.Config.MizuResourcesNamespace, config.Config.AgentImage,
|
||||||
config.Config.KratosImage, config.Config.KetoImage,
|
config.Config.KratosImage, config.Config.KetoImage,
|
||||||
nil, defaultMaxEntriesDBSizeBytes, defaultResources, config.Config.ImagePullPolicy(),
|
nil, defaultMaxEntriesDBSizeBytes, defaultResources, config.Config.ImagePullPolicy(),
|
||||||
config.Config.LogLevel(), false); err != nil {
|
config.Config.LogLevel(), false); err != nil {
|
||||||
|
@ -124,7 +124,7 @@ func RunMizuTap() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
logger.Log.Infof("Waiting for Mizu Agent to start...")
|
logger.Log.Infof("Waiting for Mizu Agent to start...")
|
||||||
if state.mizuServiceAccountExists, err = resources.CreateTapMizuResources(ctx, kubernetesProvider, serializedValidationRules, serializedContract, serializedMizuConfig, config.Config.IsNsRestrictedMode(), config.Config.MizuResourcesNamespace, config.Config.AgentImage, config.Config.BasenineImage, getSyncEntriesConfig(), config.Config.Tap.MaxEntriesDBSizeBytes(), config.Config.Tap.ApiServerResources, config.Config.ImagePullPolicy(), config.Config.LogLevel()); err != nil {
|
if state.mizuServiceAccountExists, err = resources.CreateTapMizuResources(ctx, kubernetesProvider, serializedValidationRules, serializedContract, serializedMizuConfig, config.Config.IsNsRestrictedMode(), config.Config.MizuResourcesNamespace, config.Config.AgentImage, getSyncEntriesConfig(), config.Config.Tap.MaxEntriesDBSizeBytes(), config.Config.Tap.ApiServerResources, config.Config.ImagePullPolicy(), config.Config.LogLevel()); err != nil {
|
||||||
var statusError *k8serrors.StatusError
|
var statusError *k8serrors.StatusError
|
||||||
if errors.As(err, &statusError) {
|
if errors.As(err, &statusError) {
|
||||||
if statusError.ErrStatus.Reason == metav1.StatusReasonAlreadyExists {
|
if statusError.ErrStatus.Reason == metav1.StatusReasonAlreadyExists {
|
||||||
|
@ -28,7 +28,6 @@ type ConfigStruct struct {
|
|||||||
Auth configStructs.AuthConfig `yaml:"auth"`
|
Auth configStructs.AuthConfig `yaml:"auth"`
|
||||||
Config configStructs.ConfigConfig `yaml:"config,omitempty"`
|
Config configStructs.ConfigConfig `yaml:"config,omitempty"`
|
||||||
AgentImage string `yaml:"agent-image,omitempty" readonly:""`
|
AgentImage string `yaml:"agent-image,omitempty" readonly:""`
|
||||||
BasenineImage string `yaml:"basenine-image,omitempty" readonly:""`
|
|
||||||
KratosImage string `yaml:"kratos-image,omitempty" readonly:""`
|
KratosImage string `yaml:"kratos-image,omitempty" readonly:""`
|
||||||
KetoImage string `yaml:"keto-image,omitempty" readonly:""`
|
KetoImage string `yaml:"keto-image,omitempty" readonly:""`
|
||||||
ImagePullPolicyStr string `yaml:"image-pull-policy" default:"Always"`
|
ImagePullPolicyStr string `yaml:"image-pull-policy" default:"Always"`
|
||||||
@ -52,7 +51,6 @@ func (config *ConfigStruct) validate() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (config *ConfigStruct) SetDefaults() {
|
func (config *ConfigStruct) SetDefaults() {
|
||||||
config.BasenineImage = fmt.Sprintf("%s:%s", shared.BasenineImageRepo, shared.BasenineImageTag)
|
|
||||||
config.KratosImage = shared.KratosImageDefault
|
config.KratosImage = shared.KratosImageDefault
|
||||||
config.KetoImage = shared.KetoImageDefault
|
config.KetoImage = shared.KetoImageDefault
|
||||||
config.AgentImage = fmt.Sprintf("%s:%s", shared.MizuAgentImageRepo, mizu.SemVer)
|
config.AgentImage = fmt.Sprintf("%s:%s", shared.MizuAgentImageRepo, mizu.SemVer)
|
||||||
|
@ -15,7 +15,7 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/util/intstr"
|
"k8s.io/apimachinery/pkg/util/intstr"
|
||||||
)
|
)
|
||||||
|
|
||||||
func CreateTapMizuResources(ctx context.Context, kubernetesProvider *kubernetes.Provider, serializedValidationRules string, serializedContract string, serializedMizuConfig string, isNsRestrictedMode bool, mizuResourcesNamespace string, agentImage string, basenineImage string, syncEntriesConfig *shared.SyncEntriesConfig, maxEntriesDBSizeBytes int64, apiServerResources shared.Resources, imagePullPolicy core.PullPolicy, logLevel logging.Level) (bool, error) {
|
func CreateTapMizuResources(ctx context.Context, kubernetesProvider *kubernetes.Provider, serializedValidationRules string, serializedContract string, serializedMizuConfig string, isNsRestrictedMode bool, mizuResourcesNamespace string, agentImage string, syncEntriesConfig *shared.SyncEntriesConfig, maxEntriesDBSizeBytes int64, apiServerResources shared.Resources, imagePullPolicy core.PullPolicy, logLevel logging.Level) (bool, error) {
|
||||||
if !isNsRestrictedMode {
|
if !isNsRestrictedMode {
|
||||||
if err := createMizuNamespace(ctx, kubernetesProvider, mizuResourcesNamespace); err != nil {
|
if err := createMizuNamespace(ctx, kubernetesProvider, mizuResourcesNamespace); err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
@ -42,7 +42,6 @@ func CreateTapMizuResources(ctx context.Context, kubernetesProvider *kubernetes.
|
|||||||
Namespace: mizuResourcesNamespace,
|
Namespace: mizuResourcesNamespace,
|
||||||
PodName: kubernetes.ApiServerPodName,
|
PodName: kubernetes.ApiServerPodName,
|
||||||
PodImage: agentImage,
|
PodImage: agentImage,
|
||||||
BasenineImage: basenineImage,
|
|
||||||
KratosImage: "",
|
KratosImage: "",
|
||||||
KetoImage: "",
|
KetoImage: "",
|
||||||
ServiceAccountName: serviceAccountName,
|
ServiceAccountName: serviceAccountName,
|
||||||
@ -68,7 +67,7 @@ func CreateTapMizuResources(ctx context.Context, kubernetesProvider *kubernetes.
|
|||||||
return mizuServiceAccountExists, nil
|
return mizuServiceAccountExists, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateInstallMizuResources(ctx context.Context, kubernetesProvider *kubernetes.Provider, serializedValidationRules string, serializedContract string, serializedMizuConfig string, isNsRestrictedMode bool, mizuResourcesNamespace string, agentImage string, basenineImage string, kratosImage string, ketoImage string, syncEntriesConfig *shared.SyncEntriesConfig, maxEntriesDBSizeBytes int64, apiServerResources shared.Resources, imagePullPolicy core.PullPolicy, logLevel logging.Level, noPersistentVolumeClaim bool) error {
|
func CreateInstallMizuResources(ctx context.Context, kubernetesProvider *kubernetes.Provider, serializedValidationRules string, serializedContract string, serializedMizuConfig string, isNsRestrictedMode bool, mizuResourcesNamespace string, agentImage string, kratosImage string, ketoImage string, syncEntriesConfig *shared.SyncEntriesConfig, maxEntriesDBSizeBytes int64, apiServerResources shared.Resources, imagePullPolicy core.PullPolicy, logLevel logging.Level, noPersistentVolumeClaim bool) error {
|
||||||
if err := createMizuNamespace(ctx, kubernetesProvider, mizuResourcesNamespace); err != nil {
|
if err := createMizuNamespace(ctx, kubernetesProvider, mizuResourcesNamespace); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -98,7 +97,6 @@ func CreateInstallMizuResources(ctx context.Context, kubernetesProvider *kuberne
|
|||||||
Namespace: mizuResourcesNamespace,
|
Namespace: mizuResourcesNamespace,
|
||||||
PodName: kubernetes.ApiServerPodName,
|
PodName: kubernetes.ApiServerPodName,
|
||||||
PodImage: agentImage,
|
PodImage: agentImage,
|
||||||
BasenineImage: basenineImage,
|
|
||||||
KratosImage: kratosImage,
|
KratosImage: kratosImage,
|
||||||
KetoImage: ketoImage,
|
KetoImage: ketoImage,
|
||||||
ServiceAccountName: serviceAccountName,
|
ServiceAccountName: serviceAccountName,
|
||||||
|
@ -17,8 +17,6 @@ const (
|
|||||||
MizuAgentImageRepo = "docker.io/up9inc/mizu"
|
MizuAgentImageRepo = "docker.io/up9inc/mizu"
|
||||||
BasenineHost = "127.0.0.1"
|
BasenineHost = "127.0.0.1"
|
||||||
BaseninePort = "9099"
|
BaseninePort = "9099"
|
||||||
BasenineImageRepo = "docker.io/up9inc/basenine"
|
|
||||||
BasenineImageTag = "v0.4.13"
|
|
||||||
KratosImageDefault = "gcr.io/up9-docker-hub/mizu-kratos/stable:0.0.0"
|
KratosImageDefault = "gcr.io/up9-docker-hub/mizu-kratos/stable:0.0.0"
|
||||||
KetoImageDefault = "gcr.io/up9-docker-hub/mizu-keto/stable:0.0.0"
|
KetoImageDefault = "gcr.io/up9-docker-hub/mizu-keto/stable:0.0.0"
|
||||||
)
|
)
|
||||||
|
@ -169,7 +169,6 @@ type ApiServerOptions struct {
|
|||||||
Namespace string
|
Namespace string
|
||||||
PodName string
|
PodName string
|
||||||
PodImage string
|
PodImage string
|
||||||
BasenineImage string
|
|
||||||
KratosImage string
|
KratosImage string
|
||||||
KetoImage string
|
KetoImage string
|
||||||
ServiceAccountName string
|
ServiceAccountName string
|
||||||
@ -275,7 +274,7 @@ func (provider *Provider) GetMizuApiServerPodObject(opts *ApiServerOptions, moun
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "basenine",
|
Name: "basenine",
|
||||||
Image: opts.BasenineImage,
|
Image: opts.PodImage,
|
||||||
ImagePullPolicy: opts.ImagePullPolicy,
|
ImagePullPolicy: opts.ImagePullPolicy,
|
||||||
VolumeMounts: volumeMounts,
|
VolumeMounts: volumeMounts,
|
||||||
ReadinessProbe: &core.Probe{
|
ReadinessProbe: &core.Probe{
|
||||||
@ -299,7 +298,7 @@ func (provider *Provider) GetMizuApiServerPodObject(opts *ApiServerOptions, moun
|
|||||||
"memory": memRequests,
|
"memory": memRequests,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Command: []string{"/basenine"},
|
Command: []string{"basenine"},
|
||||||
Args: []string{"-addr", "0.0.0.0", "-port", shared.BaseninePort, "-persistent"},
|
Args: []string{"-addr", "0.0.0.0", "-port", shared.BaseninePort, "-persistent"},
|
||||||
WorkingDir: shared.DataDirPath,
|
WorkingDir: shared.DataDirPath,
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user