Skip to content

Commit

Permalink
Connect reverse proxy to enclave networks at startup.
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentluce committed Dec 4, 2023
1 parent 128f2e4 commit e5f396d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ func CreateEngine(
removeReverseProxyFunc()
}
}()
if err = reverse_proxy_functions.ConnectReverseProxyToEnclaveNetworks(ctx, dockerManager); err != nil {
return nil, stacktrace.Propagate(err, "An error occured connecting the reverse proxy to the enclave networks")
}
logrus.Infof("Reverse proxy started.")

enclaveManagerUIPortSpec, err := port_spec.NewPortSpec(uint16(enclaveManagerUIPort), consts.EngineTransportProtocol, consts.HttpApplicationProtocol, defaultWait)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ const (

////////////////////////--TRAEFIK CONFIGURATION SECTION--/////////////////////////////
configFileTemplate = `
accesslog: {}
log:
level: DEBUG
api:
debug: true
dashboard: true
insecure: true
disabledashboardad: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"net"

"github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_impls/docker/docker_manager"
"github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_impls/docker/object_attributes_provider/docker_label_key"
"github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_impls/docker/object_attributes_provider/label_value_consts"
"github.com/kurtosis-tech/stacktrace"
"github.com/sirupsen/logrus"
)
Expand Down Expand Up @@ -52,3 +54,21 @@ func DisconnectReverseProxyFromNetwork(ctx context.Context, dockerManager *docke

return nil
}

func ConnectReverseProxyToEnclaveNetworks(ctx context.Context, dockerManager *docker_manager.DockerManager) error {
kurtosisNetworkLabels := map[string]string{
docker_label_key.AppIDDockerLabelKey.GetString(): label_value_consts.AppIDDockerLabelValue.GetString(),
}
enclaveNetworks, err := dockerManager.GetNetworksByLabels(ctx, kurtosisNetworkLabels)
if err != nil {
return stacktrace.Propagate(err, "An error occurred getting Kurtosis networks")
}

for _, enclaveNetwork := range enclaveNetworks {
if err = ConnectReverseProxyToNetwork(ctx, dockerManager, enclaveNetwork.GetId()); err != nil {
return stacktrace.Propagate(err, "An error occurred connecting the reverse proxy to the enclave network with id '%v'", enclaveNetwork.GetId())
}
}

return nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package reverse_proxy_functions

import (
"context"
"github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_impls/docker/object_attributes_provider/docker_label_key"
"net"

"github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_impls/docker/object_attributes_provider/docker_label_key"

"github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/consts"
"github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_impls/docker/docker_manager"
"github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_impls/docker/docker_manager/types"
Expand Down Expand Up @@ -95,7 +96,7 @@ func getReverseProxyObjectFromContainerInfo(
if privateIpAddr == nil {
return nil, stacktrace.NewError("Couldn't parse private IP address string '%v' to an IP", privateIpAddrStr)
}

networksIpAddressStr, err := dockerManager.GetContainerIps(ctx, containerId)
if err != nil {
return nil, stacktrace.Propagate(err, "An error occurred getting the networks private IP address of container '%v'", containerId)
Expand Down

0 comments on commit e5f396d

Please sign in to comment.