Skip to content

Instantly share code, notes, and snippets.

@simon-mo
Created December 19, 2019 17:12
Show Gist options
  • Select an option

  • Save simon-mo/48665b4d43313951beda539eee363b7f to your computer and use it in GitHub Desktop.

Select an option

Save simon-mo/48665b4d43313951beda539eee363b7f to your computer and use it in GitHub Desktop.

Deployment notes:

  • Dev container: any regular ubuntu container should do but requires (1) docker socket (2) host network
set -x

docker run -d \
       --name mantis-dev \
       --network=host \
       -v /var/run/docker.sock:/var/run/docker.sock \
       ubuntu:18.04 bash -c "while true;do sleep 1000;done"

create the cluster as follows

set -ex

k3d create --publish 7000:32700@k3d-k3s-default-worker-0 --workers 1
KUBECONFIG="$(k3d get-kubeconfig --name='k3s-default')"
cat $KUBECONFIG

This will printout kubeconfig on the screen. This file contains the secret to access the cluster. Make sure you have access to this file when running mantis controllers.

The dev environment assumes the following installed: kubectl

  • Prepare sheel environment: make sure your KUBECONFIG environment variable is set to the kubeconfic file.

  • Install all the dependencies of the controller

  • Start a trial

    • go to ./k8s folder in mantis-module
    • kubectl apply -f redis.yaml
    • kubectl get service --watch # watch for redis to combine healthy
    • kubectl apply -f worker.yaml
    • kubectl get deployment --watch # watch for all worker pod started successfully
    • kubectl apply -f load_gen.yaml # kick off the job
    • then run your controller script.
  • Cleanup a trial

    • go to ./k8s folder
    • kubectl delete -f .
  • Limitation

    • Fractional replica:
      • There is a mechanism to adjust fractional replica in redis.
      • Controller does not hook into fractional replica.
      • Need to deploy a fraction replica pod/deployment.
    • Delayed spin-up time:
      • Might not a concern right now. But replicas start working when they are ready.
      • Most likely they are faster than start than we expected.
    • Spin-down cleanup issue:
      • In some cases, a replica gets killed before it can drain its queue.
      • There are some configuration need to be made inside worker.yaml to adjust the spin down timeout and signal sent.
    • Traces file:
      • currently they are hard coded and copied to the docker container
      • might use persistent value for it
      • or it could just be more straight forward to move all traces to the docker container
    • Docker images running as root right now. We will need to change it for both the base image and the k3s worker image.
    • Query traces are not written to file. This should be easy fix to be taken care of by the controller.
  • Resource

    • mantis.cc is the redis module code. It should be straighforward to read it.
    • python directory is structured to be a command line application. you can install it via pip install -e . inside the python directory.
@simon-mo
Copy link
Author

Docker image needs at least:

apt update
apt install -y curl git vim 

curl -s https://get.docker.com/ | bash

curl -s https://raw.githubusercontent.com/rancher/k3d/master/install.sh | bash

curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl
chmod +x ./kubectl
mv ./kubectl /usr/local/bin/kubectl


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment