k8s.base module¶
- exception k8s.base.APIServerError(api_error)[source]¶
Bases:
ExceptionRaised when the API server returns an error event in the watch stream
- class k8s.base.ApiMixIn[source]¶
Bases:
objectApiMixIn class for top level Models
Contains methods for working with the API
- classmethod find(name='', namespace='default', labels=None)[source]¶
Find resources using label selection
- Param:
strname: The name of the resource, as indicated by the app label- Param:
strnamespace: The namespace to search in- Param:
dictlabels: More advanced label selection (see below)- Returns:
A list of matching objects
When a labels dictionary is supplied, the name parameter is ignored. See the docs for _label_selector for more details
- classmethod list_with_meta(namespace='default')[source]¶
List all resources in given namespace. Return ModelList
- classmethod watch_list(namespace=None, resource_version=None, allow_bookmarks=False)[source]¶
Return a generator that yields WatchEvents of cls. If allowBookmarks is True, WatchBookmarks will also be yielded. It’s recommended to use the Watcher class instead of calling this directly, since it handles reconnects and resource versions.
- class k8s.base.Equality(value='')[source]¶
Bases:
LabelSelector- operator = '='¶
Operator used in selection query
- class k8s.base.Exists[source]¶
Bases:
LabelSelector
- class k8s.base.In(value='')[source]¶
Bases:
LabelSetSelector- operator = 'in'¶
Operator used in selection query
- class k8s.base.Inequality(value='')[source]¶
Bases:
LabelSelector- operator = '!='¶
Operator used in selection query
- class k8s.base.LabelSelector(value='')[source]¶
Bases:
objectBase for label select operations
- operator = None¶
Operator used in selection query
- class k8s.base.LabelSetSelector(value='')[source]¶
Bases:
LabelSelector
- class k8s.base.ListMeta(new=True, **kwargs)[source]¶
Bases:
Model- remainingItemCount¶
Generic field on a k8s model
- resourceVersion¶
Generic field on a k8s model
- class k8s.base.MetaModel(cls, bases, attrs)[source]¶
Bases:
typeMetaclass for Model
Responsibilities:
Creating the _meta attribute, with url_template (if present), list of fields and for convenience, a list of field names.
Creates properties for name and namespace if the instance has a metadata field.
Mixes in ApiMixIn if the Model has a Meta attribute, indicating a top level Model (not to be confused with _meta).
- class k8s.base.Model(new=True, **kwargs)[source]¶
Bases:
objectA kubernetes Model object
Contains fields for each attribute in the API specification, and methods for export/import.
- merge(other)[source]¶
merge sets each field in self to the value provided by other This is mostly equivalent to just replacing self with other, except read only fields in self are preserved.
- update(other)¶
merge sets each field in self to the value provided by other This is mostly equivalent to just replacing self with other, except read only fields in self are preserved.
- class k8s.base.ModelList(metadata: ListMeta, items: List[Model])[source]¶
Bases:
objectGeneric type to hold list of Model instances (items) together with ListMeta (metadata), as returned by list API calls
- class k8s.base.NotIn(value='')[source]¶
Bases:
LabelSetSelector- operator = 'notin'¶
Operator used in selection query
- class k8s.base.SelfModel[source]¶
Bases:
objectUse SelfModel as Field.type to set Field.type to the model the Field was defined in during model instantiation.
This allows models to have fields with their own type. It is not possible to reference a class in its own attributes.
Example: ``` class MyModel(Model):
submodel = Field(SelfModel) # submodel gets the type MyModel
- class k8s.base.SyntheticAddedWatchEvent(obj: Model)[source]¶
Bases:
WatchEvent- resource_version¶
- class k8s.base.WatchBaseEvent(event_json=None, resource_version=None)[source]¶
Bases:
ABCAbstract base class for Watch events. Contains the resource version of the event as property resource_version.
- resource_version¶
- class k8s.base.WatchBookmark(event_json)[source]¶
Bases:
WatchBaseEventBookmark events, if enabled, are sent periodically by the API server. They only contain the resourceVersion of the event.
- resource_version¶