首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >kubectl应用报告错误“操作无法在serviceaccount上完成”

kubectl应用报告错误“操作无法在serviceaccount上完成”
EN

Stack Overflow用户
提问于 2021-02-01 13:26:36
回答 1查看 478关注 0票数 2

我有一个ServiceAccount YAML文件,我正在将其应用于一个新的集群。

我的YAML如下:

代码语言:javascript
复制
apiVersion: v1
items:
- apiVersion: v1
  kind: ServiceAccount
  metadata:
    creationTimestamp: 2019-03-20T23:17:42Z
    name: default
    namespace: dev4
    resourceVersion: "80999"
    selfLink: /api/v1/namespaces/dev4/serviceaccounts/default
    uid: 5c6e0d09-4b66-11e9-b4e3-0a779a87bb40
  secrets:
  - name: default-token-tl4dd
- apiVersion: v1
  kind: ServiceAccount
  metadata:
    annotations:
      kubectl.kubernetes.io/last-applied-configuration: |
        {"apiVersion":"v1","kind":"ServiceAccount","metadata":{"annotations":{},"name":"pod-labeler","namespace":"dev4"}}
    creationTimestamp: 2020-04-21T05:46:25Z
    name: pod-labeler
    namespace: dev4
    resourceVersion: "113455688"
    selfLink: /api/v1/namespaces/dev4/serviceaccounts/pod-labeler
    uid: 702dadda-8393-11ea-abd9-0a768ca51346
  secrets:
  - name: pod-labeler-token-6vgp7
kind: List
metadata:
  resourceVersion: ""
  selfLink: ""

当我应用到1.16版本的新EKS集群时,通过命令kubectl apply -f <yaml file>,我得到了如下错误:

代码语言:javascript
复制
Warning: kubectl apply should be used on resource created by either kubectl create --save-config or kubectl apply
Error from server (Conflict): Operation cannot be fulfilled on serviceaccounts "default": the object has been modified; please apply your changes to the latest version and try again
Error from server (Conflict): Operation cannot be fulfilled on serviceaccounts "pod-labeler": the object has been modified; please apply your changes to the latest version and try again
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-02-01 13:56:15

在申请前,从yaml中删除resourceVersionselfLinkuid。Kubernetes使用版本维护对象的一致性,试图用错误的版本覆盖它会导致此错误。

代码语言:javascript
复制
resourceVersion: "80999"
selfLink: /api/v1/namespaces/dev4/serviceaccounts/default
uid: 5c6e0d09-4b66-11e9-b4e3-0a779a87bb40
...
resourceVersion: "113455688"
selfLink: /api/v1/namespaces/dev4/serviceaccounts/pod-labeler
uid: 702dadda-8393-11ea-abd9-0a768ca51346
票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65987577

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档