KubeCon + CloudNativeCon North America 2018

Sig API Machinery Deep Dive 2018

1. Sig API Machinery Deep Dive Daniel Smith (Google) – Stefan Schimanski (Red Hat)
2. CR[!D] Versioning & Conversion dee ive d p
3. CR Conversion ● Since 1.13 as alpha: Webhook Conversion ○ similar to admission webhooks, via apiextensions.k8s.io/v1beta.ConversionReview v1 ConversionResponse v1 kube-apiserver GET v1 ConversionRequest v1beta ⇾ v1 v1beta1 etcd in-cluster webhook server
7. v1 v1 v1 v2 v1 v1 v1
8. v1 v1 v1 0 1 v1 0 0 1 0 v2 v1 v1 0
9. n 0 0 0 1 0 0 retries!
10. n 0 0 0 1 0 0 Plus feeding watches, 1 per watched version
11. Co v1 m na par tive iso typ n w es ith handler chain v1 v1 v1 mux hub/internal version v1 int int int v1 int v1 int int v2 data flow calls back to
12. Roundtrip’ability getting lossless conversion right is hard established test pattern: roundtrip test between all versions: 1. 2. 3. 4. 5. 6. take YourResource e.g. in v1 fill with random values (“fuzzing”) convert to e.g. v1beta1 convert back to v1 compare result with original repeat Example: k8s.io/sample-apiserver/blob/master/pkg/apis/wardle/install/roundtrip_test.go @the_sttts @mbohlool
13. 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:
14. CRD – Outlook for 2019 and beyond
15. 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 @the_sttts @mbohlool
16. The other big 2019 theme: Server-side Apply
17. Serverside Apply ● ● Plumbing: mostly done Pivot! ○ ● ● Low level operations: mostly done API: in progress! ○ ● ● From x = a + (b - c) to field “managers” 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) @the_sttts @mbohlool
18. API Machinery Q & A

相关幻灯片