k8s_openapi/v1_34/api/certificates/v1alpha1/
pod_certificate_request_spec.rs

1// Generated from definition io.k8s.api.certificates.v1alpha1.PodCertificateRequestSpec
2
3/// PodCertificateRequestSpec describes the certificate request.  All fields are immutable after creation.
4#[derive(Clone, Debug, Default, PartialEq)]
5pub struct PodCertificateRequestSpec {
6    /// maxExpirationSeconds is the maximum lifetime permitted for the certificate.
7    ///
8    /// If omitted, kube-apiserver will set it to 86400(24 hours). kube-apiserver will reject values shorter than 3600 (1 hour).  The maximum allowable value is 7862400 (91 days).
9    ///
10    /// The signer implementation is then free to issue a certificate with any lifetime *shorter* than MaxExpirationSeconds, but no shorter than 3600 seconds (1 hour).  This constraint is enforced by kube-apiserver. `kubernetes.io` signers will never issue certificates with a lifetime longer than 24 hours.
11    pub max_expiration_seconds: Option<i32>,
12
13    /// nodeName is the name of the node the pod is assigned to.
14    pub node_name: std::string::String,
15
16    /// nodeUID is the UID of the node the pod is assigned to.
17    pub node_uid: std::string::String,
18
19    /// pkixPublicKey is the PKIX-serialized public key the signer will issue the certificate to.
20    ///
21    /// The key must be one of RSA3072, RSA4096, ECDSAP256, ECDSAP384, ECDSAP521, or ED25519. Note that this list may be expanded in the future.
22    ///
23    /// Signer implementations do not need to support all key types supported by kube-apiserver and kubelet.  If a signer does not support the key type used for a given PodCertificateRequest, it must deny the request by setting a status.conditions entry with a type of "Denied" and a reason of "UnsupportedKeyType". It may also suggest a key type that it does support in the message field.
24    pub pkix_public_key: crate::ByteString,
25
26    /// podName is the name of the pod into which the certificate will be mounted.
27    pub pod_name: std::string::String,
28
29    /// podUID is the UID of the pod into which the certificate will be mounted.
30    pub pod_uid: std::string::String,
31
32    /// proofOfPossession proves that the requesting kubelet holds the private key corresponding to pkixPublicKey.
33    ///
34    /// It is contructed by signing the ASCII bytes of the pod's UID using `pkixPublicKey`.
35    ///
36    /// kube-apiserver validates the proof of possession during creation of the PodCertificateRequest.
37    ///
38    /// If the key is an RSA key, then the signature is over the ASCII bytes of the pod UID, using RSASSA-PSS from RFC 8017 (as implemented by the golang function crypto/rsa.SignPSS with nil options).
39    ///
40    /// If the key is an ECDSA key, then the signature is as described by \[SEC 1, Version 2.0\](https://www.secg.org/sec1-v2.pdf) (as implemented by the golang library function crypto/ecdsa.SignASN1)
41    ///
42    /// If the key is an ED25519 key, the the signature is as described by the \[ED25519 Specification\](https://ed25519.cr.yp.to/) (as implemented by the golang library crypto/ed25519.Sign).
43    pub proof_of_possession: crate::ByteString,
44
45    /// serviceAccountName is the name of the service account the pod is running as.
46    pub service_account_name: std::string::String,
47
48    /// serviceAccountUID is the UID of the service account the pod is running as.
49    pub service_account_uid: std::string::String,
50
51    /// signerName indicates the requested signer.
52    ///
53    /// All signer names beginning with `kubernetes.io` are reserved for use by the Kubernetes project.  There is currently one well-known signer documented by the Kubernetes project, `kubernetes.io/kube-apiserver-client-pod`, which will issue client certificates understood by kube-apiserver.  It is currently unimplemented.
54    pub signer_name: std::string::String,
55}
56
57impl crate::DeepMerge for PodCertificateRequestSpec {
58    fn merge_from(&mut self, other: Self) {
59        crate::DeepMerge::merge_from(&mut self.max_expiration_seconds, other.max_expiration_seconds);
60        crate::DeepMerge::merge_from(&mut self.node_name, other.node_name);
61        crate::DeepMerge::merge_from(&mut self.node_uid, other.node_uid);
62        crate::DeepMerge::merge_from(&mut self.pkix_public_key, other.pkix_public_key);
63        crate::DeepMerge::merge_from(&mut self.pod_name, other.pod_name);
64        crate::DeepMerge::merge_from(&mut self.pod_uid, other.pod_uid);
65        crate::DeepMerge::merge_from(&mut self.proof_of_possession, other.proof_of_possession);
66        crate::DeepMerge::merge_from(&mut self.service_account_name, other.service_account_name);
67        crate::DeepMerge::merge_from(&mut self.service_account_uid, other.service_account_uid);
68        crate::DeepMerge::merge_from(&mut self.signer_name, other.signer_name);
69    }
70}
71
72impl<'de> crate::serde::Deserialize<'de> for PodCertificateRequestSpec {
73    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
74        #[allow(non_camel_case_types)]
75        enum Field {
76            Key_max_expiration_seconds,
77            Key_node_name,
78            Key_node_uid,
79            Key_pkix_public_key,
80            Key_pod_name,
81            Key_pod_uid,
82            Key_proof_of_possession,
83            Key_service_account_name,
84            Key_service_account_uid,
85            Key_signer_name,
86            Other,
87        }
88
89        impl<'de> crate::serde::Deserialize<'de> for Field {
90            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: crate::serde::Deserializer<'de> {
91                struct Visitor;
92
93                impl crate::serde::de::Visitor<'_> for Visitor {
94                    type Value = Field;
95
96                    fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
97                        f.write_str("field identifier")
98                    }
99
100                    fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> where E: crate::serde::de::Error {
101                        Ok(match v {
102                            "maxExpirationSeconds" => Field::Key_max_expiration_seconds,
103                            "nodeName" => Field::Key_node_name,
104                            "nodeUID" => Field::Key_node_uid,
105                            "pkixPublicKey" => Field::Key_pkix_public_key,
106                            "podName" => Field::Key_pod_name,
107                            "podUID" => Field::Key_pod_uid,
108                            "proofOfPossession" => Field::Key_proof_of_possession,
109                            "serviceAccountName" => Field::Key_service_account_name,
110                            "serviceAccountUID" => Field::Key_service_account_uid,
111                            "signerName" => Field::Key_signer_name,
112                            _ => Field::Other,
113                        })
114                    }
115                }
116
117                deserializer.deserialize_identifier(Visitor)
118            }
119        }
120
121        struct Visitor;
122
123        impl<'de> crate::serde::de::Visitor<'de> for Visitor {
124            type Value = PodCertificateRequestSpec;
125
126            fn expecting(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
127                f.write_str("PodCertificateRequestSpec")
128            }
129
130            fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error> where A: crate::serde::de::MapAccess<'de> {
131                let mut value_max_expiration_seconds: Option<i32> = None;
132                let mut value_node_name: Option<std::string::String> = None;
133                let mut value_node_uid: Option<std::string::String> = None;
134                let mut value_pkix_public_key: Option<crate::ByteString> = None;
135                let mut value_pod_name: Option<std::string::String> = None;
136                let mut value_pod_uid: Option<std::string::String> = None;
137                let mut value_proof_of_possession: Option<crate::ByteString> = None;
138                let mut value_service_account_name: Option<std::string::String> = None;
139                let mut value_service_account_uid: Option<std::string::String> = None;
140                let mut value_signer_name: Option<std::string::String> = None;
141
142                while let Some(key) = crate::serde::de::MapAccess::next_key::<Field>(&mut map)? {
143                    match key {
144                        Field::Key_max_expiration_seconds => value_max_expiration_seconds = crate::serde::de::MapAccess::next_value(&mut map)?,
145                        Field::Key_node_name => value_node_name = crate::serde::de::MapAccess::next_value(&mut map)?,
146                        Field::Key_node_uid => value_node_uid = crate::serde::de::MapAccess::next_value(&mut map)?,
147                        Field::Key_pkix_public_key => value_pkix_public_key = crate::serde::de::MapAccess::next_value(&mut map)?,
148                        Field::Key_pod_name => value_pod_name = crate::serde::de::MapAccess::next_value(&mut map)?,
149                        Field::Key_pod_uid => value_pod_uid = crate::serde::de::MapAccess::next_value(&mut map)?,
150                        Field::Key_proof_of_possession => value_proof_of_possession = crate::serde::de::MapAccess::next_value(&mut map)?,
151                        Field::Key_service_account_name => value_service_account_name = crate::serde::de::MapAccess::next_value(&mut map)?,
152                        Field::Key_service_account_uid => value_service_account_uid = crate::serde::de::MapAccess::next_value(&mut map)?,
153                        Field::Key_signer_name => value_signer_name = crate::serde::de::MapAccess::next_value(&mut map)?,
154                        Field::Other => { let _: crate::serde::de::IgnoredAny = crate::serde::de::MapAccess::next_value(&mut map)?; },
155                    }
156                }
157
158                Ok(PodCertificateRequestSpec {
159                    max_expiration_seconds: value_max_expiration_seconds,
160                    node_name: value_node_name.unwrap_or_default(),
161                    node_uid: value_node_uid.unwrap_or_default(),
162                    pkix_public_key: value_pkix_public_key.unwrap_or_default(),
163                    pod_name: value_pod_name.unwrap_or_default(),
164                    pod_uid: value_pod_uid.unwrap_or_default(),
165                    proof_of_possession: value_proof_of_possession.unwrap_or_default(),
166                    service_account_name: value_service_account_name.unwrap_or_default(),
167                    service_account_uid: value_service_account_uid.unwrap_or_default(),
168                    signer_name: value_signer_name.unwrap_or_default(),
169                })
170            }
171        }
172
173        deserializer.deserialize_struct(
174            "PodCertificateRequestSpec",
175            &[
176                "maxExpirationSeconds",
177                "nodeName",
178                "nodeUID",
179                "pkixPublicKey",
180                "podName",
181                "podUID",
182                "proofOfPossession",
183                "serviceAccountName",
184                "serviceAccountUID",
185                "signerName",
186            ],
187            Visitor,
188        )
189    }
190}
191
192impl crate::serde::Serialize for PodCertificateRequestSpec {
193    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: crate::serde::Serializer {
194        let mut state = serializer.serialize_struct(
195            "PodCertificateRequestSpec",
196            9 +
197            self.max_expiration_seconds.as_ref().map_or(0, |_| 1),
198        )?;
199        if let Some(value) = &self.max_expiration_seconds {
200            crate::serde::ser::SerializeStruct::serialize_field(&mut state, "maxExpirationSeconds", value)?;
201        }
202        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "nodeName", &self.node_name)?;
203        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "nodeUID", &self.node_uid)?;
204        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "pkixPublicKey", &self.pkix_public_key)?;
205        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "podName", &self.pod_name)?;
206        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "podUID", &self.pod_uid)?;
207        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "proofOfPossession", &self.proof_of_possession)?;
208        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "serviceAccountName", &self.service_account_name)?;
209        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "serviceAccountUID", &self.service_account_uid)?;
210        crate::serde::ser::SerializeStruct::serialize_field(&mut state, "signerName", &self.signer_name)?;
211        crate::serde::ser::SerializeStruct::end(state)
212    }
213}
214
215#[cfg(feature = "schemars")]
216impl crate::schemars::JsonSchema for PodCertificateRequestSpec {
217    fn schema_name() -> std::borrow::Cow<'static, str> {
218        "io.k8s.api.certificates.v1alpha1.PodCertificateRequestSpec".into()
219    }
220
221    fn json_schema(__gen: &mut crate::schemars::SchemaGenerator) -> crate::schemars::Schema {
222        crate::schemars::json_schema!({
223            "description": "PodCertificateRequestSpec describes the certificate request.  All fields are immutable after creation.",
224            "type": "object",
225            "properties": {
226                "maxExpirationSeconds": {
227                    "description": "maxExpirationSeconds is the maximum lifetime permitted for the certificate.\n\nIf omitted, kube-apiserver will set it to 86400(24 hours). kube-apiserver will reject values shorter than 3600 (1 hour).  The maximum allowable value is 7862400 (91 days).\n\nThe signer implementation is then free to issue a certificate with any lifetime *shorter* than MaxExpirationSeconds, but no shorter than 3600 seconds (1 hour).  This constraint is enforced by kube-apiserver. `kubernetes.io` signers will never issue certificates with a lifetime longer than 24 hours.",
228                    "type": "integer",
229                    "format": "int32",
230                },
231                "nodeName": {
232                    "description": "nodeName is the name of the node the pod is assigned to.",
233                    "type": "string",
234                },
235                "nodeUID": {
236                    "description": "nodeUID is the UID of the node the pod is assigned to.",
237                    "type": "string",
238                },
239                "pkixPublicKey": {
240                    "description": "pkixPublicKey is the PKIX-serialized public key the signer will issue the certificate to.\n\nThe key must be one of RSA3072, RSA4096, ECDSAP256, ECDSAP384, ECDSAP521, or ED25519. Note that this list may be expanded in the future.\n\nSigner implementations do not need to support all key types supported by kube-apiserver and kubelet.  If a signer does not support the key type used for a given PodCertificateRequest, it must deny the request by setting a status.conditions entry with a type of \"Denied\" and a reason of \"UnsupportedKeyType\". It may also suggest a key type that it does support in the message field.",
241                    "type": "string",
242                    "format": "byte",
243                },
244                "podName": {
245                    "description": "podName is the name of the pod into which the certificate will be mounted.",
246                    "type": "string",
247                },
248                "podUID": {
249                    "description": "podUID is the UID of the pod into which the certificate will be mounted.",
250                    "type": "string",
251                },
252                "proofOfPossession": {
253                    "description": "proofOfPossession proves that the requesting kubelet holds the private key corresponding to pkixPublicKey.\n\nIt is contructed by signing the ASCII bytes of the pod's UID using `pkixPublicKey`.\n\nkube-apiserver validates the proof of possession during creation of the PodCertificateRequest.\n\nIf the key is an RSA key, then the signature is over the ASCII bytes of the pod UID, using RSASSA-PSS from RFC 8017 (as implemented by the golang function crypto/rsa.SignPSS with nil options).\n\nIf the key is an ECDSA key, then the signature is as described by [SEC 1, Version 2.0](https://www.secg.org/sec1-v2.pdf) (as implemented by the golang library function crypto/ecdsa.SignASN1)\n\nIf the key is an ED25519 key, the the signature is as described by the [ED25519 Specification](https://ed25519.cr.yp.to/) (as implemented by the golang library crypto/ed25519.Sign).",
254                    "type": "string",
255                    "format": "byte",
256                },
257                "serviceAccountName": {
258                    "description": "serviceAccountName is the name of the service account the pod is running as.",
259                    "type": "string",
260                },
261                "serviceAccountUID": {
262                    "description": "serviceAccountUID is the UID of the service account the pod is running as.",
263                    "type": "string",
264                },
265                "signerName": {
266                    "description": "signerName indicates the requested signer.\n\nAll signer names beginning with `kubernetes.io` are reserved for use by the Kubernetes project.  There is currently one well-known signer documented by the Kubernetes project, `kubernetes.io/kube-apiserver-client-pod`, which will issue client certificates understood by kube-apiserver.  It is currently unimplemented.",
267                    "type": "string",
268                },
269            },
270            "required": [
271                "nodeName",
272                "nodeUID",
273                "pkixPublicKey",
274                "podName",
275                "podUID",
276                "proofOfPossession",
277                "serviceAccountName",
278                "serviceAccountUID",
279                "signerName",
280            ],
281        })
282    }
283}