Portable workloads and provider integrations
Portable API objects versus portable behavior
A Deployment describes replicated Pods; a Service provides a stable access point; a PersistentVolumeClaim (PVC) requests storage. These standard Kubernetes objects can often be reused across providers, but the infrastructure they request can differ. The same YAML may be accepted in EKS, AKS and GKE yet produce different network routes, storage classes, IAM behavior and bills. Portability includes behavior, data and operations, not just syntax.
A useful design separates a base workload from reviewed provider-specific overlays. The base holds common image, resource, health and internal-service settings. An overlay supplies the actual registry reference, workload identity association, storage class and approved ingress integration. Maintain one versioned interface contract and test each target separately.
Read a static workload manifest
The following is an illustrative, non-deployable teaching fixture. The image is a placeholder at a reserved domain, and the fictional application contract is HTTP port 8080 with a /ready endpoint. A real lab requires an approved image pinned by digest, verified probes, namespace, resource policy and access controls. No cloud account is necessary to read it.
apiVersion: apps/v1kind: Deploymentmetadata: name: catalogspec: replicas: 3 selector: matchLabels: app: catalog template: metadata: labels: app: catalog spec: containers: - name: catalog image: registry.example/catalog:illustrative ports: - containerPort: 8080 resources: requests: cpu: 250m memory: 128Mi limits: cpu: 500m memory: 256Mi readinessProbe: httpGet: path: /ready port: 8080---apiVersion: v1kind: Servicemetadata: name: catalogspec: type: ClusterIP selector: app: catalog ports: - port: 80 targetPort: 8080The Service matches Pods labeled app: catalog and forwards to their port 8080 when endpoints are eligible. ClusterIP is for internal service access, not an external load balancer or authentication boundary. If the application does not listen on 8080 or readiness fails, valid YAML alone does not provide a working service. Three replicas request 750m CPU and 384Mi memory before additional overhead.
Network, storage and access overlays
A Service with type LoadBalancer asks an implementation to provision or integrate a load balancer. Internal versus external exposure, health checks, annotations, address ownership and charges depend on the controller and provider. Never assume a private cluster API makes every workload private. Start with ClusterIP and review an explicit internal entry-point design, caller authentication, ingress and egress policy. Verify that the installed network implementation enforces the intended NetworkPolicy. DNS and access from other networks need separate tests.
A PVC's storageClassName refers to an actual cluster StorageClass, which describes provisioning and storage policy. EBS on AWS, Azure managed disks and Compute Engine persistent disks are candidate block-storage families; their CSI configuration and mode support must be verified. File storage may suit shared filesystem access instead. Check zone placement, access modes, performance, encryption, expansion, snapshot support, reclaim policy and backup/restore. A retained volume can cost money after a workload is deleted. A PVC copied to another cluster does not copy its data.
For identity, use a dedicated service account and a provider-specific association granting only the required data resource actions. Image pull authorization is separate from application authorization. A successful image pull does not prove access to a database or bucket. Check authentication, DNS, reachability and permission individually.
Test readiness before switching traffic
This deterministic Python example is an offline decision function. It uses precomputed boolean evidence, not actual Kubernetes or cloud API results. It prioritizes missing capacity, identity, storage and network evidence. A passing result means ready for human review, not permission to deploy.
def readiness_gate(ready, required, identity_ok, storage_ok, network_ok): if ready < required: return "hold: capacity" if not identity_ok: return "hold: identity" if not storage_ok: return "hold: storage" if not network_ok: return "hold: network" return "candidate: review"
print(readiness_gate(3, 3, True, True, True))print(readiness_gate(3, 3, True, False, True))Expected output:
candidate: reviewhold: storageIn the second case the application has enough ready replicas, but the storage check failed, so traffic should not be switched on the basis of readiness alone. In a real migration use independent read/write tests with synthetic data, authorization checks for allowed and denied actions, telemetry and a rollback plan. Validate the API schema and admission behavior on an authorized staging cluster; offline parsing alone does not test scheduling, provisioning or policy enforcement.
Troubleshoot and recover systematically
If a Pod stays Pending, inspect scheduling events, requested capacity, affinities, quotas, IP availability and PVC binding. If it is running but not ready, inspect the probe, port, logs and dependencies. If the Service has no ready endpoints, compare selectors and Pod readiness before changing networking. If an external entry point fails, inspect the controller, routes, firewall, TLS and application health. A 403 from a cloud API suggests reviewing the effective workload principal and IAM policy, not widening permissions indiscriminately.
Backup application configuration and persistent data separately. Define RPO (acceptable data loss) and RTO (time to recover), restore to an isolated destination, verify application data and permissions, then plan the cutover. Monitor error rate, latency, resource saturation, restart counts, pending Pods, controller errors and backup age. Remove only lab-owned resources after approval. Keep the provider overlay and dependency inventory in version control; never include live tokens or kubeconfig.
Practice and next steps
Compare the base manifest on three paper clusters with different storage class names, identity mechanisms and private ingress controllers. Identify which fields belong in an overlay and list evidence needed to approve traffic switching. Run the Python gate locally with invented booleans. Explain why a successful gate is not proof of actual cloud deployment. Next: infrastructure as code and configuration management.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Portable workloads and provider integrations — knowledge check
Choose the best answer for each offline scenario.
What does a ClusterIP Service primarily provide?
What happens when a PVC is copied to another cluster?
A Pod can pull its private image but gets a cloud API 403. What should you review?
What does a passing offline readiness gate prove?
Which item belongs in a provider-specific overlay?