kubernetes/kubernetes · error

user is not running as root

Error message

user is not running as root

What it means

Returned by IsPrivilegedUserCheck.Check (unix build) when os.Getuid() != 0. kubeadm must run as root on Linux to write /etc/kubernetes, manipulate certs, systemd, and iptables. This is a hard preflight error.

Source

Thrown at cmd/kubeadm/app/preflight/checks_unix.go:30

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package preflight

import (
	"os"

	"k8s.io/kubernetes/cmd/kubeadm/app/util/errors"
)

// Check validates if an user has elevated (root) privileges.
func (ipuc IsPrivilegedUserCheck) Check() (warnings, errorList []error) {
	if os.Getuid() != 0 {
		return nil, []error{errors.New("user is not running as root")}
	}

	return nil, nil
}

View on GitHub (pinned to b882c60b40)

Solutions

  1. Run kubeadm with root privileges: prefix with sudo or run as the root user.
  2. If using sudo, ensure the full command and environment are elevated (sudo kubeadm ...).
  3. Avoid su-to-non-root wrappers that reset uid.

Example fix

# before
kubeadm init ...   # error: user is not running as root
# after
sudo kubeadm init ...
Defensive patterns

Strategy: validation

Validate before calling

if os.Getuid() != 0 {
    return errors.New("kubeadm must run as root; re-run with sudo")
}

Prevention

When it happens

Trigger: Running 'kubeadm init/join/reset/upgrade' on a non-Linux-Windows platform (the !windows build) as a non-root user (uid != 0).

Common situations: Running kubeadm without sudo. SSH'ing as a non-root user and invoking kubeadm directly. Containers/contexts that drop privileges.

Related errors


AI-assisted analysis of kubernetes/kubernetes@b882c60b40 (2026-08-07). Data as JSON: /api/errors/c10633e777da0047. Report an issue: GitHub.