An open API service indexing awesome lists of open source software.

https://github.com/yolo-sh/agent-container

The agent that connects your environment container with the host
https://github.com/yolo-sh/agent-container

docker go grpc yolo

Last synced: 5 months ago
JSON representation

The agent that connects your environment container with the host

Awesome Lists containing this project

README

          

# 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](https://github.com/yolo-sh/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](#requirements)
- [Usage](#usage)
- [Generating the gRPC server's code](#generating-the-grpc-servers-code)
- [Container agent](#container-agent)
- [Network manager](#network-manager)
- [gRPC Server](#grpc-server)
- [License](#license)

## Requirements

The container agent only works on `linux` and requires:

- `go >= 1.17`

- `protoc >= 3.0` (see [Protocol Buffer Compiler Installation](https://grpc.io/docs/protoc-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**:

```bash
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](https://github.com/yolo-sh/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](https://github.com/yolo-sh/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:

```proto
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](https://github.com/yolo-sh/agent-container/blob/main/internal/grpcserver/init.sh) 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](http://opensource.org/licenses/MIT).