Skip to content

Commit

Permalink
Merge branch 'main' into laurent/reverse-proxy-network-endpoint-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentluce committed Jan 3, 2024
2 parents bb2e4fd + 7de8faa commit 43405b9
Show file tree
Hide file tree
Showing 47 changed files with 864 additions and 272 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Changelog

## [0.85.55](https://github.com/kurtosis-tech/kurtosis/compare/0.85.54...0.85.55) (2024-01-03)


### Features

* Engine K8S ingress for REST API reverse proxy routing ([#1970](https://github.com/kurtosis-tech/kurtosis/issues/1970)) ([4287f88](https://github.com/kurtosis-tech/kurtosis/commit/4287f88dafb3005cbc3400b093a391a84f87bf53))
* match emui catalog to final designs ([#2012](https://github.com/kurtosis-tech/kurtosis/issues/2012)) ([c55fc7a](https://github.com/kurtosis-tech/kurtosis/commit/c55fc7af45368e250da437561aa051384e92bbfc))

## [0.85.54](https://github.com/kurtosis-tech/kurtosis/compare/0.85.53...0.85.54) (2024-01-02)


### Bug Fixes

* log file path formatting for week ([#2008](https://github.com/kurtosis-tech/kurtosis/issues/2008)) ([d032ff5](https://github.com/kurtosis-tech/kurtosis/commit/d032ff581432ac1871e5a8c304150e19a87d15ba))

## [0.85.53](https://github.com/kurtosis-tech/kurtosis/compare/0.85.52...0.85.53) (2023-12-20)


Expand Down
6 changes: 3 additions & 3 deletions LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ Business Source License 1.1
Parameters

Licensor: Kurtosis Technologies, Inc.
Licensed Work: Kurtosis 0.85.53
The Licensed Work is (c) 2023 Kurtosis Technologies, Inc.
Licensed Work: Kurtosis 0.85.55
The Licensed Work is (c) 2024 Kurtosis Technologies, Inc.
Additional Use Grant: You may make use of the Licensed Work, provided that
you may not use the Licensed Work for an Environment Orchestration Service.

An “Environment Orchestration Service” is any offering that
allows third parties (other than your employees and
contractors) to create distributed system environments.

Change Date: 2027-12-20
Change Date: 2028-01-03

Change License: Apache 2.0 (Apache License, Version 2.0)

Expand Down
2 changes: 1 addition & 1 deletion api/golang/kurtosis_version/kurtosis_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ const (
// !!!!!!!!!!! DO NOT UPDATE! WILL BE MANUALLY UPDATED DURING THE RELEASE PROCESS !!!!!!!!!!!!!!!!!!!!!!
// This is necessary so that Kurt Core consumers will know if they're compatible with the currently-running
// API container
KurtosisVersion = "0.85.53"
KurtosisVersion = "0.85.55"
// !!!!!!!!!!! DO NOT UPDATE! WILL BE MANUALLY UPDATED DURING THE RELEASE PROCESS !!!!!!!!!!!!!!!!!!!!!!
)
2 changes: 1 addition & 1 deletion api/rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "kurtosis-sdk"
version = "0.85.53"
version = "0.85.55"
license = "BUSL-1.1"
description = "Rust SDK for Kurtosis"
edition = "2021"
Expand Down
2 changes: 1 addition & 1 deletion api/typescript/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "kurtosis-sdk",
"//": "NOTE: DO NOT UPDATE THIS VERSION MANUALLY - IT WILL BE UPDATED DURING THE RELEASE PROCESS!",
"version": "0.85.53",
"version": "0.85.55",
"main": "./build/index",
"description": "This repo contains a Typescript client for communicating with the Kurtosis Engine server, which is responsible for creating, managing and destroying Kurtosis Enclaves.",
"types": "./build/index",
Expand Down
2 changes: 1 addition & 1 deletion api/typescript/src/kurtosis_version/kurtosis_version.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// !!!!!!!!!!! DO NOT UPDATE! WILL BE MANUALLY UPDATED DURING THE RELEASE PROCESS !!!!!!!!!!!!!!!!!!!!!!
// This is necessary so that Kurt Core consumers (e.g. modules) will know if they're compatible with the currently-running
// API container
export const KURTOSIS_VERSION: string = "0.85.53"
export const KURTOSIS_VERSION: string = "0.85.55"
// !!!!!!!!!!! DO NOT UPDATE! WILL BE MANUALLY UPDATED DURING THE RELEASE PROCESS !!!!!!!!!!!!!!!!!!!!!!
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const (
//TODO: pass this parameter
enclaveManagerUIPort = 9711
enclaveManagerAPIPort = 8081
restAPIPort = 9779 //TODO: pass this parameter
maxWaitForEngineAvailabilityRetries = 10
timeBetweenWaitForEngineAvailabilityRetries = 1 * time.Second
logsStorageDirpath = "/var/log/kurtosis/"
Expand Down Expand Up @@ -160,12 +159,12 @@ func CreateEngine(
)
}

restAPIPortSpec, err := port_spec.NewPortSpec(uint16(restAPIPort), consts.EngineTransportProtocol, consts.HttpApplicationProtocol, defaultWait)
restAPIPortSpec, err := port_spec.NewPortSpec(engine.RESTAPIPortAddr, consts.EngineTransportProtocol, consts.HttpApplicationProtocol, defaultWait)
if err != nil {
return nil, stacktrace.Propagate(
err,
"An error occurred creating the REST API server's http port spec object using number '%v' and protocol '%v'",
restAPIPort,
engine.RESTAPIPortAddr,
consts.EngineTransportProtocol.String(),
)
}
Expand Down Expand Up @@ -208,7 +207,7 @@ func CreateEngine(
privateGrpcDockerPort: docker_manager.NewManualPublishingSpec(grpcPortNum),
enclaveManagerUIDockerPort: docker_manager.NewManualPublishingSpec(uint16(enclaveManagerUIPort)),
enclaveManagerAPIDockerPort: docker_manager.NewManualPublishingSpec(uint16(enclaveManagerAPIPort)),
restAPIDockerPort: docker_manager.NewManualPublishingSpec(uint16(restAPIPort)),
restAPIDockerPort: docker_manager.NewManualPublishingSpec(engine.RESTAPIPortAddr),
}

bindMounts := map[string]string{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ package consts

import (
"github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_interface/objects/port_spec"
"k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
netv1 "k8s.io/api/networking/v1"
)

const (
Expand All @@ -14,11 +15,16 @@ const (
// be stored in the port spec label
KurtosisInternalContainerGrpcPortSpecId = "grpc"

// The ID of the GRPC proxy port for Kurtosis-internal containers. This is necessary because
// Typescript's grpc-web cannot communicate directly with GRPC ports, so Kurtosis-internal containers
// need a proxy that will translate grpc-web requests before they hit the main GRPC server
KurtosisInternalContainerGrpcProxyPortSpecId = "grpc-proxy"
HttpApplicationProtocol = "http"
// The ID of the REST API port
KurtosisInternalContainerRESTAPIPortSpecId = "rest-api"

HttpApplicationProtocol = "http"

IngressRulePathAllPaths = "/"
)

var (
IngressRulePathTypePrefix = netv1.PathTypePrefix
)

// This maps a Kubernetes pod's phase to a binary "is the pod considered running?" determiner
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package engine_functions
import (
"context"
"fmt"
"time"

"github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_impls/kubernetes/kubernetes_kurtosis_backend/consts"
"github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_impls/kubernetes/kubernetes_kurtosis_backend/shared_helpers"
"github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_impls/kubernetes/kubernetes_manager"
Expand All @@ -16,8 +18,8 @@ import (
"github.com/kurtosis-tech/stacktrace"
"github.com/sirupsen/logrus"
apiv1 "k8s.io/api/core/v1"
netv1 "k8s.io/api/networking/v1"
rbacv1 "k8s.io/api/rbac/v1"
"time"
)

const (
Expand All @@ -26,6 +28,8 @@ const (
maxWaitForEngineContainerAvailabilityRetries = 30
timeBetweenWaitForEngineContainerAvailabilityRetries = 1 * time.Second
httpApplicationProtocol = "http"

restAPIPortHost = "engine"
)

var noWait *port_spec.Wait = nil
Expand Down Expand Up @@ -65,6 +69,15 @@ func CreateEngine(
consts.KurtosisServersTransportProtocol.String(),
)
}
privateRESTAPIPortSpec, err := port_spec.NewPortSpec(engine.RESTAPIPortAddr, consts.KurtosisServersTransportProtocol, httpApplicationProtocol, noWait)
if err != nil {
return nil, stacktrace.Propagate(
err,
"An error occurred creating the engine's private rest api port spec object using number '%v' and protocol '%v'",
engine.RESTAPIPortAddr,
consts.KurtosisServersTransportProtocol.String(),
)
}
privatePortSpecs := map[string]*port_spec.PortSpec{
consts.KurtosisInternalContainerGrpcPortSpecId: privateGrpcPortSpec,
}
Expand Down Expand Up @@ -149,6 +162,7 @@ func CreateEngine(
namespaceName,
engineAttributesProvider,
privateGrpcPortSpec,
privateRESTAPIPortSpec,
enginePodLabels,
kubernetesManager,
)
Expand All @@ -165,13 +179,34 @@ func CreateEngine(
}
}()

engineIngress, err := createEngineIngress(
ctx,
namespaceName,
engineAttributesProvider,
privateRESTAPIPortSpec,
kubernetesManager,
)
if err != nil {
return nil, stacktrace.Propagate(err, "An error occurred creating the engine ingress")
}
var shouldRemoveIngress = true
defer func() {
if shouldRemoveIngress {
if err := kubernetesManager.RemoveIngress(ctx, engineIngress); err != nil {
logrus.Errorf("Creating the engine didn't complete successfully, so we tried to delete Kubernetes ingress '%v' that we created but an error was thrown:\n%v", engineIngress.Name, err)
logrus.Errorf("ACTION REQUIRED: You'll need to manually remove Kubernetes ingress with name '%v'!!!!!!!", engineIngress.Name)
}
}
}()

engineResources := &engineKubernetesResources{
clusterRole: clusterRole,
clusterRoleBinding: clusterRoleBindings,
namespace: namespace,
serviceAccount: serviceAccount,
service: engineService,
pod: enginePod,
ingress: engineIngress,
}
engineObjsById, err := getEngineObjectsFromKubernetesResources(map[engine.EngineGUID]*engineKubernetesResources{
engineGuid: engineResources,
Expand Down Expand Up @@ -216,6 +251,7 @@ func CreateEngine(
shouldRemoveClusterRoleBinding = false
shouldRemovePod = false
shouldRemoveService = false
shouldRemoveIngress = false
return resultEngine, nil
}

Expand Down Expand Up @@ -448,18 +484,21 @@ func createEngineService(
namespace string,
engineAttributesProvider object_attributes_provider.KubernetesEngineObjectAttributesProvider,
privateGrpcPortSpec *port_spec.PortSpec,
privateRESTAPIPortSpec *port_spec.PortSpec,
podMatchLabels map[*kubernetes_label_key.KubernetesLabelKey]*kubernetes_label_value.KubernetesLabelValue,
kubernetesManager *kubernetes_manager.KubernetesManager,
) (*apiv1.Service, error) {
engineServiceAttributes, err := engineAttributesProvider.ForEngineService(
consts.KurtosisInternalContainerGrpcPortSpecId,
privateGrpcPortSpec,
consts.KurtosisInternalContainerGrpcProxyPortSpecId, nil)
consts.KurtosisInternalContainerRESTAPIPortSpecId,
privateRESTAPIPortSpec)
if err != nil {
return nil, stacktrace.Propagate(
err,
"An error occurred getting the engine service attributes using private grpc port spec '%+v'",
"An error occurred getting the engine service attributes using private grpc port spec '%+v' and private REST API port spec '%+v'",
privateGrpcPortSpec,
privateRESTAPIPortSpec,
)
}
engineServiceName := engineServiceAttributes.GetName().GetString()
Expand All @@ -468,7 +507,8 @@ func createEngineService(

// Define service ports. These hook up to ports on the containers running in the engine pod
servicePorts, err := shared_helpers.GetKubernetesServicePortsFromPrivatePortSpecs(map[string]*port_spec.PortSpec{
consts.KurtosisInternalContainerGrpcPortSpecId: privateGrpcPortSpec,
consts.KurtosisInternalContainerGrpcPortSpecId: privateGrpcPortSpec,
consts.KurtosisInternalContainerRESTAPIPortSpecId: privateRESTAPIPortSpec,
})
if err != nil {
return nil, stacktrace.Propagate(err, "An error occurred getting the engine service's ports using the engine private port specs")
Expand All @@ -490,11 +530,83 @@ func createEngineService(
if err != nil {
return nil, stacktrace.Propagate(
err,
"An error occurred while creating the service with name '%s' in namespace '%s' with ports '%v'",
"An error occurred while creating the service with name '%s' in namespace '%s' with ports '%v' and '%v'",
engineServiceName,
namespace,
privateGrpcPortSpec.GetNumber(),
privateRESTAPIPortSpec.GetNumber(),
)
}
return service, nil
}

func createEngineIngress(
ctx context.Context,
namespace string,
engineAttributesProvider object_attributes_provider.KubernetesEngineObjectAttributesProvider,
privateRESTAPIPortSpec *port_spec.PortSpec,
kubernetesManager *kubernetes_manager.KubernetesManager,
) (*netv1.Ingress, error) {
engineIngressAttributes, err := engineAttributesProvider.ForEngineIngress()
if err != nil {
return nil, stacktrace.Propagate(
err,
"An error occurred getting the engine ingress attributes",
)
}
engineIngressName := engineIngressAttributes.GetName().GetString()
engineIngressLabels := shared_helpers.GetStringMapFromLabelMap(engineIngressAttributes.GetLabels())
engineIngressAnnotations := shared_helpers.GetStringMapFromAnnotationMap(engineIngressAttributes.GetAnnotations())

engineIngressRules, err := getEngineIngressRules(engineIngressName, privateRESTAPIPortSpec)
if err != nil {
return nil, stacktrace.Propagate(err, "An error occurred creating the user service ingress rules for ingress service with name '%v'", engineIngressName)
}

createdIngress, err := kubernetesManager.CreateIngress(
ctx,
namespace,
engineIngressName,
engineIngressLabels,
engineIngressAnnotations,
engineIngressRules,
)
if err != nil {
return nil, stacktrace.Propagate(err, "An error occurred while creating the ingress with name '%s' in namespace '%s'", engineIngressName, namespace)
}

return createdIngress, nil
}

func getEngineIngressRules(
engineIngressName string,
privateRESTAPIPortSpec *port_spec.PortSpec,
) ([]netv1.IngressRule, error) {
var ingressRules []netv1.IngressRule
ingressRule := netv1.IngressRule{
Host: restAPIPortHost,
IngressRuleValue: netv1.IngressRuleValue{
HTTP: &netv1.HTTPIngressRuleValue{
Paths: []netv1.HTTPIngressPath{
{
Path: consts.IngressRulePathAllPaths,
PathType: &consts.IngressRulePathTypePrefix,
Backend: netv1.IngressBackend{
Service: &netv1.IngressServiceBackend{
Name: engineIngressName,
Port: netv1.ServiceBackendPort{
Name: "",
Number: int32(privateRESTAPIPortSpec.GetNumber()),
},
},
Resource: nil,
},
},
},
},
},
}
ingressRules = append(ingressRules, ingressRule)

return ingressRules, nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package engine_functions

import (
apiv1 "k8s.io/api/core/v1"
netv1 "k8s.io/api/networking/v1"
rbacv1 "k8s.io/api/rbac/v1"
)

Expand All @@ -21,4 +22,7 @@ type engineKubernetesResources struct {

// Should always be nil if namespace is nil
pod *apiv1.Pod

// Should always be nil if namespace is nil
ingress *netv1.Ingress
}
Loading

0 comments on commit 43405b9

Please sign in to comment.