zoukankan      html  css  js  c++  java
  • kubernetes secret 和 serviceaccount删除

    背景

    今天通过配置创建了一个serviceaccounts和secret,后面由于某种原因想再次创建发现已存在一个serviceaccounts和rolebindings.rbac.authorization.k8s.io,如下:

    [root@master mysql-operator-master]# cat <<EOF | kubectl create -f -
    > apiVersion: v1
    > kind: ServiceAccount
    > metadata:
    >   name: mysql-agent
    >   namespace: mysql-operator
    > ---
    > kind: RoleBinding
    > apiVersion: rbac.authorization.k8s.io/v1beta1
    > metadata:
    >   name: mysql-agent
    >   namespace: mysql-operator
    > roleRef:
    >   apiGroup: rbac.authorization.k8s.io
    >   kind: ClusterRole
    >   name: mysql-agent
    > subjects:
    > - kind: ServiceAccount
    >   name: mysql-agent
    >   namespace: mysql-operator
    > EOF
    Error from server (AlreadyExists): error when creating "STDIN": serviceaccounts "mysql-agent" already exists
    Error from server (AlreadyExists): error when creating "STDIN": rolebindings.rbac.authorization.k8s.io "mysql-agent" already exists
    

    解决过程

    于是删除这两个东西,删不掉,如下:

    [root@master mysql-operator-master]# kubectl get sa
    NAME          SECRETS   AGE
    default       1         33d
    mysql-agent   1         15m
    [root@master mysql-operator-master]# kubectl delete secret mysql-agent
    Error from server (NotFound): secrets "mysql-agent" not found
    [root@master mysql-operator-master]# kubectl get sa
    NAME          SECRETS   AGE
    default       1         33d
    mysql-agent   1         16m
    [root@master mysql-operator-master]#
    

    尝试换了一个命令,提示删掉了,但是查看依然存在

    [root@master mysql-operator-master]# kubectl delete serviceaccount -n mysql-operator mysql-agent
    serviceaccount "mysql-agent" deleted
    You have new mail in /var/spool/mail/root
    [root@master mysql-operator-master]# kubectl get sa
    NAME          SECRETS   AGE
    default       1         33d
    mysql-agent   1         25m
    

    再次删除sa,这次不指定ns,删除成功

    [root@master mysql-operator-master]# kubectl delete serviceaccounts mysql-agent
    serviceaccount "mysql-agent" deleted
    [root@master mysql-operator-master]# 
    [root@master mysql-operator-master]# kubectl get serviceaccounts
    NAME      SECRETS   AGE
    default   1         33d
    [root@master mysql-operator-master]#
    
    WilliamZheng©版权所有 转载请注明出处! 运维架构师群:833329925
  • 相关阅读:
    Knockout应用开发指南 第十章:更多信息(完结篇)
    Knockout应用开发指南 第九章:高级应用举例
    汤姆大叔博客索引
    HTML5学习笔记简明版(1):HTML5介绍与语法
    HTML5学习笔记简明版 目录索引
    大叔手记(1):使用Visual Studio的查找与替换替代默认的系统搜索
    微软ASP.NET站点部署指南(9):部署数据库更新
    微软ASP.NET站点部署指南(11):部署SQL Server数据库更新
    彻底搞定C指针
    linux svn 使用
  • 原文地址:https://www.cnblogs.com/williamzheng/p/11464883.html
Copyright © 2011-2022 走看看