# limitations under the License.
import asyncio
+from typing import Union
import os
import uuid
import yaml
# if it fails in the middle of the process
cleanup_data = []
try:
+ self.log.debug("Initializing K8s cluster for juju")
kubectl.create_cluster_role(
name=metadata_name,
labels=labels,
)
+ self.log.debug("Cluster role created")
cleanup_data.append(
{
"delete": kubectl.delete_cluster_role,
name=metadata_name,
labels=labels,
)
+ self.log.debug("Service account created")
cleanup_data.append(
{
"delete": kubectl.delete_service_account,
name=metadata_name,
labels=labels,
)
+ self.log.debug("Role binding created")
cleanup_data.append(
{
"delete": kubectl.delete_service_account,
)
default_storage_class = kubectl.get_default_storage_class()
+ self.log.debug("Default storage class: {}".format(default_storage_class))
await libjuju.add_k8s(
name=cluster_uuid,
rbac_id=rbac_id,
storage_class=default_storage_class,
credential_name=self._get_credential_name(cluster_uuid),
)
+ self.log.debug("K8s cluster added to juju controller")
return cluster_uuid, True
except Exception as e:
- self.log.error("Error initializing k8scluster: {}".format(e))
+ self.log.error("Error initializing k8scluster: {}".format(e), exc_info=True)
if len(cleanup_data) > 0:
self.log.debug("Cleaning up created resources in k8s cluster...")
for item in cleanup_data:
name: str,
url: str,
_type: str = "charm",
+ cert: str = None,
+ user: str = None,
+ password: str = None,
):
raise MethodNotImplemented()
raise K8sException("bundle must be set")
if bundle.startswith("cs:"):
+ # For Juju Bundles provided by the Charm Store
+ pass
+ elif bundle.startswith("ch:"):
+ # For Juju Bundles provided by the Charm Hub (this only works for juju version >= 2.9)
pass
elif bundle.startswith("http"):
# Download the file
complete_status: bool = False,
yaml_format: bool = False,
**kwargs,
- ) -> dict:
+ ) -> Union[str, dict]:
"""Get the status of the KDU
Get the current status of the KDU instance.