Accessing application-config from charm code

Is there a way to access application-config items from charm code?

The k8s charm I’m writing is for an application that needs to know its URL. If I could access juju-external-hostname from the charm code, I would not need to add a charm setting.

However, application-config items don’t show up in config-get on Juju 2.8-rc2.

1 Like

The application settings were done to nominally to inform Juju of how to provision resources rather than things the charm needed to know. In the case of expose in particular, the Juju model is quite limited - a charm can only ask to open ports to the whole world and for all endpoints. We are looking to enhance the expose model to allow ports to be restricted to certain subnet ranges or particular endpoints. This perhaps sort of falls into that rework, ie it could be considered a charm config that is passed to juju as part of the enhanced expose model.

1 Like

Since Juju unfortunately doesn’t support configuring TLS ingress, I’ve ended up changing my approach to use a site_url setting on the application. It’s a pity, because the only thing I’m adding to the ingress over what Juju already provides is the “tls” dict.

You can work around juju expose by having your charm create a k8s ingress resource directly, eg.

version: 2
    - name: test-ingress
        foo: bar
      annotations: /
        - http:
            - path: /testpath
                serviceName: test
                servicePort: 80

Yep, this is what the MP I linked above does, albeit via the operator framework.