Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lobs communication spike #947

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Lobs communication spike #947

wants to merge 1 commit into from

Conversation

tleed5
Copy link
Contributor

@tleed5 tleed5 commented May 27, 2024

Description

This is a POC to evaluate ways of handling communication between processes for live kubernetes object status

Includes changes from main...robe/reverse-tentacle
Octopus Server side: https://github.com/OctopusDeploy/OctopusDeploy/compare/robe/reverse-tentacle

What it does

  • Configures a kestrel server to run when the tentacle process is running to handle gRPC requests
  • Creates a basic gRPC service that forwards along a message to Octopus server using existing Halibut polling connections by creating a Halibut client for a service that exists in Octopus server using the polling tentacle service endpoint and making a request with it.

Example with simple Go App hitting the gRPC service in Tentacle all running in a cluster

Top left terminal is the Go App's pod logs, top right terminal is Tentacles pod logs and bottom terminal is Octopus server's logs

Screen.Recording.2024-05-27.at.4.05.04.pm.mov

Go app

package main

//go:generate protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative greet.proto

import (
	"context"
	"flag"
	"log"
	"time"

	pb "LobsCommsSpike/protos"
	"google.golang.org/grpc"
	"google.golang.org/grpc/credentials/insecure"
)

const (
	defaultName = "world"
)

var (
	addr = flag.String("addr", "agent-service.octopus-agent-agent.svc.cluster.local:5002", "the address to connect to")
	name = flag.String("name", defaultName, "Name to greet")
)

func main() {
	flag.Parse()
	// Set up a connection to the server.
	conn, err := grpc.NewClient(*addr, grpc.WithTransportCredentials(insecure.NewCredentials()))
	if err != nil {
		log.Fatalf("did not connect: %v", err)
	}
	defer conn.Close()
	c := pb.NewGreeterClient(conn)

	for {
		// Contact the server and print out its response.
		ctx, cancel := context.WithTimeout(context.Background(), time.Second)
		r, err := c.SayHello(ctx, &pb.HelloRequest{Name: *name})
		time.Sleep(3 * time.Second)

		if err != nil {
			log.Fatalf("could not greet: %v", err)
		}
		log.Printf("Greeting: %s", r.GetMessage())
		cancel()
	}
}

Comment on lines +118 to +127
options.ListenAnyIP(5001, listenOptions =>
{
listenOptions.Protocols = HttpProtocols.Http1;
// listenOptions.UseHttps(configuration.Value.TentacleCertificate!);
});
options.ListenAnyIP(5002, listenOptions =>
{
listenOptions.Protocols = HttpProtocols.Http2;
// listenOptions.UseHttps(configuration.Value.TentacleCertificate!);
});
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

});
});
webBuilder.UseStartup<Startup>();
}).UseServiceProviderFactory(new AutofacChildLifetimeScopeServiceProviderFactory(container));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to update Autofac so I could easily get the existing container services into the Kestrel's container to allow for DI in the gRPC service

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant