kubernetes.utils.create_from_yaml module¶
- exception kubernetes.utils.create_from_yaml.FailToCreateError(api_exceptions)¶
Bases:
ExceptionAn exception class for handling error if an error occurred when handling a yaml file.
- kubernetes.utils.create_from_yaml.create_from_dict(k8s_client, data, verbose=False, namespace='default', apply=False, **kwargs)¶
Perform an action from a dictionary containing valid kubernetes API object (i.e. List, Service, etc).
Input: k8s_client: an ApiClient object, initialized with the client args. data: a dictionary holding valid kubernetes objects verbose: If True, print confirmation from the create action.
Default is False.
- namespace: string. Contains the namespace to create all
resources inside. The namespace must preexist otherwise the resource creation will fail. If the API object in the yaml file already contains a namespace definition this parameter has no effect.
apply: bool. If True, use server-side apply for creating resources.
- Returns:
The created kubernetes API objects.
- Raises:
FailToCreateError which holds list of client.rest.ApiException instances for each object that failed to create.
- kubernetes.utils.create_from_yaml.create_from_directory(k8s_client, yaml_dir=None, verbose=False, namespace='default', apply=False, **kwargs)¶
Perform an action from files from a directory. Pass True for verbose to print confirmation information.
Input: k8s_client: an ApiClient object, initialized with the client args. yaml_dir: string. Contains the path to directory. verbose: If True, print confirmation from the create action.
Default is False.
- namespace: string. Contains the namespace to create all
resources inside. The namespace must preexist otherwise the resource creation will fail. If the API object in the yaml file already contains a namespace definition this parameter has no effect.
apply: bool. If True, use server-side apply for creating resources.
Available parameters for creating <kind>: :param bool async_req: Whether to execute the request asynchronously. :param bool include_uninitialized: If true, partially initialized
resources are included in the response.
- Parameters:
pretty (str) – If ‘true’, then the output is pretty printed.
dry_run (str) – When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed
- Returns:
The list containing the created kubernetes API objects.
- Raises:
FailToCreateError which holds list of client.rest.ApiException instances for each object that failed to create.
- kubernetes.utils.create_from_yaml.create_from_yaml(k8s_client, yaml_file=None, yaml_objects=None, verbose=False, namespace='default', apply=False, **kwargs)¶
Perform an action from a yaml file. Pass True for verbose to print confirmation information. Input: yaml_file: string. Contains the path to yaml file. k8s_client: an ApiClient object, initialized with the client args. yaml_objects: List[dict]. Optional list of YAML objects; used instead
of reading the yaml_file. Default is None.
- verbose: If True, print confirmation from the create action.
Default is False.
- namespace: string. Contains the namespace to create all
resources inside. The namespace must preexist otherwise the resource creation will fail. If the API object in the yaml file already contains a namespace definition this parameter has no effect.
apply: bool. If True, use server-side apply for creating resources.
Available parameters for creating <kind>: :param bool async_req: Whether to execute the request asynchronously. :param bool include_uninitialized: If true, partially initialized
resources are included in the response.
- Parameters:
pretty (str) – If ‘true’, then the output is pretty printed.
dry_run (str) – When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed
- Returns:
The created kubernetes API objects.
- Raises:
FailToCreateError which holds list of client.rest.ApiException instances for each object that failed to create.
- kubernetes.utils.create_from_yaml.create_from_yaml_single_item(k8s_client, yml_object, verbose=False, apply=False, **kwargs)¶