Introducing Swiftkube

Swiftkube is Swift tooling for Kubernetes.

Motivation

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.

Current State

The project currently consists of two packages and an examples repository

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.MicroTime field (ISO8601 with milliseconds) e.g. or core/v1/Event 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. AppsV1beta1Deployment or PolicyV1beta1PodSecurityPolicy. Compare this to Swiftkube's apps.v1.Deployment and policy.v1beta.PodSecurityPolicy

The implementation is a little bit opionated and borrows some ideas from the fabric8 Kubernetes Java Client, and others from cdk8s. Mainly because I find those really pleasant to work with.

Feedback and contributions are really welcome!

16 Likes

This is awesome. Thanks a lot for the hard work!

1 Like

This is awesome!

1 Like
Terms of Service

Privacy Policy

Cookie Policy