Skip to content
This repository was archived by the owner on Dec 21, 2021. It is now read-only.
Merged
Changes from all 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
18 changes: 13 additions & 5 deletions src/bin/agent.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use std::env;
use std::ffi::OsString;

use kube::config::Config as KubeConfig;
use kube::config::KubeConfigOptions;
use kubelet::config::{Config, ServerConfig};
use kubelet::Kubelet;
use log::{info, warn};
Expand Down Expand Up @@ -78,9 +76,15 @@ async fn main() -> anyhow::Result<()> {
insecure_registries: None,
};

let kubeconfig = KubeConfig::from_kubeconfig(&KubeConfigOptions::default())
.await
.expect("Failed to create Kubernetes Client!");
// Bootstrap a kubernetes config, if no valid config is found
// This also generates certificates for the webserver the krustlet
// runs
let kubeconfig = kubelet::bootstrap(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked at the krustlet docs (not code) for this and I can't see the "if no valid config is found" part. Are you sure this is the case?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My comment is based on this documentation and my take on what I saw in the code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, I see. I only looked at the docs

&krustlet_config,
&krustlet_config.bootstrap_file,
notify_bootstrap,
)
.await?;

let provider = StackableProvider::new(
kube::Client::new(kubeconfig.clone()),
Expand All @@ -101,3 +105,7 @@ fn export_env(var_name: &str, var_value: &str) {
info!("Exporting {}={}", var_name, var_value);
std::env::set_var(var_name, var_value);
}

fn notify_bootstrap(message: String) {
info!("Successfully bootstrapped TLS certificate: {}", message);
}