From 775d0f59c96b2b6fca25f6a1f070ca27de291080 Mon Sep 17 00:00:00 2001 From: Xabier Larrakoetxea Date: Sun, 27 Mar 2022 10:38:32 +0200 Subject: [PATCH] Add CRDs to Helm chart Signed-off-by: Xabier Larrakoetxea --- deploy/kubernetes/helm/sloth/Chart.yaml | 2 +- ...loth.slok.dev_prometheusservicelevels.yaml | 269 ++++++++++++++++++ scripts/kubegen.sh | 4 + 3 files changed, 274 insertions(+), 1 deletion(-) create mode 100644 deploy/kubernetes/helm/sloth/crds/sloth.slok.dev_prometheusservicelevels.yaml diff --git a/deploy/kubernetes/helm/sloth/Chart.yaml b/deploy/kubernetes/helm/sloth/Chart.yaml index 35121957..4faa986a 100644 --- a/deploy/kubernetes/helm/sloth/Chart.yaml +++ b/deploy/kubernetes/helm/sloth/Chart.yaml @@ -4,4 +4,4 @@ description: Base chart for Sloth. type: application home: https://github.com/slok/sloth kubeVersion: ">= 1.19.0-0" -version: 0.4.3 +version: 0.5.0 diff --git a/deploy/kubernetes/helm/sloth/crds/sloth.slok.dev_prometheusservicelevels.yaml b/deploy/kubernetes/helm/sloth/crds/sloth.slok.dev_prometheusservicelevels.yaml new file mode 100644 index 00000000..2bc1a778 --- /dev/null +++ b/deploy/kubernetes/helm/sloth/crds/sloth.slok.dev_prometheusservicelevels.yaml @@ -0,0 +1,269 @@ + +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: (devel) + creationTimestamp: null + name: prometheusservicelevels.sloth.slok.dev +spec: + group: sloth.slok.dev + names: + categories: + - slo + - slos + - sli + - slis + kind: PrometheusServiceLevel + listKind: PrometheusServiceLevelList + plural: prometheusservicelevels + shortNames: + - psl + - pslo + singular: prometheusservicelevel + scope: Namespaced + versions: + - additionalPrinterColumns: + - jsonPath: .spec.service + name: SERVICE + type: string + - jsonPath: .status.processedSLOs + name: DESIRED SLOs + type: integer + - jsonPath: .status.promOpRulesGeneratedSLOs + name: READY SLOs + type: integer + - jsonPath: .status.promOpRulesGenerated + name: GEN OK + type: boolean + - jsonPath: .status.lastPromOpRulesSuccessfulGenerated + name: GEN AGE + type: date + - jsonPath: .metadata.creationTimestamp + name: AGE + type: date + name: v1 + schema: + openAPIV3Schema: + description: PrometheusServiceLevel is the expected service quality level + using Prometheus as the backend used by Sloth. + 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: ServiceLevelSpec is the spec for a PrometheusServiceLevel. + properties: + labels: + additionalProperties: + type: string + description: Labels are the Prometheus labels that will have all the + recording and alerting rules generated for the service SLOs. + type: object + service: + description: Service is the application of the SLOs. + type: string + slos: + description: SLOs are the SLOs of the service. + items: + description: SLO is the configuration/declaration of the service + level objective of a service. + properties: + alerting: + description: Alerting is the configuration with all the things + related with the SLO alerts. + properties: + annotations: + additionalProperties: + type: string + description: Annotations are the Prometheus annotations + that will have all the alerts generated by this SLO. + type: object + labels: + additionalProperties: + type: string + description: Labels are the Prometheus labels that will + have all the alerts generated by this SLO. + type: object + name: + description: Name is the name used by the alerts generated + for this SLO. + type: string + pageAlert: + description: Page alert refers to the critical alert (check + multiwindow-multiburn alerts). + properties: + annotations: + additionalProperties: + type: string + description: Annotations are the Prometheus annotations + for the specific alert. + type: object + disable: + description: Disable disables the alert and makes Sloth + not generating this alert. This can be helpful for + example to disable ticket(warning) alerts. + type: boolean + labels: + additionalProperties: + type: string + description: Labels are the Prometheus labels for the + specific alert. For example can be useful to route + the Page alert to specific Slack channel. + type: object + type: object + ticketAlert: + description: TicketAlert alert refers to the warning alert + (check multiwindow-multiburn alerts). + properties: + annotations: + additionalProperties: + type: string + description: Annotations are the Prometheus annotations + for the specific alert. + type: object + disable: + description: Disable disables the alert and makes Sloth + not generating this alert. This can be helpful for + example to disable ticket(warning) alerts. + type: boolean + labels: + additionalProperties: + type: string + description: Labels are the Prometheus labels for the + specific alert. For example can be useful to route + the Page alert to specific Slack channel. + type: object + type: object + type: object + description: + description: Description is the description of the SLO. + type: string + labels: + additionalProperties: + type: string + description: Labels are the Prometheus labels that will have + all the recording and alerting rules for this specific SLO. + These labels are merged with the previous level labels. + type: object + name: + description: Name is the name of the SLO. + maxLength: 128 + type: string + objective: + description: Objective is target of the SLO the percentage (0, + 100] (e.g 99.9). + type: number + sli: + description: SLI is the indicator (service level indicator) + for this specific SLO. + properties: + events: + description: Events is the events SLI type. + properties: + errorQuery: + description: ErrorQuery is a Prometheus query that will + get the number/count of events that we consider that + are bad for the SLO (e.g "http 5xx", "latency > 250ms"...). + Requires the usage of `{{.window}}` template variable. + type: string + totalQuery: + description: TotalQuery is a Prometheus query that will + get the total number/count of events for the SLO (e.g + "all http requests"...). Requires the usage of `{{.window}}` + template variable. + type: string + required: + - errorQuery + - totalQuery + type: object + plugin: + description: Plugin is the pluggable SLI type. + properties: + id: + description: Name is the name of the plugin that needs + to load. + type: string + options: + additionalProperties: + type: string + description: Options are the options used for the plugin. + type: object + required: + - id + type: object + raw: + description: Raw is the raw SLI type. + properties: + errorRatioQuery: + description: ErrorRatioQuery is a Prometheus query that + will get the raw error ratio (0-1) for the SLO. + type: string + required: + - errorRatioQuery + type: object + type: object + required: + - alerting + - name + - objective + - sli + type: object + minItems: 1 + type: array + required: + - service + type: object + status: + properties: + lastPromOpRulesSuccessfulGenerated: + description: LastPromOpRulesGeneration tells the last atemp made for + a successful SLO rules generate. + format: date-time + type: string + observedGeneration: + description: ObservedGeneration tells the generation was acted on, + normally this is required to stop an infinite loop when the status + is updated because it sends a watch updated event to the watchers + of the K8s object. + format: int64 + type: integer + processedSLOs: + description: ProcessedSLOs tells how many SLOs haven been processed + for Prometheus operator. + type: integer + promOpRulesGenerated: + description: PromOpRulesGenerated tells if the rules for prometheus + operator CRD have been generated. + type: boolean + promOpRulesGeneratedSLOs: + description: PromOpRulesGeneratedSLOs tells how many SLOs have been + processed and generated for Prometheus operator successfully. + type: integer + required: + - observedGeneration + - processedSLOs + - promOpRulesGenerated + - promOpRulesGeneratedSLOs + type: object + type: object + served: true + storage: true + subresources: + status: {} +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] diff --git a/scripts/kubegen.sh b/scripts/kubegen.sh index 94b012c5..89ba7e37 100755 --- a/scripts/kubegen.sh +++ b/scripts/kubegen.sh @@ -30,3 +30,7 @@ docker run -it --rm \ -e CRD_TYPES_PATH=/src/pkg/kubernetes/api \ -e CRD_OUT_PATH=/src/pkg/kubernetes/gen/crd \ ${IMAGE_CRD_GEN} update-crd.sh + +echo "Copying crd to helm chart..." +rm ./deploy/kubernetes/helm/sloth/crds/* +cp "${GEN_DIRECTORY}/crd"/* deploy/kubernetes/helm/sloth/crds/