Skip to content

Commit f6ea3e7

Browse files
Merge pull request krustlet#678 from olivierlemasle/update-k8s-openapi
Update k8s-openapi to 0.13 and k8s 1.22
2 parents da51a43 + 10871b0 commit f6ea3e7

23 files changed

Lines changed: 309 additions & 238 deletions

File tree

Cargo.lock

Lines changed: 13 additions & 12 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 & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ anyhow = "1.0"
4646
dirs = {package = "dirs-next", version = "2.0.0"}
4747
futures = "0.3"
4848
hostname = "0.3"
49-
k8s-openapi = {version = "0.12", default-features = false, features = ["v1_21"]}
50-
krator = {version = "0.4", default-features = false}
51-
kube = {version = "0.58", default-features = false}
49+
k8s-openapi = {version = "0.13", default-features = false, features = ["v1_22"]}
50+
krator = {version = "0.5", default-features = false}
51+
kube = {version = "0.60", default-features = false}
5252
kubelet = {path = "./crates/kubelet", version = "1.0.0-alpha.1", default-features = false, features = ["cli"]}
5353
oci-distribution = {path = "./crates/oci-distribution", version = "0.7", default-features = false}
5454
regex = "1.3"
@@ -61,7 +61,7 @@ wasi-provider = {path = "./crates/wasi-provider", version = "1.0.0-alpha.1", def
6161
async-trait = "0.1"
6262
compiletest_rs = "0.6"
6363
k8s-csi = "0.4"
64-
kube-runtime = {version = "0.58", default-features = false}
64+
kube-runtime = {version = "0.60", default-features = false}
6565
reqwest = {version = "0.11", default-features = false}
6666
serde_derive = "1.0"
6767
serde_json = "1.0"

crates/kubelet/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ http = "0.2"
4949
hyper = {version = "0.14", default-features = false, features = ["stream"]}
5050
json-patch = "0.2"
5151
k8s-csi = "0.4"
52-
k8s-openapi = {version = "0.12", default-features = false, features = ["v1_21", "api"]}
53-
krator = {version = "0.4", default-features = false}
54-
kube = {version = "0.58", default-features = false, features = ["jsonpatch"]}
55-
kube-runtime = {version = "0.58", default-features = false}
52+
k8s-openapi = {version = "0.13", default-features = false, features = ["v1_22", "api"]}
53+
krator = {version = "0.5", default-features = false}
54+
kube = {version = "0.60", default-features = false, features = ["jsonpatch"]}
55+
kube-runtime = {version = "0.60", default-features = false}
5656
lazy_static = "1.4"
5757
notify = "5.0.0-pre.3"
5858
oci-distribution = {path = "../oci-distribution", version = "0.7", default-features = false}

crates/kubelet/src/bootstrapping/mod.rs

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

146146
if let Some(cert) = status.certificate {
147-
if status
148-
.conditions
149-
.into_iter()
150-
.any(|c| c.type_.as_str() == APPROVED_TYPE)
151-
{
152-
debug!("Certificate has been approved, generating kubeconfig");
153-
generated_kubeconfig = gen_kubeconfig(
154-
ca_data,
155-
server,
156-
cert,
157-
cert_bundle.serialize_private_key_pem(),
158-
)?;
159-
got_cert = true;
160-
break;
147+
if let Some(v) = status.conditions {
148+
if v.into_iter().any(|c| c.type_.as_str() == APPROVED_TYPE) {
149+
debug!("Certificate has been approved, generating kubeconfig");
150+
generated_kubeconfig = gen_kubeconfig(
151+
ca_data,
152+
server,
153+
cert,
154+
cert_bundle.serialize_private_key_pem(),
155+
)?;
156+
got_cert = true;
157+
break;
158+
}
161159
}
162160
}
163161

@@ -261,15 +259,13 @@ async fn bootstrap_tls(
261259
};
262260

263261
if let Some(cert) = status.certificate {
264-
if status
265-
.conditions
266-
.into_iter()
267-
.any(|c| c.type_.as_str() == APPROVED_TYPE)
268-
{
269-
debug!("Certificate has been approved, extracting cert from response");
270-
certificate = std::str::from_utf8(&cert.0)?.to_owned();
271-
got_cert = true;
272-
break;
262+
if let Some(v) = status.conditions {
263+
if v.into_iter().any(|c| c.type_.as_str() == APPROVED_TYPE) {
264+
debug!("Certificate has been approved, extracting cert from response");
265+
certificate = std::str::from_utf8(&cert.0)?.to_owned();
266+
got_cert = true;
267+
break;
268+
}
273269
}
274270
}
275271
info!(remaining = ?start.elapsed(), "Got modified event, but CSR for serving certs is not currently approved");

crates/kubelet/src/container/mod.rs

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

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

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

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

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

160160
/// Get image of container as `oci_distribution::Reference`.
@@ -186,8 +186,8 @@ impl Container {
186186
}
187187

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

193193
/// Get readiness probe of container.
@@ -236,13 +236,13 @@ impl Container {
236236
}
237237

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

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

248248
/// Get working directory of container.

crates/kubelet/src/kubelet.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ mod test {
325325
#[tokio::test]
326326
async fn test_env_vars() {
327327
let container = Container::new(&KubeContainer {
328-
env: vec![
328+
env: Some(vec![
329329
EnvVar {
330330
name: "first".into(),
331331
value: Some("value".into()),
@@ -397,7 +397,7 @@ mod test {
397397
}),
398398
..Default::default()
399399
},
400-
],
400+
]),
401401
..Default::default()
402402
});
403403
let name = "my-name".to_string();
@@ -408,8 +408,8 @@ mod test {
408408
annotations.insert("annotation".to_string(), "value".to_string());
409409
let pod = Pod::from(KubePod {
410410
metadata: ObjectMeta {
411-
labels,
412-
annotations,
411+
labels: Some(labels),
412+
annotations: Some(annotations),
413413
name: Some(name),
414414
namespace,
415415
..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: self.annotations,
659-
labels: self.labels,
658+
annotations: Some(self.annotations),
659+
labels: Some(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: self.taints,
665+
taints: Some(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: self.capacity,
681-
allocatable: self.allocatable,
680+
capacity: Some(self.capacity),
681+
allocatable: Some(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: self.conditions,
688-
addresses: self.addresses,
687+
conditions: Some(self.conditions),
688+
addresses: Some(self.addresses),
689689
..Default::default()
690690
};
691691

0 commit comments

Comments
 (0)