Skip to content

Commit 4846df7

Browse files
k8s 1.21 upgrades
1 parent da85061 commit 4846df7

25 files changed

Lines changed: 687 additions & 795 deletions

File tree

Cargo.lock

Lines changed: 478 additions & 543 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,13 @@ maintenance = { status = "actively-developed" }
2929
default = ["native-tls"]
3030
native-tls = [
3131
"kube/native-tls",
32-
"kube-runtime/native-tls",
3332
"krator/kube-native-tls",
3433
"kubelet/kube-native-tls",
3534
"wasi-provider/native-tls",
3635
"oci-distribution/native-tls",
3736
]
3837
rustls-tls = [
3938
"kube/rustls-tls",
40-
"kube-runtime/rustls-tls",
4139
"krator/rustls-tls",
4240
"kubelet/rustls-tls",
4341
"wasi-provider/rustls-tls",
@@ -47,10 +45,10 @@ rustls-tls = [
4745
[dependencies]
4846
anyhow = "1.0"
4947
tokio = { version = "1.0", features = ["macros", "rt-multi-thread", "time"] }
50-
kube = { version = "0.55", default-features = false }
51-
k8s-openapi = { version = "0.11", default-features = false, features = ["v1_20"] }
48+
kube = { version = "0.58", default-features = false }
49+
k8s-openapi = { version = "0.12", default-features = false, features = ["v1_21"] }
5250
futures = "0.3"
53-
krator = { version = "0.3", default-features = false }
51+
krator = { version = "0.3", default-features = false, path = "../krator/krator" }
5452
kubelet = { path = "./crates/kubelet", version = "0.7", default-features = false, features = ["cli"] }
5553
wasi-provider = { path = "./crates/wasi-provider", version = "0.7", default-features = false }
5654
oci-distribution = { path = "./crates/oci-distribution", version = "0.6", default-features = false }
@@ -64,7 +62,7 @@ serde = "1.0"
6462
serde_derive = "1.0"
6563
serde_json = "1.0"
6664
reqwest = { version = "0.11", default-features = false }
67-
kube-runtime = { version = "0.55", default-features = false }
65+
kube-runtime = { version = "0.58", default-features = false }
6866
compiletest_rs = "0.6"
6967
tempfile = "3.2"
7068
k8s-csi = "0.3"

crates/kubelet/Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ maintenance = { status = "actively-developed" }
2929

3030
[features]
3131
default = ["kube-native-tls"]
32-
kube-native-tls = ["kube/native-tls", "kube-runtime/native-tls", "oci-distribution/native-tls", "reqwest/native-tls", "krator/kube-native-tls"]
33-
rustls-tls = ["kube/rustls-tls", "kube-runtime/rustls-tls","oci-distribution/rustls-tls", "reqwest/rustls-tls", "krator/rustls-tls"]
32+
kube-native-tls = ["kube/native-tls", "oci-distribution/native-tls", "reqwest/native-tls", "krator/kube-native-tls"]
33+
rustls-tls = ["kube/rustls-tls","oci-distribution/rustls-tls", "reqwest/rustls-tls", "krator/rustls-tls"]
3434
cli = ["structopt"]
3535
docs = ["cli", "derive"]
3636
derive = ["krator/derive"]
@@ -48,9 +48,9 @@ hyper = { version = "0.14", default-features = false, features = ["stream"] }
4848
reqwest = { version = "0.11", default-features = false, features = ["json", "stream"]}
4949
tokio = { version = "1.0", features = ["fs", "macros", "signal", "net"] }
5050
tokio-stream = { version="0.1", features = ["fs", "net"] }
51-
kube = { version = "0.55", default-features = false, features = ["jsonpatch"] }
52-
kube-runtime = { version= "0.55", default-features = false }
53-
k8s-openapi = { version = "0.11", default-features = false, features = ["v1_20"] }
51+
kube = { version = "0.58", default-features = false, features = ["jsonpatch"] }
52+
kube-runtime = { version= "0.58", default-features = false }
53+
k8s-openapi = { version = "0.12", default-features = false, features = ["v1_21"] }
5454
k8s-csi = "0.3"
5555
chrono = { version = "0.4", features = ["serde"] }
5656
structopt = { version = "0.3", features = ["wrap_help"], optional = true }
@@ -64,7 +64,7 @@ http = "0.2"
6464
regex = "1.5"
6565
rcgen = "0.8"
6666
uuid = { version = "0.8.1", features = ["v4"] }
67-
krator = { version = "0.3", default-features = false }
67+
krator = { version = "0.3", default-features = false, path = "../../../krator/krator" }
6868
json-patch = "0.2"
6969
tempfile = "3.2"
7070
tonic = "0.4"

crates/kubelet/src/bootstrapping/mod.rs

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -128,18 +128,20 @@ async fn bootstrap_auth<K: AsRef<Path>>(
128128
};
129129

130130
if let Some(cert) = status.certificate {
131-
if let Some(v) = status.conditions {
132-
if v.into_iter().any(|c| c.type_.as_str() == APPROVED_TYPE) {
133-
debug!("Certificate has been approved, generating kubeconfig");
134-
generated_kubeconfig = gen_kubeconfig(
135-
ca_data,
136-
server,
137-
cert,
138-
cert_bundle.serialize_private_key_pem(),
139-
)?;
140-
got_cert = true;
141-
break;
142-
}
131+
if status
132+
.conditions
133+
.into_iter()
134+
.any(|c| c.type_.as_str() == APPROVED_TYPE)
135+
{
136+
debug!("Certificate has been approved, generating kubeconfig");
137+
generated_kubeconfig = gen_kubeconfig(
138+
ca_data,
139+
server,
140+
cert,
141+
cert_bundle.serialize_private_key_pem(),
142+
)?;
143+
got_cert = true;
144+
break;
143145
}
144146
}
145147

@@ -243,13 +245,15 @@ async fn bootstrap_tls(
243245
};
244246

245247
if let Some(cert) = status.certificate {
246-
if let Some(v) = status.conditions {
247-
if v.into_iter().any(|c| c.type_.as_str() == APPROVED_TYPE) {
248-
debug!("Certificate has been approved, extracting cert from response");
249-
certificate = std::str::from_utf8(&cert.0)?.to_owned();
250-
got_cert = true;
251-
break;
252-
}
248+
if status
249+
.conditions
250+
.into_iter()
251+
.any(|c| c.type_.as_str() == APPROVED_TYPE)
252+
{
253+
debug!("Certificate has been approved, extracting cert from response");
254+
certificate = std::str::from_utf8(&cert.0)?.to_owned();
255+
got_cert = true;
256+
break;
253257
}
254258
}
255259
info!(remaining = ?start.elapsed(), "Got modified event, but CSR for serving certs is not currently approved");

crates/kubelet/src/config.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ mod test {
710710
assert_eq!(config.data_dir.to_string_lossy(), "/krusty/data/dir");
711711
assert_eq!(format!("{}", config.node_ip), "173.183.193.2");
712712
assert_eq!(config.max_pods, 400);
713-
assert_eq!(config.allow_local_modules, true);
713+
assert!(config.allow_local_modules);
714714
assert_eq!(config.node_labels.len(), 2);
715715
assert_eq!(config.node_labels.get("label1"), Some(&("val1".to_owned())));
716716
assert_eq!(config.insecure_registries.clone().unwrap().len(), 2);
@@ -775,7 +775,7 @@ mod test {
775775
assert_eq!(config.hostname, "fallback-hostname");
776776
assert_eq!(config.data_dir.to_string_lossy(), "/fallback/data/dir");
777777
assert_eq!(format!("{}", config.node_ip), "4.4.4.4");
778-
assert_eq!(config.allow_local_modules, false);
778+
assert!(!config.allow_local_modules);
779779
assert_eq!(config.insecure_registries, None);
780780
assert_eq!(config.node_labels.len(), 0);
781781
assert_eq!(
@@ -855,7 +855,7 @@ mod test {
855855
assert_eq!(config.max_pods, 30);
856856
assert_eq!(config.data_dir.to_string_lossy(), "/krusty/data/dir/2");
857857
assert_eq!(format!("{}", config.node_ip), "173.183.193.22");
858-
assert_eq!(config.allow_local_modules, false);
858+
assert!(!config.allow_local_modules);
859859
assert_eq!(config.insecure_registries.clone().unwrap().len(), 1);
860860
assert_eq!(&config.insecure_registries.clone().unwrap()[0], "local");
861861
assert_eq!(config.node_labels.len(), 2);
@@ -910,7 +910,7 @@ mod test {
910910
assert_eq!(config.hostname, "krusty-host");
911911
assert_eq!(config.data_dir.to_string_lossy(), "/krusty/data/dir");
912912
assert_eq!(format!("{}", config.node_ip), "173.183.193.2");
913-
assert_eq!(config.allow_local_modules, true);
913+
assert!(config.allow_local_modules);
914914
assert_eq!(config.insecure_registries.clone().unwrap().len(), 1);
915915
assert_eq!(&config.insecure_registries.clone().unwrap()[0], "local");
916916
assert_eq!(config.node_labels.len(), 2);

crates/kubelet/src/container/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -138,22 +138,22 @@ impl Container {
138138
}
139139

140140
/// Get arguments of container.
141-
pub fn args(&self) -> &Option<Vec<String>> {
141+
pub fn args(&self) -> &Vec<String> {
142142
&self.0.args
143143
}
144144

145145
/// Get command of container.
146-
pub fn command(&self) -> &Option<Vec<String>> {
146+
pub fn command(&self) -> &Vec<String> {
147147
&self.0.command
148148
}
149149

150150
/// Get environment of container.
151-
pub fn env(&self) -> &Option<Vec<k8s_openapi::api::core::v1::EnvVar>> {
151+
pub fn env(&self) -> &Vec<k8s_openapi::api::core::v1::EnvVar> {
152152
&self.0.env
153153
}
154154

155155
/// Get environment of container.
156-
pub fn env_from(&self) -> &Option<Vec<k8s_openapi::api::core::v1::EnvFromSource>> {
156+
pub fn env_from(&self) -> &Vec<k8s_openapi::api::core::v1::EnvFromSource> {
157157
&self.0.env_from
158158
}
159159

@@ -186,7 +186,7 @@ impl Container {
186186
}
187187

188188
/// Get ports of container.
189-
pub fn ports(&self) -> &Option<Vec<k8s_openapi::api::core::v1::ContainerPort>> {
189+
pub fn ports(&self) -> &Vec<k8s_openapi::api::core::v1::ContainerPort> {
190190
&self.0.ports
191191
}
192192

@@ -236,12 +236,12 @@ impl Container {
236236
}
237237

238238
/// Get volume devices of container.
239-
pub fn volume_devices(&self) -> &Option<Vec<k8s_openapi::api::core::v1::VolumeDevice>> {
239+
pub fn volume_devices(&self) -> &Vec<k8s_openapi::api::core::v1::VolumeDevice> {
240240
&self.0.volume_devices
241241
}
242242

243243
/// Get volume mounts of container.
244-
pub fn volume_mounts(&self) -> &Option<Vec<k8s_openapi::api::core::v1::VolumeMount>> {
244+
pub fn volume_mounts(&self) -> &Vec<k8s_openapi::api::core::v1::VolumeMount> {
245245
&self.0.volume_mounts
246246
}
247247

crates/kubelet/src/kubelet.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,7 @@ mod test {
259259
use tokio::sync::RwLock;
260260

261261
fn mock_client() -> kube::Client {
262-
kube::Client::try_from(kube::Config::new(
263-
reqwest::Url::parse("http://127.0.0.1:8080").unwrap(),
264-
))
265-
.unwrap()
262+
kube::Client::try_from(kube::Config::new("http://127.0.0.1:8080".parse().unwrap())).unwrap()
266263
}
267264

268265
struct MockProvider;
@@ -328,7 +325,7 @@ mod test {
328325
#[tokio::test]
329326
async fn test_env_vars() {
330327
let container = Container::new(&KubeContainer {
331-
env: Some(vec![
328+
env: vec![
332329
EnvVar {
333330
name: "first".into(),
334331
value: Some("value".into()),
@@ -400,7 +397,7 @@ mod test {
400397
}),
401398
..Default::default()
402399
},
403-
]),
400+
],
404401
..Default::default()
405402
});
406403
let name = "my-name".to_string();
@@ -411,8 +408,8 @@ mod test {
411408
annotations.insert("annotation".to_string(), "value".to_string());
412409
let pod = Pod::from(KubePod {
413410
metadata: ObjectMeta {
414-
labels: Some(labels),
415-
annotations: Some(annotations),
411+
labels,
412+
annotations,
416413
name: Some(name),
417414
namespace,
418415
..Default::default()

crates/kubelet/src/node/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -655,14 +655,14 @@ impl Builder {
655655
pub fn build(self) -> Node {
656656
let metadata = k8s_openapi::apimachinery::pkg::apis::meta::v1::ObjectMeta {
657657
name: Some(self.name),
658-
annotations: Some(self.annotations),
659-
labels: Some(self.labels),
658+
annotations: self.annotations,
659+
labels: self.labels,
660660
..Default::default()
661661
};
662662

663663
let spec = k8s_openapi::api::core::v1::NodeSpec {
664664
pod_cidr: Some(self.pod_cidr),
665-
taints: Some(self.taints),
665+
taints: self.taints,
666666
..Default::default()
667667
};
668668

@@ -677,15 +677,15 @@ impl Builder {
677677

678678
let status = k8s_openapi::api::core::v1::NodeStatus {
679679
node_info: Some(node_info),
680-
capacity: Some(self.capacity),
681-
allocatable: Some(self.allocatable),
680+
capacity: self.capacity,
681+
allocatable: self.allocatable,
682682
daemon_endpoints: Some(k8s_openapi::api::core::v1::NodeDaemonEndpoints {
683683
kubelet_endpoint: Some(k8s_openapi::api::core::v1::DaemonEndpoint {
684684
port: self.port,
685685
}),
686686
}),
687-
conditions: Some(self.conditions),
688-
addresses: Some(self.addresses),
687+
conditions: self.conditions,
688+
addresses: self.addresses,
689689
..Default::default()
690690
};
691691

0 commit comments

Comments
 (0)