MCPcopy Create free account
hub / github.com/kubernetes-client/python / create_from_yaml

Function create_from_yaml

kubernetes/utils/create_from_yaml.py:99–181  ·  view source on GitHub ↗

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;

(
    k8s_client,
    yaml_file=None,
    yaml_objects=None,
    verbose=False,
    namespace="default",
    apply=False,
    **kwargs,
)

Source from the content-addressed store, hash-verified

97
98
99def create_from_yaml(
100 k8s_client,
101 yaml_file=None,
102 yaml_objects=None,
103 verbose=False,
104 namespace="default",
105 apply=False,
106 **kwargs,
107):
108 """
109 Perform an action from a yaml file. Pass True for verbose to
110 print confirmation information.
111 Input:
112 yaml_file: string. Contains the path to yaml file.
113 k8s_client: an ApiClient object, initialized with the client args.
114 yaml_objects: List[dict]. Optional list of YAML objects; used instead
115 of reading the `yaml_file`. Default is None.
116 verbose: If True, print confirmation from the create action.
117 Default is False.
118 namespace: string. Contains the namespace to create all
119 resources inside. The namespace must preexist otherwise
120 the resource creation will fail. If the API object in
121 the yaml file already contains a namespace definition
122 this parameter has no effect.
123 apply: bool. If True, use server-side apply for creating resources.
124
125 Available parameters for creating <kind>:
126 :param async_req bool
127 :param bool include_uninitialized: If true, partially initialized
128 resources are included in the response.
129 :param str pretty: If 'true', then the output is pretty printed.
130 :param str dry_run: When present, indicates that modifications
131 should not be persisted. An invalid or unrecognized dryRun
132 directive will result in an error response and no further
133 processing of the request.
134 Valid values are: - All: all dry run stages will be processed
135
136 Returns:
137 The created kubernetes API objects.
138
139 Raises:
140 FailToCreateError which holds list of `client.rest.ApiException`
141 instances for each object that failed to create.
142 """
143
144 def create_with(objects, apply=apply):
145 failures = []
146 k8s_objects = []
147 for yml_document in objects:
148 if yml_document is None:
149 continue
150 try:
151 created = create_from_dict(
152 k8s_client,
153 yml_document,
154 verbose,
155 namespace=namespace,
156 apply=apply,

Callers 1

create_from_directoryFunction · 0.70

Calls 1

create_withFunction · 0.85

Tested by

no test coverage detected