diff --git a/config/default/custom-resource-state.yaml b/config/default/custom-resource-state.yaml index eaffa65..45fde4e 100644 --- a/config/default/custom-resource-state.yaml +++ b/config/default/custom-resource-state.yaml @@ -511,6 +511,59 @@ spec: labelsFromPath: type: ["type"] valueFrom: ["status"] + - groupVersionKind: + group: kuadrant.io + kind: "DNSPolicy" + version: "v1alpha1" + metricNamePrefix: gatewayapi_dnspolicy + labelsFromPath: + name: + - metadata + - name + namespace: + - metadata + - namespace + metrics: + - name: "labels" + help: "Kubernetes labels converted to Prometheus labels." + each: + type: Info + info: + path: [metadata] + labelsFromPath: + "*": [labels] + - name: "created" + help: "created timestamp" + each: + type: Gauge + gauge: + path: [metadata, creationTimestamp] + - name: "deleted" + help: "deletion timestamp" + each: + type: Gauge + gauge: + path: [metadata, deletionTimestamp] + - name: "target_info" + help: "Target references that the dnspolicy wants to be attached to" + each: + type: Info + info: + path: [spec, targetRef] + labelsFromPath: + target_group: ["group"] + target_kind: ["kind"] + target_name: ["name"] + target_namespace: ["namespace"] + - name: "status" + help: "status condition" + each: + type: Gauge + gauge: + path: [status, conditions] + labelsFromPath: + type: ["type"] + valueFrom: ["status"] - groupVersionKind: group: kuadrant.io kind: "RateLimitPolicy" diff --git a/config/examples/dashboards/policies.json b/config/examples/dashboards/policies.json index 136a476..782855a 100644 --- a/config/examples/dashboards/policies.json +++ b/config/examples/dashboards/policies.json @@ -35,7 +35,7 @@ "h": 3, "w": 2, "x": 0, - "y": 1 + "y": 0 }, "id": 2, "pluginVersion": "v10.0.0", @@ -62,7 +62,7 @@ "h": 3, "w": 2, "x": 2, - "y": 1 + "y": 0 }, "id": 3, "pluginVersion": "v10.0.0", @@ -113,7 +113,7 @@ "h": 6, "w": 10, "x": 4, - "y": 1 + "y": 0 }, "id": 4, "pluginVersion": "v10.0.0", @@ -164,6 +164,148 @@ "y": 2 }, "id": 5, + "title": "DNSPolicy", + "type": "row" + }, + { + "datasource": { + "type": "prometheus", + "uid": "$datasource" + }, + "description": "Total number of DNSPolicy across all clusters", + "gridPos": { + "h": 3, + "w": 2, + "x": 0, + "y": 2 + }, + "id": 6, + "pluginVersion": "v10.0.0", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "$datasource" + }, + "expr": "count(gatewayapi_dnspolicy_status{name=~\"${dnspolicy}\"})", + "instant": true + } + ], + "title": "Total", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "$datasource" + }, + "description": "Total DNSPolicy with an Ready state", + "gridPos": { + "h": 3, + "w": 2, + "x": 2, + "y": 2 + }, + "id": 7, + "pluginVersion": "v10.0.0", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "$datasource" + }, + "expr": "count(gatewayapi_dnspolicy_status{type=\"Ready\", name=~\"${dnspolicy}\"})", + "instant": true + } + ], + "title": "Ready", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "$datasource" + }, + "fieldConfig": { + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "Target Name" + }, + "properties": [ + { + "id": "custom.displayMode", + "value": "color-text" + }, + { + "id": "links", + "value": [ + { + "title": "Gateway Details", + "url": "/d/gatewayapigateways/gateway-api-state-gateways?var-gateway=${__value.text}" + } + ] + } + ] + } + ] + }, + "gridPos": { + "h": 6, + "w": 10, + "x": 4, + "y": 2 + }, + "id": 8, + "pluginVersion": "v10.0.0", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "$datasource" + }, + "expr": "gatewayapi_dnspolicy_target_info{name=~\"${dnspolicy}\"}", + "format": "table", + "instant": true, + "range": false + } + ], + "title": "DNSPolicy", + "transformations": [ + { + "id": "filterFieldsByName", + "options": { + "include": { + "names": [ + "name", + "target_kind", + "target_name" + ] + } + } + }, + { + "id": "organize", + "options": { + "renameByName": { + "name": "Name", + "target_kind": "Target Kind", + "target_name": "Target Name" + } + } + } + ], + "type": "table" + }, + { + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 4 + }, + "id": 9, "title": "RateLimitPolicy", "type": "row" }, @@ -177,9 +319,9 @@ "h": 3, "w": 2, "x": 0, - "y": 3 + "y": 4 }, - "id": 6, + "id": 10, "pluginVersion": "v10.0.0", "targets": [ { @@ -204,9 +346,9 @@ "h": 3, "w": 2, "x": 2, - "y": 3 + "y": 4 }, - "id": 7, + "id": 11, "pluginVersion": "v10.0.0", "targets": [ { @@ -255,9 +397,9 @@ "h": 6, "w": 10, "x": 4, - "y": 7 + "y": 4 }, - "id": 8, + "id": 12, "pluginVersion": "v10.0.0", "targets": [ { @@ -303,9 +445,9 @@ "h": 1, "w": 24, "x": 0, - "y": 8 + "y": 6 }, - "id": 9, + "id": 13, "title": "AuthPolicy", "type": "row" }, @@ -319,9 +461,9 @@ "h": 3, "w": 2, "x": 0, - "y": 9 + "y": 6 }, - "id": 10, + "id": 14, "pluginVersion": "v10.0.0", "targets": [ { @@ -346,9 +488,9 @@ "h": 3, "w": 2, "x": 2, - "y": 9 + "y": 6 }, - "id": 11, + "id": 15, "pluginVersion": "v10.0.0", "targets": [ { @@ -397,9 +539,9 @@ "h": 6, "w": 10, "x": 4, - "y": 9 + "y": 6 }, - "id": 12, + "id": 16, "pluginVersion": "v10.0.0", "targets": [ { @@ -445,9 +587,9 @@ "h": 1, "w": 24, "x": 0, - "y": 10 + "y": 8 }, - "id": 13, + "id": 17, "title": "BackendTLSPolicy", "type": "row" }, @@ -463,9 +605,9 @@ "h": 6, "w": 10, "x": 4, - "y": 10 + "y": 8 }, - "id": 14, + "id": 18, "pluginVersion": "v10.0.0", "targets": [ { @@ -537,6 +679,22 @@ "regex": "/(.*)/", "type": "query" }, + { + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "includeAll": true, + "label": "DNSPolicy", + "multi": true, + "name": "dnspolicy", + "query": { + "query": "label_values(gatewayapi_dnspolicy_created, name)", + "refId": "StandardVariableQuery" + }, + "regex": "/(.*)/", + "type": "query" + }, { "datasource": { "type": "prometheus", diff --git a/config/examples/dashboards/policies.yaml b/config/examples/dashboards/policies.yaml index a09c8f1..72fe6b6 100644 --- a/config/examples/dashboards/policies.yaml +++ b/config/examples/dashboards/policies.yaml @@ -7,4 +7,4 @@ spec: matchLabels: dashboards: "grafana" json: > - {"editable":false,"links":[{"asDropdown":false,"includeVars":true,"keepTime":true,"tags":["gateway-api-state"],"targetBlank":false,"title":"Gateway Dashboards","type":"dashboards"}],"panels":[{"gridPos":{"h":1,"w":24,"x":0,"y":0},"id":1,"title":"TLSPolicy","type":"row"},{"datasource":{"type":"prometheus","uid":"$datasource"},"description":"Total number of TLSPolicy across all clusters","gridPos":{"h":3,"w":2,"x":0,"y":1},"id":2,"pluginVersion":"v10.0.0","targets":[{"datasource":{"type":"prometheus","uid":"$datasource"},"expr":"count(gatewayapi_tlspolicy_status{name=~\"${tlspolicy}\"})","instant":true}],"title":"Total","type":"stat"},{"datasource":{"type":"prometheus","uid":"$datasource"},"description":"Total TLSPolicy with an Ready state","gridPos":{"h":3,"w":2,"x":2,"y":1},"id":3,"pluginVersion":"v10.0.0","targets":[{"datasource":{"type":"prometheus","uid":"$datasource"},"expr":"count(gatewayapi_tlspolicy_status{type=\"Ready\", name=~\"${tlspolicy}\"})","instant":true}],"title":"Ready","type":"stat"},{"datasource":{"type":"prometheus","uid":"$datasource"},"fieldConfig":{"overrides":[{"matcher":{"id":"byName","options":"Target Name"},"properties":[{"id":"custom.displayMode","value":"color-text"},{"id":"links","value":[{"title":"Gateway Details","url":"/d/gatewayapigateways/gateway-api-state-gateways?var-gateway=${__value.text}"}]}]}]},"gridPos":{"h":6,"w":10,"x":4,"y":1},"id":4,"pluginVersion":"v10.0.0","targets":[{"datasource":{"type":"prometheus","uid":"$datasource"},"expr":"gatewayapi_tlspolicy_target_info{name=~\"${tlspolicy}\"}","format":"table","instant":true,"range":false}],"title":"TLSPolicy","transformations":[{"id":"filterFieldsByName","options":{"include":{"names":["name","target_kind","target_name"]}}},{"id":"organize","options":{"renameByName":{"name":"Name","target_kind":"Target Kind","target_name":"Target Name"}}}],"type":"table"},{"gridPos":{"h":1,"w":24,"x":0,"y":2},"id":5,"title":"RateLimitPolicy","type":"row"},{"datasource":{"type":"prometheus","uid":"$datasource"},"description":"Total number of RateLimitPolicy across all clusters","gridPos":{"h":3,"w":2,"x":0,"y":3},"id":6,"pluginVersion":"v10.0.0","targets":[{"datasource":{"type":"prometheus","uid":"$datasource"},"expr":"count(gatewayapi_ratelimitpolicy_status{name=~\"${ratelimitpolicy}\"})","instant":true}],"title":"Total","type":"stat"},{"datasource":{"type":"prometheus","uid":"$datasource"},"description":"Total RateLimitPolicy with an Available state","gridPos":{"h":3,"w":2,"x":2,"y":3},"id":7,"pluginVersion":"v10.0.0","targets":[{"datasource":{"type":"prometheus","uid":"$datasource"},"expr":"count(gatewayapi_ratelimitpolicy_status{type=\"Available\", name=~\"${ratelimitpolicy}\"})","instant":true}],"title":"Available","type":"stat"},{"datasource":{"type":"prometheus","uid":"$datasource"},"fieldConfig":{"overrides":[{"matcher":{"id":"byName","options":"Target Name"},"properties":[{"id":"custom.displayMode","value":"color-text"},{"id":"links","value":[{"title":"HTTPRoute Details","url":"/d/gatewayapihttproutes/gateway-api-state-httproutes?var-httproute=${__value.text}"}]}]}]},"gridPos":{"h":6,"w":10,"x":4,"y":7},"id":8,"pluginVersion":"v10.0.0","targets":[{"datasource":{"type":"prometheus","uid":"$datasource"},"expr":"gatewayapi_ratelimitpolicy_target_info{name=~\"${ratelimitpolicy}\"}","format":"table","instant":true,"range":false}],"title":"RateLimitPolicy","transformations":[{"id":"filterFieldsByName","options":{"include":{"names":["name","target_kind","target_name"]}}},{"id":"organize","options":{"renameByName":{"name":"Name","target_kind":"Target Kind","target_name":"Target Name"}}}],"type":"table"},{"gridPos":{"h":1,"w":24,"x":0,"y":8},"id":9,"title":"AuthPolicy","type":"row"},{"datasource":{"type":"prometheus","uid":"$datasource"},"description":"Total number of AuthPolicy across all clusters","gridPos":{"h":3,"w":2,"x":0,"y":9},"id":10,"pluginVersion":"v10.0.0","targets":[{"datasource":{"type":"prometheus","uid":"$datasource"},"expr":"count(gatewayapi_authpolicy_status{name=~\"${authpolicy}\"})","instant":true}],"title":"Total","type":"stat"},{"datasource":{"type":"prometheus","uid":"$datasource"},"description":"Total AuthPolicy with an Available state","gridPos":{"h":3,"w":2,"x":2,"y":9},"id":11,"pluginVersion":"v10.0.0","targets":[{"datasource":{"type":"prometheus","uid":"$datasource"},"expr":"count(gatewayapi_authpolicy_status{type=\"Available\", name=~\"${authpolicy}\"})","instant":true}],"title":"Available","type":"stat"},{"datasource":{"type":"prometheus","uid":"$datasource"},"fieldConfig":{"overrides":[{"matcher":{"id":"byName","options":"Target Name"},"properties":[{"id":"custom.displayMode","value":"color-text"},{"id":"links","value":[{"title":"HTTPRoute Details","url":"/d/gatewayapihttproutes/gateway-api-state-httproutes?var-httproute=${__value.text}"}]}]}]},"gridPos":{"h":6,"w":10,"x":4,"y":9},"id":12,"pluginVersion":"v10.0.0","targets":[{"datasource":{"type":"prometheus","uid":"$datasource"},"expr":"gatewayapi_authpolicy_target_info{name=~\"${authpolicy}\"}","format":"table","instant":true,"range":false}],"title":"AuthPolicy","transformations":[{"id":"filterFieldsByName","options":{"include":{"names":["name","target_kind","target_name"]}}},{"id":"organize","options":{"renameByName":{"name":"Name","target_kind":"Target Kind","target_name":"Target Name"}}}],"type":"table"},{"gridPos":{"h":1,"w":24,"x":0,"y":10},"id":13,"title":"BackendTLSPolicy","type":"row"},{"datasource":{"type":"prometheus","uid":"$datasource"},"fieldConfig":{"overrides":[]},"gridPos":{"h":6,"w":10,"x":4,"y":10},"id":14,"pluginVersion":"v10.0.0","targets":[{"datasource":{"type":"prometheus","uid":"$datasource"},"expr":"gatewayapi_backendtlspolicy_target_info{name=~\"${backendtlspolicy}\"}","format":"table","instant":true,"range":false}],"title":"BackendTLSPolicy","transformations":[{"id":"filterFieldsByName","options":{"include":{"names":["name","target_kind","target_name"]}}},{"id":"organize","options":{"renameByName":{"name":"Name","target_kind":"Target Kind","target_name":"Target Name"}}}],"type":"table"}],"schemaVersion":36,"style":"dark","tags":["gateway-api","gateway-api-state"],"templating":{"list":[{"label":"Data Source","name":"datasource","query":"prometheus","type":"datasource"},{"datasource":{"type":"prometheus","uid":"${datasource}"},"includeAll":true,"label":"TLSPolicy","multi":true,"name":"tlspolicy","query":{"query":"label_values(gatewayapi_tlspolicy_created, name)","refId":"StandardVariableQuery"},"regex":"/(.*)/","type":"query"},{"datasource":{"type":"prometheus","uid":"${datasource}"},"includeAll":true,"label":"RateLimitPolicy","multi":true,"name":"ratelimitpolicy","query":{"query":"label_values(gatewayapi_ratelimitpolicy_created, name)","refId":"StandardVariableQuery"},"regex":"/(.*)/","type":"query"},{"datasource":{"type":"prometheus","uid":"${datasource}"},"includeAll":true,"label":"AuthPolicy","multi":true,"name":"authpolicy","query":{"query":"label_values(gatewayapi_authpolicy_created, name)","refId":"StandardVariableQuery"},"regex":"/(.*)/","type":"query"},{"datasource":{"type":"prometheus","uid":"${datasource}"},"includeAll":true,"label":"BackendTLSPolicy","multi":true,"name":"backendtlspolicy","query":{"query":"label_values(gatewayapi_backendtlspolicy_created, name)","refId":"StandardVariableQuery"},"regex":"/(.*)/","type":"query"}]},"time":{"from":"now-1h","to":"now"},"timezone":"utc","title":"Gateway API State / Policies","uid":"gatewayapipolicies"} + {"editable":false,"links":[{"asDropdown":false,"includeVars":true,"keepTime":true,"tags":["gateway-api-state"],"targetBlank":false,"title":"Gateway Dashboards","type":"dashboards"}],"panels":[{"gridPos":{"h":1,"w":24,"x":0,"y":0},"id":1,"title":"TLSPolicy","type":"row"},{"datasource":{"type":"prometheus","uid":"$datasource"},"description":"Total number of TLSPolicy across all clusters","gridPos":{"h":3,"w":2,"x":0,"y":0},"id":2,"pluginVersion":"v10.0.0","targets":[{"datasource":{"type":"prometheus","uid":"$datasource"},"expr":"count(gatewayapi_tlspolicy_status{name=~\"${tlspolicy}\"})","instant":true}],"title":"Total","type":"stat"},{"datasource":{"type":"prometheus","uid":"$datasource"},"description":"Total TLSPolicy with an Ready state","gridPos":{"h":3,"w":2,"x":2,"y":0},"id":3,"pluginVersion":"v10.0.0","targets":[{"datasource":{"type":"prometheus","uid":"$datasource"},"expr":"count(gatewayapi_tlspolicy_status{type=\"Ready\", name=~\"${tlspolicy}\"})","instant":true}],"title":"Ready","type":"stat"},{"datasource":{"type":"prometheus","uid":"$datasource"},"fieldConfig":{"overrides":[{"matcher":{"id":"byName","options":"Target Name"},"properties":[{"id":"custom.displayMode","value":"color-text"},{"id":"links","value":[{"title":"Gateway Details","url":"/d/gatewayapigateways/gateway-api-state-gateways?var-gateway=${__value.text}"}]}]}]},"gridPos":{"h":6,"w":10,"x":4,"y":0},"id":4,"pluginVersion":"v10.0.0","targets":[{"datasource":{"type":"prometheus","uid":"$datasource"},"expr":"gatewayapi_tlspolicy_target_info{name=~\"${tlspolicy}\"}","format":"table","instant":true,"range":false}],"title":"TLSPolicy","transformations":[{"id":"filterFieldsByName","options":{"include":{"names":["name","target_kind","target_name"]}}},{"id":"organize","options":{"renameByName":{"name":"Name","target_kind":"Target Kind","target_name":"Target Name"}}}],"type":"table"},{"gridPos":{"h":1,"w":24,"x":0,"y":2},"id":5,"title":"DNSPolicy","type":"row"},{"datasource":{"type":"prometheus","uid":"$datasource"},"description":"Total number of DNSPolicy across all clusters","gridPos":{"h":3,"w":2,"x":0,"y":2},"id":6,"pluginVersion":"v10.0.0","targets":[{"datasource":{"type":"prometheus","uid":"$datasource"},"expr":"count(gatewayapi_dnspolicy_status{name=~\"${dnspolicy}\"})","instant":true}],"title":"Total","type":"stat"},{"datasource":{"type":"prometheus","uid":"$datasource"},"description":"Total DNSPolicy with an Ready state","gridPos":{"h":3,"w":2,"x":2,"y":2},"id":7,"pluginVersion":"v10.0.0","targets":[{"datasource":{"type":"prometheus","uid":"$datasource"},"expr":"count(gatewayapi_dnspolicy_status{type=\"Ready\", name=~\"${dnspolicy}\"})","instant":true}],"title":"Ready","type":"stat"},{"datasource":{"type":"prometheus","uid":"$datasource"},"fieldConfig":{"overrides":[{"matcher":{"id":"byName","options":"Target Name"},"properties":[{"id":"custom.displayMode","value":"color-text"},{"id":"links","value":[{"title":"Gateway Details","url":"/d/gatewayapigateways/gateway-api-state-gateways?var-gateway=${__value.text}"}]}]}]},"gridPos":{"h":6,"w":10,"x":4,"y":2},"id":8,"pluginVersion":"v10.0.0","targets":[{"datasource":{"type":"prometheus","uid":"$datasource"},"expr":"gatewayapi_dnspolicy_target_info{name=~\"${dnspolicy}\"}","format":"table","instant":true,"range":false}],"title":"DNSPolicy","transformations":[{"id":"filterFieldsByName","options":{"include":{"names":["name","target_kind","target_name"]}}},{"id":"organize","options":{"renameByName":{"name":"Name","target_kind":"Target Kind","target_name":"Target Name"}}}],"type":"table"},{"gridPos":{"h":1,"w":24,"x":0,"y":4},"id":9,"title":"RateLimitPolicy","type":"row"},{"datasource":{"type":"prometheus","uid":"$datasource"},"description":"Total number of RateLimitPolicy across all clusters","gridPos":{"h":3,"w":2,"x":0,"y":4},"id":10,"pluginVersion":"v10.0.0","targets":[{"datasource":{"type":"prometheus","uid":"$datasource"},"expr":"count(gatewayapi_ratelimitpolicy_status{name=~\"${ratelimitpolicy}\"})","instant":true}],"title":"Total","type":"stat"},{"datasource":{"type":"prometheus","uid":"$datasource"},"description":"Total RateLimitPolicy with an Available state","gridPos":{"h":3,"w":2,"x":2,"y":4},"id":11,"pluginVersion":"v10.0.0","targets":[{"datasource":{"type":"prometheus","uid":"$datasource"},"expr":"count(gatewayapi_ratelimitpolicy_status{type=\"Available\", name=~\"${ratelimitpolicy}\"})","instant":true}],"title":"Available","type":"stat"},{"datasource":{"type":"prometheus","uid":"$datasource"},"fieldConfig":{"overrides":[{"matcher":{"id":"byName","options":"Target Name"},"properties":[{"id":"custom.displayMode","value":"color-text"},{"id":"links","value":[{"title":"HTTPRoute Details","url":"/d/gatewayapihttproutes/gateway-api-state-httproutes?var-httproute=${__value.text}"}]}]}]},"gridPos":{"h":6,"w":10,"x":4,"y":4},"id":12,"pluginVersion":"v10.0.0","targets":[{"datasource":{"type":"prometheus","uid":"$datasource"},"expr":"gatewayapi_ratelimitpolicy_target_info{name=~\"${ratelimitpolicy}\"}","format":"table","instant":true,"range":false}],"title":"RateLimitPolicy","transformations":[{"id":"filterFieldsByName","options":{"include":{"names":["name","target_kind","target_name"]}}},{"id":"organize","options":{"renameByName":{"name":"Name","target_kind":"Target Kind","target_name":"Target Name"}}}],"type":"table"},{"gridPos":{"h":1,"w":24,"x":0,"y":6},"id":13,"title":"AuthPolicy","type":"row"},{"datasource":{"type":"prometheus","uid":"$datasource"},"description":"Total number of AuthPolicy across all clusters","gridPos":{"h":3,"w":2,"x":0,"y":6},"id":14,"pluginVersion":"v10.0.0","targets":[{"datasource":{"type":"prometheus","uid":"$datasource"},"expr":"count(gatewayapi_authpolicy_status{name=~\"${authpolicy}\"})","instant":true}],"title":"Total","type":"stat"},{"datasource":{"type":"prometheus","uid":"$datasource"},"description":"Total AuthPolicy with an Available state","gridPos":{"h":3,"w":2,"x":2,"y":6},"id":15,"pluginVersion":"v10.0.0","targets":[{"datasource":{"type":"prometheus","uid":"$datasource"},"expr":"count(gatewayapi_authpolicy_status{type=\"Available\", name=~\"${authpolicy}\"})","instant":true}],"title":"Available","type":"stat"},{"datasource":{"type":"prometheus","uid":"$datasource"},"fieldConfig":{"overrides":[{"matcher":{"id":"byName","options":"Target Name"},"properties":[{"id":"custom.displayMode","value":"color-text"},{"id":"links","value":[{"title":"HTTPRoute Details","url":"/d/gatewayapihttproutes/gateway-api-state-httproutes?var-httproute=${__value.text}"}]}]}]},"gridPos":{"h":6,"w":10,"x":4,"y":6},"id":16,"pluginVersion":"v10.0.0","targets":[{"datasource":{"type":"prometheus","uid":"$datasource"},"expr":"gatewayapi_authpolicy_target_info{name=~\"${authpolicy}\"}","format":"table","instant":true,"range":false}],"title":"AuthPolicy","transformations":[{"id":"filterFieldsByName","options":{"include":{"names":["name","target_kind","target_name"]}}},{"id":"organize","options":{"renameByName":{"name":"Name","target_kind":"Target Kind","target_name":"Target Name"}}}],"type":"table"},{"gridPos":{"h":1,"w":24,"x":0,"y":8},"id":17,"title":"BackendTLSPolicy","type":"row"},{"datasource":{"type":"prometheus","uid":"$datasource"},"fieldConfig":{"overrides":[]},"gridPos":{"h":6,"w":10,"x":4,"y":8},"id":18,"pluginVersion":"v10.0.0","targets":[{"datasource":{"type":"prometheus","uid":"$datasource"},"expr":"gatewayapi_backendtlspolicy_target_info{name=~\"${backendtlspolicy}\"}","format":"table","instant":true,"range":false}],"title":"BackendTLSPolicy","transformations":[{"id":"filterFieldsByName","options":{"include":{"names":["name","target_kind","target_name"]}}},{"id":"organize","options":{"renameByName":{"name":"Name","target_kind":"Target Kind","target_name":"Target Name"}}}],"type":"table"}],"schemaVersion":36,"style":"dark","tags":["gateway-api","gateway-api-state"],"templating":{"list":[{"label":"Data Source","name":"datasource","query":"prometheus","type":"datasource"},{"datasource":{"type":"prometheus","uid":"${datasource}"},"includeAll":true,"label":"TLSPolicy","multi":true,"name":"tlspolicy","query":{"query":"label_values(gatewayapi_tlspolicy_created, name)","refId":"StandardVariableQuery"},"regex":"/(.*)/","type":"query"},{"datasource":{"type":"prometheus","uid":"${datasource}"},"includeAll":true,"label":"DNSPolicy","multi":true,"name":"dnspolicy","query":{"query":"label_values(gatewayapi_dnspolicy_created, name)","refId":"StandardVariableQuery"},"regex":"/(.*)/","type":"query"},{"datasource":{"type":"prometheus","uid":"${datasource}"},"includeAll":true,"label":"RateLimitPolicy","multi":true,"name":"ratelimitpolicy","query":{"query":"label_values(gatewayapi_ratelimitpolicy_created, name)","refId":"StandardVariableQuery"},"regex":"/(.*)/","type":"query"},{"datasource":{"type":"prometheus","uid":"${datasource}"},"includeAll":true,"label":"AuthPolicy","multi":true,"name":"authpolicy","query":{"query":"label_values(gatewayapi_authpolicy_created, name)","refId":"StandardVariableQuery"},"regex":"/(.*)/","type":"query"},{"datasource":{"type":"prometheus","uid":"${datasource}"},"includeAll":true,"label":"BackendTLSPolicy","multi":true,"name":"backendtlspolicy","query":{"query":"label_values(gatewayapi_backendtlspolicy_created, name)","refId":"StandardVariableQuery"},"regex":"/(.*)/","type":"query"}]},"time":{"from":"now-1h","to":"now"},"timezone":"utc","title":"Gateway API State / Policies","uid":"gatewayapipolicies"} diff --git a/config/examples/kube-prometheus/bundle.yaml b/config/examples/kube-prometheus/bundle.yaml index 34d60f4..e47feea 100644 --- a/config/examples/kube-prometheus/bundle.yaml +++ b/config/examples/kube-prometheus/bundle.yaml @@ -1496,6 +1496,59 @@ data: labelsFromPath: type: ["type"] valueFrom: ["status"] + - groupVersionKind: + group: kuadrant.io + kind: "DNSPolicy" + version: "v1alpha1" + metricNamePrefix: gatewayapi_dnspolicy + labelsFromPath: + name: + - metadata + - name + namespace: + - metadata + - namespace + metrics: + - name: "labels" + help: "Kubernetes labels converted to Prometheus labels." + each: + type: Info + info: + path: [metadata] + labelsFromPath: + "*": [labels] + - name: "created" + help: "created timestamp" + each: + type: Gauge + gauge: + path: [metadata, creationTimestamp] + - name: "deleted" + help: "deletion timestamp" + each: + type: Gauge + gauge: + path: [metadata, deletionTimestamp] + - name: "target_info" + help: "Target references that the dnspolicy wants to be attached to" + each: + type: Info + info: + path: [spec, targetRef] + labelsFromPath: + target_group: ["group"] + target_kind: ["kind"] + target_name: ["name"] + target_namespace: ["namespace"] + - name: "status" + help: "status condition" + each: + type: Gauge + gauge: + path: [status, conditions] + labelsFromPath: + type: ["type"] + valueFrom: ["status"] - groupVersionKind: group: kuadrant.io kind: "RateLimitPolicy" @@ -41288,7 +41341,7 @@ data: "h": 3, "w": 2, "x": 0, - "y": 1 + "y": 0 }, "id": 2, "pluginVersion": "v10.0.0", @@ -41315,7 +41368,7 @@ data: "h": 3, "w": 2, "x": 2, - "y": 1 + "y": 0 }, "id": 3, "pluginVersion": "v10.0.0", @@ -41366,7 +41419,7 @@ data: "h": 6, "w": 10, "x": 4, - "y": 1 + "y": 0 }, "id": 4, "pluginVersion": "v10.0.0", @@ -41417,6 +41470,148 @@ data: "y": 2 }, "id": 5, + "title": "DNSPolicy", + "type": "row" + }, + { + "datasource": { + "type": "prometheus", + "uid": "$datasource" + }, + "description": "Total number of DNSPolicy across all clusters", + "gridPos": { + "h": 3, + "w": 2, + "x": 0, + "y": 2 + }, + "id": 6, + "pluginVersion": "v10.0.0", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "$datasource" + }, + "expr": "count(gatewayapi_dnspolicy_status{name=~\"${dnspolicy}\"})", + "instant": true + } + ], + "title": "Total", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "$datasource" + }, + "description": "Total DNSPolicy with an Ready state", + "gridPos": { + "h": 3, + "w": 2, + "x": 2, + "y": 2 + }, + "id": 7, + "pluginVersion": "v10.0.0", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "$datasource" + }, + "expr": "count(gatewayapi_dnspolicy_status{type=\"Ready\", name=~\"${dnspolicy}\"})", + "instant": true + } + ], + "title": "Ready", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "$datasource" + }, + "fieldConfig": { + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "Target Name" + }, + "properties": [ + { + "id": "custom.displayMode", + "value": "color-text" + }, + { + "id": "links", + "value": [ + { + "title": "Gateway Details", + "url": "/d/gatewayapigateways/gateway-api-state-gateways?var-gateway=${__value.text}" + } + ] + } + ] + } + ] + }, + "gridPos": { + "h": 6, + "w": 10, + "x": 4, + "y": 2 + }, + "id": 8, + "pluginVersion": "v10.0.0", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "$datasource" + }, + "expr": "gatewayapi_dnspolicy_target_info{name=~\"${dnspolicy}\"}", + "format": "table", + "instant": true, + "range": false + } + ], + "title": "DNSPolicy", + "transformations": [ + { + "id": "filterFieldsByName", + "options": { + "include": { + "names": [ + "name", + "target_kind", + "target_name" + ] + } + } + }, + { + "id": "organize", + "options": { + "renameByName": { + "name": "Name", + "target_kind": "Target Kind", + "target_name": "Target Name" + } + } + } + ], + "type": "table" + }, + { + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 4 + }, + "id": 9, "title": "RateLimitPolicy", "type": "row" }, @@ -41430,9 +41625,9 @@ data: "h": 3, "w": 2, "x": 0, - "y": 3 + "y": 4 }, - "id": 6, + "id": 10, "pluginVersion": "v10.0.0", "targets": [ { @@ -41457,9 +41652,9 @@ data: "h": 3, "w": 2, "x": 2, - "y": 3 + "y": 4 }, - "id": 7, + "id": 11, "pluginVersion": "v10.0.0", "targets": [ { @@ -41508,9 +41703,9 @@ data: "h": 6, "w": 10, "x": 4, - "y": 7 + "y": 4 }, - "id": 8, + "id": 12, "pluginVersion": "v10.0.0", "targets": [ { @@ -41556,9 +41751,9 @@ data: "h": 1, "w": 24, "x": 0, - "y": 8 + "y": 6 }, - "id": 9, + "id": 13, "title": "AuthPolicy", "type": "row" }, @@ -41572,9 +41767,9 @@ data: "h": 3, "w": 2, "x": 0, - "y": 9 + "y": 6 }, - "id": 10, + "id": 14, "pluginVersion": "v10.0.0", "targets": [ { @@ -41599,9 +41794,9 @@ data: "h": 3, "w": 2, "x": 2, - "y": 9 + "y": 6 }, - "id": 11, + "id": 15, "pluginVersion": "v10.0.0", "targets": [ { @@ -41650,9 +41845,9 @@ data: "h": 6, "w": 10, "x": 4, - "y": 9 + "y": 6 }, - "id": 12, + "id": 16, "pluginVersion": "v10.0.0", "targets": [ { @@ -41698,9 +41893,9 @@ data: "h": 1, "w": 24, "x": 0, - "y": 10 + "y": 8 }, - "id": 13, + "id": 17, "title": "BackendTLSPolicy", "type": "row" }, @@ -41716,9 +41911,9 @@ data: "h": 6, "w": 10, "x": 4, - "y": 10 + "y": 8 }, - "id": 14, + "id": 18, "pluginVersion": "v10.0.0", "targets": [ { @@ -41790,6 +41985,22 @@ data: "regex": "/(.*)/", "type": "query" }, + { + "datasource": { + "type": "prometheus", + "uid": "${datasource}" + }, + "includeAll": true, + "label": "DNSPolicy", + "multi": true, + "name": "dnspolicy", + "query": { + "query": "label_values(gatewayapi_dnspolicy_created, name)", + "refId": "StandardVariableQuery" + }, + "regex": "/(.*)/", + "type": "query" + }, { "datasource": { "type": "prometheus", @@ -41850,7 +42061,7 @@ data: } kind: ConfigMap metadata: - name: grafana-policies-tc54tb8694 + name: grafana-policies-9hc77dfk2b namespace: monitoring --- @@ -44605,7 +44816,7 @@ spec: name: grafana-tlsroutes - configMap: defaultMode: 420 - name: grafana-policies-tc54tb8694 + name: grafana-policies-9hc77dfk2b name: grafana-policies - configMap: defaultMode: 420 diff --git a/config/kuadrant/clusterrole-patch.yaml b/config/kuadrant/clusterrole-patch.yaml index 029dbde..3991751 100644 --- a/config/kuadrant/clusterrole-patch.yaml +++ b/config/kuadrant/clusterrole-patch.yaml @@ -15,6 +15,7 @@ - "kuadrant.io" resources: - tlspolicies + - dnspolicies - ratelimitpolicies - authpolicies verbs: diff --git a/config/kuadrant/crd/kuadrant.io_dnspolicies.yaml b/config/kuadrant/crd/kuadrant.io_dnspolicies.yaml new file mode 100644 index 0000000..2c0aff3 --- /dev/null +++ b/config/kuadrant/crd/kuadrant.io_dnspolicies.yaml @@ -0,0 +1,358 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.10.0 + creationTimestamp: null + name: dnspolicies.kuadrant.io +spec: + group: kuadrant.io + names: + kind: DNSPolicy + listKind: DNSPolicyList + plural: dnspolicies + singular: dnspolicy + scope: Namespaced + versions: + - additionalPrinterColumns: + - description: DNSPolicy ready. + jsonPath: .status.conditions[?(@.type=="Ready")].status + name: Ready + type: string + name: v1alpha1 + schema: + openAPIV3Schema: + description: DNSPolicy is the Schema for the dnspolicies API + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: DNSPolicySpec defines the desired state of DNSPolicy + properties: + healthCheck: + description: HealthCheckSpec configures health checks in the DNS provider. + By default this health check will be applied to each unique DNS + A Record for the listeners assigned to the target gateway + properties: + additionalHeadersRef: + properties: + name: + type: string + required: + - name + type: object + allowInsecureCertificates: + type: boolean + endpoint: + type: string + expectedResponses: + items: + type: integer + type: array + failureThreshold: + type: integer + interval: + type: string + port: + type: integer + protocol: + description: HealthProtocol represents the protocol to use when + making a health check request + type: string + type: object + loadBalancing: + properties: + geo: + properties: + defaultGeo: + description: "defaultGeo is the country/continent/region code + to use when no other can be determined for a dns target + cluster. \n The values accepted are determined by the target + dns provider, please refer to the appropriate docs below. + \n Route53: https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/resource-record-sets-values-geo.html" + type: string + type: object + weighted: + properties: + custom: + items: + properties: + selector: + description: 'Label selector used by MGC to match resource + storing custom weight attribute values e.g. kuadrant.io/lb-attribute-custom-weight: + AWS' + properties: + matchExpressions: + description: matchExpressions is a list of label + selector requirements. The requirements are ANDed. + items: + description: A label selector requirement is a + selector that contains values, a key, and an + operator that relates the key and values. + properties: + key: + description: key is the label key that the + selector applies to. + type: string + operator: + description: operator represents a key's relationship + to a set of values. Valid operators are + In, NotIn, Exists and DoesNotExist. + type: string + values: + description: values is an array of string + values. If the operator is In or NotIn, + the values array must be non-empty. If the + operator is Exists or DoesNotExist, the + values array must be empty. This array is + replaced during a strategic merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} + pairs. A single {key,value} in the matchLabels + map is equivalent to an element of matchExpressions, + whose key field is "key", the operator is "In", + and the values array contains only "value". The + requirements are ANDed. + type: object + type: object + x-kubernetes-map-type: atomic + weight: + minimum: 0 + type: integer + required: + - selector + type: object + type: array + defaultWeight: + default: 120 + description: "defaultWeight is the record weight to use when + no other can be determined for a dns target cluster. \n + The maximum value accepted is determined by the target dns + provider, please refer to the appropriate docs below. \n + Route53: https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/routing-policy-weighted.html" + minimum: 0 + type: integer + type: object + type: object + targetRef: + description: PolicyTargetReference identifies an API object to apply + policy to. This should be used as part of Policy resources that + can target Gateway API resources. For more information on how this + policy attachment model works, and a sample Policy resource, refer + to the policy attachment documentation for Gateway API. + properties: + group: + description: Group is the group of the target resource. + maxLength: 253 + pattern: ^$|^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$ + type: string + kind: + description: Kind is kind of the target resource. + maxLength: 63 + minLength: 1 + pattern: ^[a-zA-Z]([-a-zA-Z0-9]*[a-zA-Z0-9])?$ + type: string + name: + description: Name is the name of the target resource. + maxLength: 253 + minLength: 1 + type: string + namespace: + description: Namespace is the namespace of the referent. When + unspecified, the local namespace is inferred. Even when policy + targets a resource in a different namespace, it MUST only apply + to traffic originating from the same namespace as the policy. + maxLength: 63 + minLength: 1 + pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$ + type: string + required: + - group + - kind + - name + type: object + required: + - targetRef + type: object + status: + description: DNSPolicyStatus defines the observed state of DNSPolicy + properties: + conditions: + description: "conditions are any conditions associated with the policy + \n If configuring the policy fails, the \"Failed\" condition will + be set with a reason and message describing the cause of the failure." + items: + description: "Condition contains details for one aspect of the current + state of this API Resource. --- This struct is intended for direct + use as an array at the field path .status.conditions. For example, + \n type FooStatus struct{ // Represents the observations of a + foo's current state. // Known .status.conditions.type are: \"Available\", + \"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge + // +listType=map // +listMapKey=type Conditions []metav1.Condition + `json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\" + protobuf:\"bytes,1,rep,name=conditions\"` \n // other fields }" + properties: + lastTransitionTime: + description: lastTransitionTime is the last time the condition + transitioned from one status to another. This should be when + the underlying condition changed. If that is not known, then + using the time when the API field changed is acceptable. + format: date-time + type: string + message: + description: message is a human readable message indicating + details about the transition. This may be an empty string. + maxLength: 32768 + type: string + observedGeneration: + description: observedGeneration represents the .metadata.generation + that the condition was set based upon. For instance, if .metadata.generation + is currently 12, but the .status.conditions[x].observedGeneration + is 9, the condition is out of date with respect to the current + state of the instance. + format: int64 + minimum: 0 + type: integer + reason: + description: reason contains a programmatic identifier indicating + the reason for the condition's last transition. Producers + of specific condition types may define expected values and + meanings for this field, and whether the values are considered + a guaranteed API. The value should be a CamelCase string. + This field may not be empty. + maxLength: 1024 + minLength: 1 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + description: status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown + type: string + type: + description: type of condition in CamelCase or in foo.example.com/CamelCase. + --- Many .condition.type values are consistent across resources + like Available, but because arbitrary conditions can be useful + (see .node.status.conditions), the ability to deconflict is + important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt) + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + required: + - lastTransitionTime + - message + - reason + - status + - type + type: object + type: array + healthCheck: + properties: + conditions: + items: + description: "Condition contains details for one aspect of the + current state of this API Resource. --- This struct is intended + for direct use as an array at the field path .status.conditions. + \ For example, \n type FooStatus struct{ // Represents the + observations of a foo's current state. // Known .status.conditions.type + are: \"Available\", \"Progressing\", and \"Degraded\" // +patchMergeKey=type + // +patchStrategy=merge // +listType=map // +listMapKey=type + Conditions []metav1.Condition `json:\"conditions,omitempty\" + patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"` + \n // other fields }" + properties: + lastTransitionTime: + description: lastTransitionTime is the last time the condition + transitioned from one status to another. This should be + when the underlying condition changed. If that is not + known, then using the time when the API field changed + is acceptable. + format: date-time + type: string + message: + description: message is a human readable message indicating + details about the transition. This may be an empty string. + maxLength: 32768 + type: string + observedGeneration: + description: observedGeneration represents the .metadata.generation + that the condition was set based upon. For instance, if + .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration + is 9, the condition is out of date with respect to the + current state of the instance. + format: int64 + minimum: 0 + type: integer + reason: + description: reason contains a programmatic identifier indicating + the reason for the condition's last transition. Producers + of specific condition types may define expected values + and meanings for this field, and whether the values are + considered a guaranteed API. The value should be a CamelCase + string. This field may not be empty. + maxLength: 1024 + minLength: 1 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + description: status of the condition, one of True, False, + Unknown. + enum: + - "True" + - "False" + - Unknown + type: string + type: + description: type of condition in CamelCase or in foo.example.com/CamelCase. + --- Many .condition.type values are consistent across + resources like Available, but because arbitrary conditions + can be useful (see .node.status.conditions), the ability + to deconflict is important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt) + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + required: + - lastTransitionTime + - message + - reason + - status + - type + type: object + type: array + type: object + observedGeneration: + description: observedGeneration is the most recently observed generation + of the DNSPolicy. When the DNSPolicy is updated, the controller + updates the corresponding configuration. If an update fails, that + failure is recorded in the status condition + format: int64 + type: integer + type: object + type: object + served: true + storage: true + subresources: + status: {} diff --git a/config/kuadrant/kuadrant.yaml b/config/kuadrant/kuadrant.yaml index 3b98428..509408e 100644 --- a/config/kuadrant/kuadrant.yaml +++ b/config/kuadrant/kuadrant.yaml @@ -42,6 +42,25 @@ status: status: "True" type: Ready --- +apiVersion: kuadrant.io/v1alpha1 +kind: DNSPolicy +metadata: + name: external + namespace: istio-system +spec: + targetRef: + group: gateway.networking.k8s.io + kind: Gateway + name: external +status: + conditions: + - lastTransitionTime: "2023-11-13T17:11:41Z" + message: Gateway is DNS Enabled + reason: GatewayDNSEnabled + status: "True" + type: Ready + observedGeneration: 1 +--- apiVersion: kuadrant.io/v1beta2 kind: RateLimitPolicy metadata: diff --git a/src/dashboards/policies.jsonnet b/src/dashboards/policies.jsonnet index b366407..ca6d465 100644 --- a/src/dashboards/policies.jsonnet +++ b/src/dashboards/policies.jsonnet @@ -4,23 +4,28 @@ local var = import 'lib/gwapi/variables.libsonnet'; gwapi.dashboard('Policies', 'gatewayapipolicies', [ var.routes('tlspolicy', 'TLSPolicy'), + var.routes('dnspolicy', 'DNSPolicy'), var.routes('ratelimitpolicy', 'RateLimitPolicy'), var.routes('authpolicy', 'AuthPolicy'), var.routes('backendtlspolicy', 'BackendTLSPolicy') ]) + g.dashboard.withPanels([ gwapi.row('TLSPolicy', 1, 24, 0, 0), - gwapi.stat('Total', 3, 2, 0, 1, 'Total number of TLSPolicy across all clusters', 'count(gatewayapi_tlspolicy_status{name=~"${tlspolicy}"})'), - gwapi.stat('Ready', 3, 2, 2, 1, 'Total TLSPolicy with an Ready state', 'count(gatewayapi_tlspolicy_status{type="Ready", name=~"${tlspolicy}"})'), - gwapi.policyPanel('TLSPolicy',6,10,4,1,'gatewayapi_tlspolicy_target_info{name=~"${tlspolicy}"}', 'Target Name', 'Gateway Details', '/d/gatewayapigateways/gateway-api-state-gateways?var-gateway=${__value.text}'), - gwapi.row('RateLimitPolicy', 1, 24, 0, 2), - gwapi.stat('Total', 3, 2, 0, 3, 'Total number of RateLimitPolicy across all clusters', 'count(gatewayapi_ratelimitpolicy_status{name=~"${ratelimitpolicy}"})'), - gwapi.stat('Available', 3, 2, 2, 3, 'Total RateLimitPolicy with an Available state', 'count(gatewayapi_ratelimitpolicy_status{type="Available", name=~"${ratelimitpolicy}"})'), - gwapi.policyPanel('RateLimitPolicy',6,10,4,7,'gatewayapi_ratelimitpolicy_target_info{name=~"${ratelimitpolicy}"}', 'Target Name', 'HTTPRoute Details', '/d/gatewayapihttproutes/gateway-api-state-httproutes?var-httproute=${__value.text}'), - gwapi.row('AuthPolicy', 1, 24, 0, 8), - gwapi.stat('Total', 3, 2, 0, 9, 'Total number of AuthPolicy across all clusters', 'count(gatewayapi_authpolicy_status{name=~"${authpolicy}"})'), - gwapi.stat('Available', 3, 2, 2, 9, 'Total AuthPolicy with an Available state', 'count(gatewayapi_authpolicy_status{type="Available", name=~"${authpolicy}"})'), - gwapi.policyPanel('AuthPolicy',6,10,4,9,'gatewayapi_authpolicy_target_info{name=~"${authpolicy}"}', 'Target Name', 'HTTPRoute Details', '/d/gatewayapihttproutes/gateway-api-state-httproutes?var-httproute=${__value.text}'), - gwapi.row('BackendTLSPolicy', 1, 24, 0, 10), - gwapi.policyPanel('BackendTLSPolicy',6,10,4,10,'gatewayapi_backendtlspolicy_target_info{name=~"${backendtlspolicy}"}'), + gwapi.stat('Total', 3, 2, 0, 0, 'Total number of TLSPolicy across all clusters', 'count(gatewayapi_tlspolicy_status{name=~"${tlspolicy}"})'), + gwapi.stat('Ready', 3, 2, 2, 0, 'Total TLSPolicy with an Ready state', 'count(gatewayapi_tlspolicy_status{type="Ready", name=~"${tlspolicy}"})'), + gwapi.policyPanel('TLSPolicy',6,10,4,0,'gatewayapi_tlspolicy_target_info{name=~"${tlspolicy}"}', 'Target Name', 'Gateway Details', '/d/gatewayapigateways/gateway-api-state-gateways?var-gateway=${__value.text}'), + gwapi.row('DNSPolicy', 1, 24, 0, 2), + gwapi.stat('Total', 3, 2, 0, 2, 'Total number of DNSPolicy across all clusters', 'count(gatewayapi_dnspolicy_status{name=~"${dnspolicy}"})'), + gwapi.stat('Ready', 3, 2, 2, 2, 'Total DNSPolicy with an Ready state', 'count(gatewayapi_dnspolicy_status{type="Ready", name=~"${dnspolicy}"})'), + gwapi.policyPanel('DNSPolicy',6,10,4,2,'gatewayapi_dnspolicy_target_info{name=~"${dnspolicy}"}', 'Target Name', 'Gateway Details', '/d/gatewayapigateways/gateway-api-state-gateways?var-gateway=${__value.text}'), + gwapi.row('RateLimitPolicy', 1, 24, 0, 4), + gwapi.stat('Total', 3, 2, 0, 4, 'Total number of RateLimitPolicy across all clusters', 'count(gatewayapi_ratelimitpolicy_status{name=~"${ratelimitpolicy}"})'), + gwapi.stat('Available', 3, 2, 2, 4, 'Total RateLimitPolicy with an Available state', 'count(gatewayapi_ratelimitpolicy_status{type="Available", name=~"${ratelimitpolicy}"})'), + gwapi.policyPanel('RateLimitPolicy',6,10,4,4,'gatewayapi_ratelimitpolicy_target_info{name=~"${ratelimitpolicy}"}', 'Target Name', 'HTTPRoute Details', '/d/gatewayapihttproutes/gateway-api-state-httproutes?var-httproute=${__value.text}'), + gwapi.row('AuthPolicy', 1, 24, 0, 6), + gwapi.stat('Total', 3, 2, 0, 6, 'Total number of AuthPolicy across all clusters', 'count(gatewayapi_authpolicy_status{name=~"${authpolicy}"})'), + gwapi.stat('Available', 3, 2, 2, 6, 'Total AuthPolicy with an Available state', 'count(gatewayapi_authpolicy_status{type="Available", name=~"${authpolicy}"})'), + gwapi.policyPanel('AuthPolicy',6,10,4,6,'gatewayapi_authpolicy_target_info{name=~"${authpolicy}"}', 'Target Name', 'HTTPRoute Details', '/d/gatewayapihttproutes/gateway-api-state-httproutes?var-httproute=${__value.text}'), + gwapi.row('BackendTLSPolicy', 1, 24, 0, 8), + gwapi.policyPanel('BackendTLSPolicy',6,10,4,8,'gatewayapi_backendtlspolicy_target_info{name=~"${backendtlspolicy}"}'), ]) \ No newline at end of file diff --git a/tests/e2e/main_test.go b/tests/e2e/main_test.go index 53e3a5f..60a332a 100644 --- a/tests/e2e/main_test.go +++ b/tests/e2e/main_test.go @@ -588,6 +588,45 @@ func testTLSPolicy(t *testing.T, metrics map[string][][]string) { expectEqual(t, tlspolicy1Status1Labels["type"], "Ready", "gatewayapi_tlspolicy_status__1 type") } +func testDNSPolicy(t *testing.T, metrics map[string][][]string) { + // gatewayapi_dnspolicy_created + dnspolicyCreated := metrics["gatewayapi_dnspolicy_created"] + dnspolicy1Created := dnspolicyCreated[0] + expectValidTimestampInPast(t, dnspolicy1Created[3], "gatewayapi_dnspolicy_created__1 value") + dnspolicy1CreatedLabels := parseLabels(string(dnspolicy1Created[2])) + expectEqual(t, dnspolicy1CreatedLabels["customresource_group"], "kuadrant.io", "gatewayapi_dnspolicy_created__1 customresource_group") + expectEqual(t, dnspolicy1CreatedLabels["customresource_kind"], "DNSPolicy", "gatewayapi_dnspolicy_created__1 customresource_kind") + expectEqual(t, dnspolicy1CreatedLabels["customresource_version"], "v1alpha1", "gatewayapi_dnspolicy_created__1 customresource_version") + expectEqual(t, dnspolicy1CreatedLabels["name"], "testdnspolicy1", "gatewayapi_dnspolicy_created__1 name") + expectEqual(t, dnspolicy1CreatedLabels["namespace"], "default", "gatewayapi_dnspolicy_created__1 namespace") + + //gatewayapi_dnspolicy_target_info + dnspolicyParentInfo := metrics["gatewayapi_dnspolicy_target_info"] + dnspolicy1ParentInfo1 := dnspolicyParentInfo[0] + expectEqual(t, dnspolicy1ParentInfo1[3], "1", "gatewayapi_dnspolicy_target_info__1 value") + dnspolicy1ParentInfo1Labels := parseLabels(string(dnspolicy1ParentInfo1[2])) + expectEqual(t, dnspolicy1ParentInfo1Labels["customresource_group"], "kuadrant.io", "gatewayapi_dnspolicy_target_info__1 customresource_group") + expectEqual(t, dnspolicy1ParentInfo1Labels["customresource_kind"], "DNSPolicy", "gatewayapi_dnspolicy_target_info__1 customresource_kind") + expectEqual(t, dnspolicy1ParentInfo1Labels["customresource_version"], "v1alpha1", "gatewayapi_dnspolicy_target_info__1 customresource_version") + expectEqual(t, dnspolicy1ParentInfo1Labels["name"], "testdnspolicy1", "gatewayapi_dnspolicy_target_info__1 name") + expectEqual(t, dnspolicy1ParentInfo1Labels["namespace"], "default", "gatewayapi_dnspolicy_target_info__1 namespace") + expectEqual(t, dnspolicy1ParentInfo1Labels["target_group"], "gateway.networking.k8s.io", "gatewayapi_dnspolicy_target_info__1 target_group") + expectEqual(t, dnspolicy1ParentInfo1Labels["target_kind"], "Gateway", "gatewayapi_dnspolicy_target_info__1 target_kind") + expectEqual(t, dnspolicy1ParentInfo1Labels["target_name"], "testgateway1", "gatewayapi_dnspolicy_target_info__1 target_name") + + //gatewayapi_dnspolicy_status + dnspolicyStatus := metrics["gatewayapi_dnspolicy_status"] + dnspolicy1Status1 := dnspolicyStatus[0] + expectEqual(t, dnspolicy1Status1[3], "1", "gatewayapi_dnspolicy_status__1 value") + dnspolicy1Status1Labels := parseLabels(string(dnspolicy1Status1[2])) + expectEqual(t, dnspolicy1Status1Labels["customresource_group"], "kuadrant.io", "gatewayapi_dnspolicy_status__1 customresource_group") + expectEqual(t, dnspolicy1Status1Labels["customresource_kind"], "DNSPolicy", "gatewayapi_dnspolicy_status__1 customresource_kind") + expectEqual(t, dnspolicy1Status1Labels["customresource_version"], "v1alpha1", "gatewayapi_dnspolicy_status__1 customresource_version") + expectEqual(t, dnspolicy1Status1Labels["name"], "testdnspolicy1", "gatewayapi_dnspolicy_status__1 name") + expectEqual(t, dnspolicy1Status1Labels["namespace"], "default", "gatewayapi_dnspolicy_status__1 namespace") + expectEqual(t, dnspolicy1Status1Labels["type"], "Ready", "gatewayapi_dnspolicy_status__1 type") +} + func testAuthPolicy(t *testing.T, metrics map[string][][]string) { // gatewayapi_authpolicy_created authpolicyCreated := metrics["gatewayapi_authpolicy_created"] diff --git a/tests/manifests/testdnspolicy.yaml b/tests/manifests/testdnspolicy.yaml new file mode 100644 index 0000000..129e463 --- /dev/null +++ b/tests/manifests/testdnspolicy.yaml @@ -0,0 +1,18 @@ +apiVersion: kuadrant.io/v1alpha1 +kind: DNSPolicy +metadata: + name: testdnspolicy1 + namespace: default +spec: + targetRef: + group: gateway.networking.k8s.io + kind: Gateway + name: testgateway1 +status: + conditions: + - lastTransitionTime: "2023-11-13T17:11:41Z" + message: Gateway is DNS Enabled + reason: GatewayDNSEnabled + status: "True" + type: Ready + observedGeneration: 1 \ No newline at end of file