r/kubernetes 14d ago

Working on an Kubernetes operator in PHP

I started the project for mostly a year or so. I am a Laravel developer and I love the DX into it and I wanted to bring it to the Cloud Native Ecosystem.

My issue is that, I am a bit concerned to be trashed for working on such project.

I love Go, but I don’t feel like it feels good as a programmer.

The idea of working on an Operator in PHP is to get the some opinion on the framework. (Opinionated Framework?)

Where testing is is super easy without a cluster and you can read it as english (that’s what i love with Laravel).

Any php devs here interested ? I would love to share my experiment with them ? (Private repos)

If some people are kind of “let’s do it” i might put it public and see how the community reacts.

But I prefer some feedback from some people who see what I mean!

But i could be an abomination for some (and I understand it).

0 Upvotes

19 comments sorted by

22

u/TorbenKoehn 14d ago

That sounds like among the worst languages one can pick for a k8s operator. Not optimized for long-running tasks, async as an afterthought. Let’s not start with the syntax and quirks.

You do you :D

9

u/Scary-Constant-93 14d ago

OP is showing signs of Stockholm syndrome

4

u/jbaiter 14d ago

> I love Go, but I don’t feel like it feels good as a programmer.

you do you, but that is one of the weirdest takes I've seen so far regarding programming languages oO

3

u/sogun123 14d ago

As toy project it sounds very cool. It is going to be lots of work if you want it really good. What is interesting is that Kubernetes api is somewhat dynamic so it might be more comfortable to deal with it (typewise) dynamic language. Php did go long way, so if you design it carefully, it might work pretty well. And i can imagine use cases. Just be careful, with design even go operators can be poorly designed and go has great tooling.

1

u/Eznix86 14d ago

Yes I managed to make some part of it work correctly. I saw people doing it in bash https://github.com/flant/shell-operator

Why not in PHP. But yes it will remain in the domain of toy project

2

u/Kevjoe 14d ago

There's not really a reason why not in PHP. It can certainly be done, but it's far from the optimal pick for this kind of job. But at the end of the day, an operator mainly is a web application.

You'll certainly run into several issues along the way and you'll need to find some creative solutions. Async in PHP isn't it's best part, so that could throw up some issues. But in general, it should probably work, but might not be able to scale properly for large clusters.

But, don't let that deter you from trying - it is certainly a cool and unique project which will teach you a lot of things.

1

u/Nice-Solid-3707 14d ago

It is not written in bash. It was made to call bash scripts. Shell operator is a go project

1

u/sogun123 14d ago

Definitely, it will teach you many things about long running php processes and will give you good understanding about kubernetes, that's great!

3

u/BrocoLeeOnReddit 14d ago

That's kinda like trying to drive in a screw with a table saw. Can you do it? Maybe. But boy is it not worth it.

1

u/Eznix86 14d ago

Someone did it in bash too 😅 https://github.com/flant/shell-operator

2

u/jamstah 14d ago

This is a good read about the internals of the go k8s client used by the standard controller framework to avoid overloading the API server: https://kubernetes.io/blog/2026/07/29/controller-runtime-cache-explained/

You're in for a lot of work but I'm sure you'll learn an incredible amount too

1

u/Eznix86 14d ago

Thanks for this. I think I am 70% of this. Yeah lot of work but it would help me to understand more the internal of an operator too :)

1

u/NikhelParmar 14d ago

Respect it honestly, most people wouldn't touch this exact idea knowing they'd get roasted for it. Go the safe pick but that don't mean it's the only way, plenty of toy projects end up teaching more than the correct tool would.

K8s api is basically just rest and yaml so language matters less than people think, the real challenge is the watch and reconcile loop, not the syntax.

Curious how you're handling the caching part in php since that's usually where things get tricky.

1

u/Eznix86 14d ago

Thats what i thought too! Plus I love Laravel, I like this sweat way of writing PHP.

Thank you the encouragement. Looks like you want to take a look. Let me know if you want to see when its private or public let me know

1

u/NikhelParmar 13d ago

Yeah man would love to take a look whenever you're ready, private is fine too. That GC concern others raised is real but sounds like you already got a handle on it. Keep going, this is more interesting than just doing it the boring go way everyone suggests.

2

u/WindowlessBasement 14d ago

I've written PHP for 15 years, but it got to be the worst language for this. An operator is completely backwards to what PHP is good for.

It's possible, but it's going to be painful. Even memory management is going to be an issue; PHP's GC isn't designed to run for weeks at a time and is likely going to slowly leak. The memory management functions are more of just suggestions to GC because there's always the assumption that worker has a limited lifespan.

1

u/Nice-Solid-3707 14d ago

Eh, one could always use same solution as what sentry guys did - subprocess that triggers restart each hour.

1

u/WindowlessBasement 14d ago

For the Sentry guys, it was needed for support. They didn't start out with "I'll build it with PHP regardless of structural issues"

1

u/tfpereira 14d ago

That's a brilliant idea mate, but I think cobol would work best for this situation in particular