Skip to content

Commit

Permalink
Merge pull request kubernetes#113374 from ahmedtd/kep-3257-projected-…
Browse files Browse the repository at this point in the history
…types

Implement ClusterTrustBundlePEM projected volume
  • Loading branch information
k8s-ci-robot committed Nov 4, 2023
2 parents 953afbb + bd64313 commit 9f319c3
Show file tree
Hide file tree
Showing 101 changed files with 4,962 additions and 1,487 deletions.
33 changes: 33 additions & 0 deletions api/openapi-spec/swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 42 additions & 0 deletions api/openapi-spec/v3/api__v1_openapi.json
Expand Up @@ -715,6 +715,40 @@
},
"type": "object"
},
"io.k8s.api.core.v1.ClusterTrustBundleProjection": {
"description": "ClusterTrustBundleProjection describes how to select a set of ClusterTrustBundle objects and project their contents into the pod filesystem.",
"properties": {
"labelSelector": {
"allOf": [
{
"$ref": "#/components/schemas/io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelector"
}
],
"description": "Select all ClusterTrustBundles that match this label selector. Only has effect if signerName is set. Mutually-exclusive with name. If unset, interpreted as \"match nothing\". If set but empty, interpreted as \"match everything\"."
},
"name": {
"description": "Select a single ClusterTrustBundle by object name. Mutually-exclusive with signerName and labelSelector.",
"type": "string"
},
"optional": {
"description": "If true, don't block pod startup if the referenced ClusterTrustBundle(s) aren't available. If using name, then the named ClusterTrustBundle is allowed not to exist. If using signerName, then the combination of signerName and labelSelector is allowed to match zero ClusterTrustBundles.",
"type": "boolean"
},
"path": {
"default": "",
"description": "Relative path from the volume root to write the bundle.",
"type": "string"
},
"signerName": {
"description": "Select all ClusterTrustBundles that match this signer name. Mutually-exclusive with name. The contents of all selected ClusterTrustBundles will be unified and deduplicated.",
"type": "string"
}
},
"required": [
"path"
],
"type": "object"
},
"io.k8s.api.core.v1.ComponentCondition": {
"description": "Information about the condition of a component.",
"properties": {
Expand Down Expand Up @@ -7916,6 +7950,14 @@
"io.k8s.api.core.v1.VolumeProjection": {
"description": "Projection that may be projected along with other supported volume types",
"properties": {
"clusterTrustBundle": {
"allOf": [
{
"$ref": "#/components/schemas/io.k8s.api.core.v1.ClusterTrustBundleProjection"
}
],
"description": "ClusterTrustBundle allows a pod to access the `.spec.trustBundle` field of ClusterTrustBundle objects in an auto-updating file.\n\nAlpha, gated by the ClusterTrustBundleProjection feature gate.\n\nClusterTrustBundle objects can either be selected by name, or by the combination of signer name and a label selector.\n\nKubelet performs aggressive normalization of the PEM contents written into the pod filesystem. Esoteric PEM features such as inter-block comments and block headers are stripped. Certificates are deduplicated. The ordering of certificates within the file is arbitrary, and Kubelet may change the order over time."
},
"configMap": {
"allOf": [
{
Expand Down
42 changes: 42 additions & 0 deletions api/openapi-spec/v3/apis__apps__v1_openapi.json
Expand Up @@ -1579,6 +1579,40 @@
},
"type": "object"
},
"io.k8s.api.core.v1.ClusterTrustBundleProjection": {
"description": "ClusterTrustBundleProjection describes how to select a set of ClusterTrustBundle objects and project their contents into the pod filesystem.",
"properties": {
"labelSelector": {
"allOf": [
{
"$ref": "#/components/schemas/io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelector"
}
],
"description": "Select all ClusterTrustBundles that match this label selector. Only has effect if signerName is set. Mutually-exclusive with name. If unset, interpreted as \"match nothing\". If set but empty, interpreted as \"match everything\"."
},
"name": {
"description": "Select a single ClusterTrustBundle by object name. Mutually-exclusive with signerName and labelSelector.",
"type": "string"
},
"optional": {
"description": "If true, don't block pod startup if the referenced ClusterTrustBundle(s) aren't available. If using name, then the named ClusterTrustBundle is allowed not to exist. If using signerName, then the combination of signerName and labelSelector is allowed to match zero ClusterTrustBundles.",
"type": "boolean"
},
"path": {
"default": "",
"description": "Relative path from the volume root to write the bundle.",
"type": "string"
},
"signerName": {
"description": "Select all ClusterTrustBundles that match this signer name. Mutually-exclusive with name. The contents of all selected ClusterTrustBundles will be unified and deduplicated.",
"type": "string"
}
},
"required": [
"path"
],
"type": "object"
},
"io.k8s.api.core.v1.ConfigMapEnvSource": {
"description": "ConfigMapEnvSource selects a ConfigMap to populate the environment variables with.\n\nThe contents of the target ConfigMap's Data field will represent the key-value pairs as environment variables.",
"properties": {
Expand Down Expand Up @@ -4990,6 +5024,14 @@
"io.k8s.api.core.v1.VolumeProjection": {
"description": "Projection that may be projected along with other supported volume types",
"properties": {
"clusterTrustBundle": {
"allOf": [
{
"$ref": "#/components/schemas/io.k8s.api.core.v1.ClusterTrustBundleProjection"
}
],
"description": "ClusterTrustBundle allows a pod to access the `.spec.trustBundle` field of ClusterTrustBundle objects in an auto-updating file.\n\nAlpha, gated by the ClusterTrustBundleProjection feature gate.\n\nClusterTrustBundle objects can either be selected by name, or by the combination of signer name and a label selector.\n\nKubelet performs aggressive normalization of the PEM contents written into the pod filesystem. Esoteric PEM features such as inter-block comments and block headers are stripped. Certificates are deduplicated. The ordering of certificates within the file is arbitrary, and Kubelet may change the order over time."
},
"configMap": {
"allOf": [
{
Expand Down
42 changes: 42 additions & 0 deletions api/openapi-spec/v3/apis__batch__v1_openapi.json
Expand Up @@ -896,6 +896,40 @@
},
"type": "object"
},
"io.k8s.api.core.v1.ClusterTrustBundleProjection": {
"description": "ClusterTrustBundleProjection describes how to select a set of ClusterTrustBundle objects and project their contents into the pod filesystem.",
"properties": {
"labelSelector": {
"allOf": [
{
"$ref": "#/components/schemas/io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelector"
}
],
"description": "Select all ClusterTrustBundles that match this label selector. Only has effect if signerName is set. Mutually-exclusive with name. If unset, interpreted as \"match nothing\". If set but empty, interpreted as \"match everything\"."
},
"name": {
"description": "Select a single ClusterTrustBundle by object name. Mutually-exclusive with signerName and labelSelector.",
"type": "string"
},
"optional": {
"description": "If true, don't block pod startup if the referenced ClusterTrustBundle(s) aren't available. If using name, then the named ClusterTrustBundle is allowed not to exist. If using signerName, then the combination of signerName and labelSelector is allowed to match zero ClusterTrustBundles.",
"type": "boolean"
},
"path": {
"default": "",
"description": "Relative path from the volume root to write the bundle.",
"type": "string"
},
"signerName": {
"description": "Select all ClusterTrustBundles that match this signer name. Mutually-exclusive with name. The contents of all selected ClusterTrustBundles will be unified and deduplicated.",
"type": "string"
}
},
"required": [
"path"
],
"type": "object"
},
"io.k8s.api.core.v1.ConfigMapEnvSource": {
"description": "ConfigMapEnvSource selects a ConfigMap to populate the environment variables with.\n\nThe contents of the target ConfigMap's Data field will represent the key-value pairs as environment variables.",
"properties": {
Expand Down Expand Up @@ -4167,6 +4201,14 @@
"io.k8s.api.core.v1.VolumeProjection": {
"description": "Projection that may be projected along with other supported volume types",
"properties": {
"clusterTrustBundle": {
"allOf": [
{
"$ref": "#/components/schemas/io.k8s.api.core.v1.ClusterTrustBundleProjection"
}
],
"description": "ClusterTrustBundle allows a pod to access the `.spec.trustBundle` field of ClusterTrustBundle objects in an auto-updating file.\n\nAlpha, gated by the ClusterTrustBundleProjection feature gate.\n\nClusterTrustBundle objects can either be selected by name, or by the combination of signer name and a label selector.\n\nKubelet performs aggressive normalization of the PEM contents written into the pod filesystem. Esoteric PEM features such as inter-block comments and block headers are stripped. Certificates are deduplicated. The ordering of certificates within the file is arbitrary, and Kubelet may change the order over time."
},
"configMap": {
"allOf": [
{
Expand Down
44 changes: 44 additions & 0 deletions pkg/api/pod/util.go
Expand Up @@ -549,6 +549,7 @@ func dropDisabledFields(
dropDisabledMatchLabelKeysFieldInTopologySpread(podSpec, oldPodSpec)
dropDisabledMatchLabelKeysFieldInPodAffinity(podSpec, oldPodSpec)
dropDisabledDynamicResourceAllocationFields(podSpec, oldPodSpec)
dropDisabledClusterTrustBundleProjection(podSpec, oldPodSpec)

if !utilfeature.DefaultFeatureGate.Enabled(features.InPlacePodVerticalScaling) && !inPlacePodVerticalScalingInUse(oldPodSpec) {
// Drop ResizePolicy fields. Don't drop updates to Resources field as template.spec.resources
Expand Down Expand Up @@ -969,6 +970,49 @@ func restartableInitContainersInUse(podSpec *api.PodSpec) bool {
return inUse
}

func clusterTrustBundleProjectionInUse(podSpec *api.PodSpec) bool {
if podSpec == nil {
return false
}
for _, v := range podSpec.Volumes {
if v.Projected == nil {
continue
}

for _, s := range v.Projected.Sources {
if s.ClusterTrustBundle != nil {
return true
}
}
}

return false
}

func dropDisabledClusterTrustBundleProjection(podSpec, oldPodSpec *api.PodSpec) {
if utilfeature.DefaultFeatureGate.Enabled(features.ClusterTrustBundleProjection) {
return
}
if podSpec == nil {
return
}

// If the pod was already using it, it can keep using it.
if clusterTrustBundleProjectionInUse(oldPodSpec) {
return
}

for i := range podSpec.Volumes {
if podSpec.Volumes[i].Projected == nil {
continue
}

for j := range podSpec.Volumes[i].Projected.Sources {
podSpec.Volumes[i].Projected.Sources[j].ClusterTrustBundle = nil
}
}
}

func hasInvalidLabelValueInAffinitySelector(spec *api.PodSpec) bool {
if spec.Affinity != nil {
if spec.Affinity.PodAffinity != nil {
Expand Down

0 comments on commit 9f319c3

Please sign in to comment.