kubernetes-client / kubernetes-client/python

Implement base class for Kubernetes model classes

Open
#784 11 comments 1 reaction 0 assignees View on GitHub
lifecycle/frozen
Dominant language
Python
Stars
7.7k
Forks
3.5k
Avg merge
1d 14h
Merged PRs (30d)
18

Description

This is a feature request. Most of the Kubernetes objects have a set of fields in common:

* kind
* apiVersion
* metadata
* spec

Currently the various model classes all inherit from `object`. Is there a way to implement a base class for all k8s resources and have all the models extend that?

It'd also be nice to have `utils.parse_from_yaml(yaml_file)` that just parses a YAML file into the correct model (no API requests at all). I'm not sure how the models are generated, but I suspect it may be related to this [analogous java client issue](https://github.com/kubernetes-client/java/issues/101).

Contributor guide

Open the contributing guide

Research direction

Start by tracing how the generated Kubernetes model classes are produced and how they currently inherit from object. Then assess the proposed common resource base class alongside the utils.parse_from_yaml(yaml_file) entry point. Done would mean a decided design for shared kind, apiVersion, metadata, and spec fields plus YAML parsing into the correct model without API requests.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.