Deployment workflow

This page describes the general workflow for deploying an application. Each step of the Implementing Microservices with Akka tutorial also has instructions of how to run in Kubernetes. The tutorial includes build files for creating Docker images and template deployment descriptors.

The steps below assume that you have already read the overview of Kubernetes deployment, and have created a Kubernetes cluster and installed the Akka Operator (in AWS or GCP).

1. Build Docker image

Build and publish a Docker image of the application.

AWS

Follow the instructions in Amazon Elastic Container Registry to deploy Docker images on AWS’s container registry.

GCP

Follow the instructions in Using Container Registry with Google Cloud new tab to deploy Docker images on GCP’s container registry.

2. Update the deployment descriptor

Update the deployment descriptor in kubernetes/shopping-cart-service-cr.yml of the AkkaMicroservice that the Akka Operator will use when deploying the application in Kubernetes.

kubernetes/shopping-cart-service-cr.yml:
apiVersion: "v1"
kind: "Namespace"
metadata:
  name: "shopping"
---
apiVersion: akka.lightbend.com/v1
kind: AkkaMicroservice
metadata:
  name: shopping-cart-service
  namespace: "shopping"
spec:
  replicas: 1
  image: <docker-registry>/shopping-cart-service:<tag> (1)
  javaOptions: "-Xlog:gc -XX:InitialRAMPercentage=75 -XX:MaxRAMPercentage=75"
  resources:
    limits:
      memory: "2Gi"
    requests:
      memory: "2Gi"
      cpu: "1"
1 Replace <docker-registry> with your docker registry address and update the image reference with the image tag you just created. The specific value and syntax of the <docker-registry> can vary depending on the registry you used. the most popular registries include DockerHub new tab and Quay.io new tab but you are probably publishing your images to AWS’s ECR or the Container Registry in GCP.

If you published to AWS’s ECR, the final value of the image: property will look similar to: 803424716218.dkr.ecr.eu-central-1.amazonaws.com/shopping-cart-service:20201209-135004-363ae2b.

If you are using the container registry in GCP, the image: property will be similar to eu.gcr.io/earthly-project-41643/shopping-cart-service:20201209-135004-363ae2b.

3. Apply to Kubernetes

Deploy the shopping-cart-service-cr.yml to Kubernetes:

kubectl apply -f kubernetes/shopping-cart-service-cr.yml

It will also create the namespace shopping

It can be convenient to set that namespace as current instead of specifying the --namespace parameter in all kubectl commands.

kubectl config set-context --current --namespace=shopping

The Akka Operator will notice the deployment descriptor and deploy the shopping-cart-service. You can see progress by viewing the status:

kubectl get akkamicroservices

See troubleshooting deployment status for more details.

You can list the pods with:

kubectl get pods

Inspect logs:

kubectl logs -f <shopping-cart-service pod name from above>

4. Repeat

If you change the application, repeat the above steps. Kubernetes will perform a rolling update of the application.

5. Delete

You can terminate all Pods of the application by deleting the deployment descriptor:

kubectl delete akkamicroservices/shopping-cart-service --namespace=shopping