Introducing Swiftkube

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.

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 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!


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

1 Like

This is awesome!

1 Like

Hey @iabudiab, this is super cool- we needed Kubernetes service discovery pretty quickly so had to come up with this, which depends on AsyncHTTPClient directly, but we'd be open to using your swiftkubeclient, or if you also have a swift-service-discovery k8s impl, switching it out completely. It was something we needed internally but didn't really want to write & maintain. Something of a recurring theme with server-side swift ;)


Hey @m0wfo, glad you like it :smile:
I am working or rather experimenting with a service discovery implementation based on Swiftkube but don't have anything ready yet. I could make a MVP, based on your variant with Swiftkube and develop it further from there. Maybe I'll give it a go the next weekend. Will keep you posted :wink:

1 Like

@m0wfo Hey there :wave:
FYI I've just released the first version of service discovery based on Swiftkube:

It took longer that anticipated, but I really wanted to implement the reconnect behaviour in the client first, which landend in v0.6.0

Feedback and contributions are always welcome.

1 Like

@iabudiab very awesome, I will take a look!

Terms of Service

Privacy Policy

Cookie Policy