-
Notifications
You must be signed in to change notification settings - Fork 5
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
Share k8s worker and control-plane charms #11
Conversation
54d12af
to
3aeecaa
Compare
What is the status here Adam? |
I think i wanna get back into it. Lemme resolve and see if we can get this guy rolling |
1eb3480
to
a4e404b
Compare
… catch ReconcilerErrors
69c70c3
to
591b106
Compare
Really need the following PRs to land first |
0efd35d
to
0921cd0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, only a minor comment
67a728d
to
ccd8c39
Compare
charms/k8s/charmcraft.yaml
Outdated
lib: | ||
# move the ./worker/lib path to ./lib since | ||
# charmcraft assumes it to be there once the charm runs | ||
after: [charm] | ||
plugin: nil | ||
source: ./ | ||
override-prime: | | ||
rm -rf $CRAFT_PRIME/lib | ||
mv $CRAFT_PRIME/worker/lib $CRAFT_PRIME/lib |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, it seems that charmcraft expects the lib folder to always been at the same path level as charmcraft.yaml and other "charm files" when run on the unit.
This moves the lib/ folder to the top level during the charm build process.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a brief comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! LGTM 🎉
e0687f2
to
efb55ae
Compare
Structure of the charms
The
k8s
andk8s-worker
charms are noticeably tucked into one-another.While unfamiliar to some charm developers, this lets both charms share the exact same
src
folder. This is accomplished by using theparts.charm.charm-entrypoint
value in theworker
directory set tok8s/src/charm.py
.What's unique
The unique parts of the charm are what are in each charm's top-level directory:
In order to exclude the
k8s
exclusive components from thek8s-worker
charm, charmcraft will read theworker/.jujuignore
file to determine what to leave out of the final charm.What's not
The shared portions of each charm are within
worker/k8s
(except for the above mentioned exclusions). This includes shared libraries fromworker/k8s/lib
, shared source fromworker/k8s/src
, shared python dependencies fromworker/k8s/requirements.txt
How to distinguish which charm code should engage
The charm can distinguish whether it's a
control-plane
orworker
unit by usingself.is_worker
orself.is_control_plane
by querying its metadata.Why two charms?
Much of the charm's behavior will be identical. They will employ many of the same relations, many of the same resources, configure the same snap, and use many of the same configuration options. One might therefore assume the two should be 1 charm. History with Charmed Kubernetes has proven that having 2 charms split between control-plane and worker has advantages when a relation is split across
requires
andprovides
.Why not use a charm library?
Sharing code between a charm library is a really reasonable idea, there are limitations that a charm library presents:
How to use two charms in the same code base:
In cases where the charms should diverge the behavior, use a runtime switch to make the decision