github.com/sentienttechnologies/studio-go-runner@v0.0.0-20201118202441-6d21f2ced8ee/docs/workstation_k8s.md (about)

     1  # Workstation and Laptop Kubernetes based testing software infrastructure
     2  
     3  This document describes a laptop or local developer workstations testing environment for running leaf tests within a fully deployed studioML eco-system.
     4  
     5  This document does not detail using GPU hardware in this setup primarily, however the microk8s tools do have support for a GPU plugin and this should work without major changes to the setup other than the GPU plugin installation.  The GPU support is only useful on PC equipment due to Mac OSX not supporting Nvidia hardware appropriate for TensorFlow.
     6  
     7  ## Introduction
     8  
     9  In order to be able to run tests in a standalone format without depending upon publically deployed application infrastructure Kubernetes can be used to standup all of the components that StudioML requires.
    10  
    11  In order to instantiate the servers needed Kubernetes is used to orchestrate multiple containers into a virtual private network.
    12  
    13  The deployments needed include a Queue Server (RabbitMQ), a file server (minio using S3 V4), and the go runner (the system under test) to execute studioML experiments.
    14  
    15  ## Setup for single host Kubernetes
    16  
    17  Single host Kubernetes deployments are typically what is used by an individual developer or for release based tasks where production cloud based clusters are not available.
    18  
    19  For laptops, and private workstations using Windows 10 Professional Edition, or Mac OS 10.6 or later the infrastructure needs for Kubernetes can be meet by installation of Docker Desktop.  Once the docker desktop has been installed you can navigate to the Docker UI Preferences panel select the Kubernetes tab and then use a checkbox to install kubernetes.  Once this is done the machine will have a fully functional Kubernetes deployment that the testing instruction in this document details.
    20  
    21  For Ubuntu hosts a microk8s solution exists that implements a single host deployment, https://microk8s.io/. Use snap on Ubuntu to install this component to allow for management of the optional features of microk8s.
    22  
    23  The following example details how to configure microk8s once it has been installed:
    24  
    25  ```
    26  # Allow the containers within the cluster to communicate with the public internet.  Needed for rabbitMQ pkg to be fetched and installed
    27  sudo ufw default allow routed
    28  sudo iptables -P FORWARD ACCEPT
    29  sudo /snap/bin/microk8s.start
    30  sudo /snap/bin/microk8s.enable dashboard dns ingress storage registry gpu
    31  ```
    32  
    33  ## Usage
    34  
    35  Before following these instruction you will need to install the version management and template tools using the main README.md file, refer to the compilation section, and the prerequistes subsection.
    36  
    37  ### Docker based build
    38  
    39  A prerequiste for following these instructions is that a local copy of the go runner has been checked out of github.  To this use the following commands:
    40  
    41  ```
    42  mkdir ~/project
    43  cd ~/project
    44  export GOPATH=`pwd`
    45  export PATH=$GOPATH/bin:$PATH
    46  mkdir -p src/github.com/leaf-ai
    47  cd src/github.com/leaf-ai
    48  git clone https://github.com/leaf-ai/studio-go-runner.git
    49  cd studio-go-runner
    50  ```
    51  
    52  Having obtained a copy of the studio go runner code the next step is to build an appropriate image for use in testing within a local single host kubernetes cluster.  If you make changes to source code you should re-build the image to refresh the contents with the new code.
    53  
    54  ```
    55  cd ~/projects/src/github.com/leaf-ai/studio-go-runner
    56  docker pull quay.io/leafai/studio-go-runner-dev-base:0.0.5
    57  docker build -t leafai/studio-go-runner-standalone-build -f Dockerfile_standalone .
    58  ```
    59  
    60  ### Kubernetes test deployment and results collection
    61  
    62  ```
    63  cd ~/projects/src/github.com/leaf-ai/studio-go-runner
    64  export GIT_BRANCH=`echo '{{.duat.gitBranch}}'|stencil - | tr '_' '-' | tr '\/' '-'`
    65  docker tag leafai/studio-go-runner-standalone-build:${GIT\_BRANCH} localhost:32000/leafai/studio-go-runner-standalone-build
    66  docker push localhost:32000/leafai/studio-go-runner-standalone-build
    67  /snap/bin/microk8s.kubectl apply -f test_k8s_local.yaml
    68  /snap/bin/microk8s.kubectl --namespace build-test-k8s-local get pods
    69  # Get the full pod name for the build-xxx pod and substitute it into the following command
    70  # to get a full log of the test
    71  /snap/bin/microk8s.kubectl --namespace build-test-k8s-local logs build-xxx
    72  ```
    73  
    74  A kubernetes config file can be obtained from microk8s by using the following command:
    75  
    76  ```
    77  /snap/bin/microk8s.kubectl config view --raw > ~/.kube/temp.config
    78  export KUBE_CONFIG=~/.kube/temp.config
    79  ```
    80  
    81  Copyright © 2019-2020 Cognizant Digital Business, Evolutionary AI. All rights reserved. Issued under the Apache 2.0 license.