Skip to content

Basic implementation of ZooKeeper Operator - #7

Closed
lfrancke wants to merge 24 commits into
stackabletech:mainfrom
lfrancke:start
Closed

lfrancke wants to merge 24 commits into
stackabletech:mainfrom
lfrancke:start

Conversation

@lfrancke

@lfrancke lfrancke commented Nov 23, 2020 •

Copy link
Copy Markdown
Member

This is a start.

It defines a simple ZooKeeperCluster object and reacts to it.
It creates pods as necessary but the configuration is still missing.

This fixes #3, #1 and #2

I will keep this as a draft until the operator-rs code has been reviewed and will then migrate this code to use the new library.

Based on https://github.com/clux/controller-rs
This does not handle deletions yet.
The operator now creates a single pod object per ZooKeeperCluster and also watches these pods for changes.
Used to be v3_5_8 but is now 3.5.8 as intended.
I need to pull out the configuration options into a common object.
This is a temporary workaround, the goal is to use nodeSelectors and let the Scheduler assign pods.
@lfrancke lfrancke linked an issue Nov 26, 2020 that may be closed by this pull request
@lfrancke lfrancke removed a link to an issue Nov 26, 2020
@lfrancke lfrancke linked an issue Nov 26, 2020 that may be closed by this pull request
@lfrancke
lfrancke requested review from soenkeliebau and removed request for soenkeliebau November 26, 2020 11:39
@lfrancke
lfrancke marked this pull request as draft November 26, 2020 11:43
@lfrancke lfrancke self-assigned this Nov 29, 2020

@soenkeliebau soenkeliebau left a comment

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.

I've left a few comments, more thoughts than actual requests for changes, I'd be happy for this to go in as is.
We are currently missing the rust build checks though, those could just go in this PR so we have them in place..

properties:
version:
type: string
enum: [ 3.4.14 ]

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.

Is this on purpose or just a leftover from the demo?

Comment thread crd/src/lib.rs
use kube::CustomResource;
use serde::{Deserialize, Serialize};
use stackable_operator::CRD;
use std::collections::HashMap;

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.

unused

Comment thread operator/src/lib.rs
/// This method contains the logic of reconciling an object (the desired state) we received with the actual state.
///
/// We distinguish between three different types:
/// * Create

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.

I'm still a bit shaky on the whole reconciliation concept, but shouldn't we treat create and update the same? From looking at the code the only extra thing we do when creating a cluster is adding the finalizer, which we use to check if we call create or update when reconciliation is started - seems to me to be a bit of hen and egg?

Comment thread operator/src/lib.rs

/// This creates an instance of a [`Controller`] which waits for incoming events and reconciles them.
///
/// This is an async method and the returned future needs to be consumed to make progress.

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.

nit: might be clearer: consumed -> awaited

Comment thread operator/src/lib.rs Outdated
zk_cluster: &ZooKeeperCluster,
context: &Context<ContextData>,
) -> Result<ReconcilerAction, Error> {
let zk_spec: ZooKeeperClusterSpec = zk_cluster.spec.clone();

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.

This could be a reference I think

Comment thread operator/src/lib.rs
labels.insert("zookeeper-name".to_string(), name.clone());

let mut options = HashMap::new();
options.insert("tickTime".to_string(), "2000".to_string());

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.

maybe add a TODO here to pull this out into a generic option crate?

Comment thread operator/src/lib.rs
for (i, server) in zk_spec.servers.iter().enumerate() {
options.insert(
format!("server.{}", i + 1),
format!("{}:2888:3888", server.node_name),

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.

add TODO to make this configurable?

Comment thread operator/src/lib.rs Outdated
patch_resource(&pods_api, &pod_name, &pod, FIELD_MANAGER).await?;

let config = handlebars
.render("conf", &json!({ "options": options }))

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.

Just a suggestion: I've used strict mode in the agent to ensure we fail early, in case a necessary variable is undefined

Comment thread operator/src/lib.rs
})
}

fn build_pod(

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.

Haven't looked too closely at this function as I assume this will change fundamentally and was more to get the demo of the ground.
What I looked at seems totally fine.

…tion of pods.

This is WIP and relies on unreviewed changes to operator-rs
@lfrancke

Copy link
Copy Markdown
Member Author

Closing in favor of a new branch

@lfrancke lfrancke closed this Dec 19, 2020
soenkeliebau added a commit that referenced this pull request Nov 24, 2021
…ackabletech/operator-templating repo.

Original commit message:
Add actions to build Helm charts to the operators and retire os package building. (#7)

* First version - mostly working

* Replace operator version placeholder in Helm chart.

* Fix ansible equality test with older jinja version and make Makefile a j2 template.

* Reenable all repos

* Bugfix: indentation and Makefile.

* Update template/.github/workflows/publish_dev_artifacts.yml.j2

Co-authored-by: Teo Klestrup Röijezon <teo.roijezon@stackable.de>

* Update repositories.yaml

Co-authored-by: Teo Klestrup Röijezon <teo.roijezon@stackable.de>

* Update template/.github/workflows/publish_dev_artifacts.yml.j2

Co-authored-by: Teo Klestrup Röijezon <teo.roijezon@stackable.de>

* Update template/.github/workflows/publish_dev_artifacts.yml.j2

Co-authored-by: Razvan-Daniel Mihai <84674+razvan@users.noreply.github.com>

* Update template/.github/workflows/publish_release_artifacts.yml.j2

Co-authored-by: Razvan-Daniel Mihai <84674+razvan@users.noreply.github.com>

* Update template/.github/workflows/publish_release_artifacts.yml.j2

Co-authored-by: Razvan-Daniel Mihai <84674+razvan@users.noreply.github.com>

* Moved crd.yaml to crds directory.

* Update template/deploy/helm/[[product]]-operator/README.md.j2

Co-authored-by: Razvan-Daniel Mihai <84674+razvan@users.noreply.github.com>

* Update template/deploy/helm/[[product]]-operator/templates/serviceaccount.yaml.j2

Co-authored-by: Siegfried Weber <mail@siegfriedweber.net>

* Removed kind action from Makefile.

Added chart linting config back in.

* Text fix

* Addressed review comments

* Added note to Readme about potentielly missing details.

* Fix yp call and indentation in Makefile.j2

* Install roles.yaml when compiling the Helm chart

* Added wildcard cluster role for all operators.

* WIP: testing hive and druid.

* WIP: testing with Trino fails.

* Make roles.yaml a Jinja template.

* More templating of the roles.yaml.j2

* Add update verb to configmaps resource.

Co-authored-by: Razvan-Daniel Mihai <84674+razvan@users.noreply.github.com>
Co-authored-by: Teo Klestrup Röijezon <teo.roijezon@stackable.de>
Co-authored-by: Siegfried Weber <mail@siegfriedweber.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Handle creation Create Zookeeper CRD (Custom Resource Definition)

2 participants