Services

Each Service type wraps the one before it

CLUSTERIP: ONE STABLE ADDRESS INSIDE10.96.0.20the ServicepodpodpodNODEPORT: THE SAME PORT ON EVERY NODEnode port30080LOADBALANCER: A CLOUD LOAD BALANCER IN FRONTcloud loadbalancera client onthe internetA Service gives a changing set of pods one stable address, and each type wraps the one before.ClusterIP is reachable only inside the cluster. NodePort adds a port on every node that forwards toit. LoadBalancer adds a cloud load balancer that forwards to the node port. Pods come and go, theService address stays, and kube-proxy keeps the forwarding rules up to date.

ClusterIP inside the cluster, NodePort on every node, LoadBalancer from the cloud.

Services · Going deeper

Service types, selectors and DNS

Service typeReachable fromUse it forClusterIPinside the cluster onlyone service calling another; the defaultNodePortany node address, on a high portsimple external access, and under load balancersLoadBalancera public or private cloud addressexposing one service to the outsideExternalNamea DNS name outside the clustergiving an external system an in-cluster nameHeadlessthe pod addresses themselvesStatefulSets: clients need each pod, not a balancerA Service finds its pods by label selector, and the matches are listed in EndpointSlices.kube-proxy on each node turns Services into forwarding rules. CoreDNS gives each Service a name:web.shop.svc.cluster.local is the Service "web" in the namespace "shop".

ClusterIP, NodePort, LoadBalancer, ExternalName and headless.

Ingress

One entry point routes HTTP by host and path

a browser onthe internetIngress controllerone entry point forHTTP and HTTPSshop.example.com/Service: webweb podsshop.example.com/apiService: apiapi podsAn Ingress routes HTTP requests by host name and path to different Services, through one entry point.The Ingress object is only the rules. An Ingress controller, such as ingress-nginx or Traefik, is theprogram that carries them out, and a cluster has none until you install one. Gateway API is the newerand more capable way to write such rules, and it also handles traffic that is not HTTP.

An Ingress is rules. An Ingress controller carries them out. Gateway API is the successor.

Ingress · Going deeper

Gateway API

Gateway API: the same job, split by who owns each partObjectWritten bySaysGatewayClassthe infrastructure providerwhich kind of load balancer or proxy is on offerGatewaythe cluster operatoropen this listener: port 443, this certificateHTTPRoutethe application developersend this host and path to this ServiceIngress and its limitsIngressOne object for everything; HTTP and HTTPS only; extras live in annotationsIngress is one object for one role. Gateway API is three objects for three roles.Both need a controller installed. Gateway API is the successor the Kubernetes project recommends.

GatewayClass, Gateway and HTTPRoute: three objects for three roles.

Check yourself

a clientoutsidenode 1, port 30080node 2, port 30080node 3, port 30080pods

Which Service type does the drawing show?

Network policy

Every pod can reach every pod, until a policy says otherwise

NO POLICY: EVERY POD CAN REACH EVERY PODwebapidbweb can talk straight to the databaseA NETWORKPOLICY SELECTS DB: ONLY API MAY ENTERwebapidb✗only traffic from api reaches dbBy default every pod can reach every other pod. A NetworkPolicy is how you close that.A policy selects pods by label and lists what may come in (ingress) or go out (egress). Once any policyselects a pod, everything not listed is refused. The policy is only a rule: the network pluginenforces it, so a plugin without policy support silently ignores it.

The default is allow all. A NetworkPolicy selects pods and lists what may reach them.

Network policy · Going deeper

The pod network, CNI plugins and meshes

The pod network, and the plugins that build itThe modelEvery pod has its own IP; any pod reaches any pod without address translationCNIContainer Network Interface: the standard a network plugin implementsCalicoRouting between nodes, with full NetworkPolicy supportCiliumUses eBPF in the kernel; policy, visibility, can replace kube-proxyFlannelA simple overlay network; no NetworkPolicy of its ownService meshProxies beside each pod add mutual TLS, retries and traffic metricsIstio, LinkerdThe two best-known service meshes; both CNCF graduatedCNI connects pods. A Service gives them a stable name. A mesh secures and measures the calls.

CNI plugins such as Calico and Cilium build the pod network.

Storage

A pod claims storage. It never names a disk

Podmounts the claimPersistentVolumeClaim10Gi, ReadWriteOnceStorageClassnames a CSI driverPersistentVolumea real disk, made on demandwritten by the developerset up by the administratorcreated by KubernetesThe pod is deleted and replaced.The claim and the disk remain, and the new pod mounts the same data.A pod asks for storage through a claim. It never names a disk.The claim says how much and what kind. The StorageClass says how such storage is made. Kubernetesthen creates a PersistentVolume to match and binds the two: dynamic provisioning. The volumeoutlives any pod, which is the whole point.

Pod to PersistentVolumeClaim, to StorageClass, to a PersistentVolume made on demand.

Storage · Going deeper

Access modes and kinds of volume

Access modesReadWriteOnce (RWO)Mounted read-write by one nodeReadOnlyMany (ROX)Mounted read-only by many nodesReadWriteMany (RWX)Mounted read-write by many nodes; needs shared storageReadWriteOncePod (RWOP)Mounted read-write by one single podKinds of volumeemptyDirEmpty scratch space that lives and dies with the pod: ephemeralconfigMap, secretConfiguration presented to the pod as filespersistentVolumeClaimStorage that outlives the pod: persistentReclaim policyWhen the claim is deleted: Delete the disk, or Retain itEphemeral storage shares the life of the pod. Persistent storage has a life of its own.

ReadWriteOnce, ReadWriteMany, and ephemeral against persistent.

Check yourself

The podwas deleted and replaced by a new oneIts datais still there, and the new pod reads itBecausethe pod stored it through a ?

What did the pod refer to at the "?"

Interfaces

Three plugs: CRI, CNI and CSI

Kubernetesthe coreCRIcontainerscontainerd, CRI-OCNIpod networkingCalico, Cilium, FlannelCSIstoragecloud disk drivers, Ceph through Rook, LonghornKubernetes does not run containers, connect pods or make disks. It calls a plugin for each.Three standard interfaces keep the core small and let vendors compete underneath: the ContainerRuntime Interface, the Container Network Interface and the Container Storage Interface. Changeyour cloud or your storage, and the manifests you wrote stay the same.

CRI for runtimes, CNI for networking, CSI for storage.

Interfaces · Going deeper · 1 of 2

What a service mesh adds

What a service mesh addsData planeA proxy beside each pod, usually Envoy, that carries all its trafficControl planeConfigures every proxy from one placeMutual TLSEach call is encrypted, and both ends prove who they areTraffic controlRetries, timeouts, and sending 5% of calls to a new versionObservabilityRequest rates, errors and latency for every call, with no code changeSidecarThe pattern: a helper container in the same pod as the applicationA mesh moves networking concerns out of every application and into the platform.NetworkPolicy decides which pods may connect. A mesh secures and manages the connections that are allowed.

A mesh adds mutual TLS, traffic control and metrics through sidecar proxies.

Interfaces · Going deeper · 2 of 2

Clue words for networking and storage

When the question saysThe answer isBecause it is"stable address for a set of pods"Servicepods come and go"internal only", "default type"ClusterIPinside the cluster"port on every node"NodePort30000 to 32767"cloud provider provisions an address"LoadBalancerexternal load balancer"route by host name and path"Ingress, HTTPRouteHTTP routing"role-oriented successor to Ingress"Gateway APIthree objects"resolves Service names"CoreDNScluster DNS"restrict pod-to-pod traffic"NetworkPolicyenforced by the CNI plugin"mutual TLS between services"Service meshsidecar proxies"request for storage"PersistentVolumeClaimwhat the pod uses"provision volumes on demand"StorageClassdynamic provisioning"storage plugin standard"CSIContainer Storage InterfaceNetworking and storage are half of domain 2. Learn the Service types and the claim chain first.

Service types, Ingress, NetworkPolicy, and the claim chain.

Check yourself

Encryptevery call between services, both ends verifiedMeasurerequest rate, errors and latency of each callWithoutchanging any application code

A team lists what it needs as shown. What should it add?

Lesson complete

You finished “Networking and storage”

Answer the questions along the way to see your score here.

Open in a new tab