ワンクリックで
ingress
Configuring HTTP ingress with Traefik for Kubernetes charms
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Configuring HTTP ingress with Traefik for Kubernetes charms
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Known-good Juju bundle shapes (COS Lite, 12-Factor + COS, Identity Platform, Charmed Kubeflow) — canonical app lists and relation edges
Implementing Juju actions for operational tasks in charms. WHEN: add Juju actions to a charm, implement backup / rotate-credentials / restore actions, declare actions in charmcraft.yaml, write action handlers, test actions with Scenario, run actions with juju run.
Adding and validating charm configuration options. WHEN: add charm configuration options, declare config in charmcraft.yaml, validate config values in config-changed, apply config to a Pebble layer, apply config to a machine charm, write Scenario tests for config.
End-to-end workflow for building ops-framework charms for custom applications (K8s and machine). WHEN: build a custom Juju charm, write src/charm.py with Pebble, write a machine charm with systemd, decide K8s vs machine substrate, scaffold a non-paas-charm with charmcraft init, customise the ops framework charm lifecycle.
Workflow for charming infrastructure software (databases, caches, message brokers, proxies, monitoring). WHEN: charm infrastructure software, charm a database / cache / message broker / proxy / monitoring system, implement peer relations, leader election, primary/replica failover, backup and restore actions, clustering.
Expert guidance for developing, building, testing, and publishing Juju charms using charmcraft. WHEN: edit charmcraft.yaml, run charmcraft pack, run charmcraft init, manage charm libraries, publish a charm to Charmhub, set up multi-base builds, configure relations / config options, set up storage or containers.
| name | ingress |
| description | Configuring HTTP ingress with Traefik for Kubernetes charms |
Kubernetes charms that serve HTTP traffic need ingress to be reachable from outside the cluster. The standard approach in the Juju ecosystem is Traefik via the ingress relation.
traefik-k8s)ingress relation — the standard interface for requesting ingress from TraefikIn charmcraft.yaml:
requires:
ingress:
interface: ingress
limit: 1
Fetch the traefik_route / ingress library. As of Apr 2026 the
traefik_k8s libraries are not on PyPI — charmcraft fetch-libs
(or the single-library shortcut below) is the only way to pull them:
charmcraft fetch-lib charms.traefik_k8s.v2.ingress
Integrate in the charm:
import ops
from charms.traefik_k8s.v2.ingress import IngressPerAppRequirer
class MyCharm(ops.CharmBase):
def __init__(self, framework: ops.Framework):
super().__init__(framework)
self._ingress = IngressPerAppRequirer(
self,
relation_name="ingress",
port=8080,
)
self.framework.observe(
self._ingress.on.ready,
self._on_ingress_ready,
)
self.framework.observe(
self._ingress.on.revoked,
self._on_ingress_revoked,
)
def _on_ingress_ready(self, event):
url = self._ingress.url
# Store or use the external URL.
self.unit.status = ops.ActiveStatus(f"serving at {url}")
def _on_ingress_revoked(self, event):
self.unit.status = ops.ActiveStatus("running (no ingress)")
juju deploy traefik-k8s --trust --channel latest/stable
juju integrate my-charm:ingress traefik-k8s:ingress
For HTTPS, configure Traefik with a TLS certificate:
# Use the self-signed certificates operator for development.
juju deploy self-signed-certificates
juju integrate traefik-k8s:certificates self-signed-certificates:certificates
For production, use a proper certificate provider (e.g., tls-certificates-operator with Let's Encrypt or a CA).
Some applications need individual URLs per unit (e.g., database nodes that clients connect to directly):
from charms.traefik_k8s.v2.ingress import IngressPerUnitRequirer
class MyDBCharm(ops.CharmBase):
def __init__(self, framework: ops.Framework):
super().__init__(framework)
self._ingress = IngressPerUnitRequirer(
self,
relation_name="ingress",
port=5432,
)
This gives each unit its own external URL (e.g., mydb-0.example.com, mydb-1.example.com).
After relating:
# Check the Traefik status.
juju status traefik-k8s
# Get the external URL.
juju run traefik-k8s/0 show-proxied-endpoints
Test connectivity:
curl http://<traefik-ip>/<model>-<app>
The ingress library supports several configuration options:
port — the container port to route traffic to (required)scheme — http or https (default: http)strip_prefix — whether to strip the URL prefix before forwarding (default: False)Use IngressPerAppRequirer by default. Most web applications need a single URL. Only use per-unit ingress for stateful workloads where clients need to address specific replicas.
Always declare the port. The ingress library needs to know which port the workload listens on.
Handle ingress revocation. The charm should continue to function without ingress — it just will not be externally reachable.
Use --trust when deploying Traefik. It needs cluster-wide permissions to manage ingress resources.
12-factor PaaS charms get ingress automatically when using the paas-charm base with Traefik. No manual library integration is needed.
--trust on the Traefik deployment — it will fail to create ingress resources.revoked event — the charm should update its status when ingress is removed.