Core Configuration Resources and YAML Structure
Kubernetes relies on declarative YAML manifests that define desired state for cluster resources. Every manifest requires four foundational fields: apiVersion, kind, metadata, and spec.
Essential Resources for CKA
Master these core resources:
- Pods: Smallest deployable units containing containers with image, ports, and resource specifications
- Deployments: Manage Pod replicas through ReplicaSets with rolling updates
- Services: Provide stable networking endpoints using selectors
- ConfigMaps: Store non-sensitive key-value configuration data
- Secrets: Store sensitive data like passwords and tokens in base64 encoding
- PersistentVolumes: Cluster storage resources independent of Pod lifecycle
- PersistentVolumeClaims: Pod requests for persistent storage
How Resources Interact
Exam questions test resource relationships. A Deployment references a Pod template that may reference ConfigMaps and Secrets for configuration. Understanding these connections helps you answer scenario-based questions.
YAML Mastery Through Flashcards
Practicing YAML syntax via flashcards internalizes field names, valid values, and indentation rules. You avoid documentation lookups during the exam, saving precious time.
ConfigMaps and Secrets: Storing Application Configuration
ConfigMaps and Secrets separate configuration from container images. This lets the same image run across different environments without rebuilding.
ConfigMaps: Non-Sensitive Data
ConfigMaps store application properties, feature flags, and configuration files. Create them using three approaches:
- Literal values:
kubectl create configmap myconfig --from-literal=key=value - Files:
kubectl create configmap myconfig --from-file=path/to/file - Directories:
kubectl create configmap myconfig --from-file=path/to/directory
Pods mount ConfigMaps as environment variables or volumes for runtime access.
Secrets: Sensitive Data
Secrets store passwords, API tokens, and certificates using base64 encoding (not encrypted by default). Common types include:
- Opaque: Arbitrary sensitive data
- docker-registry: Container registry credentials
- tls: Certificate and key pairs
Create Secrets with: kubectl create secret generic mysecret --from-literal=password=secret123
Mounting Both Resources
Exam scenarios test mounting both ConfigMaps and Secrets correctly. Mount ConfigMaps as volumes at specific paths, or inject as environment variables using valueFrom with configMapKeyRef. Same approach applies to Secrets.
Critical detail: Modifying ConfigMaps does not automatically restart Pods using them via volumes. Kubernetes doesn't watch for changes, so applications see stale data until manual Pod restart.
Resource Requests, Limits, and Namespace Quotas
Resource management appears extensively in CKA exams. Every Pod container should define requests and limits for CPU and memory.
Requests vs. Limits
Requests represent minimum guaranteed resources. The scheduler uses requests to place Pods on nodes with sufficient capacity. Without requests, the scheduler cannot constrain placement.
Limits define maximum resource usage. Containers exceeding memory limits face OOMKilled termination. Containers exceeding CPU limits experience throttling, not termination.
CPU uses millicores (1000m equals 1 full CPU). Memory uses bytes with units like Mi (mebibytes) and Gi (gibibytes). Example: a container with requests of 100m CPU and 128Mi memory, limits of 500m CPU and 256Mi memory.
ResourceQuotas and LimitRanges
ResourceQuotas enforce resource usage across entire namespaces. A quota might limit a namespace to 10 total CPUs and 20Gi memory across all Pods.
LimitRanges provide per-container or per-Pod constraints. You can enforce minimum requests of 50m CPU and maximum limits of 2 CPU per container.
Critical Interaction
ResourceQuotas require containers to specify requests. Containers without requests may not schedule on constrained nodes. CKA exams test creating these resources via YAML and diagnosing scheduling failures from insufficient resources.
Flashcards help memorize specific API fields: requests, limits, cpu, memory, and unit conventions for each resource type.
RBAC: Role-Based Access Control Configuration
Role-Based Access Control (RBAC) secures Kubernetes by restricting actions for users, service accounts, and applications.
Four Primary RBAC Resources
The CKA exam requires understanding these resources:
- Role: Namespace-scoped permissions defining allowed verbs on resources
- ClusterRole: Cluster-wide permissions for cluster-scoped resources or all namespaces
- RoleBinding: Connects a Role to subjects (users, groups, service accounts) within a namespace
- ClusterRoleBinding: Connects ClusterRoles to subjects cluster-wide
Permission Structure
Roles specify three components in rules:
- apiGroups: Empty string for core API, "apps" for Deployments
- resources: pods, deployments, services, etc.
- verbs: create, get, list, watch, update, patch, delete
Example: a developer Role allows create, get, list, and watch on Pods but denies deletion.
Service Accounts and Bindings
Service accounts are Kubernetes identities for applications. Every Pod runs with a service account. You can mount the account's authentication token to allow Pod applications to call the Kubernetes API.
Typical exam pattern: create a ServiceAccount, define a ClusterRole with specific permissions, create a RoleBinding granting that role to the service account.
Verification and Testing
Test permissions with: kubectl auth can-i create pods --as=system:serviceaccount:default:myapp-sa. This command verifies if a service account has specific permissions.
Flashcards help memorize RoleBinding YAML structure and RBAC verb syntax.
Network Policies and Security Best Practices for Configuration
NetworkPolicies control traffic flow between Pods at the network layer, implementing zero-trust security. By default, Kubernetes allows all Pod-to-Pod communication.
How NetworkPolicies Work
NetworkPolicies use label selectors to target Pods and specify allowed traffic. They implement ingress rules (incoming traffic) and egress rules (outgoing traffic).
Example: create a NetworkPolicy allowing only frontend Pods to send traffic to backend Pods on port 5432, blocking all others.
Ingress rules define which source Pods or external IPs can reach targeted Pods. Egress rules define where Pods can send traffic. If you specify ingress rules, all other ingress traffic is denied by default.
Critical Requirement
NetworkPolicies require a compatible container networking interface (CNI) like Calico or Cilium. They don't work with the default kubelet networking. This is essential for exam scenarios.
Broader Security Configuration
Beyond NetworkPolicies, secure configuration involves:
- Define resource requests and limits to prevent resource exhaustion attacks
- Use RBAC to restrict API access
- Implement PodSecurityStandards to enforce container constraints (non-root users, no privileged containers)
- Use Secrets with encryption-at-rest enabled for sensitive data
- Set security context fields in Pod specs to control privileges, user ID, and filesystem permissions
Exam scenarios combine multiple concepts requiring you to secure entire application deployments across these layers.
