xco-sk / eck-custom-resources

Kubernetes operator for Indices, Index Templates, Roles, Users and other Elasticsearch and Kibana related resources.
Apache License 2.0
36 stars 8 forks source link

Add support for ElasticsearchRole kibana priveleges #62

Open georambo opened 1 year ago

georambo commented 1 year ago

Kibana privileges are not supported by the operator, but would be handy to add.

 unexpected field [kibana]"},"status":400

apiVersion: es.eck.github.com/v1alpha1 kind: ElasticsearchRole metadata: name: test namespace: test spec: targetInstance: name: elasticsearch body: | { "indices": [ { "names": [ "*"], "privileges": ["read", "read_cross_cluster"] } ], "kibana": [ { "feature": { "discover": ["read"], "dashboard": ["read"], "visualize": ["read"] }, "spaces": ["default"] } ], "metadata" : { "version" : 1 } }

xco-sk commented 1 year ago

Hi @georambo, I'm a bit unsure why it does not work at the moment. The operator takes the JSON in the body field as-is and uses it as a body of PUT request to create/update the role. If possible, can you share an example (e.g. curl or just JSON + url) of a plain REST API request? That would help a lot. Thanks :-)

georambo commented 1 year ago

Below is the documentation. this seems to hit the kibana api, not the elasticsearch one, but maybe the Elasticsearch Role CRD can handle this in the operator?

https://www.elastic.co/guide/en/kibana/current/role-management-api-put.html

curl -X PUT "localhost:5601/api/security/role/my_kibana_role" -H 'kbn-xsrf: true' -H 'Content-Type: application/json' -d'
{
  "metadata" : {
    "version" : 1
  },
  "elasticsearch": {
    "cluster" : [ ],
    "indices" : [ ]
  },
  "kibana": [
    {
      "base": [],
      "feature": {
       "discover": [
          "all"
        ],
        "visualize": [
          "all"
        ],
        "dashboard": [
          "all"
        ],
        "dev_tools": [
          "read"
        ],
        "advancedSettings": [
          "read"
        ],
        "indexPatterns": [
          "read"
        ],
        "graph": [
          "all"
        ],
        "apm": [
          "read"
        ],
        "maps": [
          "read"
        ],
        "canvas": [
          "read"
        ],
        "infrastructure": [
          "all"
        ],
        "logs": [
          "all"
        ],
        "uptime": [
          "all"
        ]
      },
      "spaces": [
        "*"
      ]
    }
  ]
}
'