From 16df35e05f3e2e62b531b941ef99d6ddbc246f6d Mon Sep 17 00:00:00 2001 From: Sebastian Florek Date: Thu, 4 Apr 2024 14:37:45 +0200 Subject: [PATCH] fix: api schema and update kong chart config (#8879) * fix api endpoint type and update kong chart config * update ingress and cronjob api docs --- charts/kubernetes-dashboard/values.yaml | 3 ++ modules/api/pkg/handler/apihandler.go | 8 ++-- modules/api/schema/swagger.json | 56 ++++++++++++++----------- modules/web/schema/schema.graphql | 10 +++-- 4 files changed, 46 insertions(+), 31 deletions(-) diff --git a/charts/kubernetes-dashboard/values.yaml b/charts/kubernetes-dashboard/values.yaml index 652c68481075..6f766198ebdd 100644 --- a/charts/kubernetes-dashboard/values.yaml +++ b/charts/kubernetes-dashboard/values.yaml @@ -335,8 +335,11 @@ metrics-server: ## for our all containers. kong: enabled: true + ## Configuration reference: https://docs.konghq.com/gateway/3.6.x/reference/configuration env: dns_order: A,CNAME,LAST,SRV + plugins: 'off' + nginx_worker_processes: 1 ingressController: enabled: false dblessConfig: diff --git a/modules/api/pkg/handler/apihandler.go b/modules/api/pkg/handler/apihandler.go index e489188308af..87322e13672c 100644 --- a/modules/api/pkg/handler/apihandler.go +++ b/modules/api/pkg/handler/apihandler.go @@ -63,6 +63,7 @@ import ( "k8s.io/dashboard/api/pkg/resource/role" "k8s.io/dashboard/api/pkg/resource/rolebinding" "k8s.io/dashboard/api/pkg/resource/secret" + "k8s.io/dashboard/api/pkg/resource/service" resourceService "k8s.io/dashboard/api/pkg/resource/service" "k8s.io/dashboard/api/pkg/resource/serviceaccount" "k8s.io/dashboard/api/pkg/resource/statefulset" @@ -258,8 +259,8 @@ func CreateHTTPAPIHandler(iManager integration.Manager) (*restful.Container, err Doc("returns a list of Services for ReplicaSet"). Param(apiV1Ws.PathParameter("namespace", "namespace of the ReplicaSet")). Param(apiV1Ws.PathParameter("replicaSet", "name of the ReplicaSets")). - Writes(pod.PodList{}). - Returns(http.StatusOK, "OK", pod.PodList{})) + Writes(service.ServiceList{}). + Returns(http.StatusOK, "OK", service.ServiceList{})) apiV1Ws.Route( apiV1Ws.GET("/replicaset/{namespace}/{replicaSet}/event").To(apiHandler.handleGetReplicaSetEvents). // docs @@ -551,6 +552,7 @@ func CreateHTTPAPIHandler(iManager integration.Manager) (*restful.Container, err Doc("returns a list of Jobs for CronJob"). Param(apiV1Ws.PathParameter("namespace", "namespace of the CronJob")). Param(apiV1Ws.PathParameter("name", "name of the CronJob")). + Param(apiV1Ws.QueryParameter("active", "filter related Jobs by active status")). Writes(job.JobList{}). Returns(http.StatusOK, "OK", job.JobList{})) apiV1Ws.Route( @@ -777,7 +779,7 @@ func CreateHTTPAPIHandler(iManager integration.Manager) (*restful.Container, err // docs Doc("returns a list of Events for Ingress"). Param(apiV1Ws.PathParameter("namespace", "namespace of the Ingress")). - Param(apiV1Ws.PathParameter("name", "name of the Ingress")). + Param(apiV1Ws.PathParameter("ingress", "name of the Ingress")). Writes(common.EventList{}). Returns(http.StatusOK, "OK", common.EventList{})) diff --git a/modules/api/schema/swagger.json b/modules/api/schema/swagger.json index 3024eb2eef8f..a883e1dbd5a0 100644 --- a/modules/api/schema/swagger.json +++ b/modules/api/schema/swagger.json @@ -1969,6 +1969,12 @@ "name": "name", "in": "path", "required": true + }, + { + "type": "string", + "description": "filter related Jobs by active status", + "name": "active", + "in": "query" } ], "responses": { @@ -3731,7 +3737,7 @@ { "type": "string", "description": "name of the Ingress", - "name": "name", + "name": "ingress", "in": "path", "required": true } @@ -6624,7 +6630,7 @@ "200": { "description": "OK", "schema": { - "$ref": "#/definitions/pod.PodList" + "$ref": "#/definitions/service.ServiceList" } } } @@ -9918,13 +9924,13 @@ }, "cronjob.CronJobDetail": { "required": [ - "containerImages", "objectMeta", "typeMeta", "schedule", "suspend", "active", "lastSchedule", + "containerImages", "concurrencyPolicy", "startingDeadlineSeconds", "errors" @@ -10049,11 +10055,11 @@ }, "daemonset.DaemonSetDetail": { "required": [ + "objectMeta", "typeMeta", "podInfo", "containerImages", "initContainerImages", - "objectMeta", "errors" ], "properties": { @@ -10593,13 +10599,13 @@ }, "horizontalpodautoscaler.HorizontalPodAutoscalerDetail": { "required": [ - "objectMeta", "typeMeta", "scaleTargetRef", "minReplicas", "maxReplicas", "currentCPUUtilizationPercentage", "targetCPUUtilizationPercentage", + "objectMeta", "currentReplicas", "desiredReplicas", "lastScaleTime" @@ -10876,13 +10882,13 @@ }, "job.JobDetail": { "required": [ - "initContainerImages", - "parallelism", - "jobStatus", "objectMeta", "typeMeta", "podInfo", "containerImages", + "initContainerImages", + "parallelism", + "jobStatus", "completions", "errors" ], @@ -11132,9 +11138,9 @@ }, "namespace.NamespaceDetail": { "required": [ + "phase", "objectMeta", "typeMeta", - "phase", "resourceQuotaList", "resourceLimits", "errors" @@ -11216,8 +11222,8 @@ }, "networkpolicy.NetworkPolicyDetail": { "required": [ - "typeMeta", "objectMeta", + "typeMeta", "podSelector", "errors" ], @@ -11552,16 +11558,16 @@ }, "persistentvolume.PersistentVolumeDetail": { "required": [ - "objectMeta", "capacity", - "storageClass", + "accessModes", + "mountOptions", "status", - "reason", "typeMeta", - "accessModes", "reclaimPolicy", - "mountOptions", + "storageClass", "claim", + "reason", + "objectMeta", "message", "persistentVolumeSource" ], @@ -11679,13 +11685,13 @@ }, "persistentvolumeclaim.PersistentVolumeClaimDetail": { "required": [ - "storageClass", - "objectMeta", - "typeMeta", "status", "volume", "capacity", - "accessModes" + "accessModes", + "storageClass", + "objectMeta", + "typeMeta" ], "properties": { "accessModes": { @@ -12089,11 +12095,11 @@ }, "replicaset.ReplicaSetDetail": { "required": [ + "initContainerImages", "objectMeta", "typeMeta", "podInfo", "containerImages", - "initContainerImages", "selector", "horizontalPodAutoscalerList", "errors" @@ -12203,11 +12209,11 @@ }, "replicationcontroller.ReplicationControllerDetail": { "required": [ - "containerImages", - "initContainerImages", "objectMeta", "typeMeta", "podInfo", + "containerImages", + "initContainerImages", "labelSelector", "errors" ], @@ -12410,8 +12416,8 @@ }, "role.RoleDetail": { "required": [ - "objectMeta", "typeMeta", + "objectMeta", "rules", "errors" ], @@ -13028,12 +13034,12 @@ }, "types.CustomResourceDefinitionDetail": { "required": [ + "objectMeta", + "typeMeta", "group", "scope", "names", "established", - "objectMeta", - "typeMeta", "conditions", "objects", "subresources", diff --git a/modules/web/schema/schema.graphql b/modules/web/schema/schema.graphql index c3d453a2a355..61eb2a000bda 100755 --- a/modules/web/schema/schema.graphql +++ b/modules/web/schema/schema.graphql @@ -346,7 +346,9 @@ type Query { metricNames: String """Aggregations to be performed for each metric (default: sum)""" aggregations: String - ): job_JobList @httpOperation(subgraph: "api", path: "/api/v1/cronjob/{args.namespace}/{args.name}/job", operationSpecificHeaders: "{\"Content-Type\":\"application/json\",\"Accept\":\"application/json\"}", httpMethod: GET, queryParamArgMap: "{\"filterBy\":\"filterBy\",\"sortBy\":\"sortBy\",\"itemsPerPage\":\"itemsPerPage\",\"page\":\"page\",\"metricNames\":\"metricNames\",\"aggregations\":\"aggregations\"}") + """filter related Jobs by active status""" + active: String + ): job_JobList @httpOperation(subgraph: "api", path: "/api/v1/cronjob/{args.namespace}/{args.name}/job", operationSpecificHeaders: "{\"Content-Type\":\"application/json\",\"Accept\":\"application/json\"}", httpMethod: GET, queryParamArgMap: "{\"filterBy\":\"filterBy\",\"sortBy\":\"sortBy\",\"itemsPerPage\":\"itemsPerPage\",\"page\":\"page\",\"metricNames\":\"metricNames\",\"aggregations\":\"aggregations\",\"active\":\"active\"}") """generates a one-time CSRF token that can be used by POST request""" handleGetCsrfToken( """action name to generate CSRF token for""" @@ -654,6 +656,8 @@ type Query { handleGetIngressEvent( """namespace of the Ingress""" namespace: String! + """name of the Ingress""" + ingress: String! """ Comma delimited string used to apply filtering: 'propertyName,filterValue' """ @@ -668,7 +672,7 @@ type Query { metricNames: String """Aggregations to be performed for each metric (default: sum)""" aggregations: String - ): common_EventList @httpOperation(subgraph: "api", path: "/api/v1/ingress/{args.namespace}/{ingress}/event", operationSpecificHeaders: "{\"Content-Type\":\"application/json\",\"Accept\":\"application/json\"}", httpMethod: GET, queryParamArgMap: "{\"filterBy\":\"filterBy\",\"sortBy\":\"sortBy\",\"itemsPerPage\":\"itemsPerPage\",\"page\":\"page\",\"metricNames\":\"metricNames\",\"aggregations\":\"aggregations\"}") + ): common_EventList @httpOperation(subgraph: "api", path: "/api/v1/ingress/{args.namespace}/{args.ingress}/event", operationSpecificHeaders: "{\"Content-Type\":\"application/json\",\"Accept\":\"application/json\"}", httpMethod: GET, queryParamArgMap: "{\"filterBy\":\"filterBy\",\"sortBy\":\"sortBy\",\"itemsPerPage\":\"itemsPerPage\",\"page\":\"page\",\"metricNames\":\"metricNames\",\"aggregations\":\"aggregations\"}") """returns detailed information about Ingress""" handleGetIngressDetail( """namespace of the Ingress""" @@ -1366,7 +1370,7 @@ type Query { metricNames: String """Aggregations to be performed for each metric (default: sum)""" aggregations: String - ): pod_PodList @httpOperation(subgraph: "api", path: "/api/v1/replicaset/{args.namespace}/{args.replicaSet}/service", operationSpecificHeaders: "{\"Content-Type\":\"application/json\",\"Accept\":\"application/json\"}", httpMethod: GET, queryParamArgMap: "{\"filterBy\":\"filterBy\",\"sortBy\":\"sortBy\",\"itemsPerPage\":\"itemsPerPage\",\"page\":\"page\",\"metricNames\":\"metricNames\",\"aggregations\":\"aggregations\"}") + ): service_ServiceList @httpOperation(subgraph: "api", path: "/api/v1/replicaset/{args.namespace}/{args.replicaSet}/service", operationSpecificHeaders: "{\"Content-Type\":\"application/json\",\"Accept\":\"application/json\"}", httpMethod: GET, queryParamArgMap: "{\"filterBy\":\"filterBy\",\"sortBy\":\"sortBy\",\"itemsPerPage\":\"itemsPerPage\",\"page\":\"page\",\"metricNames\":\"metricNames\",\"aggregations\":\"aggregations\"}") """returns a list of ReplicationController in a namespace""" handleGetReplicationControllerList( """