Core Kubernetes · 08
Namespaces and Ingress
1.What is a Namespace ?
A scope for names. A name is unique inside its namespace, and the next namespace can reuse it.
- No nesting. Each namespaced object lives in exactly one.
- Name = RFC 1123 DNS label. The fixed label
kubernetes.is added for you.io/ metadata. name - Deleting one deletes all inside (phase
Terminating): Pods first, then the rest. - Production : make your own, skip
default.
| Built in | Used for |
|---|---|
| default | Your objects when you name no namespace |
| kube-system | Objects Kubernetes itself creates |
| kube-public | Readable by anyone, even anonymous. Mostly cluster use |
| kube-node-lease | One Lease per node, the kubelet heartbeat for spotting dead nodes |
The kube- prefix is reserved for system namespaces.
2.Names and policy, not traffic
Each of these is namespaced and acts only at home :
- Role + RoleBinding : RBAC, here only
- ResourceQuota : total cap, 403 if over
- LimitRange : per Pod / Container limits
- NetworkPolicy : traffic (section 4)
DNS crosses the line too. A Service is <svc>.<ns>.. A bare api only finds your own namespace's api (the search list starts there), so use api.team-b or the full name.
3.Namespaced or not ?
| Kind | In a ns ? | Short |
|---|---|---|
| Namespace | No | ns |
| ResourceQuota | Yes | quota |
| LimitRange | Yes | limits |
| Role / RoleBinding | Yes | none |
| ClusterRole | No | none |
| NetworkPolicy | Yes | netpol |
| Ingress | Yes | ing |
| IngressClass | No | none |
apiVersion : v1 for the first three, rbac. for RBAC, networking. for the last three.
4.NetworkPolicy : the real wall
- Namespaced L3/L4 allow-list for TCP, UDP, SCTP.
- Pods start open. Once a policy selects a Pod for Ingress or Egress, only allowed traffic passes. Policies add up, no deny rules.
- Both ends must agree : egress at the source and ingress at the target.
- No
policyTypes? Ingress is implied. Egress only if it has egress rules. - Needs an enforcing network plugin (Antrea, Calico, Cilium, Kube-router, kind's kindnet). Without one it is stored and ignored, with no warning.
- A policy cannot name a namespace. Match the label
kubernetes..io/ metadata. name=web - In one
fromentry, namespaceSelector + podSelector mean AND. As two list items (two dashes) they mean OR. - Default-deny egress also blocks DNS. Allow the CoreDNS Pods.
- Test a deny policy before you trust it.
1.Ingress : rules, not a proxy
An Ingress (networking., namespaced) is just HTTP routing rules. A controller carries the traffic.
- No controller ? Stored, does nothing.
- HTTP / HTTPS only (80, 443). Else use a NodePort or LoadBalancer Service.
- Backends : Services in its own namespace.
- v1.37 : GA since v1.19, frozen. It stays, but the project recommends Gateway API.
2.Inside an Ingress
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata: {name: shop, namespace: shop}
spec:
ingressClassName: example-class
tls: # hosts = rule hosts
- {hosts: [shop.example.com], secretName: shop-tls}
rules:
- host: shop.example.com
http:
paths:
- path: /api
pathType: Prefix # required
backend:
service: {name: api, port: {number: 8080}}
- path: /
pathType: Prefix
backend: # port: number OR name
service: {name: web, port: {name: http}}
Host first (exact, or *.foo.com = one label), then the longest path, Exact winning ties. No match : spec., else the controller decides.
| Type | Path | Request | Match ? |
|---|---|---|---|
| Exact | /foo | /foo/ | no |
| Prefix | /foo/ | /foo/ | yes |
| Prefix | /foo/ | /foo/ | no, whole parts |
| Prefix | /foo/ | /foo/ | yes |
| ImplementationSpecific : up to the IngressClass | |||
- TLS ends at the LB or controller, plain text after. Port 443 only, hosts share it by SNI.
- Secret type
kubernetes.io/tls(tls.crt,tls.key). A rule with no host gets no TLS. Certs : cert-manager.
3.Picking a controller
- Cluster-scoped.
spec.controller(domain-prefixed, immutable) names the controller. - Default :
ingressclass.. Two defaults = class-less Ingresses rejected.kubernetes. io/ is-default-class: "true" kubernetes.annotation : deprecated.io/ ingress. class
- Last releases 2026-03-19, archived 2026-03-24. No more fixes, not even security. Installs keep running.
- Not F5's NGINX Ingress.
nginx.annotations don't carry over.ingress. kubernetes. io/* - Way out : Gateway API (ingress2gateway 1.0 converts) or another controller.
4.Commands
| Command | What it tells you |
|---|---|
kubectl get ingressclass | Classes and their controllers |
kubectl get ing -A | Empty ADDRESS = no controller took it (yet) |
kubectl describe ingress shop -n shop | Rules, backends with endpoints, events |
kubectl create ingress shop --rule="shop. | Draft YAML. Trailing * = Prefix, else Exact |
kubectl create secret tls shop-tls -n shop --cert=tls.crt --key=tls.key | The Secret for spec.tls |
kubectl get pods -A --selector app. | Still running the retired controller ? |