gpt4 book ai didi

kubernetes PodSecurityPolicy 设置为 runAsNonRoot,容器具有 runAsNonRoot 并且图像具有非数字用户(appuser),无法验证用户是否为非 root

转载 作者:行者123 更新时间:2023-12-02 11:27:58 27 4
gpt4 key购买 nike

kubernetes PodSecurityPolicy 设置为 runAsNonRoot,pods 没有开始发布,出现错误错误:容器具有 runAsNonRoot 并且图像具有非数字用户(appuser),无法验证用户是非 root

我们正在 docker 容器中创建用户 (appuser) uid -> 999 和组 (appgroup) gid -> 999,并使用该用户启动容器。

但是创建 pod 时抛出错误。

    Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 53s default-scheduler Successfully assigned app-578576fdc6-nfvcz to appmagent01
Normal SuccessfulMountVolume 52s kubelet, appagent01 MountVolume.SetUp succeeded for volume "default-token-ksn46"
Warning DNSConfigForming 11s (x6 over 52s) kubelet, appagent01 Search Line limits were exceeded, some search paths have been omitted, the applied search line is: app.svc.cluster.local svc.cluster.local cluster.local
Normal Pulling 11s (x5 over 51s) kubelet, appagent01 pulling image "app.dockerrepo.internal.com:5000/app:9f51e3e7ab91bb835d3b85f40cc8e6f31cdc2982"
Normal Pulled 11s (x5 over 51s) kubelet, appagent01 Successfully pulled image "app.dockerrepo.internal.com:5000/app:9f51e3e7ab91bb835d3b85f40cc8e6f31cdc2982"
Warning Failed 11s (x5 over 51s) kubelet, appagent01 Error: container has runAsNonRoot and image has non-numeric user (appuser), cannot verify user is non-root

.

最佳答案

这是implementation验证:

case uid == nil && len(username) > 0:
return fmt.Errorf("container has runAsNonRoot and image has non-numeric user (%s), cannot verify user is non-root", username)

这是 validation call评论:
// Verify RunAsNonRoot. Non-root verification only supports numeric user.
if err := verifyRunAsNonRoot(pod, container, uid, username); err != nil {
return nil, cleanupAction, err
}

如您所见,在您的案例中,该消息的唯一原因是 uid == nil .根据源代码中的注释,我们需要设置一个数字用户值。

因此,对于 UID=999 的用户,您可以在 pod 定义中执行此操作 like that :
securityContext:
runAsUser: 999

关于kubernetes PodSecurityPolicy 设置为 runAsNonRoot,容器具有 runAsNonRoot 并且图像具有非数字用户(appuser),无法验证用户是否为非 root,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49720308/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com