diff --git a/deployments/offline/README.md b/deployments/offline/README.md new file mode 100644 index 0000000000000000000000000000000000000000..81e45156fc86efbeced46c9ca347986d1b8ca0e8 --- /dev/null +++ b/deployments/offline/README.md @@ -0,0 +1,77 @@ +# Milvus offline installation + +## Manually downloading Docker images + +Your Milvus installation may fail when images are not properly loaded from public Docker registries. To pull all images and save them into a directory that can be moved to the target host and loaded manually, perform the following procedure: + +1. Save Milvus manifest and Docker images + +If you install your Milvus with the **docker-compose.yml** file, use these command: + +- Download Milvus docker-compose.yaml +```shell +# Download Milvus standalone docker-compose.yaml +wget https://raw.githubusercontent.com/milvus-io/milvus/master/deployments/docker/standalone/docker-compose.yml -O docker-compose.yml +``` + +or + +```shell +# Download Milvus cluster docker-compose.yaml +wget https://raw.githubusercontent.com/milvus-io/milvus/master/deployments/docker/cluster/docker-compose.yml -O docker-compose.yml +``` + +- Pull and save Docker images +```shell +# Pull and save Docker images +pip3 install -r requirements.txt +python3 save_image.py --manifest docker-compose.yml +``` + +If you install your Milvus with **Helm**, use these command: +- Update Helm repo +```shell +helm repo add milvus https://milvus-io.github.io/milvus-helm/ +helm repo update +``` + +- Get Kubernetes manifest of Milvus standalone +```shell +# Get Kubernetes manifest of Milvus standalone +helm template my-release milvus/milvus > milvus_manifest.yaml +``` + +or + +```shell +# Get Kubernetes manifest of Milvus cluster +helm template --set cluster.enabled=true my-release milvus/milvus > milvus_manifest.yaml +``` + +- Pull and save Docker images +```shell +pip3 install -r requirements.txt +python3 save_image.py --manifest milvus_manifest.yaml +``` + +The Docker images will be stored under **images** directory. + +2. Enter the following command to load the Docker images: + +```shell +for image in $(find images/ -type f -name "*.tar.gz") ; do gunzip -c $image | docker load; done +``` + +## Install Milvus + +- Install Milvus with Docker Compose + +```shell +docker-compose -f docker-compose.yaml up -d +``` + +- Install Milvus on Kubernetes + +```shell +kubectl apply -f milvus_manifest.yaml +``` \ No newline at end of file diff --git a/deployments/offline/save_image.py b/deployments/offline/save_image.py index e047396a4e15cdd81499bf2570541a97d14bc202..eeba2f21d5dede988014648e89b99bfd03377678 100644 --- a/deployments/offline/save_image.py +++ b/deployments/offline/save_image.py @@ -1,23 +1,27 @@ import argparse import docker import gzip +import os import yaml from nested_lookup import nested_lookup if __name__ == "__main__": parser = argparse.ArgumentParser( - description="Save Docker image") + description="Save Docker images") parser.add_argument("--manifest", required=True, help="Path to the manifest yaml") + parser.add_argument("--save_path", + type=str, + default='images', + help='Directory to save images to') arguments = parser.parse_args() - with open(arguments.manifest, 'r') as file: template = file.read() - + images=[] parts = template.split('---') for p in parts: @@ -25,11 +29,15 @@ if __name__ == "__main__": matches = nested_lookup("image", y) if (len(matches)): images += matches - + + save_path = arguments.save_path + if not os.path.isdir(save_path): + os.mkdir(save_path) + client = docker.from_env() for image_name in set(images): file_name = (image_name.split(':')[0].replace("/", "-")) - f = gzip.open( file_name + '.tar.gz', 'wb') + f = gzip.open(save_path + "/" + file_name + '.tar.gz', 'wb') try: image = client.images.get(image_name) if image.id: @@ -40,3 +48,5 @@ if __name__ == "__main__": image_tar = image.save(named=True) f.writelines(image_tar) f.close() + + print("Save docker images to \"" + save_path + "\"")