GithubHelp home page GithubHelp logo

akka-sample-cluster-kubernetes-java's Introduction

akka-sample-cluster-kubernetes-java

This is an example Maven project showing how to create an Akka Cluster on Kubernetes.

It is not always necessary to use Akka Cluster when deploying an Akka application to Kubernetes: if your application can be designed as independent stateless services that do not need coordination, deploying them on Kubernetes as individual Akka application without Akka Cluster can be a good fit. When state or coordination between nodes is necessary, this is where the Akka Cluster features become interesting and it is worth consider making the nodes form an Akka Cluster.

Kubernetes Instructions

Docker Desktop for Kubernetes

For Windows and Mac users, may be handier to use a Kubernetes cluster on Docker-Desktop. If you use Kubernetes on Docker Desktop, after turning it on, you should first issue:

export KUBECONFIG=~/.kube/config
kubectl config set-context docker-desktop

A script that comprises all steps involved is scripts/test_docker_desktop.sh. To run it, do:

cd akka-sample-cluster-kubernetes-java
scripts/test_docker_desktop.sh

Minikube

If you are using minikube for Kubernetes, please run the included scripts in the scripts directory.

Starting

First, package the application and make it available locally as a docker image:

mvn clean package docker:build

Then akka-cluster.yml should be sufficient to deploy a 2-node Akka Cluster, after creating a namespace for it:

kubectl apply -f kubernetes/namespace.json
kubectl config set-context --current --namespace=appka-1
kubectl apply -f kubernetes/akka-cluster.yml

Finally, create a service so that you can then test http://127.0.0.1:8080 for 'hello world':

kubectl expose deployment appka --type=LoadBalancer --name=appka-service

You can inspect the Akka Cluster membership status with the Cluster HTTP Management.

curl http://127.0.0.1:8558/cluster/members/

To check what you have done in Kubernetes so far, you can do:

kubectl get deployments
kubectl get pods
kubectl get replicasets
kubectl cluster-info dump
kubectl logs appka-79c98cf745-abcdee   # pod name

To wipe everything clean and start over, do:

kubectl delete namespaces appka-1

Running in a real Kubernetes cluster

Publish to a registry the cluster can access e.g. Dockerhub with the kubakka user

The app image must be in a registry the cluster can see. The build.sbt uses DockerHub by default. Use mvn -Ddocker.registry=$DOCKER_REPO_URL/$NAMESPACE if your cluster can't access DockerHub.

To push an image to docker hub run:

mvn -am -pl bootstrap-demo-kubernetes-api package docker:push 

And remove the imagePullPolicy: Never from the deployments. Then you can use the same kubectl commands as described in the Starting section.

How it works

This example uses Akka Cluster Bootstrap to initialize the cluster, using the Kubernetes API discovery mechanism to find peer nodes.

akka-sample-cluster-kubernetes-java's People

Contributors

chbatey avatar ennru avatar johanandren avatar max8github avatar patriknw avatar raboof avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.