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

Kubernetes Clients and OpenAPI Generator

Kubernetes Clients and OpenAPI Generator

Introduction to Kubernetes Clients (https://github.com/kubernetes-client/) and OpenAPI Generator (https://openapi-generator.tech)

To learn more about OpenAPI Generator, the eBook "A Beginner's Guide to Code Generation for REST APIs (OpenAPI Generator)", available in 5 different languages: English, Française, 日本語, 简体中文, 繁体中文, is a good starting point: https://gumroad.com/wing328

William Cheng

June 24, 2019
Tweet

More Decks by William Cheng

Other Decks in Technology

Transcript

  1. Kubernetes Clients Official - C#, Go, Java, Python, Javascript (reference)

    - Maintained by Kubernetes SIG API Machinery Unofficial (community-maintained) - PHP, Lisp, Elixir, Haskel, etc. Ref: https://kubernetes.io/docs/reference/using-api/client-libraries/ Manual vs auto-generated
  2. Official Kubernetes - past, present, future • Past ◦ Go:

    https://github.com/kubernetes/client-go/ (auto-generated by AutoRest) ◦ Python, Java, etc: auto-generated by Swagger Codegen (https://github.com/swagger-api/swagger-codegen) • Present ◦ Switching to OpenAPI Generator (https://github.com/openapitools/openapi-generator) • Future ◦ Support more clients (e.g. Elixir, Rust, etc) ◦ Add more tests to ensure the client works as expected ◦ Fix issues upstream in Openapi Generator
  3. Why code generation? • If the REST API is documented

    in OpenAPI (f.ka. Swagger) spec, one can easily generate clients, server stubs, documentation, etc using generators (openapi-generator, nswag, go-swagger) • Pros ◦ Save time ◦ Scalable ◦ Consistent developer experience ◦ Code maturity ◦ Maintainability • Cons ◦ Edge cases ◦ Machine-generated code not human friendly
  4. OpenAPI/Swagger Spec 1. Swagger specification donated to Linux Foundation to

    form OpenAPI Initiative backed by IBM, Google, Microsoft, PayPal, Atlassian etc in 2015 2. Renamed to OpenAPI Specification (OAS) 3. OpenAPI 3.0 officially released in July 2017 - Enhancements: anyOf, oneOf, nullable, etc References: 1. OpenAPI 2.0 spec 2. OpenAPI 3.0 spec
  5. OpenAPI Generator • Generate clients, servers, documentation, schema given an

    OpenAPI/Swaggers specifications • A fork of Swagger Codegen (May 2018): Reasons of the fork: Q&A • Formed by ~50 top contributors/template creators • Support 100+ generators (newly added: C client generator) • May 2019: 4.0.0 released (the 21st release) • Kubernetes client: Migrate from swagger-codegen to openapi-generator
  6. Example - Kubernetes Perl client 1. Generate Perl client for

    Kubernetes using OpenAPI (script, config) 2. Perform testings 3. Report bugs to OpenAPI Generator (issue tracker) 4. Get help from the community 5. Fix the issue in OpenAPI Generator (example) 6. Tested the fix (SNAPSHOT version) after the fix (PR) is merged 7. Deploy the stable release of OpenAPI Generator to the workflow