Skip to content
This repository was archived by the owner on Dec 21, 2021. It is now read-only.

Commit 0e838b5

Browse files
authored
Added first version of Readme (#35)
This also contains code to generate documentation of the command line parameters from our parameter definition in the source code and this is then imported into the readme file. This PR also restructures the entire project a little in that it now is a library crate with two binaries in the src/bin directory.
1 parent b2394a7 commit 0e838b5

19 files changed

+312
-6
lines changed

README.adoc

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
= Stackable Agent
2+
3+
== Purpose
4+
The Stackable Agent is an alternative to the Kubernetes Kubelet that executes Pods not in containers but using systemd as its backend.
5+
It is implemented in Rust as a https://github.com/deislabs/krustlet[Krustlet] provider.
6+
7+
In principle this behavior is similar to that of the the https://github.com/virtual-kubelet/virtual-kubelet[virtual kubelet] project.
8+
More specifically the functionality of this agent closely resembles that of https://github.com/virtual-kubelet/systemk[systemk].
9+
The reason why both projects currently exist is simply that systemk was not around when we started Stackable and so we had to go and build our own.
10+
11+
WARNING: We are currently evaluating whether or not we should instead use systemk and contribute to that project instead of building our own agent under https://github.com/stackabletech/agent/issues/42[issue #42]
12+
13+
The agent registers itself as a node with a kube-apiserver and will be considered by the Kubernetes scheduler for workloads (pods).
14+
To avoid _normal_ Kubernetes pods being scheduled on the Stackable agent (it would not know what to do with these) the agent assigns the following taints to its node object:
15+
16+
|===
17+
|Taint |Type|Value
18+
19+
|kubernetes.io/arch
20+
|NoSchedule
21+
|stackable-linux
22+
23+
|kubernetes.io/arch
24+
|NoExecute
25+
|stackable-linux
26+
|===
27+
28+
These taints _suggest_ to the Kubernetes scheduler that only pods with matching tolerations should be scheduled on this node.
29+
30+
== Installation
31+
=== Build from source
32+
Building from source is fairly straightforward if you have the rust toolchain installed, our CI chain tests against the latest stable version at the time the checks are run.
33+
If you need to install this, generally the recommended way is to use https://rustup.rs/[rustup].
34+
35+
After rust is installed simply run
36+
37+
cargo build
38+
39+
To create the binary file in _target/debug_.
40+
41+
=== Download binary
42+
We do not at this time provide pre-compiled binaries, as we are still in the process of setting up the build jobs to create these.
43+
This readme will be updated as soon as binary downloads are available!
44+
45+
=== OS Packages
46+
We do not at this time provide OS packages, that is due to change in the near future and this readme will be updated accordingly!
47+
48+
== Configuration
49+
50+
=== Command Line Parameters
51+
The agent accepts the following command line parameters:
52+
53+
include::documentation/commandline_args.adoc[]
54+
55+
=== Config File
56+
In addition to directly specifying them on the command line, the agent allows specifying a config file via the environment variable `CONFIG_FILE`. Values specified in the file will have to adhere to the format `--parameter=value`.
57+
58+
This file can contain all command line parameters and will be parsed before the actual command line.
59+
For parameters that are present in the file and on the command line, the command line will take precedence, unless it is a parameter that can be specified multiple times, in which case parameters from both, file and commandline, will be merged.
60+
61+
.Example config file
62+
--package-directory=/opt/stackable/agent/work/packages
63+
--config-directory=/etc/stackable/agent
64+
--server-cert-file=/etc/stackable/agent/secure/cert.crt
65+
--server-key-file=/etc/stackable/agent/secure/key.key
66+
67+
=== Kubernetes Config
68+
The agent uses the default way of looking for a kube-apiserver, so if your system is already set up to connect to Kubernetes with kubectl you should be good to go right of the bat.
69+
70+
The default location for the Kubernetes client config is `~/.kube/config`, if you want to change this location you can override this via the `KUBECONFIG` environment variable.
71+
72+
export KUBECONFIG=/etc/stackable/agent/kubeconfig
73+
74+
75+
=== Certificates
76+
The agent requires a keypair and signed certificate to start a webserver which can be used to handle callbacks.
77+
If these are not specified on the commandline, the agent will create a keypair, upload a certificate signing request to Kubernetes and wait for the certificate before continuing.
78+
These steps require a certificate manager to be set up and running in your Kubernetes cluster, which may or may not be the case.
79+
80+
You can also manually create these files and specify them on the command line.
81+
The following example shows how to create these files using https://github.com/OpenVPN/easy-rsa[easy-rsa], but this can be done in any number of different ways as well.
82+
83+
./easyrsa init-pki
84+
./easyrsa build-ca
85+
./easyrsa gen-req krustlet1
86+
./easyrsa import-req pki/reqs/krustlet1.req krustlet1-req
87+
./easyrsa sign-req serverClient krustlet1-req
88+
# Convert key to pksc8 format
89+
openssl pkcs8 -topk8 -inform PEM -outform PEM -nocrypt -in pki/private/krustlet1.key -out pkcs8.key
90+
91+
== Contributing
92+
The agent is developed as an open source tool and we absolutely welcome any and all contributions!
93+
Don't hesitate to drop us a line at [email protected] or reach out directly to any of our committers / contributors.
94+
95+
We will run a bi-weekly dev call during which we will discuss current development, issues, our children and the general state of the world.
96+
Please feel free to drop in if you have the time!
97+
98+
Dial in info coming soon!
99+
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
2+
3+
4+
=== tag
5+
6+
*Default value*: No default value
7+
8+
*Required*: false
9+
10+
*Multiple values:* true
11+
12+
13+
A "key=value" pair that should be assigned to this agent as tag. This can be specified multiple times to assign additional tags.
14+
15+
Tags are the main way of identifying nodes to assign services to later on.
16+
17+
18+
=== server-key-file
19+
20+
*Default value*: No default value
21+
22+
*Required*: false
23+
24+
*Multiple values:* false
25+
26+
27+
Private key file (in PKCS8 format) to use for the local webserver the Krustlet starts.
28+
29+
30+
=== log-directory
31+
32+
*Default value*: /opt/stackable/logs
33+
34+
*Required*: false
35+
36+
*Multiple values:* false
37+
38+
39+
This directory will serve as starting point for all log files which this service creates.
40+
Every service will get its own subdirectory created within this directory.
41+
Anything that is then specified in the log4j config or similar files will be resolved relatively to this directory.
42+
43+
The agent will need full access to this directory and tries to create it if it does not exist.
44+
45+
46+
=== hostname
47+
48+
*Default value*: No default value
49+
50+
*Required*: false
51+
52+
*Multiple values:* false
53+
54+
55+
The hostname to register the node under in Kubernetes - defaults to system hostname.
56+
57+
58+
=== server-cert-file
59+
60+
*Default value*: No default value
61+
62+
*Required*: false
63+
64+
*Multiple values:* false
65+
66+
67+
The certificate file for the local webserver which the Krustlet starts.
68+
69+
70+
=== no-config
71+
72+
*Default value*: No default value
73+
74+
*Required*: false
75+
76+
*Multiple values:* false
77+
78+
79+
If this option is specified, any file referenced in AGENT_CONF environment variable will be ignored.
80+
81+
82+
=== bootstrap-file
83+
84+
*Default value*: /etc/kubernetes/bootstrap-kubelet.conf
85+
86+
*Required*: false
87+
88+
*Multiple values:* false
89+
90+
91+
The bootstrap file to use in case Kubernetes bootstraping is used to add the agent.
92+
93+
94+
=== server-bind-ip
95+
96+
*Default value*: No default value
97+
98+
*Required*: false
99+
100+
*Multiple values:* false
101+
102+
103+
The local IP to register as the node's ip with the apiserver. Will be automatically set to the first address of the first non-loopback interface if not specified.
104+
105+
106+
=== data-directory
107+
108+
*Default value*: /var/stackable/agent/data
109+
110+
*Required*: false
111+
112+
*Multiple values:* false
113+
114+
115+
The directory where the stackable agent should keep its working data.
116+
117+
118+
=== config-directory
119+
120+
*Default value*: /opt/stackable/config
121+
122+
*Required*: false
123+
124+
*Multiple values:* false
125+
126+
127+
This directory will serve as starting point for all log files which this service creates.
128+
129+
Every service will get its own subdirectories created within this directory - for every service start a
130+
new subdirectory will be created to show a full history of configuration that was used for this service.
131+
132+
ConfigMaps which are specified in the pod that describes this service will be created relative to these run
133+
directories - unless the mounts specify an absolute path, in which case it is allowed to break out of this directory.
134+
135+
WARNING: This allows anybody who can specify pods more or less full access to the file system on the machine running the agent!
136+
137+
The agent will need full access to this directory and tries to create it if it does not exist.
138+
139+
140+
=== server-port
141+
142+
*Default value*: 3000
143+
144+
*Required*: false
145+
146+
*Multiple values:* false
147+
148+
149+
Port to listen on for callbacks.
150+
151+
152+
=== package-directory
153+
154+
*Default value*: /opt/stackable/packages
155+
156+
*Required*: false
157+
158+
*Multiple values:* false
159+
160+
161+
This directory will serve as starting point for packages that are needed by pods assigned to this node.\n Packages will be downloaded into the "_download" folder at the top level of this folder as archives and remain there for potential future use.
162+
163+
Archives will the be extracted directly into this folder in subdirectories following the naming
164+
scheme of "productname-productversion".
165+
166+
The agent will need full access to this directory and tries to create it if it does not exist.

src/main.rs renamed to src/bin/agent.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,8 @@ use kubelet::Kubelet;
88
use log::{info, warn};
99
use stackable_config::ConfigBuilder;
1010

11-
use crate::agentconfig::AgentConfig;
12-
use crate::provider::StackableProvider;
13-
14-
mod agentconfig;
15-
mod provider;
11+
use stackable_agent::config::AgentConfig;
12+
use stackable_agent::provider::StackableProvider;
1613

1714
#[tokio::main(threaded_scheduler)]
1815
async fn main() -> anyhow::Result<()> {

src/bin/generate_doc.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/// This is a helper binary which generates the file _documentation/commandline_args.adoc_ which
2+
/// contains documentation of the available command line options for the agent binary.
3+
///
4+
/// It gets the content by calling [`stackable_agent::config::AgentConfig::get_documentation()`]
5+
///
6+
/// # Panics
7+
/// This will panic if an error occurs when trying to write the file.
8+
9+
fn main() {
10+
use stackable_agent::config::AgentConfig;
11+
use std::fs;
12+
13+
let target_file = "documentation/commandline_args.adoc";
14+
fs::write(target_file, AgentConfig::get_documentation()).unwrap_or_else(|err| {
15+
panic!(
16+
"Could not write documentation to [{}]: {}",
17+
target_file, err
18+
)
19+
});
20+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)