eip-work / kuboard-press

Kuboard 是基于 Kubernetes 的微服务管理界面。同时提供 Kubernetes 免费中文教程,入门教程,最新版本的 Kubernetes v1.23.4 安装手册,(k8s install) 在线答疑,持续更新。
https://kuboard.cn/
22.11k stars 1.5k forks source link

kuboard编辑服务保存导致注解丢失(prometheus) #336

Open alfredking12 opened 2 years ago

alfredking12 commented 2 years ago

问题现象和步骤:

  1. 通过kuboard编辑Deployment的YAML配置,配置pod template 注解(增加prometheus相关注解),查看Deployment的YAML文件注解增加有效
    spec:
    template:
    metadata:
      annotations:
        prometheus.io/path: /actuator/prometheus
        prometheus.io/scrape: 'true'
  2. 通过kuboard编辑服务,点击保存
  3. 查看Deployment的YAML文件中注解丢失

问题分析: 使用kuboard编辑服务并保存后,会导致Deployment丢失pod template的注解。查看对应的HTTP请求如下:

  1. 发送Deployment查询请求

    GET http://ip:32567/k8s-api/apis/apps/v1/namespaces/{namespace}/deployments/{name}
  2. 应答如下(对原数据做过精简)

    {
    "kind": "Deployment",
    "apiVersion": "apps/v1",
    "metadata": {
    "name": "name",
    "namespace": "namespace"
    
    },
    "spec": {
    "replicas": 1,
    "selector": {
      "matchLabels": {
        "k8s.kuboard.cn/name": "name"
      }
    },
    "template": {
      "metadata": {
        "creationTimestamp": null,
        "labels": {
          "k8s.kuboard.cn/name": "name"
        },
        "annotations": {
          "prometheus.io/path": "/actuator/prometheus",
          "prometheus.io/scrape": "true"
        }
      },
      "spec": {
        "containers": [
          {
            "name": "name",
            "image": "image:latest"
          }
        ]
      }
    }
    }
    }
  3. 发送Deployment更新请求(注意:丢失了annotation)

    {
    "kind": "Deployment",
    "apiVersion": "apps/v1",
    "metadata": {
    "name": "name",
    "namespace": "namespace"
    
    },
    "spec": {
    "replicas": 1,
    "selector": {
      "matchLabels": {
        "k8s.kuboard.cn/name": "name"
      }
    },
    "template": {
      "metadata": {
        "creationTimestamp": null,
        "labels": {
          "k8s.kuboard.cn/name": "name"
        }
      },
      "spec": {
        "containers": [
          {
            "name": "name",
            "image": "image:latest"
          }
        ]
      }
    }
    }
    }

K8S版本: v1.23.6+k3s1

alfredking12 commented 2 years ago

希望能够帮处理一下,便于使用

alfredking12 commented 2 years ago

kuboard版本:2.0.5.5