Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Sig API Machinery Deep Dive – KubeCon NA 2018

Sig API Machinery Deep Dive – KubeCon NA 2018

Dr. Stefan Schimanski

December 13, 2018
Tweet

More Decks by Dr. Stefan Schimanski

Other Decks in Programming

Transcript

  1. CR Conversion • Since 1.13 as alpha: Webhook Conversion ◦

    similar to admission webhooks, via apiextensions.k8s.io/v1beta.ConversionReview kube-apiserver etcd GET v1 v1beta1 in-cluster webhook server ConversionRequest v1beta ⇾ v1 ConversionResponse v1 v1
  2. n 1 0 0 0 0 0 Plus feeding watches,

    per watched version 1
  3. handler chain mux data flow calls back to v1 v1

    v1 int int v1 int v1 int v2 v1 int int v1 hub/internal version Comparison with native types
  4. @the_sttts @mbohlool Roundtrip’ability getting lossless conversion right is hard established

    test pattern: roundtrip test between all versions: 1. take YourResource e.g. in v1 2. fill with random values (“fuzzing”) 3. convert to e.g. v1beta1 4. convert back to v1 5. compare result with original 6. repeat Example: k8s.io/sample-apiserver/blob/master/pkg/apis/wardle/install/roundtrip_test.go
  5. Roundtrip testing – how we do that in upstream use

    the gofuzz library + k8s.io/apimachinery/pkg/api/apitesting/roundtrip: func Funcs(codecs runtimeserializer.CodecFactory) []interface{} { return []interface{}{ func(e *audit.Event, c fuzz.Continue) { c.FuzzNoCustom(e) doAuditEventDefaulting() enforceAnyOtherTypeInvariant() } } } func TestRoundTrip(t *testing.T) { roundtrip.RoundTripTestForAPIGroup(t, Install, fuzzer.Funcs) } Example: pkg/apis/audit/fuzzer/fuzzer.go & pkg/apis/audit/install/roundtrip_test.go:
  6. @the_sttts @mbohlool Outlook for 2019 and beyond • critical issues

    identified for moving CRDs to GA (issue #58682): ◦ generate OpenAPI spec from validation schema ➡ kubectl-side validation, kubectl explain ◦ quota support ◦ defaulting and pruning ◦ … a number of smaller topics • Other open, undecided topics: ◦ validation schema language: alternative language, OpenAPI references, Go-types to schema ◦ graceful deletion ◦ validation webhook ◦ arbitrary field selectors ◦ protobuf encoding ◦ namespace-local CRDs
  7. @the_sttts @mbohlool Serverside Apply • Plumbing: mostly done • Pivot!

    ◦ From x = a + (b - c) to field “managers” • Low level operations: mostly done • API: in progress! ◦ Looks to be a big improvement over the old last-applied annotation ▪ Shorter ▪ Omits values • Alpha in 1.14 • Next steps ◦ Perfect place to check general schema concerns (e.g, add discriminated unions)