mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-05 23:47:50 +00:00
Add custom pod conversion functions from pre-v1.1 mirror pods
The functions would default values added after v1.0, so that kubelet wouldn't fail at comparing the mirror pods against their associated static pods. This code would need to be maintained if we ever change the default value in Pod until we drop support for v1.0 nodes.
This commit is contained in:
@@ -153,6 +153,68 @@ func TestCompatibility_v1_PodSecurityContext(t *testing.T) {
|
||||
"spec.hostPID",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "reseting defaults for pre-v1.1 mirror pods",
|
||||
input: `
|
||||
{
|
||||
"kind":"Pod",
|
||||
"apiVersion":"v1",
|
||||
"metadata":{
|
||||
"name":"my-pod-name",
|
||||
"namespace":"my-pod-namespace",
|
||||
"annotations": {
|
||||
"kubernetes.io/config.mirror": "mirror"
|
||||
}
|
||||
},
|
||||
"spec": {
|
||||
"containers":[{
|
||||
"name":"a",
|
||||
"image":"my-container-image",
|
||||
"resources": {
|
||||
"limits": {
|
||||
"cpu": "100m"
|
||||
}
|
||||
}
|
||||
}]
|
||||
}
|
||||
}
|
||||
`,
|
||||
absentKeys: []string{
|
||||
"spec.terminationGracePeriodSeconds",
|
||||
"spec.containers[0].resources.requests",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "preserving defaults for v1.1+ mirror pods",
|
||||
input: `
|
||||
{
|
||||
"kind":"Pod",
|
||||
"apiVersion":"v1",
|
||||
"metadata":{
|
||||
"name":"my-pod-name",
|
||||
"namespace":"my-pod-namespace",
|
||||
"annotations": {
|
||||
"kubernetes.io/config.mirror": "cbe924f710c7e26f7693d6a341bcfad0"
|
||||
}
|
||||
},
|
||||
"spec": {
|
||||
"containers":[{
|
||||
"name":"a",
|
||||
"image":"my-container-image",
|
||||
"resources": {
|
||||
"limits": {
|
||||
"cpu": "100m"
|
||||
}
|
||||
}
|
||||
}]
|
||||
}
|
||||
}
|
||||
`,
|
||||
expectedKeys: map[string]string{
|
||||
"spec.terminationGracePeriodSeconds": "30",
|
||||
"spec.containers[0].resources.requests": "map[cpu:100m]",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
validator := func(obj runtime.Object) fielderrors.ValidationErrorList {
|
||||
|
||||
Reference in New Issue
Block a user