Skip to content

Instantly share code, notes, and snippets.

@maoo
Last active November 8, 2021 23:10
Show Gist options
  • Save maoo/3f8f22c6d22c3e97cbb6bdd3661028d3 to your computer and use it in GitHub Desktop.
Save maoo/3f8f22c6d22c3e97cbb6bdd3661028d3 to your computer and use it in GitHub Desktop.
Legend on Minikube

Running Legend on Minikube

This page reports instructions on how to run the Legend Helm chart on a local Minikube installation. The whole process should take from 15 to 30 minutes, depending on your knowledge on cloud native technologies, your current workstation setup and your connection speed.

Prerequisites

Install Minikube

Please refer to https://minikube.sigs.k8s.io/docs/start/

Install Helm

Please refer to https://helm.sh/docs/intro/install/

Install Ngrok

Please refer to https://ngrok.com/download

Gitlab.com account

If you don't have already an account, please sign up on https://gitlab.com , then sign in.

Setting useful aliases

To make our life easier, let's copy/paste some aliases in our terminal(s):

alias k8context="kubectl config get-contexts"
alias k8ns="kubectl get namespace"
alias k8get="kubectl get $@"
alias k8del="kubectl delete $@"
alias k8all="kubectl get all $@"
alias k8log="kubectl logs -f $@"
alias k8svc="kubectl get svc $@"
alias k8desc="kubectl describe $@"

Start Minikube

With the following commands, we'll start minikube (with right amount of resources and plugins) and switch the kubectl context to point at it:

minikube start --memory 4096
minikube addons enable ingress
eval $(minikube docker-env)
kubectl config use-context minikube

Below the expected outcome:

πŸ˜„  minikube v1.18.1 on Darwin 11.6
    β–ͺ MINIKUBE_ACTIVE_DOCKERD=minikube
✨  Automatically selected the hyperkit driver. Other choices: virtualbox, ssh
πŸ‘  Starting control plane node minikube in cluster minikube
πŸ”₯  Creating hyperkit VM (CPUs=2, Memory=4096MB, Disk=20000MB) ...
🐳  Preparing Kubernetes v1.20.2 on Docker 20.10.3 ...
    β–ͺ Generating certificates and keys ...
    β–ͺ Booting up control plane ...
    β–ͺ Configuring RBAC rules ...
πŸ”Ž  Verifying Kubernetes components...
    β–ͺ Using image gcr.io/k8s-minikube/storage-provisioner:v4
🌟  Enabled addons: storage-provisioner, default-storageclass
πŸ„  Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default
Switched to context "minikube".

If you now run k8context, you should get minikube as the current one:

CURRENT   NAME                 CLUSTER              AUTHINFO                   NAMESPACE
*         minikube             minikube             minikube                   default

If you want to know the local IP that Minikube is using, simply run minikube ip.

Start Ngrok

To allow gitlab.com to call your application, we'll need to create a tunnel between your Minikube virtual machine (port 80) and a public host; we use NGrok for that.

Open a new terminal window and run ngrok http $(minikube ip):80, below is the expected output:

Session Status                online
Account                       Maurizio Pillitu (Plan: Free)
Update                        update available (version 2.3.40, Ctrl-U to update)
Version                       2.3.38
Region                        United States (us)
Web Interface                 http://127.0.0.1:4040
Forwarding                    http://4114-139-47-125-122.ngrok.io -> http://192.168.64.10:80
Forwarding                    https://4114-139-47-125-122.ngrok.io -> http://192.168.64.10:80

Connections                   ttl     opn     rt1     rt5     p50     p90
                              0       0       0.00    0.00    0.00    0.00

In this case, 4114-139-47-125-122.ngrok.io is our host, or $HOST_DNS.

Setting up the gitlab.com Application

Legend relies on Gitlab to host data models, map user permissions and much more; for this demo we will use GitLab.com. Follow these steps to create a Gitlab.com Application and allow Legend to run operations against your GitLab projects.

  1. Navigate to User Settings > Applications
  2. Create a new application
  3. Set the following parameters:
    • Name: Legend Demo
    • Redirect URI:
    http://{HOST_DNS}/engine/callback
    http://{HOST_DNS}/sdlc/api/auth/callback
    http://{HOST_DNS}/sdlc/api/pac4j/login/callback
    http://{HOST_DNS}/studio/log.in/callback
    
    • Enable the "Confidential" check box
    • Enable these scopes: openid, profile, api
  4. Save Application
  5. Grab the Application ID (needed to set GITLAB_OAUTH_CLIENT_ID) and Secret (needed to set GITLAB_OAUTH_SECRET) that is associated to the Application

Start Helm chart

Open a new terminal and run the following commands:

git clone https://github.com/naeemarsalan/legend.git
cd legend
git checkout feature/helm-chart-installer
export HOST_DNS="4114-139-47-125-122.ngrok.io"
export GITLAB_OAUTH_CLIENT_ID="xyz"
export GITLAB_OAUTH_SECRET="123"
helm install legend ./installers/helm/ --set env.LEGEND_HOST="$HOST_DNS" \
                                       --set env.GITLAB_OAUTH_CLIENT_ID="$GITLAB_OAUTH_CLIENT_ID" \
                                       --set env.GITLAB_OAUTH_SECRET="$GITLAB_OAUTH_SECRET" \
                                       --set sdlc.tag="0.54.0" \
                                       --set studio.tag="0.2.56" \
                                       --set engine.tag="2.46.0" \
                                       --namespace legend \
                                       --create-namespace

This command should take roughly 100 seconds for the first run; if Docker images are already downloaded, should take roughly 40 seconds.

Check Helm status

Run k8get pod -n legend to know if/what Legend components are running; the expected outcome is that all pods are runnning (check the READY column for 1/1):

NAME                                  READY   STATUS    RESTARTS   AGE
pod/legend-engine-66fc94c79-t5v4b    1/1     Running   0          1m46s
pod/legend-mongo-8d4dcd4bd-fn8xp     1/1     Running   0          1m46s
pod/legend-sdlc-5f5d4d89c4-ntp69     1/1     Running   0          1m46s
pod/legend-studio-5d7dd777bb-tmsh4   1/1     Running   0          1m46s

Use Legend for the first time

You can now access http://${HOST_DNS}/studio

In the dropdown, you should be able to see one workspace for each Project in Gitlab.com that you can access and has a Topic called pure; you can set project Topics from Settings > General.

Troubleshooting

  • To uninstall Helm chart, run helm uninstall legend -n legend
  • To restart from a fresh Minikube environment, run minikube delete and start minikube again (see above).
  • After redeployments, it's recommented to Clear browser cookies associated with {DNS_HOST}.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment