Skip to content

Commit 55dbbe0

Browse files
authored
feat: Add FluxCD GitOps templates and OpenMCP resources (#1)
* Add FluxCD GitOps templates and OpenMCP resources - Introduced `gotk-sync.yaml` for Git repository synchronization with FluxCD. - Created `kustomization.yaml` to manage FluxCD resources. - Added `values.yaml` for Git repository configuration. - Implemented `ClusterProvider` and `Deployment` for OpenMCP with Kind. - Defined `kind-cluster-config.yaml` for Kind cluster configuration. - Established OpenMCP operator deployment with necessary configurations and secrets. - Added namespace and kustomization resources for OpenMCP. - Included usage operator configuration for platform services. * refactored build command * refactor: streamline linting process in GitHub Actions and Taskfile
1 parent 2bdf15a commit 55dbbe0

34 files changed

+30688
-0
lines changed

.github/workflows/lint.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Lint YAML and Kustomization
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- "templates/**.yaml"
7+
- "templates/**.yml"
8+
push:
9+
paths:
10+
- "templates/**.yaml"
11+
- "templates/**.yml"
12+
13+
jobs:
14+
lint:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Set up Python
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: "3.x"
24+
25+
- name: Install Task
26+
uses: arduino/setup-task@v2
27+
with:
28+
version: 3.x
29+
repo-token: ${{ secrets.GITHUB_TOKEN }}
30+
31+
- name: Run lint task
32+
run: task lint

.github/workflows/publish.yaml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Publish
2+
3+
on:
4+
push:
5+
tags:
6+
- v*
7+
workflow_dispatch:
8+
9+
permissions:
10+
packages: write
11+
12+
env:
13+
OCI_URL: ghcr.io/openmcp-project
14+
15+
jobs:
16+
release_tag:
17+
name: Release version
18+
runs-on: ubuntu-24.04
19+
steps:
20+
- name: Create GitHub App token
21+
uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2
22+
id: app-token
23+
with:
24+
# required
25+
app-id: 1312871
26+
private-key: ${{ secrets.OPENMCP_CI_APP_PRIVATE_KEY }}
27+
28+
- name: Checkout code
29+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
30+
with:
31+
token: ${{ steps.app-token.outputs.token }}
32+
fetch-tags: true
33+
fetch-depth: 0
34+
submodules: recursive
35+
36+
- name: Install Task
37+
uses: arduino/setup-task@v2
38+
with:
39+
version: 3.x
40+
repo-token: ${{ secrets.GITHUB_TOKEN }}
41+
42+
- name: Read and validate VERSION
43+
id: version
44+
run: |
45+
VERSION=$(task version)
46+
if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-dev(-[0-9a-f]*)?)?$ ]]; then
47+
echo "Invalid version format: $VERSION"
48+
exit 1
49+
fi
50+
echo "New version: $VERSION"
51+
echo "version=$VERSION" >> $GITHUB_ENV
52+
53+
- name: Skip release if version is a dev version
54+
if: contains(env.version, '-dev')
55+
run: |
56+
echo "Skipping development version release: ${{ env.version }}"
57+
echo "SKIP=true" >> $GITHUB_ENV
58+
exit 0
59+
60+
- name: Set up QEMU
61+
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3
62+
63+
- name: Set up Docker Context for Buildx
64+
id: buildx-context
65+
run: |
66+
docker context create builders
67+
68+
- name: Login to GitHub Container Registry
69+
uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3
70+
with:
71+
registry: ghcr.io
72+
username: ${{ github.actor }}
73+
password: ${{ secrets.GITHUB_TOKEN }}
74+
75+
- name: Set up Docker Buildx
76+
timeout-minutes: 5
77+
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3
78+
with:
79+
version: latest
80+
81+
- name: Set up Go
82+
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5
83+
with:
84+
go-version-file: go.mod
85+
86+
- name: Build and Push OCM Component
87+
run: |
88+
task build --verbose
89+
task push --verbose

.github/workflows/release.yaml

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: Versioned Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: write # we need this to be able to push tags
10+
pull-requests: read
11+
12+
env:
13+
OCI_URL: ghcr.io/openmcp-project
14+
15+
jobs:
16+
release_tag:
17+
name: Release version
18+
runs-on: ubuntu-24.04
19+
steps:
20+
- name: Create GitHub App token
21+
uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2
22+
id: app-token
23+
with:
24+
# required
25+
app-id: 1312871
26+
private-key: ${{ secrets.OPENMCP_CI_APP_PRIVATE_KEY }}
27+
28+
- name: Checkout code
29+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
30+
with:
31+
token: ${{ steps.app-token.outputs.token }}
32+
fetch-tags: true
33+
fetch-depth: 0
34+
submodules: recursive
35+
- name: test-action
36+
run: cd hack/common; git status
37+
- name: Install Task
38+
uses: arduino/setup-task@v2
39+
with:
40+
version: 3.x
41+
repo-token: ${{ secrets.GITHUB_TOKEN }}
42+
43+
- name: Read and validate VERSION
44+
id: version
45+
run: |
46+
VERSION=$(task version)
47+
if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-dev(-[0-9a-f]*)?)?$ ]]; then
48+
echo "Invalid version format: $VERSION"
49+
exit 1
50+
fi
51+
echo "New version: $VERSION"
52+
echo "version=$VERSION" >> $GITHUB_ENV
53+
54+
- name: Skip release if version is a dev version
55+
if: contains(env.version, '-dev')
56+
run: |
57+
echo "Skipping development version release: ${{ env.version }}"
58+
echo "SKIP=true" >> $GITHUB_ENV
59+
exit 0
60+
61+
- name: Check if VERSION is already tagged
62+
id: check_tag
63+
run: |
64+
if git rev-parse "refs/tags/${{ env.version }}" >/dev/null 2>&1; then
65+
echo "Tag ${{ env.version }} already exists. Skipping release."
66+
echo "SKIP=true" >> $GITHUB_ENV
67+
exit 0
68+
fi
69+
echo "Tag ${{ env.version }} doesn't exists. Proceeding with release."
70+
71+
- name: Create Git tag
72+
if: ${{ env.SKIP != 'true' }}
73+
run: |
74+
AUTHOR_NAME=$(git log -1 --pretty=format:'%an')
75+
AUTHOR_EMAIL=$(git log -1 --pretty=format:'%ae')
76+
echo "Tagging as $AUTHOR_NAME <$AUTHOR_EMAIL>"
77+
78+
echo "AUTHOR_NAME=$AUTHOR_NAME" >> $GITHUB_ENV
79+
echo "AUTHOR_EMAIL=$AUTHOR_EMAIL" >> $GITHUB_ENV
80+
81+
git config user.name "$AUTHOR_NAME"
82+
git config user.email "$AUTHOR_EMAIL"
83+
84+
git tag -a "${{ env.version }}" -m "Release ${{ env.version }}"
85+
git push origin "${{ env.version }}"
86+
87+
NESTED_GO_MODULES="$(task release:list-nested-modules)"
88+
89+
for MODULE in $NESTED_GO_MODULES; do
90+
git tag -a "${MODULE}/${{ env.version }}" -m "Release ${{ env.version }}"
91+
git push origin "${MODULE}/${{ env.version }}"
92+
done
93+
94+
- name: Build Changelog
95+
id: github_release
96+
run: task r:generate-changelog
97+
env:
98+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
99+
100+
- name: Create GitHub release
101+
if: ${{ env.SKIP != 'true' }}
102+
uses: softprops/action-gh-release@72f2c25fcb47643c292f7107632f7a47c1df5cd8 # v2
103+
with:
104+
tag_name: ${{ env.version }}
105+
name: Release ${{ env.version }}
106+
body_path: ./CHANGELOG.md
107+
draft: true
108+
prerelease: false
109+
env:
110+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
111+
112+
- name: Push dev VERSION
113+
if: ${{ env.SKIP != 'true' }}
114+
run: |
115+
task release:set-version --verbose -- "${{ env.version }}-dev"
116+
git config user.name "${{ env.AUTHOR_NAME }}"
117+
git config user.email "${{ env.AUTHOR_EMAIL }}"
118+
git add VERSION
119+
git commit -m "chore(release): Update VERSION to ${{ env.version }}-dev"
120+
git push origin main

.github/workflows/reuse.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: REUSE Compliance Check
2+
3+
on: [push, pull_request]
4+
5+
permissions:
6+
contents: read
7+
8+
jobs:
9+
run_reuse:
10+
uses: openmcp-project/build/.github/workflows/reuse.lib.yaml@main
11+
secrets: inherit

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
**/config/*

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "hack/common"]
2+
path = hack/common
3+
url = https://github.com/openmcp-project/build.git

Taskfile.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
version: '3'
2+
3+
includes:
4+
release:
5+
taskfile: hack/common/tasks_rls.yaml
6+
aliases:
7+
- rls
8+
- r
9+
10+
tasks:
11+
build:
12+
desc: Build ocm component
13+
cmds:
14+
- |
15+
ocm add componentversions \
16+
--copy-resources --force --create \
17+
--file .out \
18+
--settings settings.yaml \
19+
component-constructor.yaml
20+
lint:
21+
desc: Lint YAML files in templates directory
22+
cmds:
23+
- yamllint templates
24+
25+
push:
26+
desc: Push to OCM Registry
27+
cmds:
28+
- ocm transfer ctf -f .out "{{.COMPONENT_REGISTRY}}" {{.overwrite_mod}}
29+
vars:
30+
overwrite_mod:
31+
sh: 'if [[ -n ${OVERWRITE_COMPONENTS:-} ]] && [[ ${OVERWRITE_COMPONENTS} != "false" ]]; then echo -n "--overwrite"; fi'
32+
COMPONENT_REGISTRY:
33+
sh: 'PROJECT_ROOT="{{.ROOT_DIR2}}" hack/common/get-registry.sh --component'
34+
35+
flux:
36+
desc: Renders the latest flux template using the flux cli
37+
cmds:
38+
- |
39+
flux install --export \
40+
--components-extra="image-reflector-controller,image-automation-controller" \
41+
> gotk-components.yaml
42+
dir: ./templates/fluxcd
43+
44+
pull:
45+
desc: Pulls the resources from the gitops-template ocm.
46+
cmds:
47+
- |
48+
ocm download resources \
49+
--downloader ocm/dirtree \
50+
--repo OCIRegistry::ghcr.io/n3rdc4ptn/ocm \
51+
github.com/openmcp-project/gitops-templates:0.0.2 \
52+
openmcp fluxcd
53+
54+
template:
55+
desc: Testing command just to show the templates
56+
cmds:
57+
- |
58+
helm template --output-dir {{.OUTPUT_DIR}} \
59+
--set openmcpOperator.image="ghcr.io/openmcp-project/images/openmcp-operator" \
60+
--set openmcpOperator.tag="latest" \
61+
./github.com/openmcp-project/gitops-templates/0.0.2/openmcp
62+
- |
63+
helm template --output-dir {{.OUTPUT_DIR}} \
64+
--set openmcpOperator.image="ghcr.io/openmcp-project/images/openmcp-operator" \
65+
--set openmcpOperator.tag="latest" \
66+
./github.com/openmcp-project/gitops-templates/0.0.2/openmcp
67+
vars:
68+
OUTPUT_DIR: "output"

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v0.0.1

component-constructor.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
components:
2+
- name: "github.com/openmcp-project/gitops-templates"
3+
version: "${OPENMCP_VERSION}"
4+
labels:
5+
- name: "org.opencontainers.image.source"
6+
value: "https://github.com/openmcp-project/gitops-templates"
7+
provider:
8+
name: openmcp-project
9+
resources:
10+
- name: openmcp-operator
11+
type: ociImage
12+
input:
13+
type: ociImage
14+
path: ghcr.io/openmcp-project/images/openmcp-operator:${OPENMCP_OPERATOR_VERSION}
15+
repository: openmcp-project/openmcp-operator
16+
- name: openmcp
17+
type: fileSystem
18+
input:
19+
type: dir
20+
path: ./templates/openmcp
21+
- name: fluxcd
22+
type: fileSystem
23+
input:
24+
type: dir
25+
path: ./templates/fluxcd
26+
- name: gitops-templates
27+
type: blob
28+
version: ${OPENMCP_VERSION}
29+
access:
30+
type: gitHub
31+
repoUrl: "https://github.com/openmcp-project/gitops-templates"
32+
commit: "2bdf15aab6df0234ef7621d4a876e4e37eaf1fa0"

docs/commands.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
```
2+
ocm add componentversions --copy-resources --force --create --file .out --settings settings.yaml component-constructor.yaml
3+
4+
ocm transfer ctf --copy-resources --enforce -f .out ghcr.io/n3rdc4ptn/ocm
5+
6+
ocm download resources --downloader ocm/dirtree --repo OCIRegistry::ghcr.io/n3rdc4ptn/ocm github.com/openmcp-project/gitops-templates:0.0.1 openmcp openmcpdir
7+
```

0 commit comments

Comments
 (0)