Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make tls features additive #383

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 2 additions & 5 deletions examples/configmap_reflector.rs
@@ -1,10 +1,7 @@
#[macro_use] extern crate log;
use futures::{StreamExt, TryStreamExt};
use k8s_openapi::api::core::v1::ConfigMap;
use kube::{
api::{Api, ListParams, Meta},
Client,
};
use kube::{Client, Tls, api::{Api, ListParams, Meta}};
use kube_runtime::{reflector, reflector::Store, utils::try_flatten_applied, watcher};

fn spawn_periodic_reader(reader: Store<ConfigMap>) {
Expand All @@ -22,7 +19,7 @@ fn spawn_periodic_reader(reader: Store<ConfigMap>) {
async fn main() -> anyhow::Result<()> {
std::env::set_var("RUST_LOG", "info,kube=debug");
env_logger::init();
let client = Client::try_default().await?;
let client = Client::try_default(Tls::pick()).await?;
let namespace = std::env::var("NAMESPACE").unwrap_or("default".into());

let cms: Api<ConfigMap> = Api::namespaced(client, &namespace);
Expand Down
7 changes: 2 additions & 5 deletions examples/configmap_watcher.rs
@@ -1,17 +1,14 @@
#[macro_use] extern crate log;
use futures::{StreamExt, TryStreamExt};
use k8s_openapi::api::core::v1::ConfigMap;
use kube::{
api::{Api, ListParams},
Client,
};
use kube::{Client, Tls, api::{Api, ListParams}};
use kube_runtime::watcher;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
std::env::set_var("RUST_LOG", "info,kube=debug");
env_logger::init();
let client = Client::try_default().await?;
let client = Client::try_default(Tls::pick()).await?;
let namespace = std::env::var("NAMESPACE").unwrap_or("default".into());

let cms: Api<ConfigMap> = Api::namespaced(client, &namespace);
Expand Down
7 changes: 2 additions & 5 deletions examples/configmapgen_controller.rs
Expand Up @@ -5,10 +5,7 @@ use k8s_openapi::{
api::core::v1::ConfigMap,
apimachinery::pkg::apis::meta::v1::{ObjectMeta, OwnerReference},
};
use kube::{
api::{ListParams, Meta, PatchParams, PatchStrategy},
Api, Client, CustomResource,
};
use kube::{Api, Client, CustomResource, Tls, api::{ListParams, Meta, PatchParams, PatchStrategy}};
use kube_runtime::controller::{Context, Controller, ReconcilerAction};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -114,7 +111,7 @@ struct Data {
async fn main() -> Result<()> {
std::env::set_var("RUST_LOG", "info,kube-runtime=debug,kube=debug");
env_logger::init();
let client = Client::try_default().await?;
let client = Client::try_default(Tls::pick()).await?;

let cmgs = Api::<ConfigMapGenerator>::all(client.clone());
let cms = Api::<ConfigMap>::all(client.clone());
Expand Down
7 changes: 2 additions & 5 deletions examples/crd_api.rs
Expand Up @@ -9,10 +9,7 @@ use tokio::time::sleep;
use apiexts::CustomResourceDefinition;
use k8s_openapi::apiextensions_apiserver::pkg::apis::apiextensions::v1beta1 as apiexts;

use kube::{
api::{Api, DeleteParams, ListParams, Meta, PatchParams, PostParams},
Client, CustomResource,
};
use kube::{Client, CustomResource, Tls, api::{Api, DeleteParams, ListParams, Meta, PatchParams, PostParams}};

// Own custom resource
#[derive(CustomResource, Deserialize, Serialize, Clone, Debug, JsonSchema)]
Expand All @@ -37,7 +34,7 @@ pub struct FooStatus {
async fn main() -> anyhow::Result<()> {
std::env::set_var("RUST_LOG", "info,kube=debug");
env_logger::init();
let client = Client::try_default().await?;
let client = Client::try_default(Tls::pick()).await?;
let namespace = std::env::var("NAMESPACE").unwrap_or("default".into());

// Manage CRDs first
Expand Down
23 changes: 12 additions & 11 deletions examples/crd_apply.rs
@@ -1,15 +1,13 @@
#[macro_use] extern crate log;
#[macro_use]
extern crate log;
use futures::{StreamExt, TryStreamExt};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

use apiexts::CustomResourceDefinition;
use k8s_openapi::apiextensions_apiserver::pkg::apis::apiextensions::v1beta1 as apiexts;

use kube::{
api::{Api, ListParams, Meta, PatchParams, WatchEvent},
Client, CustomResource,
};
use kube::{Client, CustomResource, Tls, api::{Api, ListParams, Meta, PatchParams, WatchEvent}};

// NB: This example uses server side apply and beta1 customresources
// Please test against Kubernetes 1.16.X!
Expand All @@ -36,7 +34,7 @@ pub struct FooStatus {
async fn main() -> anyhow::Result<()> {
std::env::set_var("RUST_LOG", "info,kube=info");
env_logger::init();
let client = Client::try_default().await?;
let client = Client::try_default(Tls::pick()).await?;
let namespace = std::env::var("NAMESPACE").unwrap_or("default".into());

let ssapply = PatchParams::apply("crd_apply_example").force();
Expand All @@ -61,11 +59,14 @@ async fn main() -> anyhow::Result<()> {
let foos: Api<Foo> = Api::namespaced(client.clone(), &namespace);

// 1. Apply from a full struct (e.g. equivalent to replace w/o resource_version)
let foo = Foo::new("baz", FooSpec {
name: "baz".into(),
info: Some("old baz".into()),
replicas: 3,
});
let foo = Foo::new(
"baz",
FooSpec {
name: "baz".into(),
info: Some("old baz".into()),
replicas: 3,
},
);
info!("Applying 1: \n{}", serde_yaml::to_string(&foo)?);
let o = foos.patch("baz", &ssapply, serde_yaml::to_vec(&foo)?).await?;
info!("Applied 1 {}: {:?}", Meta::name(&o), o.spec);
Expand Down
7 changes: 2 additions & 5 deletions examples/crd_derive_schema.rs
@@ -1,10 +1,7 @@
use anyhow::{anyhow, Result};
use futures::{StreamExt, TryStreamExt};
use k8s_openapi::apiextensions_apiserver::pkg::apis::apiextensions::v1::CustomResourceDefinition;
use kube::{
api::{Api, DeleteParams, ListParams, PostParams, Resource, WatchEvent},
Client, CustomResource,
};
use kube::{Client, CustomResource, Tls, api::{Api, DeleteParams, ListParams, PostParams, Resource, WatchEvent}};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -90,7 +87,7 @@ async fn main() -> Result<()> {

// Creating CRD v1 works as expected.
println!("Creating CRD v1");
let client = Client::try_default().await?;
let client = Client::try_default(Tls::pick()).await?;
delete_crd(client.clone()).await?;
assert!(create_crd(client.clone()).await.is_ok());

Expand Down
7 changes: 2 additions & 5 deletions examples/crd_reflector.rs
@@ -1,9 +1,6 @@
#[macro_use] extern crate log;
use futures::{StreamExt, TryStreamExt};
use kube::{
api::{Api, ListParams, Meta},
Client, CustomResource,
};
use kube::{Client, CustomResource, Tls, api::{Api, ListParams, Meta}};
use kube_runtime::{reflector, utils::try_flatten_applied, watcher};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
Expand All @@ -19,7 +16,7 @@ pub struct FooSpec {
async fn main() -> anyhow::Result<()> {
std::env::set_var("RUST_LOG", "info,kube=debug");
env_logger::init();
let client = Client::try_default().await?;
let client = Client::try_default(Tls::pick()).await?;
let namespace = std::env::var("NAMESPACE").unwrap_or("default".into());

// This example requires `kubectl apply -f examples/foo.yaml` run first
Expand Down
7 changes: 2 additions & 5 deletions examples/deployment_reflector.rs
@@ -1,17 +1,14 @@
#[macro_use] extern crate log;
use futures::{StreamExt, TryStreamExt};
use k8s_openapi::api::apps::v1::Deployment;
use kube::{
api::{Api, ListParams, Meta},
Client,
};
use kube::{Client, Tls, api::{Api, ListParams, Meta}};
use kube_runtime::{reflector, utils::try_flatten_applied, watcher};

#[tokio::main]
async fn main() -> anyhow::Result<()> {
std::env::set_var("RUST_LOG", "info,kube=debug");
env_logger::init();
let client = Client::try_default().await?;
let client = Client::try_default(Tls::pick()).await?;

let namespace = std::env::var("NAMESPACE").unwrap_or("default".into());

Expand Down
4 changes: 2 additions & 2 deletions examples/dynamic_api.rs
@@ -1,11 +1,11 @@
#[macro_use] extern crate log;
use kube::{api::DynamicResource, Client};
use kube::{Client, Tls, api::DynamicResource};

#[tokio::main]
async fn main() -> anyhow::Result<()> {
std::env::set_var("RUST_LOG", "info,kube=debug");
env_logger::init();
let client = Client::try_default().await?;
let client = Client::try_default(Tls::pick()).await?;

let v = client.apiserver_version().await?;
info!("api version: {:?}", v);
Expand Down
7 changes: 2 additions & 5 deletions examples/event_watcher.rs
@@ -1,17 +1,14 @@
#[macro_use] extern crate log;
use futures::{StreamExt, TryStreamExt};
use k8s_openapi::api::core::v1::Event;
use kube::{
api::{Api, ListParams},
Client,
};
use kube::{Client, Tls, api::{Api, ListParams}};
use kube_runtime::{utils::try_flatten_applied, watcher};

#[tokio::main]
async fn main() -> anyhow::Result<()> {
std::env::set_var("RUST_LOG", "info,kube=debug");
env_logger::init();
let client = Client::try_default().await?;
let client = Client::try_default(Tls::pick()).await?;

let events: Api<Event> = Api::all(client);
let lp = ListParams::default();
Expand Down
7 changes: 2 additions & 5 deletions examples/job_api.rs
Expand Up @@ -3,16 +3,13 @@ use futures::{StreamExt, TryStreamExt};
use k8s_openapi::api::batch::v1::Job;
use serde_json::json;

use kube::{
api::{Api, DeleteParams, ListParams, Meta, PostParams, WatchEvent},
Client,
};
use kube::{Client, Tls, api::{Api, DeleteParams, ListParams, Meta, PostParams, WatchEvent}};

#[tokio::main]
async fn main() -> anyhow::Result<()> {
std::env::set_var("RUST_LOG", "info,kube=debug");
env_logger::init();
let client = Client::try_default().await?;
let client = Client::try_default(Tls::pick()).await?;
let namespace = std::env::var("NAMESPACE").unwrap_or("default".into());

// Create a Job
Expand Down
7 changes: 2 additions & 5 deletions examples/log_stream.rs
Expand Up @@ -2,17 +2,14 @@
use anyhow::{anyhow, Result};
use futures::{StreamExt, TryStreamExt};
use k8s_openapi::api::core::v1::Pod;
use kube::{
api::{Api, LogParams},
Client,
};
use kube::{Client, Tls, api::{Api, LogParams}};
use std::env;

#[tokio::main]
async fn main() -> Result<()> {
std::env::set_var("RUST_LOG", "info,kube=debug");
env_logger::init();
let client = Client::try_default().await?;
let client = Client::try_default(Tls::pick()).await?;
let namespace = std::env::var("NAMESPACE").unwrap_or("default".into());

let mypod = env::args()
Expand Down
7 changes: 2 additions & 5 deletions examples/multi_watcher.rs
Expand Up @@ -4,17 +4,14 @@ use k8s_openapi::api::{
apps::v1::Deployment,
core::v1::{ConfigMap, Secret},
};
use kube::{
api::{Api, ListParams, Meta},
Client,
};
use kube::{Client, Tls, api::{Api, ListParams, Meta}};
use kube_runtime::{utils::try_flatten_applied, watcher};

#[tokio::main]
async fn main() -> anyhow::Result<()> {
std::env::set_var("RUST_LOG", "info,multi_watcher=debug,kube=debug");
env_logger::init();
let client = Client::try_default().await?;
let client = Client::try_default(Tls::pick()).await?;
let namespace = std::env::var("NAMESPACE").unwrap_or("default".into());

let deploys: Api<Deployment> = Api::namespaced(client.clone(), &namespace);
Expand Down
7 changes: 2 additions & 5 deletions examples/node_reflector.rs
@@ -1,17 +1,14 @@
#[macro_use] extern crate log;
use futures::{StreamExt, TryStreamExt};
use k8s_openapi::api::core::v1::Node;
use kube::{
api::{Api, ListParams, Meta},
Client,
};
use kube::{Client, Tls, api::{Api, ListParams, Meta}};
use kube_runtime::{reflector, utils::try_flatten_applied, watcher};

#[tokio::main]
async fn main() -> anyhow::Result<()> {
std::env::set_var("RUST_LOG", "info,kube=debug");
env_logger::init();
let client = Client::try_default().await?;
let client = Client::try_default(Tls::pick()).await?;

let nodes: Api<Node> = Api::all(client.clone());
let lp = ListParams::default()
Expand Down
7 changes: 2 additions & 5 deletions examples/node_watcher.rs
@@ -1,17 +1,14 @@
#[macro_use] extern crate log;
use futures::{StreamExt, TryStreamExt};
use k8s_openapi::api::core::v1::{Event, Node};
use kube::{
api::{Api, ListParams, Meta},
Client,
};
use kube::{Client, Tls, api::{Api, ListParams, Meta}};
use kube_runtime::{utils::try_flatten_applied, watcher};

#[tokio::main]
async fn main() -> anyhow::Result<()> {
std::env::set_var("RUST_LOG", "info,node_watcher=debug,kube=debug");
env_logger::init();
let client = Client::try_default().await?;
let client = Client::try_default(Tls::pick()).await?;
let events: Api<Event> = Api::all(client.clone());
let nodes: Api<Node> = Api::all(client.clone());

Expand Down
7 changes: 2 additions & 5 deletions examples/pod_api.rs
Expand Up @@ -3,16 +3,13 @@ use futures::{StreamExt, TryStreamExt};
use k8s_openapi::api::core::v1::Pod;
use serde_json::json;

use kube::{
api::{Api, DeleteParams, ListParams, Meta, PatchParams, PostParams, WatchEvent},
Client,
};
use kube::{Client, Tls, api::{Api, DeleteParams, ListParams, Meta, PatchParams, PostParams, WatchEvent}};

#[tokio::main]
async fn main() -> anyhow::Result<()> {
std::env::set_var("RUST_LOG", "info,kube=debug");
env_logger::init();
let client = Client::try_default().await?;
let client = Client::try_default(Tls::pick()).await?;
let namespace = std::env::var("NAMESPACE").unwrap_or("default".into());

// Manage pods
Expand Down
7 changes: 2 additions & 5 deletions examples/pod_attach.rs
Expand Up @@ -5,16 +5,13 @@ use std::io::Write;
use futures::{join, stream, StreamExt, TryStreamExt};
use k8s_openapi::api::core::v1::Pod;

use kube::{
api::{Api, AttachParams, AttachedProcess, DeleteParams, ListParams, Meta, PostParams, WatchEvent},
Client,
};
use kube::{Client, Tls, api::{Api, AttachParams, AttachedProcess, DeleteParams, ListParams, Meta, PostParams, WatchEvent}};

#[tokio::main]
async fn main() -> anyhow::Result<()> {
std::env::set_var("RUST_LOG", "info,kube=debug");
env_logger::init();
let client = Client::try_default().await?;
let client = Client::try_default(Tls::pick()).await?;
let namespace = std::env::var("NAMESPACE").unwrap_or_else(|_| "default".into());

info!("Creating a Pod that outputs numbers for 15s");
Expand Down
7 changes: 2 additions & 5 deletions examples/pod_exec.rs
Expand Up @@ -3,17 +3,14 @@
use futures::{StreamExt, TryStreamExt};
use k8s_openapi::api::core::v1::Pod;

use kube::{
api::{Api, AttachParams, AttachedProcess, DeleteParams, ListParams, Meta, PostParams, WatchEvent},
Client,
};
use kube::{Client, Tls, api::{Api, AttachParams, AttachedProcess, DeleteParams, ListParams, Meta, PostParams, WatchEvent}};
use tokio::io::AsyncWriteExt;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
std::env::set_var("RUST_LOG", "info,kube=debug");
env_logger::init();
let client = Client::try_default().await?;
let client = Client::try_default(Tls::pick()).await?;
let namespace = std::env::var("NAMESPACE").unwrap_or_else(|_| "default".into());

let p: Pod = serde_json::from_value(serde_json::json!({
Expand Down
4 changes: 2 additions & 2 deletions examples/pod_reflector.rs
@@ -1,12 +1,12 @@
use color_eyre::Result;
use futures::prelude::*;
use k8s_openapi::api::core::v1::Pod;
use kube::{api::ListParams, Api, Client, Config};
use kube::{Api, Client, Config, Tls, api::ListParams};
use kube_runtime::{reflector, watcher};

#[tokio::main]
async fn main() -> Result<()> {
let config = Config::infer().await?;
let config = Config::infer(Tls::pick()).await?;
let client = Client::new(config);
let namespace = std::env::var("NAMESPACE").unwrap_or("default".into());

Expand Down