Skip to content

The agent that connects your environment container with the host

License

Notifications You must be signed in to change notification settings

yolo-sh/agent-container

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Agent / Container

This repository contains the source code of the container agent.

The container agent is installed in the container running your environment via systemd (see the workspace-base repository).

The main role of this agent is to enable communication between your environment container and the host.

The container agent is composed of two components:

  • A network manager.

  • A gRPC server.

Table of contents

Requirements

The container agent only works on linux and requires:

  • go >= 1.17

  • protoc >= 3.0 (see Protocol Buffer Compiler Installation)

  • google.golang.org/protobuf/cmd/protoc-gen-go@latest (install via go install)

  • google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest (install via go install)

Usage

The container agent could be run using the go run main.go command.

The gRPC server will listen on an Unix socket at /yolo-config/agent-container-grpc.sock and the network manager will poll /proc/net/tcp for open ports.

Generating the gRPC server's code

The gRPC server's code could be generated by running the following command in the proto directory:

protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative agent_container.proto

Container agent

The network manager lets you access the services that run in the environment container network.

The gRPC server, on the other hand, is used to enable communication with the host agent (via a shared unix socket /yolo-config/agent-container-grpc.sock).

infra

Network manager

The network manager will poll /proc/net/tcp for open ports and redirect traffic from the host to the listening service.

gRPC server

The gRPC server will be accessed by the host agent via a shared unix socket /yolo-config/agent-container-grpc.sock.

It is principally used to initialize the environment container as you can see in the service definition:

service Agent {
  rpc Init (InitRequest) returns (stream InitReply) {}
}

message InitRequest {
  string env_repo_owner = 1;
  string env_repo_name = 2;
  repeated string env_repo_languages_used = 3;
  string github_user_email = 4;
  string user_full_name = 5;
}

message InitReply {
  string log_line_header = 1;
  string log_line = 2;
  optional string github_ssh_public_key_content = 3;
  optional string github_gpg_public_key_content = 4;
}

The Init method will clone your repositories and run a shell script that will, among other things, generate the SSH and GPG keys used in GitHub.

This method is idempotent.

License

Yolo is available as open source under the terms of the MIT License.