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

Adds command line parameter to control the pod cidr the agent requests from Kubernetes #50

Merged
merged 6 commits into from
Feb 11, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 59 additions & 43 deletions documentation/commandline_args.adoc
Original file line number Diff line number Diff line change
@@ -1,123 +1,126 @@



=== tag
=== server-cert-file

*Default value*: No default value
*Default value*: `No default value`

*Required*: false

*Multiple values:* true
*Multiple values:* false


A "key=value" pair that should be assigned to this agent as tag. This can be specified multiple times to assign additional tags.

Tags are the main way of identifying nodes to assign services to later on.
The certificate file for the local webserver which the Krustlet starts.


=== server-key-file
=== server-port

*Default value*: No default value
*Default value*: `3000`

*Required*: false

*Multiple values:* false


Private key file (in PKCS8 format) to use for the local webserver the Krustlet starts.
Port to listen on for callbacks.


=== log-directory
=== package-directory

*Default value*: /opt/stackable/logs
*Default value*: `/opt/stackable/packages`

*Required*: false

*Multiple values:* false


This directory will serve as starting point for all log files which this service creates.
Every service will get its own subdirectory created within this directory.
Anything that is then specified in the log4j config or similar files will be resolved relatively to this directory.
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.

Archives will the be extracted directly into this folder in subdirectories following the naming
scheme of "productname-productversion".

The agent will need full access to this directory and tries to create it if it does not exist.


=== hostname
=== data-directory

*Default value*: No default value
*Default value*: `/var/stackable/agent/data`

*Required*: false

*Multiple values:* false


The hostname to register the node under in Kubernetes - defaults to system hostname.
The directory where the stackable agent should keep its working data.


=== server-cert-file
=== no-config

*Default value*: No default value
*Default value*: `No default value`

*Required*: false

*Multiple values:* false


The certificate file for the local webserver which the Krustlet starts.
If this option is specified, any file referenced in AGENT_CONF environment variable will be ignored.


=== no-config
=== hostname

*Default value*: No default value
*Default value*: `No default value`

*Required*: false

*Multiple values:* false


If this option is specified, any file referenced in AGENT_CONF environment variable will be ignored.
The hostname to register the node under in Kubernetes - defaults to system hostname.


=== bootstrap-file
=== pod-cidr

*Default value*: /etc/kubernetes/bootstrap-kubelet.conf
*Default value*: ``

*Required*: false

*Multiple values:* false


The bootstrap file to use in case Kubernetes bootstraping is used to add the agent.
This setting controls the pod address range that the agent reports to Kubernetes.
The effect of this setting is that Kubernetes will reserve address blocks from withhin this range for every node.
Depending on the setting for maximum pods per node, these will be larger or smaller ranges, and influence the maximum number of nodes for the cluster.

The agent does not require any pod address ranges, and by default doesn't specify anything for this setting.

=== server-bind-ip

*Default value*: No default value
=== server-key-file

*Default value*: `No default value`

*Required*: false

*Multiple values:* false


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.
Private key file (in PKCS8 format) to use for the local webserver the Krustlet starts.


=== data-directory
=== server-bind-ip

*Default value*: /var/stackable/agent/data
*Default value*: `No default value`

*Required*: false

*Multiple values:* false


The directory where the stackable agent should keep its working data.
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.


=== config-directory

*Default value*: /opt/stackable/config
*Default value*: `/opt/stackable/config`

*Required*: false

Expand All @@ -137,30 +140,43 @@ WARNING: This allows anybody who can specify pods more or less full access to th
The agent will need full access to this directory and tries to create it if it does not exist.


=== server-port
=== tag

*Default value*: 3000
*Default value*: `No default value`

*Required*: false

*Multiple values:* false
*Multiple values:* true


Port to listen on for callbacks.
A "key=value" pair that should be assigned to this agent as tag. This can be specified multiple times to assign additional tags.

Tags are the main way of identifying nodes to assign services to later on.


=== package-directory
=== log-directory

*Default value*: /opt/stackable/packages
*Default value*: `/opt/stackable/logs`

*Required*: false

*Multiple values:* false


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.
This directory will serve as starting point for all log files which this service creates.
Every service will get its own subdirectory created within this directory.
Anything that is then specified in the log4j config or similar files will be resolved relatively to this directory.

The agent will need full access to this directory and tries to create it if it does not exist.


=== bootstrap-file

*Default value*: `/etc/kubernetes/bootstrap-kubelet.conf`

*Required*: false

*Multiple values:* false

Archives will the be extracted directly into this folder in subdirectories following the naming
scheme of "productname-productversion".

The agent will need full access to this directory and tries to create it if it does not exist.
The bootstrap file to use in case Kubernetes bootstraping is used to add the agent.
1 change: 1 addition & 0 deletions src/bin/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ async fn main() -> anyhow::Result<()> {
agent_config.parcel_directory.clone(),
agent_config.config_directory.clone(),
agent_config.log_directory.clone(),
agent_config.pod_cidr,
)
.await
.expect("Error initializing provider.");
Expand Down
5 changes: 5 additions & 0 deletions src/config/config_documentation/pod_cidr.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This setting controls the pod address range that the agent reports to Kubernetes.
soenkeliebau marked this conversation as resolved.
Show resolved Hide resolved
The effect of this setting is that Kubernetes will reserve address blocks from withhin this range for every node.
Depending on the setting for maximum pods per node, these will be larger or smaller ranges, and influence the maximum number of nodes for the cluster.

The agent does not require any pod address ranges, and by default doesn't specify anything for this setting.
20 changes: 20 additions & 0 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pub struct AgentConfig {
pub server_cert_file: Option<PathBuf>,
pub server_key_file: Option<PathBuf>,
pub tags: HashMap<String, String>,
pub pod_cidr: String,
}

impl AgentConfig {
Expand Down Expand Up @@ -158,6 +159,16 @@ impl AgentConfig {
list: true
};

pub const POD_CIDR: ConfigOption = ConfigOption {
name: "pod-cidr",
default: Some(""),
required: false,
takes_argument: true,
help: "An ip range in CIDR notation which designates the range that pods assigned to this node should have their ip addresses in.",
soenkeliebau marked this conversation as resolved.
Show resolved Hide resolved
documentation: include_str!("config_documentation/pod_cidr.adoc"),
list: false
};

fn get_options() -> HashSet<ConfigOption> {
[
AgentConfig::HOSTNAME,
Expand All @@ -172,6 +183,7 @@ impl AgentConfig {
AgentConfig::NO_CONFIG,
AgentConfig::TAG,
AgentConfig::BOOTSTRAP_FILE,
AgentConfig::POD_CIDR,
]
.iter()
.cloned()
Expand Down Expand Up @@ -376,6 +388,13 @@ impl Configurable for AgentConfig {
error_list.as_mut(),
);

// Parse pod cidr
let final_pod_cidr: Result<String, anyhow::Error> = AgentConfig::get_with_default(
&parsed_values,
&AgentConfig::POD_CIDR,
error_list.as_mut(),
);

// Parse cert file
let final_server_cert_file = if let Ok(server_cert_file) =
AgentConfig::get_exactly_one_string(&parsed_values, &AgentConfig::SERVER_CERT_FILE)
Expand Down Expand Up @@ -454,6 +473,7 @@ impl Configurable for AgentConfig {
server_cert_file: final_server_cert_file,
server_key_file: final_server_key_file,
tags: final_tags,
pod_cidr: final_pod_cidr.unwrap(),
})
}
}
4 changes: 4 additions & 0 deletions src/provider/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub struct StackableProvider {
parcel_directory: PathBuf,
config_directory: PathBuf,
log_directory: PathBuf,
pod_cidr: String,
}

pub const CRDS: &[&str] = &["repositories.stable.stackable.de"];
Expand Down Expand Up @@ -70,12 +71,14 @@ impl StackableProvider {
parcel_directory: PathBuf,
config_directory: PathBuf,
log_directory: PathBuf,
pod_cidr: String,
) -> Result<Self, StackableError> {
let provider = StackableProvider {
client,
parcel_directory,
config_directory,
log_directory,
pod_cidr,
};
let missing_crds = provider.check_crds().await?;
return if missing_crds.is_empty() {
Expand Down Expand Up @@ -151,6 +154,7 @@ impl Provider for StackableProvider {

async fn node(&self, builder: &mut Builder) -> anyhow::Result<()> {
builder.set_architecture(Self::ARCH);
builder.set_pod_cidr(&self.pod_cidr);
builder.add_taint("NoSchedule", "kubernetes.io/arch", Self::ARCH);
builder.add_taint("NoExecute", "kubernetes.io/arch", Self::ARCH);
Ok(())
Expand Down