Manage extensions

Contents:

View all the available extensions

To view all the available Rockcraft / Charmcraft extensions, run the rockcraft list-extensions / charmcraft list-extensions command. Sample session:

$ charmcraft list-extensions
Extension name    Supported bases    Experimental bases
----------------  -----------------  --------------------
flask-framework                      ubuntu@22.04    

See more: Rockcraft | rockcraft list-extensions, charmcraft list-extensions

View details about the extension in use

Suppose you’ve initialised a rock / charm with a profile that comes with an extension (currently, flask-framework), and your rockcraft.yaml / charmcraft.yaml > extensions lists this extension.


See sample context
$ mkdir my-flask-app-k8s
$ cd my-flask-app-k8s/
$ charmcraft init --profile flask-framework
Charmed operator package file and directory tree initialised.                                                                                                                                
                                                                                                                                                                                             
Now edit the following package files to provide fundamental charm metadata                                                                                                                   
and other information:                                                                                                                                                                       
                                                                                                                                                                                             
charmcraft.yaml                                                                                                                                                                              
src/charm.py                                                                                                                                                                                 
README.md                                                                                                                                                                                    
                                                                                                                                                                                             
user@ubuntu:~/my-flask-app-k8s$ ls -R
.:
charmcraft.yaml  requirements.txt  src

./src:
charm.py
 
$ cat charmcraft.yaml 
# This file configures Charmcraft.
# See https://juju.is/docs/sdk/charmcraft-config for guidance.

name: my-flask-app-k8s

type: charm

bases:
  - build-on:
    - name: ubuntu
      channel: "22.04"
    run-on:
    - name: ubuntu
      channel: "22.04"

# (Required)
summary: A very short one-line summary of the flask application.

# (Required)
description: |
  A comprehensive overview of your Flask application.

extensions:
  - flask-framework

# Uncomment the integrations used by your application
# requires:
#   mysql:
#     interface: mysql_client
#     limit: 1
#   postgresql:
#     interface: postgresql_client
#     limit: 1



To view details about what that extension is adding to your rock / charm, set the ROCKCRAFT_ENABLE_EXPERIMENTAL_EXTENSIONS / CHARMCRAFT_ENABLE_EXPERIMENTAL_EXTENSIONS to 1, then run the rockcraft expand-extensions / charmcraft expand-extensions command. For example:

CHARMCRAFT_ENABLE_EXPERIMENTAL_EXTENSIONS=1 charmcraft expand-extensions

See effect given sample context
$ CHARMCRAFT_ENABLE_EXPERIMENTAL_EXTENSIONS=1 charmcraft expand-extensions
*EXPERIMENTAL* extension 'flask-framework' enabled                                                                                                                                           
name: my-flask-app-k8s
summary: A very short one-line summary of the flask application.
description: |
  A comprehensive overview of your Flask application.
parts:
  charm:
    source: .
    charm-entrypoint: src/charm.py
    charm-binary-python-packages: []
    charm-python-packages: []
    charm-requirements:
    - requirements.txt
    charm-strict-dependencies: false
    plugin: charm
type: charm
bases:
- build-on:
  - name: ubuntu
    channel: '22.04'
  run-on:
  - name: ubuntu
    channel: '22.04'
actions:
  rotate-secret-key:
    description: Rotate the flask secret key. Users will be forced to log in again.
      This might be useful if a security breach occurs.
assumes:
- k8s-api
containers:
  flask-app:
    resource: flask-app-image
peers:
  secret-storage:
    interface: secret-storage
provides:
  metrics-endpoint:
    interface: prometheus_scrape
  grafana-dashboard:
    interface: grafana_dashboard
requires:
  logging:
    interface: loki_push_api
  ingress:
    interface: ingress
    limit: 1
resources:
  flask-app-image:
    type: oci-image
    description: flask application image.
config:
  options:
    webserver-keepalive:
      type: int
      description: Time in seconds for webserver to wait for requests on a Keep-Alive
        connection.
    webserver-threads:
      type: int
      description: Run each webserver worker with the specified number of threads.
    webserver-timeout:
      type: int
      description: Time in seconds to kill and restart silent webserver workers.
    webserver-workers:
      type: int
      description: The number of webserver worker processes for handling requests.
    flask-application-root:
      type: string
      description: Path in which the application / web server is mounted. This configuration
        will set the FLASK_APPLICATION_ROOT environment variable. Run `app.config.from_prefixed_env()`
        in your Flask application in order to receive this configuration.
    flask-debug:
      type: boolean
      description: Whether Flask debug mode is enabled.
    flask-env:
      type: string
      description: What environment the Flask app is running in, by default it's 'production'.
    flask-permanent-session-lifetime:
      type: int
      description: Time in seconds for the cookie to expire in the Flask application
        permanent sessions. This configuration will set the FLASK_PERMANENT_SESSION_LIFETIME
        environment variable. Run `app.config.from_prefixed_env()` in your Flask application
        in order to receive this configuration.
    flask-preferred-url-scheme:
      type: string
      default: HTTPS
      description: Scheme for generating external URLs when not in a request context
        in the Flask application. By default, it's "HTTPS". This configuration will
        set the FLASK_PREFERRED_URL_SCHEME environment variable. Run `app.config.from_prefixed_env()`
        in your Flask application in order to receive this configuration.
    flask-secret-key:
      type: string
      description: The secret key used for securely signing the session cookie and
        for any other security related needs by your Flask application. This configuration
        will set the FLASK_SECRET_KEY environment variable. Run `app.config.from_prefixed_env()`
        in your Flask application in order to receive this configuration.
    flask-session-cookie-secure:
      type: boolean
      description: Set the secure attribute in the Flask application cookies. This
        configuration will set the FLASK_SESSION_COOKIE_SECURE environment variable.
        Run `app.config.from_prefixed_env()` in your Flask application in order to
        receive this configuration.                                                 


See more: rockcraft expand-extensions, charmcraft expand-extensions


Contributors: @lengau , @tmihoc

Last updated 6 days ago. Help improve this document in the forum.