From d7f0f91a4fc89a576071ec727f99d65ebdfedeab Mon Sep 17 00:00:00 2001 From: Ramiro Algozino Date: Wed, 23 Apr 2025 17:26:13 +0200 Subject: [PATCH 1/2] feat(docs): add docs pseudo-module - Add docs pseudo module manifests - Add docs pseudo module to on-premises schema and set default values --- defaults/onpremises-kfd-v1alpha2.yaml | 7 +++ schemas/public/onpremises-kfd-v1alpha2.json | 43 +++++++++++++++ templates/distribution/_helpers.tpl | 4 ++ .../manifests/docs/deployment.yaml.tpl | 52 +++++++++++++++++++ .../manifests/docs/ingress.yaml.tpl | 30 +++++++++++ .../manifests/docs/kustomization.yaml.tpl | 10 ++++ .../manifests/docs/namespace.yaml.tpl | 8 +++ .../manifests/docs/service.yaml.tpl | 18 +++++++ .../manifests/kustomization.yaml.tpl | 3 ++ 9 files changed, 175 insertions(+) create mode 100644 templates/distribution/manifests/docs/deployment.yaml.tpl create mode 100644 templates/distribution/manifests/docs/ingress.yaml.tpl create mode 100644 templates/distribution/manifests/docs/kustomization.yaml.tpl create mode 100644 templates/distribution/manifests/docs/namespace.yaml.tpl create mode 100644 templates/distribution/manifests/docs/service.yaml.tpl diff --git a/defaults/onpremises-kfd-v1alpha2.yaml b/defaults/onpremises-kfd-v1alpha2.yaml index 8c63dd04d..6c7eaa132 100644 --- a/defaults/onpremises-kfd-v1alpha2.yaml +++ b/defaults/onpremises-kfd-v1alpha2.yaml @@ -18,6 +18,13 @@ data: networkPoliciesEnabled: false # the module section will be used to fine tune each module behaviour and configuration modules: + docs: + enabled: true + overrides: + ingresses: + docs: + host: "" + ingressClass: "" # ingress module configuration ingress: overrides: diff --git a/schemas/public/onpremises-kfd-v1alpha2.json b/schemas/public/onpremises-kfd-v1alpha2.json index 9a206b255..bad618281 100644 --- a/schemas/public/onpremises-kfd-v1alpha2.json +++ b/schemas/public/onpremises-kfd-v1alpha2.json @@ -834,6 +834,9 @@ "dr": { "$ref": "#/$defs/Spec.Distribution.Modules.Dr" }, + "docs": { + "$ref": "#/$defs/Spec.Distribution.Modules.Docs" + }, "ingress": { "$ref": "#/$defs/Spec.Distribution.Modules.Ingress" }, @@ -860,6 +863,46 @@ "policy" ] }, + "Spec.Distribution.Modules.Docs": { + "type": "object", + "additionalProperties": false, + "properties": { + "overrides": { + "$ref": "#/$defs/Spec.Distribution.Modules.Docs.Overrides" + }, + "enabled": { + "type": "boolean", + "default": true, + "description": "When enabled, the docs site will be included in the distribution and available at `docs.`." + } + } + }, + "Spec.Distribution.Modules.Docs.Overrides": { + "type": "object", + "additionalProperties": false, + "description": "Override the common configuration with a particular configuration for the Docs module.", + "properties": { + "ingresses": { + "type": "object", + "additionalProperties": false, + "properties": { + "docs": { + "$ref": "#/$defs/Types.FuryModuleOverridesIngress" + } + } }, + "nodeSelector": { + "$ref": "#/$defs/Types.KubeNodeSelector", + "description": "Set to override the node selector used to place the pods of the Ingress module." + }, + "tolerations": { + "type": "array", + "items": { + "$ref": "#/$defs/Types.KubeToleration" + }, + "description": "Set to override the tolerations that will be added to the pods of the Ingress module." + } + } + }, "Spec.Distribution.Modules.Ingress": { "type": "object", "additionalProperties": false, diff --git a/templates/distribution/_helpers.tpl b/templates/distribution/_helpers.tpl index 6f5e2a26a..844b58dac 100644 --- a/templates/distribution/_helpers.tpl +++ b/templates/distribution/_helpers.tpl @@ -224,3 +224,7 @@ cert-manager.io/cluster-issuer: {{ .spec.distribution.modules.ingress.certManage {{ define "hubbleUrl" }} {{- template "ingressHost" (dict "module" "networking" "package" "hubble" "prefix" "hubble." "spec" .) -}} {{ end }} + +{{ define "docsUrl" }} + {{- template "ingressHost" (dict "module" "docs" "package" "docs" "prefix" "docs." "spec" .) -}} +{{ end }} diff --git a/templates/distribution/manifests/docs/deployment.yaml.tpl b/templates/distribution/manifests/docs/deployment.yaml.tpl new file mode 100644 index 000000000..4b46f6a59 --- /dev/null +++ b/templates/distribution/manifests/docs/deployment.yaml.tpl @@ -0,0 +1,52 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: sd-docs + labels: + app.kubernetes.io/name: docs + app.kubernetes.io/version: "{{ .spec.distributionVersion }}" + app.kubernetes.io/part-of: sighup-distribution +spec: + replicas: 2 + selector: + matchLabels: + app.kubernetes.io/name: docs + app.kubernetes.io/version: "{{ .spec.distributionVersion }}" + app.kubernetes.io/part-of: sighup-distribution + strategy: {} + template: + metadata: + labels: + app.kubernetes.io/name: docs + app.kubernetes.io/version: "{{ .spec.distributionVersion }}" + app.kubernetes.io/part-of: sighup-distribution + spec: + tolerations: + {{ template "tolerations" dict "module" "docs" "package" "docs" "spec" .spec }} + nodeSelector: + {{ template "nodeSelector" dict "module" "docs" "package" "docs" "spec" .spec }} + containers: + - name: docs + image: registry.sighup.io/fury/docs:{{ .spec.distributionVersion | trimPrefix "v" }}-single + ports: + - name: http + containerPort: 8080 + securityContext: + privileged: false + runAsNonRoot: true + runAsUser: 101 + runAsGroup: 101 + allowPrivilegeEscalation: false + readOnlyRootFilesystem: true + seccompProfile: + type: RuntimeDefault + capabilities: + drop: + - ALL + volumeMounts: + - name: tmp + mountPath: /tmp + volumes: + - name: tmp + emptyDir: {} diff --git a/templates/distribution/manifests/docs/ingress.yaml.tpl b/templates/distribution/manifests/docs/ingress.yaml.tpl new file mode 100644 index 000000000..c1eb3b4df --- /dev/null +++ b/templates/distribution/manifests/docs/ingress.yaml.tpl @@ -0,0 +1,30 @@ +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: sd-docs + labels: + app.kubernetes.io/name: docs + app.kubernetes.io/version: "{{ .spec.distributionVersion }}" + app.kubernetes.io/part-of: sighup-distribution + annotations: + cluster.kfd.sighup.io/useful-link.url: https://{{ template "docsUrl" .spec }} + cluster.kfd.sighup.io/useful-link.name: "SD Documentation" + forecastle.stakater.com/expose: "true" + forecastle.stakater.com/appName: "SIGHUP Distribution Documentation" + forecastle.stakater.com/icon: "https://raw.githubusercontent.com/sighupio/distribution/refs/heads/main/docs/assets/black-logo.png" + {{ template "certManagerClusterIssuer" . }} +spec: + ingressClassName: {{ template "ingressClass" (dict "module" "docs" "package" "docs" "type" "internal" "spec" .spec) }} + rules: + - host: {{ template "docsUrl" .spec }} + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: sd-docs + port: + name: http +{{- template "ingressTls" (dict "module" "docs" "package" "docs" "prefix" "docs." "spec" .spec) }} diff --git a/templates/distribution/manifests/docs/kustomization.yaml.tpl b/templates/distribution/manifests/docs/kustomization.yaml.tpl new file mode 100644 index 000000000..6823011a2 --- /dev/null +++ b/templates/distribution/manifests/docs/kustomization.yaml.tpl @@ -0,0 +1,10 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namespace: sd-docs +resources: + - namespace.yaml + - deployment.yaml + - service.yaml + {{- if ne .spec.distribution.modules.ingress.nginx.type "none" }} + - ingress.yaml + {{- end }} diff --git a/templates/distribution/manifests/docs/namespace.yaml.tpl b/templates/distribution/manifests/docs/namespace.yaml.tpl new file mode 100644 index 000000000..b3b9f3f4b --- /dev/null +++ b/templates/distribution/manifests/docs/namespace.yaml.tpl @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: sd-docs + labels: + app.kubernetes.io/name: docs + app.kubernetes.io/version: "{{ .spec.distributionVersion }}" + app.kubernetes.io/part-of: sighup-distribution diff --git a/templates/distribution/manifests/docs/service.yaml.tpl b/templates/distribution/manifests/docs/service.yaml.tpl new file mode 100644 index 000000000..6af64281b --- /dev/null +++ b/templates/distribution/manifests/docs/service.yaml.tpl @@ -0,0 +1,18 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: sd-docs + labels: + app.kubernetes.io/name: docs + app.kubernetes.io/version: "{{ .spec.distributionVersion }}" + app.kubernetes.io/part-of: sighup-distribution +spec: + selector: + app.kubernetes.io/name: docs + app.kubernetes.io/version: "{{ .spec.distributionVersion }}" + app.kubernetes.io/part-of: sighup-distribution + ports: + - name: http + port: 80 + targetPort: http diff --git a/templates/distribution/manifests/kustomization.yaml.tpl b/templates/distribution/manifests/kustomization.yaml.tpl index 5ac57462d..5ffcd84a9 100644 --- a/templates/distribution/manifests/kustomization.yaml.tpl +++ b/templates/distribution/manifests/kustomization.yaml.tpl @@ -35,6 +35,9 @@ resources: {{- if and (eq .spec.distribution.modules.tracing.type "tempo") (.checks.storageClassAvailable) }} - tracing {{- end }} +{{- if .spec.distribution.modules.docs.enabled }} + - docs +{{- end }} {{- if .spec.distribution.customPatches.patchesStrategicMerge }} patchesStrategicMerge: From 4c789f86b42560b8e18c34e9f233d3416367446f Mon Sep 17 00:00:00 2001 From: Ramiro Algozino Date: Wed, 23 Apr 2025 17:30:27 +0200 Subject: [PATCH 2/2] docs(releases): mention new embedded docs --- docs/releases/unreleased.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/releases/unreleased.md b/docs/releases/unreleased.md index 293924698..d5ed185ad 100644 --- a/docs/releases/unreleased.md +++ b/docs/releases/unreleased.md @@ -14,6 +14,16 @@ The distribution is maintained with ❤️ by the team [SIGHUP by ReeVo](https:/ ## New features 🌟 +- [[#XXX](https://github.com/sighupio/distribution/pull/XXX)] **Embedded Docs site**: the distribution now includes an embedded version of the docs site with the documentation for the SD version. The docs will be deployed by default and an (unprotected) ingress will be automatically created. You can disable and / or override some values with the new configuration key, for example: + +```yaml +spec: + distribution: + modules: + docs: + enabled: false # disable embedded Docs +``` + ## Fixes 🐞 - [[#387](https://github.com/sighupio/distribution/pull/387)]: This PR fixed an issue that prevented the control planes nodes array to be treated as immutable under the OnPremises provider. The number of control plane nodes was originally set as immutable in the 1.31.1 release cycle because there isn't any support to scale the etcd cluster with the number of control plane nodes in the SIGHUP Distribution yet. The issue allowed users to change the number of the control plane, even if it was explicitly marked as immutable.