-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
minio storage: support dry run and container spec overrides
- Loading branch information
Showing
5 changed files
with
198 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Set CPU/Memory resource requirements for Minio" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from ckan_cloud_operator import kubectl\n", | ||
"\n", | ||
"old_minio_pods = [pod for pod in kubectl.get('pod')['items'] if pod['metadata']['labels'].get('app') == 'provider-storage-minio']\n", | ||
"assert len(old_minio_pods) == 1\n", | ||
"old_minio_containers = old_minio_pods[0]['spec']['containers']\n", | ||
"assert len(old_minio_containers) == 1" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import yaml\n", | ||
"from IPython.core.display import HTML\n", | ||
"\n", | ||
"HTML('<h3>OLD RESOURECS</h3>\\n{}'.format(yaml.dump(old_minio_containers[0]['resources'], default_flow_style=False)))" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Set new resources" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import json\n", | ||
"from ckan_cloud_operator.config import manager as config_manager\n", | ||
"\n", | ||
"config_manager.set(\n", | ||
" key='container-spec-overrides', \n", | ||
" value=json.dumps({\n", | ||
" \"resources\": {\n", | ||
" \"requests\": {\n", | ||
" \"cpu\": \"1\", \n", | ||
" \"memory\": \"1Gi\"\n", | ||
" },\n", | ||
" \"limits\": {\n", | ||
" \"memory\":\"2Gi\"\n", | ||
" }\n", | ||
" }\n", | ||
" }),\n", | ||
" configmap_name='ckan-cloud-provider-storage-minio'\n", | ||
")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Apply deployment: Dry Run" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from ckan_cloud_operator.providers.storage.minio import manager as minio_manager\n", | ||
"\n", | ||
"minio_manager.initialize(dry_run=True)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Apply Deployment" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from ckan_cloud_operator.providers.storage.minio import manager as minio_manager\n", | ||
"\n", | ||
"minio_manager.initialize()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Check deployment progress" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import yaml\n", | ||
"from ckan_cloud_operator import kubectl\n", | ||
"\n", | ||
"minio_pods = [pod for pod in kubectl.get('pod')['items'] if pod['metadata']['labels'].get('app') == 'provider-storage-minio']\n", | ||
"pod_names = [pod['metadata']['name'] for pod in minio_pods]\n", | ||
"print(yaml.dump(pod_names, default_flow_style=False))\n", | ||
"\n", | ||
"[print(kubectl.check_output(f'describe pod {pod_name}').decode()) for pod_name in pod_names]" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.7.3" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |