Skip to content

feat!: Add conversion webhook #958

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
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
1,301 changes: 775 additions & 526 deletions Cargo.lock

Large diffs are not rendered by default.

3,421 changes: 2,239 additions & 1,182 deletions Cargo.nix

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ repository = "https://github.com/stackabletech/zookeeper-operator"
[workspace.dependencies]
product-config = { git = "https://github.com/stackabletech/product-config.git", tag = "0.7.0" }
stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git", features = ["telemetry", "versioned"], tag = "stackable-operator-0.93.1" }
stackable-webhook = { git = "https://github.com/stackabletech/operator-rs.git", tag = "stackable-operator-0.93.1" }

anyhow = "1.0"
built = { version = "0.8", features = ["chrono", "git2"] }
Expand All @@ -31,8 +32,10 @@ tokio = { version = "1.40", features = ["full"] }
tokio-zookeeper = "0.4"
tracing = "0.1"

#[patch."https://github.com/stackabletech/operator-rs"]
[patch."https://github.com/stackabletech/operator-rs"]
# stackable-operator = { git = "https://github.com/stackabletech//operator-rs.git", branch = "main" }
stackable-operator = { path = "/home/sbernauer/stackable/operator-rs/main/crates/stackable-operator" }
stackable-webhook = { path = "/home/sbernauer/stackable/operator-rs/main/crates/stackable-webhook" }
Comment on lines +37 to +38
Copy link
Member

Choose a reason for hiding this comment

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

note(to self): We should add the stackable-webhook crate as a re-export in stackable-operator.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, I though the same before adding it here.
Back then I quickly tried it, but ran into https://github.com/stackabletech/operator-rs/blob/7328943f420156c4b5ebcfbd7cbbddfbd5b63348/crates/stackable-operator/src/lib.rs#L38-L39


[patch.crates-io]
# tokio-zookeeper = { path = "../tokio-zookeeper" }
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ compile-chart: version crds config

chart-clean:
rm -rf "deploy/helm/${OPERATOR_NAME}/configs"
rm -rf "deploy/helm/${OPERATOR_NAME}/crds"

version:
cat "deploy/helm/${OPERATOR_NAME}/Chart.yaml" | yq ".version = \"${VERSION}\" | .appVersion = \"${VERSION}\"" > "deploy/helm/${OPERATOR_NAME}/Chart.yaml.new"
Expand All @@ -117,9 +116,10 @@ config:
cp -r deploy/config-spec/* "deploy/helm/${OPERATOR_NAME}/configs";\
fi

# We generate a crds.yaml as preview, so that the effect of code changes are visible.
# The operator will take care of the CRD rollout itself.
crds:
mkdir -p deploy/helm/"${OPERATOR_NAME}"/crds
cargo run --bin stackable-"${OPERATOR_NAME}" -- crd | yq eval '.metadata.annotations["helm.sh/resource-policy"]="keep"' - > "deploy/helm/${OPERATOR_NAME}/crds/crds.yaml"
cargo run --bin stackable-"${OPERATOR_NAME}" -- crd > 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 Down
27 changes: 8 additions & 19 deletions Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,16 @@ custom_build(
outputs_image_ref_to='result/ref',
)

# Load the latest CRDs from Nix
watch_file('result')
if os.path.exists('result'):
k8s_yaml('result/crds.yaml')

# We need to set the correct image annotation on the operator Deployment to use e.g.
# oci.stackable.tech/sandbox/opa-operator:7y19m3d8clwxlv34v5q2x4p7v536s00g instead of
# oci.stackable.tech/sandbox/opa-operator:0.0.0-dev (which does not exist)
k8s_kind('Deployment', image_json_path='{.spec.template.metadata.annotations.internal\\.stackable\\.tech/image}')

# Exclude stale CRDs from Helm chart, and apply the rest
helm_crds, helm_non_crds = filter_yaml(
helm(
'deploy/helm/' + operator_name,
name=operator_name,
namespace="stackable-operators",
set=[
'image.repository=' + registry + '/' + operator_name,
],
),
api_version = "^apiextensions\\.k8s\\.io/.*$",
kind = "^CustomResourceDefinition$",
)
k8s_yaml(helm_non_crds)
k8s_yaml(helm(
'deploy/helm/' + operator_name,
name=operator_name,
namespace="stackable-operators",
set=[
'image.repository=' + registry + '/' + operator_name,
],
))
84 changes: 84 additions & 0 deletions _test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
---
apiVersion: zookeeper.stackable.tech/v1alpha1
kind: Person
metadata:
name: sbernauer1
spec:
username: sbernauer1
---
apiVersion: zookeeper.stackable.tech/v1alpha2
kind: Person
metadata:
name: sbernauer2
spec:
username: sbernauer2
firstName: Sebastian
lastName: Bernauer
---
apiVersion: zookeeper.stackable.tech/v1beta1
kind: Person
metadata:
name: sbernauer3
spec:
username: sbernauer3
firstName: Sebastian
lastName: Bernauer
---
apiVersion: zookeeper.stackable.tech/v2
kind: Person
metadata:
name: sbernauer4
spec:
username: sbernauer4
firstName: Sebastian
lastName: Bernauer
gender: Male
---
apiVersion: zookeeper.stackable.tech/v3
kind: Person
metadata:
name: sbernauer5
spec:
username: sbernauer5
firstName: Sebastian
lastName: Bernauer
gender: Male




---
apiVersion: zookeeper.stackable.tech/v1alpha1
kind: Person
metadata:
name: sbernauer40
spec:
username: sbernauer40
---
apiVersion: zookeeper.stackable.tech/v1alpha1
kind: Person
metadata:
name: sbernauer41
spec:
username: sbernauer41
---
apiVersion: zookeeper.stackable.tech/v1alpha1
kind: Person
metadata:
name: sbernauer42
spec:
username: sbernauer42
---
apiVersion: zookeeper.stackable.tech/v1alpha1
kind: Person
metadata:
name: sbernauer43
spec:
username: sbernauer43
---
apiVersion: zookeeper.stackable.tech/v1alpha1
kind: Person
metadata:
name: sbernauer44
spec:
username: sbernauer44
7 changes: 0 additions & 7 deletions crate-hashes.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading