Swiftkube is Swift tooling for Kubernetes.
This is a project I've been working on for some time now, which went through several iterations until I got into the current shape and form.
Swift as a language is among the most pleasant to use and it's seen many advancements in many areas, including the server-side. What's been lacking, IMHO, is more work put into the whole cloud native landscape, especially Kubernetes.
I hope Swiftkube will contribute towards gapping this bridge.
The project currently consists of two packages and an examples repository
- SwiftkubeModel: which is the complete Kubernetes model for v1.18.9
- SwiftkubeClient: a SwiftNIO based client
- SwiftkubeExamples: some concrete examples for what's currently possible with Swiftkube
Furthermore, I am working on two other packages, wich I'll push once they're in a more-or-less presentable state:
- Swiftkube Mock Server: a programmatically mockable Kuberentes API server, that can be used either standalone or as an embedded dependency. This one will be used for the end-2-end tests for the Client implementation.
- A proof of concept Service Discovery implementation on Kubernetes for the newly introduced swift-service-discovery
Some Background / Further Info
The model package is not generated by the OpenAPI Generator, instead I wrote a custom generator in Swift, which I will also open source after some polishing.
Why not OpenAPI?
- OpenAPI Generator for Swift doesn't generate SwiftNIO/AsyncHTTPClient code
- And OpenAPI Generator + SwiftNIO is open since January and there seems to be no progress
- Client code generated by OpenAPI Tools would probably fail to decode K8s objects, that include a
meta.v1.MicroTimefield (ISO8601 with milliseconds) e.g. or
coordination.k8s.io/v1/Lease. This is an assumption, which I haven't tested.
- And even the OpenAPI tooling could produce an AsyncHTTPClient-based client, the generated code is, IMHO, just not something I would want to use or would have fun using because of the very verbose models and client code, e.g.
PolicyV1beta1PodSecurityPolicy. Compare this to Swiftkube's
Feedback and contributions are really welcome!