github.com/NVIDIA/aistore@v1.3.23-0.20240517131212-7df6609be51d/deploy/dev/k8s/README.md (about) 1 ## Table of Contents 2 3 - [Table of Contents](#table-of-contents) 4 - [Introduction](#introduction) 5 - [Prerequisites](#prerequisites) 6 - [Makefile](#makefile) 7 - [Files](#files) 8 - [Trying AIStore on minikube](#trying-aistore-on-minikube) 9 - [Deploy](#deploy) 10 - [Stopping and cleanup](#stopping-and-cleanup) 11 - [Developing AIStore on minikube](#developing-aistore-on-minikube) 12 - [Deploy](#deploy-1) 13 - [Local](#local) 14 - [Stopping and cleanup](#stopping-and-cleanup-1) 15 - [Enabling HTTPS in Minikube for AIStore Deployment](#enabling-https-in-minikube-for-aistore-deployment) 16 - [Troubleshooting minikube](#troubleshooting-minikube) 17 - [Demo](#demo) 18 19 ## Introduction 20 21 [Minikube](https://minikube.sigs.k8s.io/docs) allows one to run Kubernetes locally (like on your laptop) thus providing for testing out applications in a native Kubernetes environment. 22 23 * [Minikube GitHub](https://github.com/kubernetes/minikube) 24 25 Minikube can only be used for a single-node Kubernetes cluster. It supports a range of drivers like Virtualbox, KVM, Docker, etc. 26 27 Virtualbox and KVM require a hypervisor. However, if you choose to use docker on a Linux machine there is no need for a hypervisor. 28 29 Our [scripts](/deploy/dev/k8s) use Docker as the driver. This document shows how to deploy AIStore on minikube and use it for some of its features like ETL(transformers) etc. or to develop new features on it. 30 31 ## Prerequisites 32 33 1. Have Linux/macOS installed on your Laptop/Machine/VirtualMachine. 34 2. [Install](https://docs.docker.com/engine/install/) Docker. 35 3. Ensure that your `$USER` is added to the `docker` group. 36 37 ```console 38 $ sudo usermod -aG docker $USER && newgrp docker 39 ``` 40 4. Install [minikube](https://minikube.sigs.k8s.io/docs/start/). 41 5. Install [kubectl](https://kubernetes.io/docs/tasks/tools/). 42 43 **Notes:** 44 - Running minikube on a VPN might be problematic. For smoother operations, try running with VPN disabled. More information can be found [here](https://minikube.sigs.k8s.io/docs/handbook/vpn_and_proxy/). 45 - Running minikube with the Docker driver on newer macOS versions may encounter problems. Please refer to the [known issues](#known-issues) section for more details. 46 47 All commands below are running from the same directory i.e `${AISTORE_ROOT}/deploy/dev/k8s` 48 49 ## [Makefile](/deploy/dev/k8s/Makefile) 50 51 | Command | Description | 52 | --- | --- | 53 | `make try` | start minikube and run a basic version of AIStore inside it ([ref](#trying-aistore-on-minikube)) | 54 | `make dev` | deploy multi-proxy/target AIStore with other utilities ([ref](#developing-aistore-on-minikube)) | 55 | `make minimal` | start a minimal AIStore deployment (1 proxy and 1 target) on an already running minikube | 56 | `make redeploy-ais` | skips the minikube and Docker registry deployment in `make dev` | 57 | `make minimal-local` | start minikube, rebuild the `aisnode` container with local changes and start a minimal deployment | 58 | `make redeploy-local` | rebuild the `aisnode` container with local changes on an already running minikube | 59 | `make stop-ais` | stop running AIStore pods | 60 | `make stop`| stop and deletes AIStore pods, minikube cluster | 61 62 ## Files 63 | File | Description | 64 | --- | --- | 65 | [Dockerfile](/deploy/dev/k8s/Dockerfile) | build AIStore node docker image on `Ubuntu 22.04` | 66 67 ## Trying AIStore on minikube 68 69 ### Deploy 70 71 You can start minikube with a basic version of AIStore (1-proxy and 1-target) running inside of it with the `make try` command. 72 73 ```console 74 $ # navigate to this directory 75 $ # cd ${AISTORE_ROOT}/deploy/dev/k8s 76 $ 77 $ make try 78 $ 79 $ # you can also set the CPU and MEMORY allocated to minikube by 80 $ CPU=8 MEMORY=16000 make -e try 81 ``` 82 83 84 ### Stopping and cleanup 85 To stop AIS nodes running inside of minikube, deleting all the pods and minikube itself, you can run the `stop` target of the [Makefile](/deploy/dev/k8s/Makefile). 86 87 ```console 88 $ make stop 89 ``` 90 91 ### Enabling HTTPS in Minikube for AIStore Deployment 92 93 To enable HTTPS for your AIStore deployment in Minikube, follow these steps: 94 #### For Minimal Deployment 95 96 To set up a minimal AIStore deployment with HTTPS, run the following command: 97 98 ```bash 99 $ HTTPS=true make try 100 ``` 101 102 #### For Development Deployment 103 104 For a development deployment, follow these steps: 105 106 1. Run the `make dev` command: 107 108 ```bash 109 $ make dev 110 ``` 111 112 2. During the setup process, you will be prompted to enable HTTPS. Respond with "y" to activate HTTPS: 113 114 ```bash 115 Enable HTTPS: (y/n)? 116 y 117 ``` 118 119 With these steps, your Minikube-based AIStore deployment will be configured for secure HTTPS communication. 120 121 #### Testing Considerations for HTTPS 122 123 When working with HTTPS-enabled AIStore deployments, here are some important testing considerations: 124 125 #### 1. AIStore CLI Configuration 126 127 If you're using the AIStore CLI for testing, set the following environment variable to bypass certificate verification and connect to the AIStore cluster: 128 129 ```bash 130 $ ais config cli set cluster.skip_verify_crt true 131 ``` 132 133 #### 2. Using `curl` 134 135 When interacting with your AIStore cluster over HTTPS using `curl`, use the `-k` flag to skip certificate validation: 136 137 ```bash 138 $ curl -k https://your-ais-cluster-url 139 ``` 140 141 #### 3. Exporting the Self-Signed Certificate 142 143 If you prefer not to skip certificate validation when using `curl`, you can export the self-signed certificate for use: 144 145 ```bash 146 $ kubectl get secret ais-tls-certs -o jsonpath='{.data.tls\.crt}' | base64 --decode > tls.crt 147 ``` 148 149 Now, you can use the exported `tls.crt` as a parameter when using `curl`, like this: 150 151 ```bash 152 $ curl --cacert tls.crt https://your-ais-cluster-url 153 ``` 154 155 ## Developing AIStore on minikube 156 157 158 ### Deploy 159 160 The `dev` target of [Makefile](/deploy/dev/k8s/Makefile) allows you to customize and run AIStore by accepting inputs from the user through the terminal. 161 162 ```console 163 $ make redeploy-ais 164 ``` 165 166 To update the aisnode images, or to redeploy AIStore, execute the `make ais-redeploy` argument, as shown below. This will skip the minikube and Docker registry deployment. 167 168 ### Local 169 170 By default, the make targets will pull the `aisnode-minikube` image from [dockerhub](https://hub.docker.com/u/aistorage/). The `minimal-local` and `redeploy-local` options provide an easy way to test changes on a minimal cluster with a rebuilt local image by pushing the image to the local minikube registry. `make dev` also includes a prompt to rebuild the local image for more complex deployments. 171 172 ### Stopping and cleanup 173 174 The `stop-ais` target stops the AIStore cluster while keeping minikube still running. 175 176 ```console 177 $ make stop-ais 178 ``` 179 180 For stopping and deleting the minikube cluster 181 182 ```console 183 $ make stop 184 ``` 185 186 NOTE: If the default jupyter local directory was overwritten while deploying, ensure `JUPYTER_LOCAL_DIR` is pointing to the correct directory when performing a cleanup. 187 188 ## Known Issues 189 190 See [known issues](https://minikube.sigs.k8s.io/docs/drivers/docker/#known-issues) with using Docker driver. 191 192 **macOS only:** One of the scripts to start AIS uses the `envsubst` command, which is not available by default. Please run the following commands as a workaround: 193 ``` 194 brew install gettext 195 brew link --force gettext 196 ``` 197 The ingress, and ingress-dns addons are currently only supported on Linux. See [issue](https://github.com/kubernetes/minikube/issues/7332). 198 199 ## Demo 200 201 1. Deploying the cluster 202 203 ```console 204 $ CPU=4 MEMORY=12000 make -e try 205 minikube delete 206 🔥 Deleting "minikube" in docker ... 207 🔥 Deleting container "minikube" ... 208 🔥 Removing /home/abhgaikwad/.minikube/machines/minikube ... 209 💀 Removed all traces of the "minikube" cluster. 210 minikube config set cpus 4 211 ❗ These changes will take effect upon a minikube delete and then a minikube start 212 minikube config set memory 12000 213 ❗ These changes will take effect upon a minikube delete and then a minikube start 214 minikube start --driver=docker 215 😄 minikube v1.26.0 on Ubuntu 20.04 216 ✨ Using the docker driver based on user configuration 217 📌 Using Docker driver with root privileges 218 👍 Starting control plane node minikube in cluster minikube 219 🚜 Pulling base image ... 220 🔥 Creating docker container (CPUs=4, Memory=12000MB) ... 221 🐳 Preparing Kubernetes v1.24.1 on Docker 20.10.17 ... 222 ▪ Generating certificates and keys ... 223 ▪ Booting up control plane ... 224 ▪ Configuring RBAC rules ... 225 🔎 Verifying Kubernetes components... 226 ▪ Using image gcr.io/k8s-minikube/storage-provisioner:v5 227 🌟 Enabled addons: storage-provisioner, default-storageclass 228 🏄 Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default 229 ./minimal.sh 230 Checking kubectl default sa account... 231 serviceaccount/default created 232 clusterrolebinding.rbac.authorization.k8s.io/fabric8-rbac created 233 No resources found in default namespace. 234 pod/ais-proxy-0 created 235 Waiting for the primary proxy to be ready... 236 pod/ais-proxy-0 condition met 237 Starting target deployment... 238 pod/ais-target-0 created 239 Waiting for the targets to be ready... 240 pod/ais-target-0 condition met 241 List of running pods 242 NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES 243 ais-proxy-0 1/1 Running 0 101s 192.168.49.2 minikube <none> <none> 244 ais-target-0 1/1 Running 0 30s 192.168.49.2 minikube <none> <none> 245 Done. 246 247 248 Set the "AIS_ENDPOINT" for use of CLI: 249 export AIS_ENDPOINT="http://192.168.49.2:8080" 250 251 ``` 252 253 2. Exporting the AIS_ENDPOINT 254 255 ```console 256 $ export AIS_ENDPOINT="http://192.168.49.2:8080" 257 ``` 258 259 3. Checking status 260 261 ```console 262 $ kubectl get pods 263 NAME READY STATUS RESTARTS AGE 264 ais-proxy-0 1/1 Running 0 7m59s 265 ais-target-0 1/1 Running 0 6m48s 266 $ # ais is running 267 $ ais create ais://test-bucket 268 "test-bucket" bucket created 269 $ cat > sample 270 This is a sample data 271 ``` 272 273 4. Putting sample object 274 275 ```console 276 $ ais put sample ais://test-bucket 277 PUT "sample" => ais://test-bucket/test-obj 278 ``` 279 280 5. Creating sample spec for transformer 281 282 ```console 283 $ cat > spec.yaml 284 apiVersion: v1 285 kind: Pod 286 metadata: 287 name: transformer-echo 288 annotations: 289 communication_type: "hpull://" 290 wait_timeout: 5m 291 spec: 292 containers: 293 - name: server 294 image: aistorage/transformer_echo:latest 295 imagePullPolicy: Always 296 ports: 297 - name: default 298 containerPort: 8000 299 command: ["gunicorn", "main:app", "--workers", "4", "--worker-class", "uvicorn.workers.UvicornWorker", "--bind", "0.0.0.0:8000"] 300 readinessProbe: 301 httpGet: 302 path: /health 303 port: default 304 ``` 305 306 6. Initiating ETL 307 308 ```console 309 $ ais etl init spec --name test-etl --from-file spec.yaml --comm-type hpull 310 ETL[test-etl]: job "etl-d3KIiNQ1-e" 311 ``` 312 313 7. Transforming an object 314 315 ```console 316 $ ais etl --help 317 NAME: 318 ais etl - use ETLs 319 320 USAGE: 321 ais etl command [command options] [arguments...] 322 323 COMMANDS: 324 init initialize ETL with yaml spec 325 build build ETL with provided code, optional dependencies and runtime 326 ls list all ETLs 327 logs retrieve logs produced by ETL 328 stop stop ETL with given id 329 object transform object with given ETL 330 bucket offline transform bucket with given ETL 331 332 OPTIONS: 333 --help, -h show help 334 335 $ ais etl object --help 336 NAME: 337 ais etl object - transform object with given ETL 338 339 USAGE: 340 ais etl object [command options] ETL_NAME BUCKET/OBJECT_NAME OUTPUT 341 342 OPTIONS: 343 --help, -h show help 344 345 $ ais etl object veSC9rvQQ test-bucket/test-obj out.txt 346 $ cat out.txt 347 This is a sample data 348 ```