Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@ Target repositories are configured in `repositories.yaml` in the following form:
|pretty_string
| The actual name of the product, including whitespaces and proper capitalization. This is intended to be used in doc or man files or similar things.

|include_crds
| Whether to include files from the `deploy/crd` folder into the os package.

*Default*: true

|include_productconfig
| Whether to include files from the `deploy/config-spec` folder into the os package.

Expand Down
6 changes: 3 additions & 3 deletions playbook/update_repo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

- name: Ensure directories exist
file:
path: "{{ item.path | replace(template_dir, work_dir + '/' + operator.name) | replace('[[product]]', operator.product_string) | dirname }}"
path: "{{ item.path | replace(template_dir, work_dir + '/' + operator.name) | replace('[[operator]]', operator.name) | dirname }}"
state: directory
with_items:
- "{{ files_j2.files }}"
Expand All @@ -62,7 +62,7 @@
template:
src: "{{ item.path }}"
mode: "preserve"
dest: "{{ item.path | replace(template_dir, work_dir + '/' + operator.name) | replace('[[product]]', operator.product_string) | regex_replace('.j2$', '') }}"
dest: "{{ item.path | replace(template_dir, work_dir + '/' + operator.name) | replace('[[operator]]', operator.name) | regex_replace('.j2$', '') }}"
variable_start_string: "{["
variable_end_string: "}]"
block_start_string: "{[%"
Expand All @@ -74,7 +74,7 @@
copy:
src: "{{ item.path }}"
mode: "preserve"
dest: "{{ item.path | replace(template_dir, work_dir + '/' + operator.name) | replace('[[product]]', operator.product_string)}}"
dest: "{{ item.path | replace(template_dir, work_dir + '/' + operator.name) | replace('[[operator]]', operator.name)}}"
with_items: "{{ files_normal.files }}"
register: file_result

Expand Down
6 changes: 6 additions & 0 deletions repositories.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ repositories:
url: stackabletech/druid-operator.git
product_string: druid
pretty_string: Apache Druid
- name: secret-operator
url: stackabletech/secret-operator.git
product_string: secret-operator
pretty_string: Stackable Secret Operator
run_as: custom
include_productconfig: false

# Anything specified in the retired_files variable will be deleted.
# This is uncommented as I had issues with everything being deleted when this was just present as an empty key.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to specify the 'deploy/crd' folder here I think, otherwise the files in there will remain in the repos as orphans.

Copy link
Copy Markdown
Contributor Author

@nightkr nightkr Mar 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those files are created by the build.rs scripts (which aren't templated), so they'll just be recreated on the next build. This requires manual intervention for each repo anyway (and I have created followup issues for this: stackabletech/zookeeper-operator#446 etc).

Comment thread
nightkr marked this conversation as resolved.
Expand Down
33 changes: 13 additions & 20 deletions template/Makefile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@

TAG := $(shell git rev-parse --short HEAD)

VERSION := $(shell cargo metadata --format-version 1 | jq '.packages[] | select(.name=="stackable-{[ operator.product_string }]-operator") | .version')
VERSION := $(shell cargo metadata --format-version 1 | jq '.packages[] | select(.name=="stackable-{[ operator.name }]") | .version')

## Docker related targets
docker-build:
docker build --force-rm -t "docker.stackable.tech/stackable/{[ operator.product_string }]-operator:${VERSION}" -f docker/Dockerfile .
docker build --force-rm -t "docker.stackable.tech/stackable/{[ operator.name }]:${VERSION}" -f docker/Dockerfile .
{[% if operator.product_string in ['opa'] %}]
docker build --force-rm -t "docker.stackable.tech/stackable/{[ operator.product_string }]-bundle-builder:${VERSION}" -f docker/Dockerfile.builder .
{[% endif %}]

docker-build-latest: docker-build
docker tag "docker.stackable.tech/stackable/{[ operator.product_string }]-operator:${VERSION}" \
"docker.stackable.tech/stackable/{[ operator.product_string }]-operator:latest"
docker tag "docker.stackable.tech/stackable/{[ operator.name }]:${VERSION}" \
"docker.stackable.tech/stackable/{[ operator.name }]:latest"

docker-publish:
echo "${NEXUS_PASSWORD}" | docker login --username github --password-stdin docker.stackable.tech
docker push --all-tags docker.stackable.tech/stackable/{[ operator.product_string }]-operator
docker push --all-tags docker.stackable.tech/stackable/{[ operator.name }]
{[% if operator.product_string in ['opa'] %}]
docker push --all-tags docker.stackable.tech/stackable/{[ operator.product_string }]-bundle-builder
{[% endif %}]
Expand All @@ -38,21 +38,21 @@ docker-release: docker-build-latest docker-publish
compile-chart: version crds config

chart-clean:
rm -rf deploy/helm/{[ operator.product_string }]-operator/configs
rm -rf deploy/helm/{[ operator.product_string }]-operator/crds
rm -rf deploy/helm/{[ operator.name }]/configs
rm -rf deploy/helm/{[ operator.name }]/crds

version:
yq eval -i '.version = ${VERSION} | .appVersion = ${VERSION}' deploy/helm/{[ operator.product_string }]-operator/Chart.yaml
yq eval -i '.version = ${VERSION} | .appVersion = ${VERSION}' deploy/helm/{[ operator.name }]/Chart.yaml

config:
if [ -d "deploy/config-spec/" ]; then\
mkdir -p deploy/helm/{[ operator.product_string }]-operator/configs;\
cp -r deploy/config-spec/* deploy/helm/{[ operator.product_string }]-operator/configs;\
mkdir -p deploy/helm/{[ operator.name }]/configs;\
cp -r deploy/config-spec/* deploy/helm/{[ operator.name }]/configs;\
fi

crds:
mkdir -p deploy/helm/{[ operator.product_string }]-operator/crds
cat deploy/crd/*.yaml | yq eval '.metadata.annotations["helm.sh/resource-policy"]="keep"' - > deploy/helm/{[ operator.product_string }]-operator/crds/crds.yaml
mkdir -p deploy/helm/{[ operator.name }]/crds
cargo run crd | yq eval '.metadata.annotations["helm.sh/resource-policy"]="keep"' - > deploy/helm/{[ operator.name }]/crds/crds.yaml

chart-lint: compile-chart
docker run -it -v $(shell pwd):/build/helm-charts -w /build/helm-charts quay.io/helmpack/chart-testing:v3.5.0 ct lint --config deploy/helm/ct.yaml
Expand All @@ -65,11 +65,4 @@ clean-manifests:
generate-manifests: clean-manifests compile-chart
./scripts/generate-manifests.sh

clean-crds:
rm -rf deploy/crd/*

generate-crds:
touch rust/operator-binary/build.rs
cargo build

regenerate-charts: clean-crds chart-clean clean-manifests generate-crds compile-chart generate-manifests
regenerate-charts: chart-clean clean-manifests compile-chart generate-manifests
4 changes: 2 additions & 2 deletions template/deny.toml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ allow = [

exceptions = [
{ name = "stackable-{[ operator.product_string }]-crd", allow = ["OSL-3.0"] },
{ name = "stackable-{[ operator.product_string }]-operator", allow = ["OSL-3.0"] },
{ name = "stackable-{[ operator.product_string }]-operator-binary", allow = ["OSL-3.0"] },
{ name = "stackable-{[ operator.name }]", allow = ["OSL-3.0"] },
{ name = "stackable-{[ operator.name }]-binary", allow = ["OSL-3.0"] },
{[% if operator.extra_crates is not undefined %}]{[% for crate in operator.extra_crates %}]{ name = "{[crate}]", allow = ["OSL-3.0"] },
{[% endfor %}]{[% endif -%}]
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
apiVersion: v2
name: {[ operator.product_string }]-operator
name: {[ operator.name }]
version: <version_placeholder>
appVersion: "<version_placeholder>"
description: The Stackable Operator for {[ operator.pretty_string }]

home: https://github.com/stackabletech/{[ operator.product_string }]-operator
home: https://github.com/stackabletech/{[ operator.name }]

maintainers:
- name: Stackable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@ This Helm Chart can be used to install Custom Resource Definitions and the Opera
# From the root of the operator repository
make compile-chart

helm install {[ operator.product_string }]-operator deploy/helm/{[ operator.product_string }]-operator
helm install {[ operator.name }] deploy/helm/{[ operator.name }]
```

## Usage of the CRDs

The usage of this operator and its CRDs is described in the [documentation](https://docs.stackable.tech/{[ operator.product_string }]/index.html)

The operator has example requests included in the [`/examples`](https://github.com/stackabletech/{[ operator.product_string }]/operator/tree/main/examples) directory.
The operator has example requests included in the [`/examples`](https://github.com/stackabletech/{[ operator.name }]/tree/main/examples) directory.

## Links

https://github.com/stackabletech/{[ operator.product_string }]-operator
https://github.com/stackabletech/{[ operator.name }]

Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{[% if operator.run_as is undefined or operator.run_as == "deployment" %}]
---
apiVersion: apps/v1
kind: Deployment
Expand Down Expand Up @@ -66,3 +67,6 @@ spec:
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{[% else %}]
# Templated Deployment disabled for this operator
{[% endif %}]
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Default values for {[ operator.product_string }]-operator.
# Default values for {[ operator.name }].
---
image:
repository: docker.stackable.tech/stackable/{[ operator.product_string }]-operator
repository: docker.stackable.tech/stackable/{[ operator.name }]
pullPolicy: IfNotPresent

imagePullSecrets: []
Expand Down
6 changes: 3 additions & 3 deletions template/docker/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ RUN microdnf update --disablerepo=* --enablerepo=ubi-8-baseos --enablerepo=ubi-8
&& microdnf install --disablerepo=* --enablerepo=ubi-8-baseos shadow-utils -y \
&& rm -rf /var/cache/yum

COPY --from=builder /app/stackable-{[ operator.product_string }]-operator /
COPY --from=builder /app/stackable-{[ operator.name }] /
{[% if operator.include_productconfig is undefined or operator.include_productconfig == true %}]
COPY deploy/config-spec/properties.yaml /etc/stackable/{[ operator.product_string }]-operator/config-spec/properties.yaml
COPY deploy/config-spec/properties.yaml /etc/stackable/{[ operator.name }]/config-spec/properties.yaml
{[% endif %}]

RUN groupadd -g 1000 stackable && adduser -u 1000 -g stackable -c 'Stackable Operator' stackable

USER 1000:1000

ENTRYPOINT ["/stackable-{[ operator.product_string }]-operator"]
ENTRYPOINT ["/stackable-{[ operator.name }]"]
CMD ["run"]
6 changes: 3 additions & 3 deletions template/scripts/generate-manifests.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ tmp=$(mktemp -d ./manifests-XXXXX)

helm template --output-dir "$tmp" \
--include-crds \
--name-template {[ operator.product_string }]-operator \
deploy/helm/{[ operator.product_string }]-operator
--name-template {[ operator.name }] \
deploy/helm/{[ operator.name }]

while IFS= read -r -d '' file
do
Expand All @@ -17,6 +17,6 @@ do
sed -i '/# Source: .*/d' "$file"
done < <(find "$tmp" -type f)

cp -r "$tmp"/{[ operator.product_string }]-operator/*/* deploy/manifests/
cp -r "$tmp"/{[ operator.name }]/*/* deploy/manifests/

rm -rf "$tmp"