diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 7ac2168..e168758 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -24,7 +24,7 @@ jobs: - uses: actions/checkout@v1 - uses: actions-rs/toolchain@v1 with: - toolchain: nightly + toolchain: stable components: clippy, rustfmt override: true - uses: actions-rs/clippy-check@v1 diff --git a/documentation/commandline_args.adoc b/documentation/commandline_args.adoc index f3f6ec7..7e64ec3 100644 --- a/documentation/commandline_args.adoc +++ b/documentation/commandline_args.adoc @@ -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 @@ -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. \ No newline at end of file +The bootstrap file to use in case Kubernetes bootstraping is used to add the agent. \ No newline at end of file diff --git a/src/bin/agent.rs b/src/bin/agent.rs index 74f8641..011a440 100644 --- a/src/bin/agent.rs +++ b/src/bin/agent.rs @@ -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."); diff --git a/src/config/config_documentation/pod_cidr.adoc b/src/config/config_documentation/pod_cidr.adoc new file mode 100644 index 0000000..c129031 --- /dev/null +++ b/src/config/config_documentation/pod_cidr.adoc @@ -0,0 +1,7 @@ +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. + +WARNING: There should almost never be a reason to use this setting, this is mostly here for very special circumstances. Do not touch it unless you really know what you're doing. \ No newline at end of file diff --git a/src/config/mod.rs b/src/config/mod.rs index ab7923b..178e243 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -33,6 +33,7 @@ pub struct AgentConfig { pub server_cert_file: Option, pub server_key_file: Option, pub tags: HashMap, + pub pod_cidr: String, } impl AgentConfig { @@ -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.", + documentation: include_str!("config_documentation/pod_cidr.adoc"), + list: false + }; + fn get_options() -> HashSet { [ AgentConfig::HOSTNAME, @@ -172,6 +183,7 @@ impl AgentConfig { AgentConfig::NO_CONFIG, AgentConfig::TAG, AgentConfig::BOOTSTRAP_FILE, + AgentConfig::POD_CIDR, ] .iter() .cloned() @@ -376,6 +388,13 @@ impl Configurable for AgentConfig { error_list.as_mut(), ); + // Parse pod cidr + let final_pod_cidr: Result = 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) @@ -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(), }) } } diff --git a/src/provider/mod.rs b/src/provider/mod.rs index 2071740..d865778 100644 --- a/src/provider/mod.rs +++ b/src/provider/mod.rs @@ -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"]; @@ -70,12 +71,14 @@ impl StackableProvider { parcel_directory: PathBuf, config_directory: PathBuf, log_directory: PathBuf, + pod_cidr: String, ) -> Result { 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() { @@ -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(())