Skip to content

Instantly share code, notes, and snippets.

View jpbetz's full-sized avatar

Joe Betz jpbetz

  • Google
  • Annapolis, MD
View GitHub Profile
@jpbetz
jpbetz / image.md
Last active April 23, 2026 18:24
Kubernetes API development over time
Screenshot From 2026-04-23 14-23-49
apiVersion: v1
kind: ConfigMap
metadata:
name: sample-configmap
namespace: default
labels:
app: my-sample-app
data:
# Configuration key-value pairs
database_url: "postgresql://db.example.com:5432/mydb"
@jpbetz
jpbetz / comparison.md
Last active March 6, 2026 22:51
Optimizing Kubernetes API `DeepEquals` with Go String Interning

Optimizing Kubernetes API DeepEquals with Go String Interning

Code used: jpbetz/kubernetes@intern-bench

Methodology

This measures performance impact of interning strings (via Go's unique.Make) on DeepEquals.

For each API type, the test:

  1. Fuzzes an object, populating it with strings of a specific length.
apiVersion: review.gemini.google.com/v1alpha1
kind: RepoWatch
metadata:
name: k8s
spec:
repoURL: https://github.com/kubernetes/kubernetes
githubSecretName: github-pat
review:
gemini:
prompt: |
@jpbetz
jpbetz / kubernetes-code-doc-guidance.md
Last active August 20, 2025 23:30
Kubernetes code documentation guidelines

SIG API Machinery Documentation Improvement Guidelines

Guiding Principles & Quality Standards

This is not just about adding comments; it's about elevating the developer experience for a critical part of the Kubernetes ecosystem. Contributors should aim to create documentation that is clear, comprehensive, and empowers new and existing developers to work with API Machinery effectively.

For a concrete example of the quality standard we are aiming for, please review the changes in pull request #133632, which documents the client-go library. The contents of this PR are also available in the client-go-docs branch for local inspection using git commands.

Our Target Audience: User Personas

@jpbetz
jpbetz / gist:7cc7c6478f8d0e153333c6f09815f52a
Created August 19, 2025 19:36
Tim's diff to add gofmt to hack/update-codegen.sh
diff --git hack/update-codegen.sh hack/update-codegen.sh
index ea899266851..2a2aff11276 100755
--- hack/update-codegen.sh
+++ hack/update-codegen.sh
@@ -153,6 +153,10 @@ function codegen::protobuf() {
kube::log::status "protoc ${PROTOC_VERSION} not found (can install with hack/install-protoc.sh); generating containerized..."
build/run.sh hack/_update-generated-protobuf-dockerized.sh "${apis[@]}"
fi
+
+ git_find -z \
var associativeListParserOld = func() *typed.Parser {
oldParser, err := typed.NewParser(`types:
- name: v1
map:
fields:
- name: list
type:
namedType: associativeList

Adding cross validation support to validation-gen

Overview

This document outlines recommendations for adding cross-field validation capabilities to the existing validation-gen framework in Kubernetes. By enhancing the current tag-based approach with more expressive validation constructs, we can enable complex validation scenarios while maintaining backward compatibility.

Design Principles

  1. Declarative Validation: Express complex validation rules through declarative tags
  2. Type-Safety: Leverage Go's type system for validation definitions

Kubernetes API Validation Rules - Migration Notes

Resource Analysis for Validation Migration

After analyzing the comprehensive validation rules from all Kubernetes resources, I've identified several resource kinds with diverse validation rules, particularly focusing on those with cross-field validations. These resources are prioritized based on both validation diversity and relative simplicity.

Prioritized Resources for Validation Migration

1. Service Resource

Kubernetes API Validation Rules

Introduction

Kubernetes API validation ensures that objects created or updated through the API server meet specific formatting requirements, constraints, and semantic rules before being stored in etcd. Validation occurs in multiple layers:

  1. OpenAPI Schema Validation - Validates basic structure and data types
  2. AdmissionWebhooks - Allow custom validation via webhooks
  3. Built-in Validation - The internal logic specific to each resource type
  4. CEL Validation Rules - For CustomResourceDefinitions