Giter VIP home page Giter VIP logo

operator's Introduction

The ops library

The ops library is a Python framework (available on PyPI) for developing and testing Juju charms in a consistent way, using standard Python constructs to allow for clean, maintainable, and reusable code.

A charm is an operator -- business logic encapsulated in a reusable software package that automates every aspect of an application's life.

Charms written with ops support Kubernetes using Juju's "sidecar charm" pattern, as well as charms that deploy to Linux-based machines and containers.

Charms should do one thing and do it well. Each charm drives a single application and can be integrated with other charms to deliver a complex system. A charm handles creating the application in addition to scaling, configuration, optimisation, networking, service mesh, observability, and other day-2 operations specific to the application.

The ops library is part of the Charm SDK (the other part being Charmcraft). Full developer documentation for the Charm SDK is available at https://juju.is/docs/sdk.

To learn more about Juju, visit https://juju.is/docs/olm.

Pure Python

The framework provides a standardised Python object model that represents the application graph, as well as an event-handling mechanism for distributed system coordination and communication.

The latest version of ops requires Python 3.8 or above.

Juju itself is written in Go for efficient concurrency even in large deployments. Charms can be written in any language, however, we recommend using Python with this framework to make development easier and more standardised. All new charms at Canonical are written using it.

Getting started

A package of operator code is called a charmed operator or simply "charm". You'll use charmcraft to register your charm name and publish it when you are ready. You can follow one of our charming tutorials to get started writing your first charm.

Testing your charms

The framework provides a testing harness, so you can ensure that your charm does the right thing in different scenarios, without having to create a full deployment. Our API documentation has the details, including this example:

harness = Harness(MyCharm)
# Do initial setup here
relation_id = harness.add_relation('db', 'postgresql')
# Now instantiate the charm to see events as the model changes
harness.begin()
harness.add_relation_unit(relation_id, 'postgresql/0')
harness.update_relation_data(relation_id, 'postgresql/0', {'key': 'val'})
# Check that charm has properly handled the relation_joined event for postgresql/0
self.assertEqual(harness.charm. ...)

Talk to us

If you need help, have ideas, or would just like to chat with us, reach out on the Charmhub Mattermost.

We also pay attention to the Charmhub Discourse.

And of course you can deep dive into the API reference.

Development of the framework

See HACKING.md for details on dev environments, testing, and so on.

operator's People

Contributors

benhoyt avatar chipaca avatar jameinel avatar dshcherb avatar johnsca avatar pietropasotti avatar rwcarlsen avatar jnsgruk avatar facundobatista avatar rbarry82 avatar niemeyer avatar pengale avatar sed-i avatar balbirthomas avatar hpidcock avatar vultaire avatar tinvaan avatar abuelodelanada avatar mthaddon avatar dstathis avatar markshuttle avatar yanksyoon avatar weiiwang01 avatar carlcsaposs-canonical avatar phvalguima avatar umtdg avatar timclicks avatar simondeziel avatar gregory-schiano avatar zmraul avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.