maclof / kubernetes-client

A simple yet elegant client for accessing and controlling a Kubernetes cluster (https://github.com/kubernetes/kubernetes)
MIT License
232 stars 82 forks source link

api version for ingress #97

Open patriceckhart opened 2 years ago

patriceckhart commented 2 years ago

I want to use the api version networking.k8s.io/v1 for Ingress.

Tried to extend the model and define the api version. But ends in an error:

{"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"the API version in the data (networking.k8s.io/v1) does not match the expected API version (networking.k8s.io/v1beta1)","reason":"BadRequest","code":400}

trylika commented 2 years ago

had same problem, solution was: implement my own Ingresses Collections/Model/Repositories. And use them instead of original ones. all the same as orginal ones, except two key changes (at first i forgot to change in Repository, that's why i was getting this error):

Ingress.php

class Ingress extends Model
{
    protected string $apiVersion = 'networking.k8s.io/v1';
}

IngressRepository.php

class IngressRepository extends Repository
{
    protected ?string $apiVersion = 'networking.k8s.io/v1';
    ....
}

@maclof i'm not sure what is the plan for 1.20+ Kubernetes support, but i could do PR to accomodate Ingress migration to networking.k8s.io/v1

trylika commented 2 years ago

to extend my idea of PR, my project unfortunatelly doesn't use anything else from what changed in Kubernetes 1.20+ so i can't test/do changes beyond Ingress. but, we use ServiceAccounts and i can add that Model if there is need for that

patriceckhart commented 2 years ago

@trylika

Doesn't work for me :-( :

IngressRepository::$apiVersion
must not be defined (as in class
Maclof\Kubernetes\Repositories\Repository) in ...
trylika commented 2 years ago

@patriceckhart not sure about this exact error, but i'm using 0.24 and my changes work, but i can see recently there where some changes regarding Ingress and other changes related to kubernetes new versions