Skip to content

Commit

Permalink
Add Minikube quickstart guide
Browse files Browse the repository at this point in the history
  • Loading branch information
Minutis committed Jan 19, 2023
1 parent ffbcc27 commit fb060db
Show file tree
Hide file tree
Showing 8 changed files with 432 additions and 149 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Lighter supports:
You can read a breaf description on how Lighter works [here](./docs/architecture.md).

## Using Lighter
- [Quickstart with Minikube](./quickstart/README.md)
- [Installation on Kubernetes](./docs/kubernetes.md)
- [Installation on Docker](./docs/docker.md)
- [Configuration Properties](./docs/configuration.md)
Expand Down
151 changes: 2 additions & 149 deletions docs/kubernetes.md
Original file line number Diff line number Diff line change
@@ -1,153 +1,6 @@
# Running Lighter on Kubernetes

You need to create multiple resources to add Lighter to your Kubernetes cluster.
On these examples we assume that you are running your spark related services on `spark` namespace.
On the following examples we assume that you are running your spark related services on `spark` namespace.

## ServiceAccount and RoleBinding

```yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: spark
namespace: spark
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: lighter-spark
namespace: spark
rules:
- apiGroups: [""]
resources: ["pods", "services", "configmaps", "pods/log"]
verbs: ["*"]
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: lighter-spark
namespace: spark
subjects:
- kind: ServiceAccount
name: spark
namespace: spark
roleRef:
kind: Role
name: lighter-spark
apiGroup: rbac.authorization.k8s.io
```
## Service
```yaml
apiVersion: v1
kind: Service
metadata:
name: lighter
namespace: spark
labels:
run: lighter
spec:
ports:
- name: api
port: 8080
protocol: TCP
- name: javagw
port: 25333
protocol: TCP
selector:
run: lighter
```
## Deployment
Make sure to change `env` values to valid ones.
[Click here](./configuration.md) to see all possible configuration options.

```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
namespace: spark
name: lighter
spec:
selector:
matchLabels:
run: lighter
replicas: 1
strategy:
rollingUpdate:
maxUnavailable: 0
maxSurge: 1
template:
metadata:
labels:
run: lighter
spec:
containers:
- image: ghcr.io/exacaster/lighter:0.0.41-spark3.3.1
name: lighter
readinessProbe:
httpGet:
path: /health/readiness
port: 8080
initialDelaySeconds: 15
periodSeconds: 15
resources:
requests:
cpu: "0.25"
memory: "512Mi"
ports:
- containerPort: 8080
env:
- name: LIGHTER_KUBERNETES_ENABLED
value: "true"
- name: LIGHTER_STORAGE_JDBC_USERNAME
value: postgres_user
- name: LIGHTER_STORAGE_JDBC_PASSWORD
value: postgres_password
- name: LIGHTER_STORAGE_JDBC_URL
value: jdbc:postgresql://postgres_host_name:5432/lighter
- name: LIGHTER_STORAGE_JDBC_DRIVER_CLASS_NAME
value: org.postgresql.Driver
- name: LIGHTER_SPARK_HISTORY_SERVER_URL
value: https://address_to_spark_history/spark-history
- name: LIGHTER_MAX_RUNNING_JOBS
value: "15"
serviceAccountName: spark
```

## Ingress

To make your Lighter UI accessible, you also need to add an Ingress component.
For example, if you are using Traefik Ingress controller, something like this should work:

```yaml
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
name: lighter-ingress-route
namespace: spark
spec:
entryPoints:
- web
routes:
- match: PathPrefix(`/lighter`)
kind: Rule
services:
- name: lighter
port: 8080
middlewares:
- name: lighter-custom-headers
---
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
name: lighter-custom-headers
namespace: spark
spec:
headers:
customRequestHeaders:
X-Forwarded-Prefix: /lighter
X-Forwarded-Proto: https
X-Forwarded-Port: "443"
```
Use [quickstart](../quickstart/) as a starting point and adjust the configuration to fit your environment.
77 changes: 77 additions & 0 deletions quickstart/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Minikube quickstart

### Install Minikube
Follow instructions in https://minikube.sigs.k8s.io/docs/start/ to install the minikube.

### Start Minikube
```
minikube start
```

### Enable Minikube `ingress` addon
```
minikube addons enable ingress
```

### Apply quickstart `.yml` configuration
Go to the location where you cloned the repository i.e.: `cd ~/git/lighter`:
1. Create main resources
```
minikube kubectl -- apply -f quickstart/lighter.yml
minikube kubectl -- apply -f quickstart/jupyterlab.yml
```
2. Create `ingress` resources
```
minikube kubectl -- apply -f quickstart/nginx/lighter-nginx.yml
minikube kubectl -- apply -f quickstart/nginx/jupyterlab-nginx.yml
```

### Verify deployment
**_NOTE:_** Jupyterlab can take few minutes to start because the container is being altered on runtime.
```
minikube kubectl -- -n spark get all
```
```
NAME READY STATUS RESTARTS AGE
pod/jupyterlab-5685dcf5c7-ggcpl 1/1 Running 0 4m34s
pod/lighter-5484769777-7r9ln 1/1 Running 0 5m12s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/jupyterlab ClusterIP 10.100.99.140 <none> 8888/TCP 4m34s
service/lighter ClusterIP 10.98.245.141 <none> 8080/TCP,25333/TCP 5m12s
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/jupyterlab 1/1 1 1 4m34s
deployment.apps/lighter 1/1 1 1 5m12s
NAME DESIRED CURRENT READY AGE
replicaset.apps/jupyterlab-5685dcf5c7 1 1 1 4m34s
replicaset.apps/lighter-5484769777 1 1 1 5m12s
```
CDRs (from `ingress` addon) needs separate call:
```
minikube kubectl -- -n spark get ingress
```
```
NAME CLASS HOSTS ADDRESS PORTS AGE
jupyterlab nginx spark.local 192.168.49.2 80 87s
lighter nginx spark.local 192.168.49.2 80 87s
```

### Optional: Windows with WSL2 with Ubuntu
1. Run this in WSL2
```
minikube tunnel
```
2. Add this entry to your `C:\Windows\System32\Drivers\etc\hosts` file on Windows:
```
127.0.0.1 spark.local
```

### Try it out!

Lighter URL: http://spark.local/lighter/

Jupyterlab URL: http://spark.local/jupyterlab/

**_NOTE:_** Jupyterlab will already have `quickstart.ipynb` notebook with two cells. Execute them and that's it.
Loading

0 comments on commit fb060db

Please sign in to comment.