Package cluster-map as a Deckhouse module
Layout, build and templates follow deckhouse/modules-template; dmt lint passes with no findings (Go files are excluded from the Flant-only license-header rule, see .dmtlint.yaml). - module.yaml, openapi schemas with Russian docs, lib-helm templates: https modes, ingress class, publicDomainTemplate, node placement, priority class, PSS-restricted security context, VPA, PDB, Ingress plus Gateway API ListenerSet/HTTPRoute, DexAuthenticator. - module-sdk hooks: hubble CA from d8-cni-cilium (public certificate only), external_auth, copy_custom_certificate. - The app moves to images/cluster-map/src and is split into packages; traffic mode Continuous/OnDemand/Disabled and retention are module settings; graceful shutdown; Prometheus metrics and two alerts; frontend embedded, English and Russian, strict CSP. - Built with werf on Deckhouse's published base images; Makefile publishes the registry layout modules-actions uses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
41f9b47556
commit
4518393ce1
@@ -0,0 +1,18 @@
|
||||
# Base Images
|
||||
{{- $baseImages := .Files.Get "base_images.yml" | fromYaml }}
|
||||
{{- range $k, $v := $baseImages }}
|
||||
{{ $baseImagePath := (printf "%s@%s" $baseImages.REGISTRY_PATH (trimSuffix "/" $v)) }}
|
||||
{{- if ne $k "REGISTRY_PATH" }}
|
||||
{{- $_ := set $baseImages $k $baseImagePath }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- $_ := unset $baseImages "REGISTRY_PATH" }}
|
||||
|
||||
{{- $_ := set . "Images" $baseImages }}
|
||||
# base images artifacts
|
||||
{{- range $k, $v := .Images }}
|
||||
---
|
||||
image: {{ $k }}
|
||||
from: {{ $v }}
|
||||
final: false
|
||||
{{- end }}
|
||||
@@ -0,0 +1,27 @@
|
||||
# Golang deps image, required to download dependencies and put it to the final module image (bundle)
|
||||
# Image for building batch hooks with https://github.com/deckhouse/module-sdk support
|
||||
---
|
||||
image: batch-hooks
|
||||
fromImage: builder/golang-alpine
|
||||
final: false
|
||||
git:
|
||||
- add: /
|
||||
to: /usr/src/app
|
||||
includePaths:
|
||||
- hooks/batch
|
||||
stageDependencies:
|
||||
install:
|
||||
- '**/go.mod'
|
||||
- '**/go.sum'
|
||||
beforeSetup:
|
||||
- '**/*.go'
|
||||
shell:
|
||||
install:
|
||||
# Build patch must contains the `hooks/` folder
|
||||
- cd /usr/src/app/hooks/batch
|
||||
- go mod download
|
||||
beforeSetup:
|
||||
- |
|
||||
cd /usr/src/app/hooks/batch;
|
||||
# don't use `-trimpath` flag for building go hooks. Embedded binary path is necessary to properly identify a hook name
|
||||
CGO_ENABLED=0 go build -gcflags=all="-l -B" -ldflags="-w -s" -o /usr/local/bin/batchhooks *.go;
|
||||
@@ -0,0 +1,47 @@
|
||||
# Bundle image, stored in your.registry.io/modules/<module-name>:<semver>
|
||||
---
|
||||
image: bundle
|
||||
fromImage: builder/scratch
|
||||
import:
|
||||
# Enrich image digest and version
|
||||
# Rendering .werf/stages/images-digests.yaml is required!
|
||||
- image: images-digests-and-version
|
||||
add: /
|
||||
to: /
|
||||
includePaths:
|
||||
- images_digests.json
|
||||
- version.json
|
||||
after: setup
|
||||
# batch hooks built with batch-go.yaml werf job
|
||||
- image: batch-hooks
|
||||
add: /usr/local/bin/batchhooks
|
||||
to: /hooks/batchhooks
|
||||
after: setup
|
||||
# Uncomment if you use python hooks
|
||||
# - image: python-dependencies
|
||||
# add: /usr/bin
|
||||
# to: /hooks/venv/
|
||||
# before: setup
|
||||
# - image: python-dependencies
|
||||
# add: /lib/python/dist
|
||||
# to: /lib/python/dist
|
||||
# before: setup
|
||||
git:
|
||||
- add: /
|
||||
to: /
|
||||
excludePaths:
|
||||
- hooks/batch # exclude sources
|
||||
- docs/internal
|
||||
includePaths:
|
||||
- .helmignore
|
||||
- docs
|
||||
- charts
|
||||
- crds
|
||||
- enabled
|
||||
- hooks
|
||||
- monitoring
|
||||
- openapi
|
||||
- templates
|
||||
- Chart.yaml
|
||||
- module.yaml
|
||||
- values.yaml
|
||||
@@ -0,0 +1,47 @@
|
||||
{{- /* Find all images digests and save use them to compose a structure for the module values. */ -}}
|
||||
{{- $ImagesIDList := list }}
|
||||
{{- $Images := tpl (.Files.Get ".werf/stages/images.yaml") . }}
|
||||
|
||||
{{- range $ImageManifest := regexSplit "\n?---[ \t]*\n" $Images -1 }}
|
||||
{{- $ImageManifest := $ImageManifest | fromYaml }}
|
||||
{{- if $ImageManifest.image }}
|
||||
{{- if ne $ImageManifest.final false }}
|
||||
{{- $ImagesIDList = append $ImagesIDList $ImageManifest.image }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
# Images Digest: a files with all image digests to be able to use them in helm templates of a module
|
||||
# Version: module version
|
||||
---
|
||||
image: images-digests-and-version
|
||||
final: false
|
||||
fromImage: builder/alpine
|
||||
import:
|
||||
- image: jq
|
||||
add: /usr/bin/jq
|
||||
before: install
|
||||
dependencies:
|
||||
{{- range $ImageID := $ImagesIDList }}
|
||||
{{- $ImageNameCamel := $ImageID | splitList "/" | last | camelcase | untitle }}
|
||||
- image: {{ $ImageID }}
|
||||
before: setup
|
||||
imports:
|
||||
- type: ImageDigest
|
||||
targetEnv: MODULE_IMAGE_DIGEST_{{ $ImageNameCamel }}
|
||||
{{- end }}
|
||||
shell:
|
||||
setup:
|
||||
- |
|
||||
env | grep MODULE_IMAGE_DIGEST | jq -Rn '
|
||||
reduce inputs as $i (
|
||||
{};
|
||||
. * (
|
||||
$i | ltrimstr("MODULE_IMAGE_DIGEST_") | sub("=";"_") |
|
||||
split("_") as [$imageName, $digest] |
|
||||
{($imageName): $digest}
|
||||
)
|
||||
)
|
||||
' > /images_digests.json
|
||||
- |
|
||||
jq -n --arg version "{{ env "MODULES_MODULE_TAG" }}" '{"version": $version}' > /version.json
|
||||
@@ -0,0 +1,16 @@
|
||||
{{- $Root := . }}
|
||||
{{- $ImagesBuildFiles := .Files.Glob "images/*/{Dockerfile,werf.inc.yaml}" }}
|
||||
|
||||
{{- range $path, $content := $ImagesBuildFiles }}
|
||||
{{- $ctx := dict }}
|
||||
{{- $_ := set $ctx "ImageName" ($path | split "/")._1 }}
|
||||
{{- $_ := set $ctx "ModuleName" "cluster-map" }}
|
||||
{{- $_ := set $ctx "ImagePath" (printf "/images/%s" $ctx.ImageName) }}
|
||||
{{- $_ := set $ctx "ModuleDir" "/" }}
|
||||
{{- $_ := set $ctx "ProjectName" (list $ctx.ModuleName $ctx.ImageName | join "/") }}
|
||||
{{- $_ := set $ctx "Commit" $Root.Commit }}
|
||||
|
||||
---
|
||||
{{- $_ := set $ctx "Files" $Root.Files }}
|
||||
{{ tpl $content $ctx }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,22 @@
|
||||
# Release image, stored in your.registry.io/modules/<module-name>/release:<semver>
|
||||
---
|
||||
image: release-channel-version
|
||||
fromImage: builder/scratch
|
||||
import:
|
||||
- image: images-digests-and-version
|
||||
add: /
|
||||
to: /
|
||||
includePaths:
|
||||
- version.json
|
||||
after: install
|
||||
git:
|
||||
- add: /
|
||||
to: /
|
||||
includePaths:
|
||||
- changelog.yaml
|
||||
- crds
|
||||
- docs
|
||||
- module.yaml
|
||||
- openapi
|
||||
excludePaths:
|
||||
- docs/internal
|
||||
Reference in New Issue
Block a user