Skip to content

Commit 9f319c3

Browse files
authored
Merge pull request kubernetes#113374 from ahmedtd/kep-3257-projected-types
Implement ClusterTrustBundlePEM projected volume
2 parents 953afbb + bd64313 commit 9f319c3

File tree

101 files changed

+4962
-1487
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+4962
-1487
lines changed

api/openapi-spec/swagger.json

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

api/openapi-spec/v3/api__v1_openapi.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,40 @@
715715
},
716716
"type": "object"
717717
},
718+
"io.k8s.api.core.v1.ClusterTrustBundleProjection": {
719+
"description": "ClusterTrustBundleProjection describes how to select a set of ClusterTrustBundle objects and project their contents into the pod filesystem.",
720+
"properties": {
721+
"labelSelector": {
722+
"allOf": [
723+
{
724+
"$ref": "#/components/schemas/io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelector"
725+
}
726+
],
727+
"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\"."
728+
},
729+
"name": {
730+
"description": "Select a single ClusterTrustBundle by object name. Mutually-exclusive with signerName and labelSelector.",
731+
"type": "string"
732+
},
733+
"optional": {
734+
"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.",
735+
"type": "boolean"
736+
},
737+
"path": {
738+
"default": "",
739+
"description": "Relative path from the volume root to write the bundle.",
740+
"type": "string"
741+
},
742+
"signerName": {
743+
"description": "Select all ClusterTrustBundles that match this signer name. Mutually-exclusive with name. The contents of all selected ClusterTrustBundles will be unified and deduplicated.",
744+
"type": "string"
745+
}
746+
},
747+
"required": [
748+
"path"
749+
],
750+
"type": "object"
751+
},
718752
"io.k8s.api.core.v1.ComponentCondition": {
719753
"description": "Information about the condition of a component.",
720754
"properties": {
@@ -7916,6 +7950,14 @@
79167950
"io.k8s.api.core.v1.VolumeProjection": {
79177951
"description": "Projection that may be projected along with other supported volume types",
79187952
"properties": {
7953+
"clusterTrustBundle": {
7954+
"allOf": [
7955+
{
7956+
"$ref": "#/components/schemas/io.k8s.api.core.v1.ClusterTrustBundleProjection"
7957+
}
7958+
],
7959+
"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."
7960+
},
79197961
"configMap": {
79207962
"allOf": [
79217963
{

api/openapi-spec/v3/apis__apps__v1_openapi.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,6 +1579,40 @@
15791579
},
15801580
"type": "object"
15811581
},
1582+
"io.k8s.api.core.v1.ClusterTrustBundleProjection": {
1583+
"description": "ClusterTrustBundleProjection describes how to select a set of ClusterTrustBundle objects and project their contents into the pod filesystem.",
1584+
"properties": {
1585+
"labelSelector": {
1586+
"allOf": [
1587+
{
1588+
"$ref": "#/components/schemas/io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelector"
1589+
}
1590+
],
1591+
"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\"."
1592+
},
1593+
"name": {
1594+
"description": "Select a single ClusterTrustBundle by object name. Mutually-exclusive with signerName and labelSelector.",
1595+
"type": "string"
1596+
},
1597+
"optional": {
1598+
"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.",
1599+
"type": "boolean"
1600+
},
1601+
"path": {
1602+
"default": "",
1603+
"description": "Relative path from the volume root to write the bundle.",
1604+
"type": "string"
1605+
},
1606+
"signerName": {
1607+
"description": "Select all ClusterTrustBundles that match this signer name. Mutually-exclusive with name. The contents of all selected ClusterTrustBundles will be unified and deduplicated.",
1608+
"type": "string"
1609+
}
1610+
},
1611+
"required": [
1612+
"path"
1613+
],
1614+
"type": "object"
1615+
},
15821616
"io.k8s.api.core.v1.ConfigMapEnvSource": {
15831617
"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.",
15841618
"properties": {
@@ -4990,6 +5024,14 @@
49905024
"io.k8s.api.core.v1.VolumeProjection": {
49915025
"description": "Projection that may be projected along with other supported volume types",
49925026
"properties": {
5027+
"clusterTrustBundle": {
5028+
"allOf": [
5029+
{
5030+
"$ref": "#/components/schemas/io.k8s.api.core.v1.ClusterTrustBundleProjection"
5031+
}
5032+
],
5033+
"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."
5034+
},
49935035
"configMap": {
49945036
"allOf": [
49955037
{

api/openapi-spec/v3/apis__batch__v1_openapi.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -896,6 +896,40 @@
896896
},
897897
"type": "object"
898898
},
899+
"io.k8s.api.core.v1.ClusterTrustBundleProjection": {
900+
"description": "ClusterTrustBundleProjection describes how to select a set of ClusterTrustBundle objects and project their contents into the pod filesystem.",
901+
"properties": {
902+
"labelSelector": {
903+
"allOf": [
904+
{
905+
"$ref": "#/components/schemas/io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelector"
906+
}
907+
],
908+
"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\"."
909+
},
910+
"name": {
911+
"description": "Select a single ClusterTrustBundle by object name. Mutually-exclusive with signerName and labelSelector.",
912+
"type": "string"
913+
},
914+
"optional": {
915+
"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.",
916+
"type": "boolean"
917+
},
918+
"path": {
919+
"default": "",
920+
"description": "Relative path from the volume root to write the bundle.",
921+
"type": "string"
922+
},
923+
"signerName": {
924+
"description": "Select all ClusterTrustBundles that match this signer name. Mutually-exclusive with name. The contents of all selected ClusterTrustBundles will be unified and deduplicated.",
925+
"type": "string"
926+
}
927+
},
928+
"required": [
929+
"path"
930+
],
931+
"type": "object"
932+
},
899933
"io.k8s.api.core.v1.ConfigMapEnvSource": {
900934
"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.",
901935
"properties": {
@@ -4167,6 +4201,14 @@
41674201
"io.k8s.api.core.v1.VolumeProjection": {
41684202
"description": "Projection that may be projected along with other supported volume types",
41694203
"properties": {
4204+
"clusterTrustBundle": {
4205+
"allOf": [
4206+
{
4207+
"$ref": "#/components/schemas/io.k8s.api.core.v1.ClusterTrustBundleProjection"
4208+
}
4209+
],
4210+
"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."
4211+
},
41704212
"configMap": {
41714213
"allOf": [
41724214
{

pkg/api/pod/util.go

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,7 @@ func dropDisabledFields(
549549
dropDisabledMatchLabelKeysFieldInTopologySpread(podSpec, oldPodSpec)
550550
dropDisabledMatchLabelKeysFieldInPodAffinity(podSpec, oldPodSpec)
551551
dropDisabledDynamicResourceAllocationFields(podSpec, oldPodSpec)
552+
dropDisabledClusterTrustBundleProjection(podSpec, oldPodSpec)
552553

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

973+
func clusterTrustBundleProjectionInUse(podSpec *api.PodSpec) bool {
974+
if podSpec == nil {
975+
return false
976+
}
977+
for _, v := range podSpec.Volumes {
978+
if v.Projected == nil {
979+
continue
980+
}
981+
982+
for _, s := range v.Projected.Sources {
983+
if s.ClusterTrustBundle != nil {
984+
return true
985+
}
986+
}
987+
}
988+
989+
return false
990+
}
991+
992+
func dropDisabledClusterTrustBundleProjection(podSpec, oldPodSpec *api.PodSpec) {
993+
if utilfeature.DefaultFeatureGate.Enabled(features.ClusterTrustBundleProjection) {
994+
return
995+
}
996+
if podSpec == nil {
997+
return
998+
}
999+
1000+
// If the pod was already using it, it can keep using it.
1001+
if clusterTrustBundleProjectionInUse(oldPodSpec) {
1002+
return
1003+
}
1004+
1005+
for i := range podSpec.Volumes {
1006+
if podSpec.Volumes[i].Projected == nil {
1007+
continue
1008+
}
1009+
1010+
for j := range podSpec.Volumes[i].Projected.Sources {
1011+
podSpec.Volumes[i].Projected.Sources[j].ClusterTrustBundle = nil
1012+
}
1013+
}
1014+
}
1015+
9721016
func hasInvalidLabelValueInAffinitySelector(spec *api.PodSpec) bool {
9731017
if spec.Affinity != nil {
9741018
if spec.Affinity.PodAffinity != nil {

0 commit comments

Comments
 (0)