fix: could not initilaize kube-rs inside cluster, should infer config now
All checks were successful
/ build (push) Successful in 5m1s
All checks were successful
/ build (push) Successful in 5m1s
This commit is contained in:
parent
beba05a56d
commit
b5f9c5e81c
2 changed files with 5 additions and 6 deletions
|
|
@ -29,9 +29,8 @@ pub struct KubeCache {
|
|||
impl KubeCache {
|
||||
/// This initializes the creation of a "kubernetes client"
|
||||
/// and if it is not possible returns a None.
|
||||
pub fn create() -> Option<KubeCache> {
|
||||
let kubeconfig = kube::config::Kubeconfig::read().unwrap();
|
||||
let client = Client::try_from(kubeconfig).unwrap();
|
||||
pub async fn create() -> Option<KubeCache> {
|
||||
let client = Client::try_default().await.unwrap();
|
||||
|
||||
let deployments: Api<Deployment> = Api::default_namespaced(client.clone());
|
||||
let services: Api<Service> = Api::default_namespaced(client);
|
||||
|
|
@ -209,9 +208,9 @@ impl MinecraftAPI<Server> for McApi {
|
|||
}
|
||||
|
||||
impl McApi {
|
||||
pub fn create() -> Option<Self> {
|
||||
pub async fn create() -> Option<Self> {
|
||||
Some(Self {
|
||||
cache: KubeCache::create()?,
|
||||
cache: KubeCache::create().await?,
|
||||
map: Arc::new(tokio::sync::Mutex::new(HashMap::new())),
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ async fn main() {
|
|||
let revision: &'static str = env!("COMMIT_HASH");
|
||||
tracing::info!(revision);
|
||||
|
||||
let api = kube_cache::McApi::create().unwrap();
|
||||
let api = kube_cache::McApi::create().await.unwrap();
|
||||
tracing::info!("initialized kube api");
|
||||
|
||||
let config: Config = Default::default();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue