mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-12-03 14:53:52 +00:00
Merge pull request #42310 from liggitt/init-container-default
Automatic merge from submit-queue (batch tested with PRs 42443, 38924, 42367, 42391, 42310) Apply custom defaults to init containers Adds overridden defaults to init containers. They were not being defaulted the same way normal containers were.
This commit is contained in:
@@ -160,6 +160,18 @@ func SetDefaults_Pod(obj *Pod) {
|
||||
}
|
||||
}
|
||||
}
|
||||
for i := range obj.Spec.InitContainers {
|
||||
if obj.Spec.InitContainers[i].Resources.Limits != nil {
|
||||
if obj.Spec.InitContainers[i].Resources.Requests == nil {
|
||||
obj.Spec.InitContainers[i].Resources.Requests = make(ResourceList)
|
||||
}
|
||||
for key, value := range obj.Spec.InitContainers[i].Resources.Limits {
|
||||
if _, exists := obj.Spec.InitContainers[i].Resources.Requests[key]; !exists {
|
||||
obj.Spec.InitContainers[i].Resources.Requests[key] = *(value.Copy())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
func SetDefaults_PodSpec(obj *PodSpec) {
|
||||
if obj.DNSPolicy == "" {
|
||||
@@ -170,6 +182,7 @@ func SetDefaults_PodSpec(obj *PodSpec) {
|
||||
}
|
||||
if obj.HostNetwork {
|
||||
defaultHostNetworkPorts(&obj.Containers)
|
||||
defaultHostNetworkPorts(&obj.InitContainers)
|
||||
}
|
||||
if obj.SecurityContext == nil {
|
||||
obj.SecurityContext = &PodSecurityContext{}
|
||||
|
||||
Reference in New Issue
Block a user