Skip to content

Commit 936ec3a

Browse files
authored
Add a script generating files for OperatorHub.io (#302)
Make a few adjustements to the base CSVs.
1 parent 82b6e39 commit 936ec3a

File tree

5 files changed

+92
-12
lines changed

5 files changed

+92
-12
lines changed

CONTRIBUTING.md

+20
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,26 @@ If several `It` sections are similar, consider refactoring them in a `DescribeTa
4848
- [Kubernetes Contributor Guide](https://git.k8s.io/community/contributors/guide) - Main contributor documentation, or you can just jump directly to the [contributing section](https://git.k8s.io/community/contributors/guide#contributing)
4949
- [Contributor Cheat Sheet](https://git.k8s.io/community/contributors/guide/contributor-cheatsheet) - Common resources for existing developers
5050

51+
## Managing releases
52+
53+
### OperatorHub.io
54+
55+
After a new version is released, it must be added manually to the
56+
[k8s-operatorhub/community-operators](https://github.com/k8s-operatorhub/community-operators) repo to be available on
57+
OperatorHub.io.
58+
59+
First, generate all manifests:
60+
61+
```shell
62+
make operatorhub-release IMAGE_TAG=<RELEASE_TAG> VERSION=<VERSION_NUMBER>
63+
```
64+
65+
This will create two directories, `kmm-operatorhub-<VERSION>` and `kmm-hub-operatorhub-<VERSION>`.
66+
67+
Then, use the contents of those directories to create new versions in
68+
[k8s-operatorhub/community-operators](https://github.com/k8s-operatorhub/community-operators).
69+
Only one operator should be affected per pull request; create separate PRs if you want to update both KMM bundles.
70+
5171
## Mentorship
5272

5373
- [Mentoring Initiatives](https://git.k8s.io/community/mentoring) - We have a diverse set of mentorship programs available that are always looking for volunteers!

Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -343,5 +343,8 @@ catalog-push: ## Push a catalog image.
343343
signimage-build: ## Build docker image with the signer.
344344
docker build -f Dockerfile.signimage -t $(SIGNER_IMG) .
345345

346+
operatorhub-release:
347+
IMG=$(IMG) HUB_IMG=$(HUB_IMG) VERSION=$(VERSION) ./hack/release-operatorhub
348+
346349
include docs.mk
347350

config/manifests-hub/bases/kernel-module-management-hub.clusterserviceversion.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ kind: ClusterServiceVersion
33
metadata:
44
annotations:
55
alm-examples: '[]'
6-
capabilities: Basic Install
6+
capabilities: Seamless Upgrades
77
categories: Drivers and plugins
8+
repository: https://github.com/kubernetes-sigs/kernel-module-management
89
name: kernel-module-management-hub.v0.0.0
910
namespace: placeholder
1011
spec:
@@ -42,8 +43,6 @@ spec:
4243
- module
4344
- modules
4445
links:
45-
- name: GitHub repository
46-
url: https://github.com/kubernetes-sigs/kernel-module-management
4746
- name: Documentation
4847
url: https://kmm.sigs.k8s.io
4948
- name: Slack
@@ -52,6 +51,7 @@ spec:
5251
5352
name: Kernel Module Management
5453
maturity: stable
54+
minKubeVersion: 1.24.0
5555
provider:
5656
name: Kubernetes SIG Node
5757
url: https://github.com/kubernetes-sigs/kernel-module-management

config/manifests/bases/kernel-module-management.clusterserviceversion.yaml

+4-9
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,15 @@ kind: ClusterServiceVersion
33
metadata:
44
annotations:
55
alm-examples: '[]'
6-
capabilities: Basic Install
6+
capabilities: Seamless Upgrades
77
categories: Drivers and plugins
8-
name: kmm-operator.v0.0.0
8+
repository: https://github.com/kubernetes-sigs/kernel-module-management
9+
name: kernel-module-management.v0.0.0
910
namespace: placeholder
1011
spec:
1112
apiservicedefinitions: {}
1213
customresourcedefinitions:
1314
owned:
14-
- description: Module is the Schema for the modules API
15-
displayName: Module
16-
kind: Module
17-
name: modules.kmm.sigs.x-k8s.io
18-
version: v1alpha1
1915
- description: Module describes how to load a module on different kernel versions
2016
displayName: Module
2117
kind: Module
@@ -52,8 +48,6 @@ spec:
5248
- module
5349
- modules
5450
links:
55-
- name: GitHub repository
56-
url: https://github.com/kubernetes-sigs/kernel-module-management
5751
- name: Documentation
5852
url: https://kmm.sigs.k8s.io
5953
- name: Slack
@@ -62,6 +56,7 @@ spec:
6256
6357
name: Kernel Module Management
6458
maturity: stable
59+
minKubeVersion: 1.24.0
6560
provider:
6661
name: Kubernetes SIG Node
6762
url: https://github.com/kubernetes-sigs/kernel-module-management

hack/release-operatorhub

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/usr/bin/env bash
2+
3+
# This script generates bundle directories to be imported into OperatorHub.io.s
4+
5+
set -euo pipefail
6+
7+
make_output_dir () {
8+
local -r dir=$1
9+
10+
if ! [ -d "$dir" ]; then
11+
mkdir "$dir"
12+
else
13+
rm -fr "${dir:?}"/*
14+
fi
15+
}
16+
17+
created_at=$(date +'%Y-%m-%d %H:%M:%S')
18+
readonly created_at
19+
20+
replace_csv () {
21+
local -r container_image=$1
22+
local -r csv_path=$2
23+
24+
yq -i "
25+
.metadata.annotations.containerImage = \"$container_image\" |
26+
.metadata.annotations.createdAt = \"$created_at\"" \
27+
"$csv_path"
28+
}
29+
30+
: "$IMG"
31+
: "$HUB_IMG"
32+
: "$VERSION"
33+
34+
# KMM
35+
36+
output_dir="kmm-operatorhub-$VERSION"
37+
38+
echo "Generating KMM bundle files for OperatorHub in $output_dir"
39+
40+
make bundle VERSION="$VERSION"
41+
42+
make_output_dir "$output_dir"
43+
44+
cp -r bundle/* "$output_dir"
45+
46+
replace_csv "$IMG" "$output_dir/manifests/kernel-module-management.clusterserviceversion.yaml"
47+
48+
# KMM-Hub
49+
50+
output_dir="kmm-hub-operatorhub-$VERSION"
51+
52+
echo "Generating KMM-Hub bundle files for OperatorHub in $output_dir"
53+
54+
make bundle-hub VERSION="$VERSION"
55+
56+
make_output_dir "$output_dir"
57+
58+
cp -r bundle/* "$output_dir"
59+
60+
replace_csv "$HUB_IMG" "$output_dir/manifests/kernel-module-management-hub.clusterserviceversion.yaml"
61+
62+
echo 'Done.'

0 commit comments

Comments
 (0)