Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README-original.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Welcome to AllegroGraph examples!

This repository contains examples of using AllegroGraph in advanced scenarios.

## Featured examples

* Configuration and setup examples
* [Clustering](clustering)
* [Load balancing multi-master replication cluster on AWS using Terraform](clustering/terraform-elb/using-terraform.md)
* [AllegroGraph Replication using NGINX Load Balancer](clustering/misc/using-nginx-load-balancer.md)
* [MMR Replication Clusters in Kubernetes and Docker Swarm](clustering/kubernetes/mmr/kubernetes-mmr.md)
* Data examples
* [Bitcoin RDF model](data/bitcoin)

* Generate AllegroGraph databases
* [Weather data](generators/weather/weather.md)

105 changes: 92 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,96 @@
# Welcome to AllegroGraph examples!
# Development/Release Notes

This repository contains examples of using AllegroGraph in advanced scenarios.
Author: Robert Wydler </br>
LinkedIn: [Profile](https://www.linkedin.com/in/robwyd/)

## Featured examples
## Introduction
### Based on ###
This is an extension of the product "AllegroGraph for Multi-Master Replication" and is based on https://github.com/franzinc/agraph-examples.

* Configuration and setup examples
* [Clustering](clustering)
* [Load balancing multi-master replication cluster on AWS using Terraform](clustering/terraform-elb/using-terraform.md)
* [AllegroGraph Replication using NGINX Load Balancer](clustering/misc/using-nginx-load-balancer.md)
* [MMR Replication Clusters in Kubernetes and Docker Swarm](clustering/kubernetes/mmr/kubernetes-mmr.md)
* Data examples
* [Bitcoin RDF model](data/bitcoin)
### Goals ###
1. Creating a docker image like [Docker and AllegroGraph 7.0.4](https://franz.com/agraph/support/documentation/current/docker.html) but for [Multi-Master Replication in AllegroGraph 7.0.4](https://franz.com/agraph/support/documentation/current/multi-master.html) based on [Welcome to AllegroGraph examples](https://github.com/franzinc/agraph-examples).

1. Run standardized Multi-master Replication in AllegroGraph 7.0.4 using [Google Kubernetes Engine, GKE](https://cloud.google.com/kubernetes-engine).

1. Make it available for semantic AI research studies with help of [Google's Free Tier ](https://cloud.google.com/free) and [AllegroGraph's Free Editon ](https://allegrograph.com/) and to learn more about both products.

1. Setup a Kubernetes namespace `agraph-ns`, Kubernetes `Update-Strategy` and the `Horizontal Pod AutoScaler, HPA` e.g. using `Google's Cluster Autoscaler`.


### Affected Parts ###

Therefore, only the clustering parts of **docker** (folders: ``clustering/kubernetes/mmr/agmmr/*``), **kubernetes** and **helm** (folders: ``clustering/kubernetes/mmr/helm/*``) has been changed.

## Important Constraints !!! ##
Currently ...
* ... it's only a **developer study** version and it's **not ready for production!**
* ... the prototype was only running in a **very small (free)** Google GKE **test environment**.
* ... **fundamental changes** had been made (e.g. from ``StateFull`` copy read only ``pods`` to ``Deployment`` copy read only ``pods``) and Kubernetes' ``Horizontal Pod Autoscaler`` had been defined added (``hpa.yaml``).

## Known Issue ##
After deployment, sometimes it may happen, that the repositories are not reachable by the `agraph-mmr-copy-loadbalancer`. That's because the `agraph-mmr-controlling` stateful set has to run before the `agraph-mmr-copy` deployment. I haven't figured out yet, how to arrange a sequential start in Helm.

You can **circumvent** the issue by deleting the `agraph-mmr-copy` pods in the Google Cloud Console or you can perform a graceful pod deletion with the following command:

`kubectl delete pods <pod>`

The `agraph-mmr-copy` pods will be recreated automatically by the deploment.

---
## ToDo's for a Reliable Release
1. Change Helm to always start the stateful set `agraph-mmr-controlling` before the `agraph-mmr-copy` deployment.

For a reliable release of the Docker Image 7.0.4 together with Kubernetes and Helm, it's important to validate and test ...
1. ... the functionality of `copy-ssl.yaml` pods after the change from `StatefulSet` to Kubernetes `Deployment` pods.
1. ... the reliability and horizontal scalability of the pods (`hpa.yaml`) and of the Kubernetes cluster (e.g. GKE) in an operational environment with high query loads.
1. ... the interaction of the state-oriented controller pods with the stateless copy pods.
1. ... etc.
---
## Overview of Changes
### Affected Parts ###
Only the clustering parts of **docker** (folders under: ``clustering/kubernetes/mmr/agmmr/*``), **kubernetes** and **helm** (folders under: ``clustering/kubernetes/mmr/helm/*``) were changed.

### Docker Image, Version 7.0.4
*.../mmr/agmmr/Dockerfile:*
* Changed to AllegroGraph version to 7.0.4
* Testrelease removed
* Changed access to `chmod +x /app/misc/runrepl.sh`

*.../mmr/agmmr/Makefile:*
* Changed to AllegroGraph version to 7.0.4
* Testrelease removed

### Helm
*.../mmr/helm/Makefile:*
* Given application name `agraph-mmr`
* Kubenretes namespace added `agraph-ns` for all components
* Changed to AllegroGraph version to 7.0.4
* Changed to AllegroGraph app version to 7.0.4

*.../mmr/helm/agraphmmr/Chart.yaml:*
* Changed to AllegroGraph version to 7.0.4
* Kept the maintainers to "Franz Inc."

*.../mmr/helm/agraphmmr/values.yaml:*
* CPU limits added
* Update behaviour added
* Horizontal Pod Autoscaler criteria added

### Kubernetes templates
*.../mmr/helm/agraphmmr/templates/controlling-ss.yaml:*
* Required `selector`added
* Update strategy added
* CPU limits for the Horizontal Pod Autoscaler, HPA added

*.../mmr/helm/agraphmmr/templates/copy-ss.yaml:*
* Because of read-only, stateless pods: Changed the `kind` from `StatefulSet` to `Deploment`
* Constant `replica` set to `1`; it's under HPA control
* `matchLabels` and `app`added
* Update strategy added
* Values added under `Resources` for HPA

*.../mmr/helm/agraphmmr/templates/hpa.yaml:*
New file added for Horizontal Pod Autoscaler, HPA concerning ...
* the controllers (controlling-ss.yaml)
* the workers (copy-ss.yaml)

* Generate AllegroGraph databases
* [Weather data](generators/weather/weather.md)

9 changes: 4 additions & 5 deletions clustering/kubernetes/mmr/agmmr/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,16 @@ FROM centos:7
# ensure we have a good set of network programs installed
RUN yum -y install net-tools iputils bind-utils wget hostname openssl

ARG agversion=7.0.0
ARG testrelease=
ARG agversion=7.0.4

ENV agdistfile=agraph-${agversion}-linuxamd64.64.tar.gz
ENV agversion=${agversion}

## Show the curl command we're about to execute
## This useful for debugging curl problems due to invalid arguments
RUN echo will do: curl -f -o ${agdistfile} http://franz.com/ftp/pri/acl/ag/ag${agversion}${testrelease}/linuxamd64.64/${agdistfile}
RUN echo will do: curl -f -o ${agdistfile} https://franz.com/ftp/pri/acl/ag/ag${agversion}/linuxamd64.64/${agdistfile}

RUN curl -f -o ${agdistfile} http://franz.com/ftp/pri/acl/ag/ag${agversion}${testrelease}/linuxamd64.64/${agdistfile}
RUN curl -f -o ${agdistfile} https://franz.com/ftp/pri/acl/ag/ag${agversion}/linuxamd64.64/${agdistfile}

## extract the AllegroGraph distribution
RUN tar xfz ${agdistfile}
Expand All @@ -40,5 +39,5 @@ COPY . /app/misc
# in the controlling instance only.
VOLUME ["/app/rootcatalog"]


RUN chmod +x /app/misc/runrepl.sh
ENTRYPOINT ["/app/misc/runrepl.sh"]
9 changes: 4 additions & 5 deletions clustering/kubernetes/mmr/agmmr/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
#
# e.g. make agversion=6.5.0 build
#
dockeraccount=unspecified
agversion=7.0.0
testrelease=
tag=7.0.0
dockeraccount = unspecified
agversion=7.0.4
tag=7.0.4

build:
docker build --build-arg agversion=$(agversion) --build-arg testrelease=$(testrelease) -t $(dockeraccount)/agmmr:$(tag) .
docker build -t $(dockeraccount)/agmmr:$(tag) --build-arg agversion=$(agversion) --build-arg $(dockeraccount)/agmmr:$(tag) .

push:
docker image push $(dockeraccount)/agmmr:$(tag)
Expand Down
49 changes: 49 additions & 0 deletions clustering/kubernetes/mmr/agmmr/helm/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# running agraph mmr in kubernetes using helm
#
# type
# % make
# to see the steps you must perform to install the cluster
#

name = agraph-mmr
namespace = agraph-ns
info:
@echo
@echo You can install the mmr cluster in kubernetes
@echo using a generated release name
@echo % make install
@echo
@echo or if you wish to choose a name for the cluster:
@echo % make name=foo install
@echo
@echo 'make install' installs AllegroGraph with no license
@echo so its capabilities are limited.
@echo If you have a license in file ~/license.txt then
@echo use make target install-with-license
@echo for example
@echo % make file=~/license.txt name=foo install-with-license
@echo


install:
helm install $(name) ./agraphmmr --create-namespace --namespace $(namespace)

# rwy added:
re-install:
helm upgrade --install $(name) ./agraphmmr --namespace $(namespace)


install-with-license:
helm install --set-file license=$(file) $(name) ./agraphmmr --namespace $(namespace)


# rwy added:
uninstall:
helm uninstall $(name) --namespace $(namespace)

## make a Helm repository with the agraphmmr chart in it
repository:
helm package ./agraphmmr
mkdir -p repo
mv agraphmmr-*.tgz repo
helm repo index repo
23 changes: 23 additions & 0 deletions clustering/kubernetes/mmr/agmmr/helm/agraphmmr/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
.#*
23 changes: 23 additions & 0 deletions clustering/kubernetes/mmr/agmmr/helm/agraphmmr/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: v2
name: agraphmmr
description: An AllegroGraph MMR cluster Helm chart for Kubernetes

type: application
home: https://github.com/franzinc/agraph-examples/tree/master/clustering/kubernetes/mmr

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
version: 7.0.4

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application.
appVersion: 7.0.4

icon: https://franz.com/images/logo.png


maintainers:
- name: "Franz Inc"
email: "[email protected]"


64 changes: 64 additions & 0 deletions clustering/kubernetes/mmr/agmmr/helm/agraphmmr/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{{ .Chart.Name }} - Helm chart for running an AllegroGraph cluster with Multi-Master Replication

The full details on this chart can be found at

https://github.com/franzinc/agraph-examples/blob/master/clustering/kubernetes/mmr/kubernetes-mmr.md

That contains a description of how the chart works as well as how to modify what it does.



Once the chart is installed you can access the controlling instance via a load balancer

Run

% kubectl get svc

To find the address of the controlling-loadbalancer.

It will take a few minutes for the external IP address to be allocated and
show by this kubectl command.

For example:

NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
sample-controlling-loadbalancer LoadBalancer 10.12.8.217 104.155.148.58 10035:32240/TCP 113s

Given the above you can access the controlling instance through the load balancer
at:

http://104.155.148.58:10035

The default username is "test" and the default password is "xyzzy"

You can do read and write access of the MMR cluster through the controlling-loadbalancer.

There is also a copy-loadbalancer. This distributes work to all the copy nodes.
The load balancer does not yet have session support so you should only
use the copy-loadbalancer for queries to the repository.

We also have a created a copy-0-loadbalancer as a demonstration of how to
communicate with a single specified copy instance. Since this load
balancer is always talking to the same instance one can do read and write accesses through
this load balancer. However the copy instances can be deleted by
kubernetes if you reduce the number of replicas defined.

One way to change the number of replicas is to edit values.yaml
and specify the desired number of replicas and then

% helm upgrade releasename chart

where releasename and chart are the same as
in the command you used to install the chart

% helm install releasename chart










Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#
# This will create a service with an external IP through which
# one can access the controlling instance.
# Since there's just one controlling instance we don't need to worry
# about the fact that the load balancer has no support for sessions.
#
# The external IP will be chosen by the cloud provider
#
apiVersion: v1
kind: Service
metadata:
name: {{ .Release.Name }}-controlling-loadbalancer
spec:
type: LoadBalancer
ports:
- port: {{ .Values.port }}
targetPort: {{ .Values.port }}
selector:
app: {{ .Release.Name }}-controlling
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#
# this service exposes the internal IP address
# of the controlling instance and makes it
# available via dns at the
# name 'releasename-controlling'
# using the dns search list
#
apiVersion: v1
kind: Service
metadata:
name: {{ .Release.Name }}-controlling
spec:
clusterIP: None
selector:
app: {{ .Release.Name }}-controlling
ports:
- name: http
port: {{ .Values.port }}
targetPort: {{ .Values.port }}




Loading