Skip to content
This repository was archived by the owner on Jan 19, 2024. It is now read-only.

Commit 2a5a60e

Browse files
authored
First few exercises added (#1)
The following exercises to get familiar with Airlock Microgateway have been added: * Getting started * Protecting a backend service * OpenAPI * Deny rules
1 parent d4067c6 commit 2a5a60e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+3026
-0
lines changed

.scripts/cleanup.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
echo ""
5+
echo "-------------------------------------------------"
6+
echo "| cleaning up ..."
7+
echo "-------------------------------------------------"
8+
echo ""
9+
kubectl delete all,ingress,configmap,secrets -l purpose=microgateway-tutorial --wait=true

.scripts/display_info.sh

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
echo ""
5+
echo "-------------------------------------------------"
6+
echo "| displaying deployment state ..."
7+
echo "-------------------------------------------------"
8+
echo ""
9+
kubectl get all
10+
11+
echo ""
12+
echo "-------------------------------------------------"
13+
echo "| describing pods ..."
14+
echo "-------------------------------------------------"
15+
echo ""
16+
kubectl describe pod -l purpose=microgateway-tutorial
17+
18+
echo ""
19+
echo "-------------------------------------------------"
20+
echo "| displaying configmaps (configuration) ..."
21+
echo "-------------------------------------------------"
22+
echo ""
23+
kubectl describe configmap -l purpose=microgateway-tutorial
24+
25+
echo ""
26+
echo "-------------------------------------------------"
27+
echo "| displaying microgateway secrets ..."
28+
echo "-------------------------------------------------"
29+
echo ""
30+
kubectl describe secret -l purpose=microgateway-tutorial
31+
32+
echo ""
33+
echo "-------------------------------------------------"
34+
echo "| displaying microgateway service ..."
35+
echo "-------------------------------------------------"
36+
echo ""
37+
kubectl describe service -l purpose=microgateway-tutorial
38+
39+
echo ""
40+
echo "-------------------------------------------------"
41+
echo "| displaying ingress ..."
42+
echo "-------------------------------------------------"
43+
echo ""
44+
kubectl describe ingress -l purpose=microgateway-tutorial
45+
46+
echo ""
47+
echo "-------------------------------------------------"
48+
echo "| displaying microgateway configbuilder log ..."
49+
echo "-------------------------------------------------"
50+
echo ""
51+
kubectl logs -l purpose=microgateway-tutorial -l app=microgateway -c configbuilder
52+
53+
echo ""
54+
echo "-------------------------------------------------"
55+
echo "| displaying logs for all pods ..."
56+
echo "-------------------------------------------------"
57+
echo ""
58+
kubectl logs -l purpose=microgateway-tutorial

.scripts/run.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
3+
display_usage() {
4+
echo "Usage: $0 tutorial_dir"
5+
echo "tutorial_dir: Tutorial to run. Should point to an Exercise or Solution folder of an exercise."
6+
echo "Example: $0 getting-started/solution"
7+
}
8+
9+
if [ -n "$1" ]; then
10+
TUTORIAL_DIR=$1
11+
else
12+
echo "Please provide a tutorial directory..."
13+
display_usage
14+
exit 1
15+
fi
16+
17+
.scripts/run_tutorial.sh $TUTORIAL_DIR
18+
19+
EXITCODE=$?
20+
if [ $EXITCODE -ne 0 ]; then
21+
22+
.scripts/display_info.sh
23+
echo ""
24+
echo "**************************************************"
25+
echo "* Deployment NOK *"
26+
echo "**************************************************"
27+
echo ""
28+
exit $EXITCODE
29+
fi
30+
31+
echo ""
32+
echo "**************************************************"
33+
echo "* Deployment OK *"
34+
echo "**************************************************"
35+
echo ""

.scripts/run_tutorial.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
display_usage() {
5+
echo "Usage: $0 tutorial_dir"
6+
echo "tutorial_dir: Tutorial to run. Should point to an Exercise or Solution folder of an exercise."
7+
echo "Example: $0 Getting_used_to_DSL/Excercise"
8+
}
9+
10+
if [ -n "$1" ]; then
11+
TUTORIAL_DIR=$1
12+
else
13+
echo "Please provide a tutorial directory..."
14+
display_usage
15+
exit 1
16+
fi
17+
18+
.scripts/cleanup.sh
19+
20+
echo ""
21+
echo "-------------------------------------------------"
22+
echo "| deploying tutorial ..."
23+
echo "-------------------------------------------------"
24+
echo ""
25+
kubectl apply -k $TUTORIAL_DIR
26+
kubectl wait --for=condition=ready --timeout=120s pod -l purpose=microgateway-tutorial
27+
28+
echo ""
29+
echo "-------------------------------------------------"
30+
echo "| verifying tutorial ..."
31+
echo "-------------------------------------------------"
32+
echo ""
33+
sleep 1
34+
.scripts/verify.sh $TUTORIAL_DIR

.scripts/verify.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
3+
display_usage() {
4+
echo "Usage: $0 tutorial_dir\n"
5+
echo "tutorial_dir: Tutorial to verify. Should point to an Exercise or Solution folder of an exercise."
6+
echo "Example: $0 getting-started/solution"
7+
}
8+
9+
if [ -n "$1" ]; then
10+
TUTORIAL_DIR=$1
11+
else
12+
echo "Please provide a tutorial directory..."
13+
display_usage
14+
exit 1
15+
fi
16+
17+
mgw_status="$(kubectl get pod -l app=microgateway --no-headers -o custom-columns=":status.phase")"
18+
19+
if [[ $mgw_status == Running ]]; then
20+
echo "OK: Microgateway is running"
21+
else
22+
echo "NOK: Microgateway is not running: $mgw_status"
23+
exit 1
24+
fi
25+
26+
if [[ -f "${TUTORIAL_DIR}/../.scripts/verify.sh" ]]; then
27+
${TUTORIAL_DIR}/../.scripts/verify.sh
28+
fi

.templates/echoserver/deployment.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
apiVersion: apps/v1
3+
kind: Deployment
4+
metadata:
5+
name: echoserver
6+
labels:
7+
app: echoserver
8+
spec:
9+
replicas: 1
10+
selector:
11+
matchLabels:
12+
app: echoserver
13+
template:
14+
metadata:
15+
labels:
16+
app: echoserver
17+
spec:
18+
imagePullSecrets:
19+
- name: dockerregcred
20+
containers:
21+
- name: echoserver
22+
image: k8s.gcr.io/echoserver:1.10
23+
imagePullPolicy: IfNotPresent
24+
ports:
25+
- name: http
26+
containerPort: 8080
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
apiVersion: kustomize.config.k8s.io/v1beta1
3+
kind: Kustomization
4+
5+
resources:
6+
- deployment.yaml
7+
- service.yaml
8+
9+
commonLabels:
10+
purpose: microgateway-tutorial

.templates/echoserver/service.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
apiVersion: v1
3+
kind: Service
4+
metadata:
5+
name: echoserver
6+
labels:
7+
app: echoserver
8+
spec:
9+
selector:
10+
app: echoserver
11+
ports:
12+
- name: http
13+
port: 8080
14+
targetPort: http

.templates/ingress/ingress.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
apiVersion: networking.k8s.io/v1
3+
kind: Ingress
4+
metadata:
5+
name: ingress-microgateway-default
6+
labels:
7+
app: microgateway
8+
annotations:
9+
kubernetes.io/ingress.class: nginx
10+
nginx.ingress.kubernetes.io/backend-protocol: https
11+
nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
12+
nginx.ingress.kubernetes.io/proxy-ssl-verify: "false"
13+
spec:
14+
rules:
15+
- http:
16+
paths:
17+
- path: /
18+
pathType: Prefix
19+
backend:
20+
service:
21+
name: microgateway
22+
port:
23+
name: https

.templates/ingress/kustomization.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
apiVersion: kustomize.config.k8s.io/v1beta1
3+
kind: Kustomization
4+
5+
resources:
6+
- ingress.yaml
7+
8+
commonLabels:
9+
purpose: microgateway-tutorial
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
apiVersion: kustomize.config.k8s.io/v1beta1
3+
kind: Kustomization
4+
5+
commonLabels:
6+
purpose: microgateway-tutorial
7+
8+
secretGenerator:
9+
- name: jwt-secrets
10+
literals:
11+
- JWT_DECRYPTION_KEY=c3VwZXJsb25ndGV4dHRoYXRpc3VzZWRmb3Jqd3R0b2tlbgo=
12+
- JWT_AUTH_CODE=superlongtextthatisusedforjwttoken

.templates/mariadb/config/my.cnf

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[mysqld]
2+
skip-name-resolve
3+
explicit_defaults_for_timestamp
4+
basedir=/opt/bitnami/mariadb
5+
plugin_dir=/opt/bitnami/mariadb/plugin
6+
port=3306
7+
socket=/opt/bitnami/mariadb/tmp/mysql.sock
8+
tmpdir=/opt/bitnami/mariadb/tmp
9+
max_allowed_packet=16M
10+
bind-address=0.0.0.0
11+
pid-file=/opt/bitnami/mariadb/tmp/mysqld.pid
12+
log-error=/opt/bitnami/mariadb/logs/mysqld.log
13+
character-set-server=UTF8
14+
collation-server=utf8_general_ci
15+
16+
[client]
17+
port=3306
18+
socket=/opt/bitnami/mariadb/tmp/mysql.sock
19+
default-character-set=UTF8
20+
plugin_dir=/opt/bitnami/mariadb/plugin
21+
22+
[manager]
23+
port=3306
24+
socket=/opt/bitnami/mariadb/tmp/mysql.sock
25+
pid-file=/opt/bitnami/mariadb/tmp/mysqld.pid

.templates/mariadb/kustomization.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
apiVersion: kustomize.config.k8s.io/v1beta1
3+
kind: Kustomization
4+
5+
resources:
6+
- statefulset.yaml
7+
- service.yaml
8+
- serviceaccount.yaml
9+
10+
commonLabels:
11+
purpose: microgateway-tutorial
12+
13+
configMapGenerator:
14+
- name: mariadb
15+
files:
16+
- config/my.cnf
17+
18+
secretGenerator:
19+
- name: mariadb
20+
literals:
21+
- mariadb-root-password=secretpassword
22+
- mariadb-password=TF9SkeLInU

.templates/mariadb/service.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
apiVersion: v1
3+
kind: Service
4+
metadata:
5+
name: mariadb
6+
labels:
7+
app: mariadb
8+
spec:
9+
selector:
10+
app: mariadb
11+
ports:
12+
- name: mysql
13+
port: 3306
14+
protocol: TCP
15+
targetPort: mysql
16+
nodePort: null
17+
type: ClusterIP
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
apiVersion: v1
3+
kind: ServiceAccount
4+
metadata:
5+
name: mariadb
6+
labels:
7+
app: mariadb

0 commit comments

Comments
 (0)