php-k8s icon indicating copy to clipboard operation
php-k8s copied to clipboard

Major feature update: New K8s resources, server-side apply, JSON Patch, PHP 8.4 support, and more

Open cuppett opened this issue 6 months ago โ€ข 7 comments

Summary

This PR adds significant new Kubernetes resource support, modern API features, and compatibility improvements. All changes maintain backward compatibility.

Key Features Added

๐Ÿš€ Core Enhancements

  • Server-side apply support - Modern K8s field management with conflict resolution
  • JSON Patch (RFC 6902) & JSON Merge Patch (RFC 7396) - Flexible resource update operations
  • Request timeouts - Configurable timeouts for HTTP and WebSocket operations

๐Ÿ“ฆ New Kubernetes Resources

  • EndpointSlice (discovery.k8s.io/v1) - Modern endpoints API
  • Gateway API (gateway.networking.k8s.io/v1) - Next-generation ingress (Gateway, GatewayClass, HTTPRoute, GRPCRoute)
  • VolumeSnapshot - Kubernetes volume snapshot support
  • ReplicaSet - Core workload controller with scale support
  • Policy & Scheduling Resources - PriorityClass, LimitRange, ResourceQuota, NetworkPolicy
  • VerticalPodAutoscaler (autoscaling.k8s.io/v1) - Auto-adjust CPU/memory requests

๐Ÿ› Bug Fixes & Compatibility

  • PHP 8.4 deprecation fixes - Explicit nullable type hints for improved compatibility
  • Spelling corrections - Fixed "Wether" โ†’ "Whether" in resource classes

๐Ÿงช Test Improvements

  • WebSocket test coverage - Comprehensive exec and attach operation tests
  • Watch operation reliability - Client-side stream timeouts to prevent CI hangs
  • Resource cleanup - Automatic test resource cleanup with configurable timeouts

๐Ÿ“š Dependency Updates

  • guzzlehttp/guzzle: ^7.9 โ†’ ^7.10
  • symfony/process: ^7.3.0 โ†’ ^7.3.4
  • orchestra/testbench: ^9.0|^10.0 โ†’ ^9.0|^10.6.0
  • vimeo/psalm: ^6.12.0 โ†’ ^6.13.1
  • Replace mysql:5.7 with mariadb:11.8 for better compatibility

โš™๏ธ CI/CD Improvements

  • Increased job timeout to 60 minutes for comprehensive test suites
  • Upgraded actions/checkout to v6
  • Added VPA addon installation for CI testing
  • Refactored test container configurations to eliminate duplication

Detailed Breakdown

Phase 1: Bug Fixes (2 commits)

  • Fix PHP 8.4 deprecation warnings for implicitly nullable parameters
  • Fix spelling: Wether โ†’ Whether in resource classes

Phase 2: Core Enhancements (3 commits)

  • Add Kubernetes server-side apply support
  • Add request timeouts
  • Add JSON Patch (RFC 6902) and JSON Merge Patch (RFC 7396) support

Phase 3: New Resources (6 commits)

  • Add EndpointSlice (discovery.k8s.io/v1) API support
  • Add Kubernetes Gateway API (gateway.networking.k8s.io/v1) support
  • Add VolumeSnapshot support for Kubernetes volume snapshots
  • Add ReplicaSet resource implementation with scale support
  • Add core Kubernetes policy and scheduling resources
  • Add VerticalPodAutoscaler support with comprehensive testing

Phase 4: Test Improvements (1 commit)

  • Improve test reliability: WebSocket coverage, watch timeouts, resource cleanup

Phase 5: Updates (2 commits)

  • Update dependencies: guzzle, symfony/process, testbench, psalm
  • Update CI: increase timeouts, upgrade actions/checkout to v6

Test Plan

  • [x] All unit tests pass
  • [x] Code compiles successfully with PHP 8.2+
  • [x] All changes are backward compatible
  • [x] Comprehensive test coverage for all new resources and features
  • [x] CI workflow updated to support new features (VPA, VolumeSnapshot, Gateway API)

Additional Notes

  • All commits maintain compatibility with existing codebase
  • No breaking changes to public APIs
  • Documentation and examples included for JSON Patch operations
  • Test matrix includes PHP 8.3, 8.4 with Kubernetes 1.32-1.34 and Laravel 11-12

๐Ÿค– Generated with Claude Code

Co-Authored-By: Claude Sonnet 4.5 (1M context) [email protected]

cuppett avatar Jun 21 '25 20:06 cuppett

@rennokki This is ready for review/approval. I'd like to catch this library up and then add new k8s APIs and features (separate PRs).

cuppett avatar Jun 21 '25 20:06 cuppett

@rennokki thank you for all your work so far. It would be great if we could catch this up to the latest laravel etc.

careybaird avatar Aug 26 '25 12:08 careybaird

As a stopgap, you can deploy from the main branch here: https://github.com/cuppett/php-k8s

It has these updates and a couple other kubernetes features added. I'm waiting to see this PR get merged and then will submit PRs for those as well.

cuppett avatar Aug 30 '25 12:08 cuppett

Thank you @cuppett , that keeps me moving forward for now.

What do you think about taking over or helping development of this package? It hasn't had anything for over a year. I would be happy to help also.

@rennokki what do you think, can we help you out with this package?

careybaird avatar Sep 02 '25 10:09 careybaird

Thank you @cuppett , that keeps me moving forward for now.

What do you think about taking over or helping development of this package? It hasn't had anything for over a year. I would be happy to help also.

@rennokki what do you think, can we help you out with this package?

Would definitely like to help maintain the main repo. It would be nice to keep continuity here on this package and on packagist.

I've also generated a vitepress documentation site now at https://php-k8s.cuppett.dev/ to try and wrangle the updates and start to point out emerging differences. We're hitting a 4.0 level of updates and changes. This PR updates as far as it can to add the relevant things without breaking any compatibility.

I can help on this and the laravel-php-k8s repo if that's useful for folks.

cuppett avatar Dec 06 '25 15:12 cuppett

I am slowly starting to get back into open source back again, I need to handle some security and administrative tasks first, including:

  • consistency across the repos (aiming to mass-edit the repos readme better)
  • setting standards and dotfiles for the orgs, for consistent style, coding standards, etc.
  • perhaps looking into auto PR reviews from coding agents (Claude is looking amazing tbh)
  • security-related setup (leaks, potential CVEs, etc.), as I think they were a damn lot in the last 2-3 years.
  • and of course, catching up with the issues/PRs

For this PR, I am trying to figure out what is the best solution for the missing K8s versions in-between. Any advice in particular?

rennokki avatar Dec 08 '25 13:12 rennokki

I am slowly starting to get back into open source back again, I need to handle some security and administrative tasks first, including:

  • consistency across the repos (aiming to mass-edit the repos readme better)
  • setting standards and dotfiles for the orgs, for consistent style, coding standards, etc.
  • perhaps looking into auto PR reviews from coding agents (Claude is looking amazing tbh)
  • security-related setup (leaks, potential CVEs, etc.), as I think they were a damn lot in the last 2-3 years.
  • and of course, catching up with the issues/PRs

For this PR, I am trying to figure out what is the best solution for the missing K8s versions in-between. Any advice in particular?

The nice thing is, for all the interim k8s versions, as I kept bumping through them, the API was stable (no kubernetes resource changes or breaking changes). Also, the Laravel and PHP versions are adjacent as well.

You could take it as is and do a 3.9 or do that and then make your structural changes before minting a 4.0.

I started to have a bit of a deviation in my "main" (not master) forked branch. I included vitepress very recently and moved to Enums. I could regenerate that on this master branch easily as well. I like the VitePress versus gitbook as it keeps everything discoverable/generated right from the repo.

The enum change I wouldn't include unless you wanted to go the 4.x route with other structural changes.

cuppett avatar Dec 08 '25 13:12 cuppett

@rennokki FWIW, following on this, I can do another PR with more k8s function adds (more kube apis) and also docs updates to vitepress (or not) or just pile all that into this PR. Just lmk.

cuppett avatar Dec 14 '25 12:12 cuppett