Kubernetes

Welcome to Kubernetes

Your guide to understanding the codebase.

Learning Path

  • 14 units • 4 levels

Orchestration & APIs (3 units)

  • Kubernetes API Fundamentals
  • API Group Organization and Versioning
  • API Machinery and Resource Lifecycle

Core Logic & Data (3 units)

  • Workload and Scheduling APIs
  • Networking and Storage Infrastructure
  • Security and Access Control

Interaction & Integration (3 units)

  • API Extensions and Aggregation
  • OpenAPI Specification Organization
  • Admission Control and Webhooks

Cross-Cutting Concerns (2 units)

  • Events and Observability
  • Development Tooling and Contribution

Test Your Knowledge

Test your deep understanding of the codebase.

Question Tiers

  1. Why
  2. Purpose & Problem
  3. Design & Patterns
  4. Implementation

Hands-On Assignment

Your Challenge

Implement a custom API resource called 'ResourceQuota' that tracks and limits the number of Pods a namespace can create. Your implementation should include a new API type with proper versioning (v1alpha1), a custom controller that watches Pod creation events, and an admission webhook that validates Pod creation requests against the quota limits. The quota should be configurable per namespace and persist its state.

Starting Points

  • api/discovery/aggregated_v2.json:1-111
  • Makefile:1-50
  • CHANGELOG.md:1-37
  • staging/src/k8s.io/api/core/v1/types.go
  • staging/src/k8s.io/apiserver/pkg/admission/plugin/webhook/
  • staging/src/k8s.io/sample-controller/
  • pkg/controller/
  • staging/src/k8s.io/api/

Success Criteria

  1. Custom ResourceQuota API type is defined with proper versioning (v1alpha1) and includes Spec and Status fields.
  2. Code generation completes successfully and produces clientset, listers, and informers for your new type.
  3. Controller successfully watches Pod events and updates ResourceQuota status with current pod count.
  4. Admission webhook denies Pod creation when namespace quota would be exceeded.
  5. ResourceQuota can be created, updated, and deleted using kubectl.
  6. Status field accurately reflects current usage vs. limits in real-time.
  7. Existing Kubernetes tests still pass: make test.

Hints

  1. Understanding API Machinery concept.
  2. API Type Structure implementation.
  3. Controller Implementation Pattern implementation.
  4. Admission Webhook Integration implementation.
  5. Code Generation code location.
  6. Testing Your Implementation implementation.

Prerequisites

  • Go programming fundamentals
  • Kubernetes API concepts (resources, controllers, admission control)
  • Understanding of informers and workqueues
  • Basic webhook concepts.