From de4b3eaa767ca7e0f1e94f6a6a4b9283b53d1094 Mon Sep 17 00:00:00 2001 From: Matheus Moraes Date: Wed, 15 Mar 2023 16:22:08 -0300 Subject: [PATCH] remove server component (#208) * refactor: remove server component * fix makefile generate cmd description * remove openapi.yaml --- .github/workflows/docker.yaml | 2 - Dockerfile.server | 42 ----- Makefile | 8 +- cmd/server/main.go | 73 -------- go.mod | 2 - go.sum | 4 - hack/make/misc.mk | 1 - handlers/base.go | 49 ------ handlers/cluster.go | 75 --------- handlers/clusters.go | 57 ------- handlers/health.go | 21 --- handlers/issues.go | 58 ------- openapi.yaml | 308 ---------------------------------- 13 files changed, 2 insertions(+), 698 deletions(-) delete mode 100644 Dockerfile.server delete mode 100644 cmd/server/main.go delete mode 100644 handlers/base.go delete mode 100644 handlers/cluster.go delete mode 100644 handlers/clusters.go delete mode 100644 handlers/health.go delete mode 100644 handlers/issues.go delete mode 100644 openapi.yaml diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index abefb309..7ee1073c 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -20,8 +20,6 @@ jobs: include: - dockerfile: Dockerfile image: operator - - dockerfile: Dockerfile.server - image: server - dockerfile: Dockerfile.worker image: worker steps: diff --git a/Dockerfile.server b/Dockerfile.server deleted file mode 100644 index 96887d2d..00000000 --- a/Dockerfile.server +++ /dev/null @@ -1,42 +0,0 @@ -# Copyright 2022 Undistro Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Build the server binary -FROM golang:1.17 as builder - -WORKDIR /workspace -# Copy the Go Modules manifests -COPY go.mod go.mod -COPY go.sum go.sum -# cache deps before building and copying source so that we don't need to re-download as much -# and so that source changes don't invalidate our downloaded layer -RUN go mod download - -# Copy the go source -COPY cmd/server/main.go cmd/server/main.go -COPY apis/ apis/ -COPY pkg/ pkg/ -COPY handlers/ handlers/ - -# Build -RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o server cmd/server/main.go - -# Use distroless as minimal base image to package the manager binary -# Refer to https://github.com/GoogleContainerTools/distroless for more details -FROM gcr.io/distroless/static:nonroot -WORKDIR / -COPY --from=builder /workspace/server . -USER 65533:65533 - -ENTRYPOINT ["/server"] diff --git a/Makefile b/Makefile index f33a4d04..e2c1e8b8 100644 --- a/Makefile +++ b/Makefile @@ -58,7 +58,7 @@ hack/scripts/gen_zora_view_kubeconfig.sh docs/targetcluster.sh: hack/scripts/m4/ script-consitency: hack/scripts/gen_zora_view_kubeconfig.sh docs/targetcluster.sh -generate: controller-gen script-consitency license ## Generate clientset and code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations. +generate: controller-gen script-consitency license ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations. ${CONTROLLER_GEN} object:headerFile="hack/boilerplate.go.txt" paths="./..." clientset-gen: ## Generate clientset @@ -78,19 +78,15 @@ clientset-gen: ## Generate clientset build: generate fmt vet ## Build manager binary. go build -o bin/manager main.go - go build -o bin/server cmd/server/main.go go build -o bin/worker worker/main.go run: install manifests generate ## Run a controller from your host. go run ./main.go -default-plugins-names ${PLUGINS} -worker-image ${WORKER_IMG} -run-server: install manifests generate ## Run Zora's server locally. - go run ./cmd/server/main.go docker-build: test ## Build manager docker image. docker build -t ${IMG} -f ${DOCKERFILE} . -docker-build-all: docker-build ## Build Docker images for all components. +docker-build-worker: docker-build ## Build Docker images for all components. ${MAKE} IMG=${WORKER_IMG} DOCKERFILE=Dockerfile.worker docker-build - ${MAKE} IMG=server:${TAG} DOCKERFILE=Dockerfile.server docker-build ##@ Deployment diff --git a/cmd/server/main.go b/cmd/server/main.go deleted file mode 100644 index 191ec740..00000000 --- a/cmd/server/main.go +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2022 Undistro Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package main - -import ( - "flag" - "fmt" - "net/http" - "os" - "time" - - // Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.) - // to ensure that exec-entrypoint and run can make use of them. - _ "k8s.io/client-go/plugin/pkg/client/auth" - - "github.com/go-chi/chi/v5" - "github.com/ory/graceful" - "go.uber.org/zap/zapcore" - ctrl "sigs.k8s.io/controller-runtime" - "sigs.k8s.io/controller-runtime/pkg/log/zap" - - "github.com/undistro/zora/handlers" - "github.com/undistro/zora/pkg/clientset/versioned" -) - -var log = ctrl.Log.WithName("server") - -func main() { - var port int - flag.IntVar(&port, "port", 3000, "server port") - opts := zap.Options{Development: true, TimeEncoder: zapcore.TimeEncoderOfLayout(time.RFC3339)} - opts.BindFlags(flag.CommandLine) - flag.Parse() - logger := zap.New(zap.UseFlagOptions(&opts)) - ctrl.SetLogger(logger) - - config := ctrl.GetConfigOrDie() - client, err := versioned.NewForConfig(config) - if err != nil { - log.Error(err, "failed to create Clusters clientset") - os.Exit(1) - } - - r := chi.NewRouter() - r.Get("/api/v1/clusters", handlers.ClusterListHandler(client, logger)) - r.Get("/api/v1/issues", handlers.IssueListHandler(client, logger)) - r.Get("/api/v1/namespaces/{namespace}/clusters/{clusterName}", handlers.ClusterHandler(client, logger)) - r.Get("/health", handlers.Health) - - server := graceful.WithDefaults(&http.Server{ - Addr: fmt.Sprintf(":%v", port), - Handler: r, - }) - - log.Info(fmt.Sprintf("starting the server at %s", server.Addr)) - if err := graceful.Graceful(server.ListenAndServe, server.Shutdown); err != nil { - log.Error(err, "failed to gracefully shutdown") - os.Exit(1) - } - log.Info("server was shutdown gracefully") -} diff --git a/go.mod b/go.mod index 3587a663..b3f2b938 100644 --- a/go.mod +++ b/go.mod @@ -3,12 +3,10 @@ module github.com/undistro/zora go 1.17 require ( - github.com/go-chi/chi/v5 v5.0.7 github.com/go-logr/logr v1.2.0 github.com/google/go-cmp v0.5.5 github.com/onsi/ginkgo v1.16.5 github.com/onsi/gomega v1.17.0 - github.com/ory/graceful v0.1.3 github.com/robfig/cron/v3 v3.0.1 go.uber.org/zap v1.19.1 k8s.io/api v0.23.5 diff --git a/go.sum b/go.sum index f1b1f5ab..64b64c13 100644 --- a/go.sum +++ b/go.sum @@ -144,8 +144,6 @@ github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5 github.com/getkin/kin-openapi v0.76.0/go.mod h1:660oXbgy5JFMKreazJaQTw7o+X00qeSyhcnluiMv+Xg= github.com/getsentry/raven-go v0.2.0/go.mod h1:KungGk8q33+aIAZUIVWZDr2OfAEBsO49PX4NzFV5kcQ= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/go-chi/chi/v5 v5.0.7 h1:rDTPXLDHGATaeHvVlLcR4Qe0zftYethFucbjVQ1PxU8= -github.com/go-chi/chi/v5 v5.0.7/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -369,8 +367,6 @@ github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1y github.com/onsi/gomega v1.17.0 h1:9Luw4uT5HTjHTN8+aNcSThgH1vdXnmdJ8xIfZ4wyTRE= github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= -github.com/ory/graceful v0.1.3 h1:FaeXcHZh168WzS+bqruqWEw/HgXWLdNv2nJ+fbhxbhc= -github.com/ory/graceful v0.1.3/go.mod h1:4zFz687IAF7oNHHiB586U4iL+/4aV09o/PYLE34t2bA= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= diff --git a/hack/make/misc.mk b/hack/make/misc.mk index ad87246d..8ef8c33c 100644 --- a/hack/make/misc.mk +++ b/hack/make/misc.mk @@ -14,7 +14,6 @@ clientset-gen \ build \ run \ - run-server \ docker-build \ docker-push \ docker-build-operator-worker \ diff --git a/handlers/base.go b/handlers/base.go deleted file mode 100644 index 82a55451..00000000 --- a/handlers/base.go +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2022 Undistro Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package handlers - -import ( - "encoding/json" - "net/http" -) - -type responseError struct { - Error string `json:"error,omitempty"` - Detail string `json:"detail,omitempty"` -} - -func RespondWithJSON(w http.ResponseWriter, code int, payload interface{}) { - response, err := json.Marshal(payload) - if err != nil { - response, _ = json.Marshal(responseError{Error: err.Error()}) - code = http.StatusInternalServerError - } - - w.Header().Set("Content-Type", "application/json") - w.WriteHeader(code) - _, _ = w.Write(response) -} - -func RespondWithError(w http.ResponseWriter, code int, message string) { - RespondWithJSON(w, code, responseError{Error: message}) -} - -func RespondWithDetailedError(w http.ResponseWriter, code int, message, detail string) { - RespondWithJSON(w, code, responseError{Error: message, Detail: detail}) -} - -func RespondWithCode(w http.ResponseWriter, code int) { - w.WriteHeader(code) -} diff --git a/handlers/cluster.go b/handlers/cluster.go deleted file mode 100644 index 43d7a61c..00000000 --- a/handlers/cluster.go +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2022 Undistro Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package handlers - -import ( - "fmt" - "net/http" - "strings" - - "github.com/go-chi/chi/v5" - "github.com/go-logr/logr" - "github.com/undistro/zora/apis/zora/v1alpha1" - "github.com/undistro/zora/pkg/clientset/versioned" - payloads "github.com/undistro/zora/pkg/payloads/v1alpha1" - apierrors "k8s.io/apimachinery/pkg/api/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -func ClusterHandler(client versioned.Interface, logger logr.Logger) func(http.ResponseWriter, *http.Request) { - return func(w http.ResponseWriter, r *http.Request) { - log := logger.WithName("handlers.cluster").WithValues("method", r.Method, "path", r.URL.Path) - - namespace := chi.URLParam(r, "namespace") - clusterName := chi.URLParam(r, "clusterName") - - cluster, err := client.ZoraV1alpha1().Clusters(namespace).Get(r.Context(), clusterName, metav1.GetOptions{}) - if err != nil { - if apierrors.IsNotFound(err) { - RespondWithCode(w, http.StatusNotFound) - return - } - log.Error(err, "failed to get Cluster") - RespondWithDetailedError(w, http.StatusInternalServerError, "Error getting Cluster", err.Error()) - return - } - var lastScanIDs []string - ls := fmt.Sprintf("%s=%s", v1alpha1.LabelCluster, clusterName) - - scanList, err := client.ZoraV1alpha1().ClusterScans(namespace).List(r.Context(), metav1.ListOptions{LabelSelector: ls}) - if err != nil { - log.Error(err, fmt.Sprintf("failed to list ClusterScans by label selector %s", ls)) - RespondWithDetailedError(w, http.StatusInternalServerError, "Error listing ClusterScans", err.Error()) - return - } - for _, cs := range scanList.Items { - lastScanIDs = append(lastScanIDs, cs.Status.LastScanIDs(true)...) - } - - if len(lastScanIDs) > 0 { - ls = fmt.Sprintf("%s,%s in (%s)", ls, v1alpha1.LabelScanID, strings.Join(lastScanIDs, ",")) - } - - issueList, err := client.ZoraV1alpha1().ClusterIssues(namespace).List(r.Context(), metav1.ListOptions{LabelSelector: ls}) - if err != nil { - log.Error(err, fmt.Sprintf("failed to list ClusterIssues by label selector %s", ls)) - RespondWithDetailedError(w, http.StatusInternalServerError, "Error listing ClusterIssues", err.Error()) - return - } - - log.Info(fmt.Sprintf("cluster %s returned with %d issues", clusterName, len(issueList.Items))) - RespondWithJSON(w, http.StatusOK, payloads.NewClusterWithIssues(*cluster, scanList.Items, issueList.Items)) - } -} diff --git a/handlers/clusters.go b/handlers/clusters.go deleted file mode 100644 index dfbd6d8d..00000000 --- a/handlers/clusters.go +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2022 Undistro Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package handlers - -import ( - "fmt" - "net/http" - - "github.com/go-logr/logr" - "github.com/undistro/zora/apis/zora/v1alpha1" - "github.com/undistro/zora/pkg/clientset/versioned" - payloads "github.com/undistro/zora/pkg/payloads/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -func ClusterListHandler(client versioned.Interface, logger logr.Logger) func(http.ResponseWriter, *http.Request) { - return func(w http.ResponseWriter, r *http.Request) { - log := logger.WithName("handlers.clusters").WithValues("method", r.Method, "path", r.URL.Path) - clusterList, err := client.ZoraV1alpha1().Clusters("").List(r.Context(), metav1.ListOptions{}) - if err != nil { - log.Error(err, "failed to list Clusters") - RespondWithDetailedError(w, http.StatusInternalServerError, "Error listing Clusters", err.Error()) - return - } - scanList, err := client.ZoraV1alpha1().ClusterScans("").List(r.Context(), metav1.ListOptions{}) - if err != nil { - log.Error(err, "failed to list ClusterScans") - RespondWithDetailedError(w, http.StatusInternalServerError, "Error listing ClusterScans", err.Error()) - return - } - scansByCluster := make(map[string][]v1alpha1.ClusterScan) - for _, cs := range scanList.Items { - nn := cs.Namespace + "/" + cs.Spec.ClusterRef.Name - scansByCluster[nn] = append(scansByCluster[nn], cs) - } - clusters := make([]payloads.Cluster, 0, len(clusterList.Items)) - for _, c := range clusterList.Items { - nn := c.Namespace + "/" + c.Name - cs := scansByCluster[nn] - clusters = append(clusters, payloads.NewClusterWithScans(c, cs)) - } - log.Info(fmt.Sprintf("%d cluster(s) returned", len(clusters))) - RespondWithJSON(w, http.StatusOK, clusters) - } -} diff --git a/handlers/health.go b/handlers/health.go deleted file mode 100644 index 40be786f..00000000 --- a/handlers/health.go +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2022 Undistro Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package handlers - -import "net/http" - -func Health(w http.ResponseWriter, _ *http.Request) { - RespondWithCode(w, http.StatusOK) -} diff --git a/handlers/issues.go b/handlers/issues.go deleted file mode 100644 index 24b07c3d..00000000 --- a/handlers/issues.go +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2022 Undistro Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package handlers - -import ( - "fmt" - "net/http" - "strings" - - "github.com/go-logr/logr" - "github.com/undistro/zora/apis/zora/v1alpha1" - "github.com/undistro/zora/pkg/clientset/versioned" - payloads "github.com/undistro/zora/pkg/payloads/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -func IssueListHandler(client versioned.Interface, logger logr.Logger) func(http.ResponseWriter, *http.Request) { - return func(w http.ResponseWriter, r *http.Request) { - log := logger.WithName("handlers.issues").WithValues("method", r.Method, "path", r.URL.Path) - - scanList, err := client.ZoraV1alpha1().ClusterScans("").List(r.Context(), metav1.ListOptions{}) - if err != nil { - log.Error(err, "failed to list ClusterScans") - RespondWithDetailedError(w, http.StatusInternalServerError, "Error listing ClusterScans", err.Error()) - return - } - var lastScanIDs []string - var ls string - for _, cs := range scanList.Items { - lastScanIDs = append(lastScanIDs, cs.Status.LastScanIDs(true)...) - } - if len(lastScanIDs) > 0 { - ls = fmt.Sprintf("%s in (%s)", v1alpha1.LabelScanID, strings.Join(lastScanIDs, ",")) - } - issueList, err := client.ZoraV1alpha1().ClusterIssues("").List(r.Context(), metav1.ListOptions{LabelSelector: ls}) - if err != nil { - log.Error(err, "failed to list ClusterIssues") - RespondWithDetailedError(w, http.StatusInternalServerError, "Error listing ClusterIssues", err.Error()) - return - } - - issues := payloads.NewIssues(issueList.Items) - log.Info(fmt.Sprintf("%d issue(s) returned", len(issues))) - RespondWithJSON(w, http.StatusOK, issues) - } -} diff --git a/openapi.yaml b/openapi.yaml deleted file mode 100644 index 93da748c..00000000 --- a/openapi.yaml +++ /dev/null @@ -1,308 +0,0 @@ -# Copyright 2022 Undistro Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -openapi: 3.0.1 -info: - title: Zora - description: 'Zora server' - version: 1.0.0 -servers: - - url: https://zora-hml.undistro.io/api/v1 -tags: - - name: cluster - description: Everything about Clusters -paths: - /clusters: - get: - tags: - - cluster - summary: List clusters, not including their issues - operationId: listClusters - responses: - 200: - description: OK - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/ClusterItem' - 500: - description: Internal Server Error - content: {} - /namespaces/{namespace}/clusters/{clusterName}: - get: - tags: - - cluster - summary: Get a cluster and its issues - operationId: getCluster - parameters: - - in: path - name: namespace - schema: - type: string - example: clusters-prd - required: true - - in: path - name: clusterName - schema: - type: string - example: mycluster - required: true - responses: - 200: - description: OK - content: - application/json: - schema: - $ref: '#/components/schemas/Cluster' - 404: - description: Not Found - content: {} - 500: - description: Internal Server Error - content: {} - /issues: - get: - tags: - - cluster - summary: List Issues - operationId: listIssues - responses: - 200: - description: OK - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/Issue' - 500: - description: Internal Server Error - content: {} -components: - schemas: - Cluster: - allOf: - - $ref: '#/components/schemas/ClusterItem' - ClusterItem: - type: object - properties: - name: - type: string - example: mycluster - namespace: - type: string - example: clusters-prd - environment: - type: string - example: prod - provider: - type: string - example: aws - region: - type: string - example: v1.21.5-eks-bc4871b - totalNodes: - type: integer - minimum: 0 - example: 178 - connection: - type: object - properties: - connected: - type: boolean - example: false - message: - type: string - example: 'the server has asked for the client to provide credentials' - version: - type: string - example: v1.21.5-eks-bc4871b - creationTimestamp: - type: string - format: date-time - example: "2022-03-17T19:45:07Z" - totalIssues: - type: integer - minimum: 0 - example: 4 - pluginStatus: - type: object - properties: - issueCount: - type: integer - example: 2 - issues: - type: array - items: - $ref: '#/components/schemas/ResourcedIssue' - scan: - type: object - properties: - status: - type: string - enum: [failed, unknown, scanned] - example: unknown - message: - type: string - example: 'no finished scan yet' - suspend: - type: boolean - example: false - lastSuccessfulScanTime: - type: string - format: date-time - example: "2022-06-14T17:30:11Z" - lastFinishedScanTime: - type: string - format: date-time - example: "2022-06-14T17:30:11Z" - nextScheduleScanTime: - type: string - format: date-time - example: "2022-06-14T17:33:00Z" - resources: - $ref: '#/components/schemas/Resources' - example: - kubescape: - scan: - status: "scanned" - message: "" - suspend: false - issueCount: 30 - issues: null - lastSuccessfulScanTime: "2022-08-04T21:47:00Z" - lastFinishedScanTime: "2022-08-04T21:47:00Z" - nextScheduleScanTime: "2022-08-04T23:45:00Z" - popeye: - scan: - status: "scanned" - message: "" - suspend: false - issueCount: 32 - issues: null - lastSuccessfulScanTime: "2022-08-04T21:47:00Z" - lastFinishedScanTime: "2022-08-04T21:47:00Z" - nextScheduleScanTime: "2022-08-04T23:45:00Z" - Resources: - type: object - properties: - discovered: - type: boolean - example: false - message: - type: string - example: "metrics API not available" - memory: - $ref: '#/components/schemas/Resource' - cpu: - $ref: '#/components/schemas/Resource' - Resource: - type: object - properties: - available: - type: string - example: '10033Mi' - usage: - type: string - example: '3363Mi' - usagePercentage: - type: integer - minimum: 0 - maximum: 100 - example: 33 - BaseIssue: - type: object - properties: - id: - type: string - example: "POP-106" - message: - type: string - example: "No resources requests/limits defined" - category: - type: string - example: "Container" - severity: - type: string - example: "Medium" - plugin: - type: string - example: "popeye" - url: - type: string - example: "https://kubernetes.io/docs/concepts/overview/working-with-objects/labels" - ResourcedIssue: - allOf: - - $ref: '#/components/schemas/BaseIssue' - - type: object - properties: - resources: - type: object - additionalProperties: - type: array - items: - type: object - properties: - name: - type: string - example: "aws-node" - namespace: - type: string - example: "kube-system" - example: - - 'name': 'kube-proxy' - 'namespace': 'kube-system' - - 'name': 'aws-node' - 'namespace': 'kube-system' - example: - 'apps/v1/daemonsets': - - 'name': 'kube-proxy' - 'namespace': 'kube-system' - - 'name': 'aws-node' - 'namespace': 'kube-system' - 'apps/v1/deployments': - - 'name': 'ingress-nginx-controller' - 'namespace': 'undistro-system' - 'v1/pods': - - 'name': 'ingress-nginx-controller-75759597f9-zkpth' - 'namespace': 'undistro-system' - - 'name': 'kube-proxy-f287p' - 'namespace': 'kube-system' - - 'name': 'kube-proxy-s67tv' - 'namespace': 'kube-system' - - 'name': 'aws-node-5qb87' - 'namespace': 'kube-system' - - 'name': 'aws-node-xls4r' - 'namespace': 'kube-system' - Issue: - allOf: - - $ref: '#/components/schemas/BaseIssue' - - type: object - properties: - clusters: - type: array - items: - type: object - properties: - name: - type: string - example: mycluster - namespace: - type: string - example: clusters-prd - totalResources: - type: integer - example: 10