kubernetes: Kubelet should enforce that static pods do not reference other API objects

What happened:

I put into /etc/kubernetes/manifests/ one defining a static pod with a serviceAccount, because I was wondering if this is supported (the documentation does not say, see https://github.com/kubernetes/website/issues/28611#issuecomment-876537379). The kubelet created the pod but without giving it the relevant mount. The kubelet did not create the corresponding mirror pod.

Here is the manifest I created:

apiVersion: v1
kind: Pod
metadata:
  name: test5
spec:
  containers:
  - name: bb
    image: busybox
    command:
    - sleep
    - "864001"
  serviceAccountName: default

Here are some relevant log entries from the kubelet:

Jul 08 15:55:05 init1 kubelet[4229]: I0708 15:55:05.335792    4229 kubelet.go:1681] "Creating a mirror pod for static pod" pod="default/test5-init1"

Jul 08 15:55:05 init1 kubelet[4229]: E0708 15:55:05.343771    4229 kubelet.go:1683] "Failed creating a mirror pod for" err="pods \"test5-init1\" is forbidden: a mirror pod may not reference service accounts" pod="default/test5-init1"

What you expected to happen:

I expected consistent treatment — real pod and mirror pod both exist or both do not exist.

How to reproduce it (as minimally and precisely as possible):

I think the above is pretty minimal.

Anything else we need to know?:

Environment:

  • Kubernetes version (use kubectl version):
    Client Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.1", GitCommit:"5e58841cce77d4bc13713ad2b91fa0d961e69192", GitTreeState:"clean", BuildDate:"2021-05-12T14:18:45Z", GoVersion:"go1.16.4", Compiler:"gc", Platform:"linux/amd64"}
     Server Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.2", GitCommit:"092fbfbf53427de67cac1e9fa54aaa09a28371d7", GitTreeState:"clean", BuildDate:"2021-06-16T12:53:14Z", GoVersion:"go1.16.5", Compiler:"gc", Platform:"linux/amd64"}
    
  • Cloud provider or hardware configuration: VirtualBox x86_64 VMs with 2 virtual CPUs and 2 GB of memory
  • OS (e.g: cat /etc/os-release): Ubuntu 20.04.1 LTS
  • Kernel (e.g. uname -a): Linux init1 5.4.0-65-generic #73-Ubuntu SMP Mon Jan 18 17:25:17 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
  • Install tools: kubeadm v1.21.2
  • Network plugin and version (if this is a network-related bug):
  • Others:

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 39 (32 by maintainers)

Most upvoted comments

make the tightened validation able to be opted out of with a feature gate marked as deprecated for a release or two

We need a KEP in this case right?

I think this falls into the “bugfix with gate as an escape hatch” category, I don’t think this needs a KEP

/lifecycle frozen /sig storage

Adding SIG storage since volume mounts outside of host path and empty dir do not make sense for static pods.