nginx-k8s
nginx-k8s provides abstractions for Juju Charms to run a sidecar Nginx container and a corresponding Prometheus exporter.
The supported Nginx configuration is not meant to fully cover all Nginx features, but a minimal subset sufficient to cover our immediate use cases.
To install, add charmlibs-nginx-k8s to your requirements. Then in your Python code, import as:
from charmlibs import nginx_k8s
Check out the reference docs on the charmlibs docsite.
Getting started
To get started, you can add two sidecar containers to your charm's charmcraft.yaml and in charm.py,
instantiate the Nginx and NginxPrometheusExporter classes in your initializer and call their .reconcile() methods whenever you wish to synchronize the configuration files.
import ops
from charmlibs import nginx_k8s
class MyCharm(ops.CharmBase):
def __init__(self, framework: ops.Framework):
super().__init__(framework)
self._nginx = nginx_k8s.Nginx(
self.unit.get_container("nginx"), # container name as defined in charmcraft.yaml
nginx_config=nginx_k8s.NginxConfig(
server_name="foo",
upstream_configs=[
nginx_k8s.NginxUpstream(name="foo", port=4040, group="backend"),
nginx_k8s.NginxUpstream(name="bar", port=4041, group="frontend"),
],
server_ports_to_locations={8080: [
nginx_k8s.NginxLocationConfig(
path="/",
backend="foo",
backend_url="/api/v1",
headers={"a": "b"},
modifier="=",
is_grpc=True,
upstream_tls=True
),
]}
)
)
self._nginx_pexp = nginx_k8s.NginxPrometheusExporter(
self.unit.get_container('nginx-pexp-container')
)
self.framework.observe(self.on.nginx_container_pebble_ready, self._on_reconcile)
self.framework.observe(self.on.nginx_pexp_container_pebble_ready, self._on_reconcile)
def _on_reconcile(self, _):
self._nginx.reconcile(
upstreams_to_addresses={
"foo": {"http://example.com"},
"bar": {"http://example.io"},
}
)
self._nginx_pexp.reconcile()
Metadata
Release files for charmlibs-nginx-k8s 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| charmlibs_nginx_k8s-1.0.1.tar.gz | 38.7 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| charmlibs_nginx_k8s-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 56.9 kB
Release files / charmlibs_nginx_k8s-1.0.1.tar.gz
| Download URL | charmlibs_nginx_k8s-1.0.1.tar.gz |
|---|---|
| Size | 38.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9dcfeb52b9dbee77d66ab90ee86117d7494889325a2961fc7c55109b3d8dbbe9
|
|
BLAKE2b-256 checksum How to use checksums |
8b644712bd0fbeda002361ef7b5e74bbf695004a29d6f3957d436ab06648b15f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 22, 2026.
Transparency logRelease files / charmlibs_nginx_k8s-1.0.1-py3-none-any.whl
| Download URL | charmlibs_nginx_k8s-1.0.1-py3-none-any.whl |
|---|---|
| Size | 18.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8e5246e26aaa6ac749f8cd82db5a1dd30535612961afc7597c75933122c02638
|
|
BLAKE2b-256 checksum How to use checksums |
bc1cef9ff46a5cb167ec917a86cfbdcb7bc2a98a8a767efa672bc30920b78dc6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 22, 2026.
Transparency logSecurity for charmlibs-nginx-k8s 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for charmlibs_nginx_k8s-1.0.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 22, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.