Kubernetes Security & Hardening›Traffic Security · Cheat sheet & self-check

Traffic Security · wrap-up

Cheat sheet & self-check

Every command from this section on one page.

07 · Ingress controllers & TLS

Inspect

kubectl get ingressclassInstalled controllers (and the default)
kubectl get ingress -AHosts, addresses and TLS per Ingress
kubectl describe ingress <name>Rules, backends and events

Test TLS

curl -vk --resolve shop.example.com:443:<LB-IP> https://shop.example.com/Test a host before DNS points to it
openssl s_client -connect <LB-IP>:443 -servername shop.example.com </dev/null | openssl x509 -noout -subject -datesWhich certificate is served for this name (SNI)

08 · Gateway API

Objects

GatewayClassWhich implementation (like IngressClass): owned by the infrastructure provider
GatewayListeners (ports, protocols, hostnames, TLS): owned by the platform team
HTTPRouteRouting rules for an app: owned by the app team
ReferenceGrantAllows a reference into another namespace (e.g. a Route to a Service)

Inspect

kubectl get gatewayclass,gateway -AImplementations and gateways (with addresses)
kubectl get httproute -ARoutes and their parent gateways
kubectl describe httproute <name>status.parents: Accepted / ResolvedRefs conditions

09 · Network policies & mTLS

Policy building blocks

podSelector: {}All pods in the namespace
policyTypes: ["Ingress", "Egress"]Which directions this policy restricts
namespaceSelector: {matchLabels: {kubernetes.io/metadata.name: shop}}Pods in a specific namespace (label set automatically)
ipBlock: {cidr: 10.0.0.0/8}Traffic to/from IP ranges (outside the cluster)

Test

kubectl -n shop exec deploy/web -- wget -qO- -T 3 http://api:8080Allowed? (timeout = blocked)
kubectl get networkpolicy -AWhich namespaces are isolated