kubernetes - 来自服务器的错误 (NotFound): deployments.extensions "1" not found(在 Kubernetes 中删除部署时出错)
问题描述
尝试使用以下命令删除部署时出现此错误,任何想法或建议可能是什么原因以及我如何只能限制删除实际运行的部署?
kubectl delete deployments $(kubectl get deployments | awk 'match($6,/[0-9]+d/) {print $0}')
来自服务器的错误 (NotFound): deployments.extensions "1" not found
来自服务器的错误 (NotFound): deployments.extensions "1d" not found
解决方案
我不确定,但可能 'kubectl get deployment' 命令中的列数在不同的 Kubernetes 客户端版本之间有所不同,因此为避免这种行为,最好使用 custom-columns 选项格式化输出以具有固定数量的字段'awk' 处理的更可预测的行为,例如
kubectl get deployment -o custom-columns=DEPLOYMENT:.metadata.name,READY_REPLICAS:.status.readyReplicas | awk '$2 ~ /[1-9]+/ {print $1}'
推荐阅读
- javascript - 如何编写 Promise 链?
- python - 无法从“假期”导入名称“复活节”
- java - 从文本文件中读取整数并将其存储到单独的变量中?(扫描器)
- php - 尝试使用 AJAX 加载 ui 时,LARAVEL GET 404(未找到)
- conan - 柯南 protobuf 编译抱怨未定义的引用
- javascript - 使用 lodash isEqual 对对象进行深度比较得到误报
- java - 请求的资源上不存在“Access-Control-Allow-Origin”标头,CORS 问题
- apache-kafka - 为什么 3 个 Kafka 代理在同时重新启动后没有启动?
- java - 如何从其群组链接中检索 whatsapp、电报和微信群组的横幅图像和标题?
- c# - 使用 Microsoft Edge 将数据发送到网站(从 Internet Explorer 切换)