You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Correct generate kube on containers userns annotation
The `podman generate kube` command on containers follows a
different codepath from pods. Pods store a lot of pod-level
configuration - including user namespace information - in
annotations, so it can be restored by `play kube`. Generating for
a container does not do the same thing, because we don't have a
pod.
However, per-container generation was still generating a nearly
identical user namespace annotation to a pod. Example:
In Pod:
io.podman.annotations.userns: auto:size=40
Not in Pod:
io.podman.annotations.userns/awesomegreider: auto:size=2048
The second annotation seems like it should apply a user namespace
config to the generated Kubernetes pod. Instead, it's just adding
an annotation to the awesomegreider container, that says said
container has a user namespace, when it does not in fact have a
user namespace configured because it is now in a pod.
After this PR, both containers in and out of pods generate
identical annotations (the In Pod version, missing container
name) and as such should generate pods with appropriately
configured user namespaces. I also added some conflict detection
to refuse to generate if you try to generate YAML containing two
containers with conflicting user namespace configuration.
Fixes#25896
Signed-off-by: Matt Heon <[email protected]>
// Certain annotations should be applied to the whole pod.
769
+
// For others, add container name as a suffix.
770
+
// For annotations such as this, error if already set.
771
+
ifk==define.UserNsAnnotation {
772
+
ifoldV, ok:=kubeAnnotations[k]; ok&&oldV!=v {
773
+
returnnil, fmt.Errorf("two or more containers have differing user namespace configuration, cannot place in same Kubernetes pod: %w", define.ErrInvalidArg)
Expect(gen).Should(ExitWithError(125, "two or more containers have differing user namespace configuration, cannot place in same Kubernetes pod: invalid argument"))
1047
+
})
1048
+
1028
1049
It("with containers in pods should fail", func() {
0 commit comments