allansun/kubernetes-php-client

[1.19+] Not able to use Ingress API v1 models.

Closed this issue · 2 comments

leroy commented

The Ingress API has been available since 1.19 under the v1 api version. However the ingress API class still requires the v1beta1 model version. Is this an error in the swagger spec or something the generation code could account for?

public function create(string $namespace, \Kubernetes\Model\Io\K8s\Api\Extensions\V1beta1\Ingress $Model, array $queries = [])

Hi @leroy sorry about this late reply, I've been away dealing with family affairs.

After looking into the generated code and the K8S swagger file, I think it's neither the fault of the code generator nor the Swagger file.

Even though the Ingress API class requires the v1beta1 model in the header, it also provides methods for the new Networking namespace API endpoint access, with the correct V1 model required.

public function create(string $namespace, \Kubernetes\Model\Io\K8s\Api\Extensions\V1beta1\Ingress $Model, array $queries = [])
{
return $this->parseResponse(
$this->client->request('post',
"/apis/extensions/v1beta1/namespaces/{$namespace}/ingresses",
[
'json' => $Model->getArrayCopy(),
'query' => $queries,
]
),
'createExtensionsV1beta1NamespacedIngress'
);
}

public function createNetworkingV1(string $namespace, \Kubernetes\Model\Io\K8s\Api\Networking\V1\Ingress $Model, array $queries = [])
{
return $this->parseResponse(
$this->client->request('post',
"/apis/networking.k8s.io/v1/namespaces/{$namespace}/ingresses",
[
'json' => $Model->getArrayCopy(),
'query' => $queries,
]
),
'createNetworkingV1NamespacedIngress'
);
}

The reason default list method is still pointing v1beta1 endpoint I believe should be for backward compatibility. I am sure when such endpoint is fully deprecated it should be updated to the new Networking endpoint.

If you are eager to use the new Networking API, you can use the method with NetworkingV1 postfix. Though I think you'd better off still use the default list/ read/ create/ delete methods so you don't have to change your code again when the v1beta1 is deprecated.

leroy commented

Hey man, thanks for the response!

I'll look into the NetworkingV1 methods!

Never apologize for responding "late" on something you created for free for others to enjoy.

Thank you for your time and effort! ✨