From 2f2ade35d436a7fd5059d04a23e9cc9fc75d6063 Mon Sep 17 00:00:00 2001 From: Grzegorz Karaluch Date: Mon, 18 Mar 2024 15:40:28 +0100 Subject: [PATCH] Apply Markdown linting in the Keda Manager repo (#376) * Apply Markdown linting in the Keda Manager repo * Change markdowlint format to yaml and add comments * Apply custom capitalize heading rule * remove markdownlintignore * change bash to yaml * Small fix * Small fix * Change the file name * Change description in capitalization.js and add markdownlintignore * Fix the capitalization rule --- .markdownlint.yaml | 26 +++++++++++++++ .markdownlintignore | 1 + CONTRIBUTING.md | 2 +- README.md | 5 +-- docs/contributor/01-10-installation.md | 16 ++++++---- docs/contributor/01-20-extend-ui.md | 2 +- docs/contributor/02-10-management.md | 6 ++-- docs/contributor/03-10-scripts-not-working.md | 3 +- docs/contributor/04-10-ci-cd.md | 4 +-- .../contributor/04-20-lifecycle-management.md | 2 +- docs/contributor/04-30-project-structure.md | 4 +-- docs/user/01-20-configuration.md | 4 ++- docs/user/04-10-footprint.md | 3 +- docs/user/04-20-demo-applications.md | 32 +++++++++++-------- docs/user/05-01-conditions.md | 2 +- docs/user/README.md | 7 ++-- examples/scale-to-zero-with-keda/README.md | 28 ++++++++++------ heading_capitalization.js | 28 ++++++++++++++++ 18 files changed, 126 insertions(+), 49 deletions(-) create mode 100644 .markdownlint.yaml create mode 100644 .markdownlintignore create mode 100644 heading_capitalization.js diff --git a/.markdownlint.yaml b/.markdownlint.yaml new file mode 100644 index 00000000..6321315a --- /dev/null +++ b/.markdownlint.yaml @@ -0,0 +1,26 @@ +# This is a configuration file for the markdownlint. You can use this file to overwrite the default settings. +# MD013 is set to false by default because many files include lines longer than the conventional 80 character limit +MD013: false +# Disable the Multiple headings with the same content rule +MD024: false +# MD029 is set to false because it generated some issues with longer lists +MD029: false +# MD044 is used to set capitalization for the particular words. You can determine whether it should be used also for code blocks and html elements +MD044: + code_blocks: false + html_elements: false + names: + - Kyma + - Kubernetes + - ConfigMap + - CronJob + - CustomResourceDefinition + - Ingress + - Node + - PodPreset + - Pod + - ProwJob + - Secret + - ServiceBinding + - ServiceClass + - ServiceInstance diff --git a/.markdownlintignore b/.markdownlintignore new file mode 100644 index 00000000..578db9cb --- /dev/null +++ b/.markdownlintignore @@ -0,0 +1 @@ +_sidebar.md \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 71bc0fc6..10c6bcc7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,4 +1,4 @@ -## Overview +# Overview To contribute to this project, follow the general [contributing](https://github.com/kyma-project/community/blob/main/docs/contributing/02-contributing.md) guidelines. diff --git a/README.md b/README.md index 11768261..b4a02bf4 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,11 @@ # Keda Manager ## Status + ![GitHub tag checks state](https://img.shields.io/github/checks-status/kyma-project/keda-manager/main?label=keda-operator&link=https%3A%2F%2Fgithub.com%2Fkyma-project%2Fkeda-manager%2Fcommits%2Fmain) [![REUSE status](https://api.reuse.software/badge/github.com/kyma-project/keda-manager)](https://api.reuse.software/info/github.com/kyma-project/keda-manager) -## Overview +## Overview Keda Manager is an extension to the Kyma runtime. It allows users to install KEDA. It follows the Kubernetes operator pattern to manage the lifecycle of the KEDA installation based on the existence and the content of the dedicated Keda custom resource (CR). @@ -29,7 +30,6 @@ KEDA is a flexible Event Driven Autoscaler for the Kubernetes workloads. It exte ### Procedure - 1. To install KEDA, you must install Keda Manager first. Apply the following script: ```bash @@ -42,6 +42,7 @@ KEDA is a flexible Event Driven Autoscaler for the Kubernetes workloads. It exte ```bash kubectl apply -f https://github.com/kyma-project/keda-manager/releases/latest/download/keda-default-cr.yaml ``` + You should get a result similar to this example: ```bash diff --git a/docs/contributor/01-10-installation.md b/docs/contributor/01-10-installation.md index 9e73e789..1ba5ad8e 100644 --- a/docs/contributor/01-10-installation.md +++ b/docs/contributor/01-10-installation.md @@ -1,15 +1,15 @@ -# Install Keda Manager +# Install Keda Manager - [Install Keda Manager](#install-keda-manager) - - [Install Keda Manager from the local sources](#install-keda-manager-from-the-local-sources) + - [Install Keda Manager From the Local Sources](#install-keda-manager-from-the-local-sources) - [Prerequisites](#prerequisites) - [Procedure](#procedure) - - [Make targets to run Keda Manager locally on k3d](#make-targets-to-run-keda-manager-locally-on-k3d) + - [Make Targets To Run Keda Manager Locally on k3d](#make-targets-to-run-keda-manager-locally-on-k3d) - [Run Keda Manager](#run-keda-manager) Learn how to install the Keda module locally (on k3d) or on your remote cluster. -## Install Keda Manager From the Local Sources +## Install Keda Manager From the Local Sources ### Prerequisites @@ -35,6 +35,7 @@ Run the following commands to deploy Keda Manager in a target Kubernetes cluster 2. Set the Keda Manager image name. > NOTE: You can use the local k3d registry or your Docker Hub account to push intermediate images. + ```bash export IMG=/custom-keda-manager:0.0.2 ``` @@ -44,11 +45,13 @@ Run the following commands to deploy Keda Manager in a target Kubernetes cluster ```bash make test ``` + 4. Build and push the image to the registry. ```bash make module-image ``` + 5. Create a target namespace. ```bash @@ -69,7 +72,7 @@ Run the following commands to deploy Keda Manager in a target Kubernetes cluster You should get a result similar to this example: - ``` + ```bash NAME READY UP-TO-DATE AVAILABLE AGE keda-manager 1/1 1 1 1m ``` @@ -86,10 +89,11 @@ Thanks to that, you don't need to push the Keda module images to a remote regist ```bash git clone https://github.com/kyma-project/keda-manager.git && cd keda-manager/ ``` + 2. Build the manager locally and run it in the k3d cluster. ```bash make -C hack/local run ``` -3. If you want to clean up the k3d cluster, use the `make -C hack/local stop` make target. +3. If you want to clean up the k3d cluster, use the `make -C hack/local stop` make target. diff --git a/docs/contributor/01-20-extend-ui.md b/docs/contributor/01-20-extend-ui.md index 38f72f6f..d38facdf 100644 --- a/docs/contributor/01-20-extend-ui.md +++ b/docs/contributor/01-20-extend-ui.md @@ -3,4 +3,4 @@ Keda Manager is not only an API extension to the Kyma runtime. You can also use it to configure a dedicated UI for your CustomResourceDefinition (CRD). To do that, use the [UI extensibility](https://github.com/kyma-project/busola/tree/main/docs/extensibility) feature of Kyma dashboard. In the [ui-extensions](../../config/ui-extensions/) folder, you can find configuration for the UI components (for example, the `list`, `form`, or `details` views) that allows you to create a dedicated UI page for your Keda CR - `ScaledObjects`. -This configuration is applied as part of the Keda Manager resources. Thanks to that, it comes and goes depending on whether the Keda module is enabled or disabled. \ No newline at end of file +This configuration is applied as part of the Keda Manager resources. Thanks to that, it comes and goes depending on whether the Keda module is enabled or disabled. diff --git a/docs/contributor/02-10-management.md b/docs/contributor/02-10-management.md index 096b32f5..e6e9f583 100644 --- a/docs/contributor/02-10-management.md +++ b/docs/contributor/02-10-management.md @@ -24,6 +24,7 @@ Keda Manager reconciles KEDA deployment based on the watched Keda custom resourc ```bash kubectl delete -f config/samples/keda-default-cr.yaml ``` + This uninstalls all KEDA workloads but leaves Keda Manager. > **NOTE:** Keda Manager uses finalizers to uninstall the Keda module from the cluster. It means that Keda Manager blocks the uninstallation process of KEDA until there are user-created CRs (for example, ScaledObjects). @@ -32,8 +33,7 @@ Keda Manager reconciles KEDA deployment based on the watched Keda custom resourc The [configuration example](../user/01-20-configuration.md) shows how to modify the Keda properties using the `keda.operator.kyma-project.io` CR. - - ```bash + ```bash cat </2 (avg) 1 5 0 27h ``` + 2. List Pods by Function name label and check that you see only the build job's Pod. No runtime Pod is up. + ```bash kubectl get pods -l serverless.kyma-project.io/function-name=scalable-worker-fn -w NAME READY STATUS RESTARTS AGE @@ -78,6 +84,7 @@ The message is pushed to Kyma Eventing. It takes time to scale up a Function from zero. But no message is lost as Eventing retries delivery of the message to the subscriber until a running worker Pod eventually consumes it. 4. Observe worker Function scaling up from zero. You can notice it by watching Function Pods or HPA. + ```bash kubectl get pods -l serverless.kyma-project.io/function-name=scalable-worker-fn -w NAME READY STATUS RESTARTS AGE @@ -90,6 +97,7 @@ scalable-worker-fn-2n269-6f6d5f675-t6nwr 0/2 Init:0/1 0 1s scalable-worker-fn-2n269-6f6d5f675-t6nwr 0/2 PodInitializing 0 2s scalable-worker-fn-2n269-6f6d5f675-t6nwr 0/2 Running 0 7s ``` + ```bash kubectl get hpa -w NAME REFERENCE TARGETS MINPODS MAXPODS REPLICAS AGE @@ -111,7 +119,7 @@ Processing ... {"foo":"bar"} ``` - + If the traffic stops, the worker Function is scaled down back to zero replicas (after a configurable cooldown period). - -6. If you generate a much higher load, for example,> 2 req/sec - as configured in the threshold value of the scaledObject, you will observe scaling up to more replicas. One replica must be added for each additional 2req/sec measured. + +6. If you generate a much higher load, for example,> 2 req/sec - as configured in the threshold value of the scaledObject, you will observe scaling up to more replicas. One replica must be added for each additional 2req/sec measured. diff --git a/heading_capitalization.js b/heading_capitalization.js new file mode 100644 index 00000000..8eb2a5f0 --- /dev/null +++ b/heading_capitalization.js @@ -0,0 +1,28 @@ +module.exports = [{ + "names": [ "custom/capitalize-headings" ], + "description": "Heading words longer than 4 characters should be capitalized", + "tags": [ "formatting" ], + "function": function rule(params, onError) { + params.tokens.filter(function filterToken(token) { + return token.type === "heading_open"; + }).forEach(function forToken(heading) { + var headingTokenContent = heading.line.trim(); + var wordsInHeading = headingTokenContent.split(' '); + + for (var i = 0; i < wordsInHeading.length; i++) { + if (wordsInHeading[i].length > 4 && wordsInHeading[i] && + wordsInHeading[i].charAt(0) !== wordsInHeading[i].charAt(0).toUpperCase()) { + var capitalizedWord = wordsInHeading[i].charAt(0).toUpperCase() + wordsInHeading[i].slice(1); + var detailMessage = "Change " + "'" + wordsInHeading[i] + "'" + " to " + "'" + capitalizedWord + "'"; + + onError({ + "lineNumber": heading.lineNumber, + "detail": detailMessage, + "context": headingTokenContent, // Show the whole heading as context + "range": [headingTokenContent.indexOf(wordsInHeading[i]), wordsInHeading[i].length] // Underline the word which needs a change + }); + } + } + }); + } +}]; \ No newline at end of file