Skip to content

Latest commit

 

History

History
139 lines (96 loc) · 4.25 KB

KUBERNETES.md

File metadata and controls

139 lines (96 loc) · 4.25 KB

Akka Cluster Orchestration Example - Kubernetes Deployment

Prerequisites:

You'll need version 0.9.0 (or later) of the CLI.

If you already have a Minikube and wish to start fresh, run minikube delete to remove your existing Minikube.

  1. Start minikube
minikube start

eval $(minikube docker-env)

minikube addons enable ingress
  1. Build and Deploy project

There's two ways to deploy this project. You can do it from within sbt or from the command line.

sbt

This is the developer friendly method of running the project. Simply invoke the deploy minikube task.

sbt 'deploy minikube'

Command Line

This matches more closely what you'd do in a production environment. You'll build the project. Then, you'll use rp to generate resources for it and pipe those to kubectl.

Build project

sbt docker:publishLocal

Inspect images

docker images

Deploy project

rp generate-kubernetes-resources akka-cluster-orchestration-example:0.1.0 \
  --generate-all \
  --ingress-annotation ingress.kubernetes.io/rewrite-target=/ \
  --ingress-annotation nginx.ingress.kubernetes.io/rewrite-target=/ \
  --pod-controller-replicas 3 | kubectl apply -f -
  1. View Results (Note: -k is needed because the certificate is self-signed)

This may take 30 seconds or so until all pods have been started and the cluster has formed. You should see a member listing.

kubectl get all
NAME                                               DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
deploy/akka-cluster-orchestration-example-v0-1-0   3         3         3            3           1m

NAME                                                      DESIRED   CURRENT   READY     AGE
rs/akka-cluster-orchestration-example-v0-1-0-6d8b954c45   3         3         3         1m

NAME                                               DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
deploy/akka-cluster-orchestration-example-v0-1-0   3         3         3            3           1m

NAME                                                      DESIRED   CURRENT   READY     AGE
rs/akka-cluster-orchestration-example-v0-1-0-6d8b954c45   3         3         3         1m

NAME                                                      READY     STATUS    RESTARTS   AGE
po/akka-cluster-orchestration-example-v0-1-0-6d8b954c45-2jzbb   1/1       Running   0          1m
po/akka-cluster-orchestration-example-v0-1-0-6d8b954c45-vfkg6   1/1       Running   0          1m
po/akka-cluster-orchestration-example-v0-1-0-6d8b954c45-zq8wj   1/1       Running   0          1m

NAME                                     TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)                         AGE
svc/akka-cluster-orchestration-example   ClusterIP   None         <none>        10000/TCP,10001/TCP,10002/TCP   1m
svc/kubernetes                           ClusterIP   10.96.0.1    <none>        443/TCP                         3m
curl -k "https://$(minikube ip)/cluster-example"
Akka Cluster Members
====================

akka.tcp://my-system@172.17.0.8:10000
akka.tcp://my-system@172.17.0.7:10000
akka.tcp://my-system@172.17.0.6:10000
  1. Run the job (Optional)

This application has a job in it that joins the existing cluster, prints a message, and then exits.

rp generate-kubernetes-resources akka-cluster-orchestration-example:0.1.0 \
  --application my-job \
  --akka-cluster-join-existing \
  --generate-pod-controllers \
  --pod-controller-type job | kubectl apply -f -

You can then inspect the jobs output using:

kubectl logs jobs/akka-cluster-orchestration-example-v0-1-0

And lastly, remove the job, thus deleting logs:

kubectl delete jobs/akka-cluster-orchestration-example-v0-1-0
  1. Remove project (Optional)

If you wish to remove the resources, you can use kubectl delete as follows:

rp generate-kubernetes-resources akka-cluster-orchestration-example:0.1.0 \
  --generate-all --pod-controller-replicas 3 | kubectl delete -f -