Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial attempt at a ReShare dev environment using Kubernetes PR-1624 #726

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
62 changes: 62 additions & 0 deletions tools/reshare-dev-k8s/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
You'll need to have the `kubectl` context set to some sort of Kubernetes
cluster, I prefer KinD and k3d as they eschew VMs. To create a cluster that
forwards the necessary ports with k3d use something like:

```
k3d cluster create rsdev -p "9130:30130@server:0" -p "54321:30543@server:0" -p"29092:30092@server:0" -p"2181:32181@server:0"
```

Then you can spin up the necessary containers via the manifests (choosing FOLIO version as appropriate):

```
kubectl apply -R -f manifests
kubectl apply -R -f folio-modules-poppy
```

You'll need to wait until all the deployments are available, which you can check via:

```
kubectl get deployment -n reshare
```

While you're waiting you can get some port forwarding running to make Okapi and
Postgres available where the ReShare scripts/configs expect it (on localhost
and ports 9130 and 54321 respectively). Your k8s environment may have some way
to persist this or set it while creating the cluster (eg. you won't need this
step if you've used the k3d command above) or you can have a few terminals
running these:

```
kubectl port-forward -n reshare svc/postgres 54321:5432
kubectl port-forward -n reshare svc/okapi 9130:9130
kubectl port-forward -n reshare svc/reshare-kafka-cardinal 29092:29092
```

Once everything is up and forwarded you can create a tenant and enable the
modules we have manifests for:

```
ls folio-modules-poppy | ./enable-modules.sh
```

To create a superuser for now we can use an existing Perl script. NB. it needs
the JSON and UUID::Tiny modules which, on a Debian based Linux system, are also
available via system packges `libjson-perl` and `libuuid-tiny-perl`. It can be
found here:
https://raw.githubusercontent.com/folio-org/folio-install/master/runbooks/single-server/scripts/bootstrap-superuser.pl

```
perl ./bootstrap-superuser.pl
```

(You might consider changing the username and password in the above script.)

Finally, you'll need to update
`service/src/main/okapi/DeploymentDescriptor-template.json` in both
mod-directory and mod-rs to point at your workstation via `host.k3d.internal`
(or however you reach it via your k8s environment) rather than `10.0.2.2`. You
may also need to make that change in mod-rs'
`service/grails-app/conf/application.yml` as it explicitly lists that ip there.

At that point you should be able to use `register_and_enable.sh` and other
ReShare scripts to configure the dev environment per usual.
33 changes: 33 additions & 0 deletions tools/reshare-dev-k8s/enable-modules.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash -e

# Loads module descriptors to Okapi at $OKAPI, creates tenant $OKAPI_TENANT,
# then deploys modules passed on STDIN and installs them for that tenant.

OKAPI="localhost:9130"
OKAPI_TENANT=diku

INSTALLJSON='[ '

echo Loading descriptors
curl -X POST -d '{ "urls": ["https://folio-registry.dev.folio.org"] }' http://${OKAPI}/_/proxy/pull/modules
echo

echo Creating tenant
curl -X POST -d '{ "id": "'"${OKAPI_TENANT}"'", "name": "ReShare Dev Tenant" }' http://${OKAPI}/_/proxy/tenants

while read MODULE; do
MODULE_DOMAIN=`echo ${MODULE} | tr . -`
echo Enabling ${MODULE}
curl -X POST -d '{ "instId":"'"${MODULE}"'-inst", "srvcId":"'"${MODULE}"'", "url":"http://'"${MODULE_DOMAIN}"':8081" }' http://${OKAPI}/_/discovery/modules
echo
echo
INSTALLJSON+='{ "id":"'"${MODULE}"'", "action":"enable" }, '
done

INSTALLJSON=${INSTALLJSON::-2}
INSTALLJSON+=' ]'

echo Installing the following modules for tenant ${OKAPI_TENANT}: ${INSTALLJSON}
echo
curl -X POST -d "${INSTALLJSON}" http://${OKAPI}/_/proxy/tenants/${OKAPI_TENANT}/install?tenantParameters=loadSample%3Dtrue,loadReference%3Dtrue
echo
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# -*- mode: yaml; -*-
apiVersion: apps/v1
kind: Deployment
metadata:
name: "mod-authtoken-2-12-0"
labels:
app: "mod-authtoken-2-12-0"
module: "mod-authtoken"
folio_role: "backend-module"
namespace: "reshare"
spec:
selector:
matchLabels:
app: "mod-authtoken-2-12-0"
replicas: 1
template:
metadata:
labels:
app: "mod-authtoken-2-12-0"
module: "mod-authtoken"
folio_role: "backend-module"
spec:
containers:
- name: "mod-authtoken-2-12-0"
image: "folioorg/mod-authtoken:2.12.0"
envFrom:
- secretRef:
name: mod-authtoken-signing-key
- secretRef:
name: folio-db-connect
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: JAVA_OPTIONS
value: "-XX:MaxRAMPercentage=66.0 -Dcache.permissions=true -Djwt.signing.key=$(SIGNING_KEY) -Dlog4j2.formatMsgNoLookups=true"
ports:
- containerPort: 8081
protocol: TCP
resources:
limits:
memory: 357913941
imagePullSecrets:
- name: "dockerhub-cred"
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# -*- mode: yaml; -*-
apiVersion: v1
kind: Service
metadata:
name: "mod-authtoken-2-12-0"
namespace: "reshare"
spec:
type: "ClusterIP"
selector:
app: "mod-authtoken-2-12-0"
ports:
- port: 8081
name: 8081tcp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# -*- mode: yaml; -*-
apiVersion: apps/v1
kind: Deployment
metadata:
name: "mod-configuration-5-9-0"
labels:
app: "mod-configuration-5-9-0"
module: "mod-configuration"
folio_role: "backend-module"
namespace: "reshare"
spec:
selector:
matchLabels:
app: "mod-configuration-5-9-0"
replicas: 1
template:
metadata:
labels:
app: "mod-configuration-5-9-0"
module: "mod-configuration"
folio_role: "backend-module"
spec:
containers:
- name: "mod-configuration-5-9-0"
image: "folioorg/mod-configuration:5.9.0"
envFrom:
- secretRef:
name: folio-db-connect
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: JAVA_OPTIONS
value: "-XX:MaxRAMPercentage=66.0 -Dlog4j2.formatMsgNoLookups=true"
ports:
- containerPort: 8081
protocol: TCP
resources:
limits:
memory: 357913941
imagePullSecrets:
- name: "dockerhub-cred"
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# -*- mode: yaml; -*-
apiVersion: v1
kind: Service
metadata:
name: "mod-configuration-5-9-0"
namespace: "reshare"
spec:
type: "ClusterIP"
selector:
app: "mod-configuration-5-9-0"
ports:
- port: 8081
name: 8081tcp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# -*- mode: yaml; -*-
apiVersion: apps/v1
kind: Deployment
metadata:
name: "mod-email-1-15-3"
labels:
app: "mod-email-1-15-3"
module: "mod-email"
folio_role: "backend-module"
namespace: "reshare"
spec:
selector:
matchLabels:
app: "mod-email-1-15-3"
replicas: 1
template:
metadata:
labels:
app: "mod-email-1-15-3"
module: "mod-email"
folio_role: "backend-module"
spec:
containers:
- name: "mod-email-1-15-3"
image: "folioorg/mod-email:1.15.3"
envFrom:
- secretRef:
name: folio-db-connect
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: JAVA_OPTIONS
value: "-XX:MaxRAMPercentage=66.0 -Dlog4j2.formatMsgNoLookups=true"
ports:
- containerPort: 8081
protocol: TCP
resources:
limits:
memory: 357913941
imagePullSecrets:
- name: "dockerhub-cred"
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# -*- mode: yaml; -*-
apiVersion: v1
kind: Service
metadata:
name: "mod-email-1-15-3"
namespace: "reshare"
spec:
type: "ClusterIP"
selector:
app: "mod-email-1-15-3"
ports:
- port: 8081
name: 8081tcp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# -*- mode: yaml; -*-
apiVersion: apps/v1
kind: Deployment
metadata:
name: "mod-inventory-storage-25-0-4"
labels:
app: "mod-inventory-storage-25-0-4"
module: "mod-inventory-storage"
folio_role: "backend-module"
namespace: "reshare"
spec:
selector:
matchLabels:
app: "mod-inventory-storage-25-0-4"
replicas: 1
template:
metadata:
labels:
app: "mod-inventory-storage-25-0-4"
module: "mod-inventory-storage"
folio_role: "backend-module"
spec:
containers:
- name: "mod-inventory-storage-25-0-4"
image: "folioorg/mod-inventory-storage:25.0.4"
envFrom:
- secretRef:
name: folio-db-connect
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: JAVA_OPTIONS
value: "-XX:MaxRAMPercentage=66.0 -Dlog4j.configuration=file:/etc/log4j2.properties -Dlog4j2.formatMsgNoLookups=true"
- name: "KAFKA_HOST"
value: "reshare-kafka-cardinal"
- name: "KAFKA_PORT"
value: "9092"
- name: "REPLICATION_FACTOR"
value: "1"
ports:
- containerPort: 8081
protocol: TCP
resources:
limits:
memory: 715827883
volumeMounts:
- name: inventory-storage-log4j-config
mountPath: "/etc/log4j.properties"
subPath: "log4j.properties"
volumes:
- name: "inventory-storage-log4j-config"
configMap:
name: "inventory-storage-log4j-config"
imagePullSecrets:
- name: "dockerhub-cred"
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# -*- mode: yaml; -*-
apiVersion: v1
kind: Service
metadata:
name: "mod-inventory-storage-25-0-4"
namespace: "reshare"
spec:
type: "ClusterIP"
selector:
app: "mod-inventory-storage-25-0-4"
ports:
- port: 8081
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# -*- mode: yaml; -*-
apiVersion: apps/v1
kind: Deployment
metadata:
name: "mod-login-7-8-0"
labels:
app: "mod-login-7-8-0"
module: "mod-login"
folio_role: "backend-module"
namespace: "reshare"
spec:
selector:
matchLabels:
app: "mod-login-7-8-0"
replicas: 1
template:
metadata:
labels:
app: "mod-login-7-8-0"
module: "mod-login"
folio_role: "backend-module"
spec:
containers:
- name: "mod-login-7-8-0"
image: "folioorg/mod-login:7.8.0"
envFrom:
- secretRef:
name: folio-db-connect
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: JAVA_OPTIONS
value: "-XX:MaxRAMPercentage=66.0 -Dlog4j2.formatMsgNoLookups=true"
ports:
- containerPort: 8081
protocol: TCP
resources:
limits:
memory: 357913941
imagePullSecrets:
- name: "dockerhub-cred"
Loading
Loading