Skip to content

Commit

Permalink
More examples (#7)
Browse files Browse the repository at this point in the history
- Add README to all directories
- Copy Kubernetes resources from docs
- Create example using kind

Signed-off-by: Anders Eknert <[email protected]>
  • Loading branch information
anderseknert authored Feb 14, 2023
1 parent 817ba90 commit 8bfdbd0
Show file tree
Hide file tree
Showing 6 changed files with 164 additions and 6 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,30 +34,30 @@ Or grab the latest version of Styra Load from the [releases](https://github.com/

**MacOS (Apple Silicon)**
```shell
$ curl -L -o load "https://github.com/StyraInc/load/releases/download/v0.49.0-2/load_Darwin_arm64"
$ curl -L -o load "https://github.com/StyraInc/load/releases/latest/download/load_Darwin_arm64"
$ xattr -d com.apple.quarantine load
$ chmod +x load
```

**MacOS (x86_64)**
```shell
$ curl -L -o load "https://github.com/StyraInc/load/releases/download/v0.49.0-2/load_Darwin_x86_64"
$ curl -L -o load "https://github.com/StyraInc/load/releases/latest/download/load_Darwin_x86_64"
$ xattr -d com.apple.quarantine load
$ chmod +x load
```

**Linux (x86_64)**
```shell
$ curl -L -o load "https://github.com/StyraInc/load/releases/download/v0.49.0-2/load_Linux_x86_64"
$ curl -L -o load "https://github.com/StyraInc/load/releases/latest/download/load_Linux_x86_64"
$ chmod +x load
```

**Windows (x86_64)**
```shell
> curl.exe -L -o load "https://github.com/StyraInc/load/releases/download/v0.49.0-2/load_Windows_x86_64.exe"
> curl.exe -L -o load "https://github.com/StyraInc/load/releases/latest/download/load_Windows_x86_64.exe"
```

Checksums for all binaries may optionally be retrieved from [here](https://github.com/StyraInc/load/releases/download/v0.49.0-2/checksums.txt).
Checksums for all binaries may optionally be retrieved from [here](https://github.com/StyraInc/load/releases/latest/download/checksums.txt).

### Obtaining a License

Expand Down Expand Up @@ -98,4 +98,5 @@ load eval --data policy.rego --input input.json ...
This repository additionally contains companion examples and blueprints from the Styra Load [documentation](https://docs.styra.com/load).

- [Performance testing](/examples/performance-testing/)
- Kubernetes [deployment example](/examples/kubernetes/)
- Streaming data from [Apache Kafka](/examples/kafka/)
3 changes: 3 additions & 0 deletions examples/kafka/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Kafka Topic Datasource

Example code for the Styra Load [Kafka integration](https://docs.styra.com/load/configuration/data/kafka-streams-api).
27 changes: 27 additions & 0 deletions examples/kubernetes/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Kubernetes Deployment

Example code for [deployment](https://docs.styra.com/load/installation/deployment) of Styra Load in a Kubernetes cluster.

To run the example code in a local [kind](https://kind.sigs.k8s.io) cluster, follow the steps outlined below.

First, create a new cluster with the provided configuration file.

```shell
$ kind create cluster --config kind-config.yaml
```

Edit the `manifests.yaml` file and add your license key in the `styra-load-license` secret manifest.

Next, deploy the resource manifests:

```shell
$ kubectl apply -f manifests.yaml
```

Last, deploy the Nginx ingress controller in order to make the deployment accessible from your machine:

```shell
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/kind/deploy.yaml
```

Your Styra Load instance should now be reachable on `localhost:8181/load`.
14 changes: 14 additions & 0 deletions examples/kubernetes/kind-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
kubeadmConfigPatches:
- |
kind: InitConfiguration
nodeRegistration:
kubeletExtraArgs:
node-labels: "ingress-ready=true"
extraPortMappings:
- containerPort: 8181
hostPort: 8181
protocol: TCP
111 changes: 111 additions & 0 deletions examples/kubernetes/manifests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
---
apiVersion: v1
kind: Namespace
metadata:
name: load
---
apiVersion: v1
kind: Secret
metadata:
name: styra-load-license
namespace: load
type: Opaque
stringData:
license: changeme
---
apiVersion: v1
kind: ConfigMap
metadata:
name: styra-load-config
namespace: load
data:
config.yaml: |
decision_logs:
console: true
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: load
namespace: load
name: load
spec:
replicas: 1
selector:
matchLabels:
app: load
template:
metadata:
labels:
app: load
name: load
spec:
containers:
- name: load
image: ghcr.io/styrainc/load:latest
args:
- "run"
- "--server"
- "--addr=0.0.0.0:8181"
- "--config-file=/etc/config/config.yaml"
env:
- name: STYRA_LOAD_LICENSE_KEY
valueFrom:
secretKeyRef:
name: styra-load-license
key: license
volumeMounts:
- name: config
mountPath: /etc/config
readinessProbe:
httpGet:
path: /health
scheme: HTTP
port: 8181
initialDelaySeconds: 3
periodSeconds: 5
livenessProbe:
httpGet:
path: /health
scheme: HTTP
port: 8181
initialDelaySeconds: 3
periodSeconds: 5
volumes:
- name: config
configMap:
name: styra-load-config
items:
- key: "config.yaml"
path: "config.yaml"
---
kind: Service
apiVersion: v1
metadata:
name: load
namespace: load
spec:
selector:
app: load
ports:
- port: 8181
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: load
namespace: load
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$2
spec:
rules:
- http:
paths:
- pathType: Prefix
path: /load(/|$)(.*)
backend:
service:
name: load
port:
number: 8181
4 changes: 3 additions & 1 deletion examples/performance-testing/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Performance Testing

This folder contains a number of large OPA bundles for performance testing.

Please see the Load documentation for instructions on how to use these bundles
in performance tests.
in [performance tests](https://docs.styra.com/load/performance-testing).

0 comments on commit 8bfdbd0

Please sign in to comment.