Repository navigation
feat(agent): run instances on hosts outside kubernetes - #50
Merged
Merged
Conversation
…m a range
Children only get PATH, HOME, LANG, LC_ALL, TZ, JAVA_HOME and TMPDIR
from the parent plus the spec env and GRUS_*. A configurable port range,
an advertised address, the {{port}} and ${GRUS_DIR} placeholders and a
java binary override support instances on a shared host.
The driver keeps the desired instances, stop and kill requests and console lines of one agent host in memory and serves them to the agent through a long poll. The agent's reports become the observed list; the list fails once the agent is silent so the reconciler keeps the state.
Adopt no longer fails when an agent host cannot be listed yet. Its unknown instances are adopted by the reconcile loop as soon as the host reports, and instances record the real host instead of the router.
Agents register, long-poll their desired state and report what they run
under /v1/agents/{host}. An agent token only works for its own host and
for template archive downloads; hosts are listed under /v1/hosts.
The controller runs a router over its configured driver and the agent hosts named in GRUS_AGENT_TOKENS. Pools are placed by their effective placement; an agent host that is not online fails the start with a clear reason instead of crashing.
The agent registers with the controller, long-polls its desired instances, runs them with the process driver and reports what it observes. Instances keep running while the controller is unreachable; processes left over from an earlier agent run are ended on start.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Grus could only start instances in the cluster or as processes on the controller's own machine. mc01 is a real server outside Kubernetes, and the proxies in the cluster need to reach game servers there.
Approach
A small agent (grus-agent) runs on mc01. It only makes outgoing HTTPS calls to the controller: it announces itself, asks what should run, starts and stops local processes, and reports what it sees. The controller treats the agent's host like any other host behind its router, so pools are placed on mc01 with
placement: {driver: agent, host: mc01}.Testing
Unit tests for the process driver changes, the remote driver (fake clock, no sleeps), the API auth and routes, controller adoption and the agent. One end-to-end test runs controller and agent in one process and takes an instance from start through Ready to stop; it polls with a deadline because a child process runs concurrently.