How would you create a Kubernetes Charm for more than one Deployment/Pod?

I’m currently working on a PoC for a Kubernetes charm and operator written in Python which would deploy OpenFaaS.

The excellent example show show to deploy a single container, which whilst useful, presents a problem for multi-container projects like OpenFaaS. The exported YAML is around 2200 lines, so difficult to write as JSON objects.

The other issue is that the example only shows a single Pod for an application. Can someone point me at a sample or documentation which would help us deploy all of the resources required by the Operator?

https://github.com/openfaas/faas-netes/tree/master/yaml

Thanks,

Alex

This is the sample operator from the Operator Day Canonical ran recently. https://github.com/jlounder/training-operator

Some examples also mention being “reactive” instead of whatever the example above is. What does that mean? How does it differ? Is one legacy? Are we meant to avoid it?

If someone should land here, I’m also struggling to get the Operator framework to accept env-vars and can’t find any documentation on the schema.

Discourse won’t allow me to post a link to GitHub?
github com canonical operator issues 463

I wondered what the reason was for flagging my two initial comments?

I apologize @alexellisuk it appears that your posts triggered the spam protection. They have both been restored :+1:

Welcome to the community :smile:

I believe by default Discourse wants you to participate a bit before sharing particular kinds of links. Sorry about the

It should be possible to have multiple containers within a single pod, it will depend whether those are logically distinct apps with a different lifecycle (thus separate pods) or pieces of the same app (thus containers in the same pod).

As for environment variables, in earlier version of the pod spec schema, this was called “config”. In v3 of the pod spec:

It is called envConfig to make it clearer that what you are passing in that block are environment variables for the runtime of the container.

Hi Alex!

I wanted to touch on a couple items from your previous posts. First, I’m sorry your post was hidden. You hit an automated spam protection which flags posts from new accounts when several posts are created in a short period of time, with links. You account has been moved out of “new user” status, so you should not run into the same issue again.

Second, the term “reactive” refers to an older charming framework. The “Operator Framework” is our current development focus - it was started near the end of 2019. The reactive framework is an older attempt at creating a Python framework for charm development. It relied heavily on a state machine and decorators, which makes following the flow of code/events more difficult to new developers, so we’re in the process of retiring it in favor of the Operator Framework.

You will likely find a lot of references to “reactive” among documentation and even within this forum. We’re working on isolating the newest documentation to make it more clear where to go for “Operator Framework” content.

With a better understanding of your use-case, I can see your need for running multiple containers within a pod. As mentioned in the issue you opened on the training codebase, we do support multiple containers via pod.set_spec. If you run into any issues, please reach out and we will be happy to assist.

Thank you for the reply, perhaps you could have a browse of the repo I started? I summarise the container dependencies and the challenges I see I’m converting openfaas
https://github.com/alexellis/openfaas-charm-example

The main multi-pod deployment is the gateway think also ships its own Kubernetes operator with RBAC. The others should all be single containers per Deployment.

For something like inlets (cloud native tunnel), it’s so much easier with a single pod and container acting as a client or a server.