This tutorial provides a step by step guide for launching cubejs using gitlab, helm, kubernetes and Rancher.

For cubejs checkout: https://cube.dev/

Step 1 — installation

Install Docker Desktop Install docker-machine on your. It is not provided with Docker Desktop, you will need to install it separately: https://docs.docker.com/toolbox/toolbox_install_mac/ Install oracle virtual box: https://www.virtualbox.org/wiki/Downloads . In some cases you will need to disable the OSX SIP: http://osxdaily.com/2015/10/05/disable-rootless-system-integrity-protection-mac-os-x/ Install helm

brew install helm

Install kubefwd. It will allow you to port fwd to your K8s services and access your deployed services from your laptop

brew install txn2/tap/kubefwd

Step 2 — setup infrastructure

Start K8s in docker. Open Docker → Preferences → K8s and check: Enable K8s

2. create docker VMs:

docker-machine create --virtualbox-memory 4096 gitlab docker-machine create rancher

3. install gitlab and docker repository on the gitlab vm (You can skip this step and use gitlab.com just make sure that you point all occurrences of 192.168.99.105 to your gitlab repository

eval $(docker-machine env gitlab) docker run -d -p 5000:5000 --name registry registry:2 docker run -d — hostname 192.168.99.105 --publish 443:443 --publish 80:80 --publish 23:22 --name gitlab --restart always gitlab/gitlab-ce:latest

4. install rancher on the rancher vm

eval $(docker-machine env rancher) docker run -d --restart=unless-stopped --name rancher-server --ulimit nofile=4098 -e DOCKER_OPTS=”$DOCKER_OPTS --insecure-registry=192.168.99.105:5000" -p 80:80 -p 443:443 rancher/rancher:latest

5. now you will be able to go to rancher: http://<your_rancher_machine> and gitlab: http://<your_gitlab_machine>

Step 3 — Configure Rancher

make sure the your kubectl is in the docker-desktop context:

kubectl config current-context

2. login to Rancher and select Add Cluster → Import an existing cluster

3. It will provide you with a command that you will need to run in the terminal. Example:

curl --insecure -sfL https://192.168.99.102/v3/import/b6mfghmr4pxsnv42csz44c5sj7sg76d2twz78q6594q85tjs9fvgvz.yaml | kubectl apply -f --

4. Wait for the cluster to be active in Rancher

Step 4 — Configure environment

Create a mysql server in Rancher. Go to you cluster default project → Click on Apps → Launch → Mysql Use database: bidding Username: bidding password: bidding All the other leave default clone project repoository

Search and replace all occurrences of the 192.168.99.105 in the with your gitlab vm ip address

Add insecure repositories to your docker setting with the ip of you gitlab machine

Create a gitlab runner in Rancher

cd cubejs-deployment ./devops/gitlab-runner-dev/apply.sh

Step 5 — Start deploying

create secrets for cubejs

user: bidding

password: bidding

secret: a085d56f3ebee22b42cd22bb62b8bf92f25992ae13888176cf9273f7b91c9d10e17ffcbf9692a2982071dd8d1f64b8a5fe2ceac656e99448faa8ff827e78cdf8

2. config map for cubejs

Step 6 — Deploy App

create repo in your local gitlab push the repo to gitlab. the gitlab-ci.yml will build the docker image and push it to the local repo and will deploy into rancher using helm Download the kubeconfig file from the cluster

save it as .kubeconfig file

export KUBECONFIG=.kubeconfig

now launch:

sudo -E kubefwd svc -n staging,mysql

This will enable you to access cubejs at http://cubejs-deployment:4000/

Step 7 — Insert mock data

create table:

CREATE TABLE `events`

(

`event_time` DATETIME NOT NULL,

`event_time_ts` bigint(20) NOT NULL,

`request_id` varchar(50) DEFAULT NULL,

`placement_id` varchar(50) DEFAULT NULL,

`app_id` varchar(50) NOT NULL,

`ad_set_id` varchar(50) NOT NULL,

`ch_id` varchar(50) NOT NULL,

`user_id` varchar(50) NOT NULL,

`offer_id` varchar(50) NOT NULL,

`creative_id` varchar(50) NOT NULL,

`event_id` varchar(50) NOT NULL,

`event_type` varchar(50) NOT NULL,

`geo` varchar(10) DEFAULT NULL,

`device` varchar(50) DEFAULT NULL,

`os_version` varchar(50) DEFAULT NULL,

`device_ip` varchar(50) DEFAULT NULL,

`ua` text CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL

);

insert mock data