Skip to content

Run the application on Kubernetes

Edwin van Wijk edited this page Feb 1, 2024 · 2 revisions

This will describe how to run the Pitstop solution using Kubernetes.

This description assumes you have basic knowledge of Kubernetes concepts. It will help to understand what's going on if you're familiar with things like: nodes, deployments, pods, services, replica-sets and namespaces. If this is not the case, check-out the Kubernetes documentation to learn about these concepts before continuing with this description.

Execute the following steps to start the application:

  • Make sure your have satisfied the Prerequisites (also for Kubernetes) and you have built all the Docker images as described in Building the Docker images. You can also pull the images from the Pitstop repo available in Docker Hub.

  • Open up a Powershell window and go to the Pitstop/src/k8s/scripts folder.

  • Issue the following command:

    start-all.ps1 -nomesh
    

    on Windows or

    start-all.sh --nomesh
    

    on Linux. This will start the solution.

Pitstop can also be run with a service-mesh. The nomesh switch indicates you want to run Pitstop on Kubernetes without any service-mesh. See Run the application using a service-mesh to learn how to run Pitstop with a service-mesh.

The start-all script uses the Kubernetes CLI (kubectl) to apply the following Kubernetes config files:

Config file Description
pitstop-namespace.yaml Creates the pitstop namespace
rabbitmq.yaml Creates the RabbitMQ deployment
logserver.yaml Creates the Seq deployment
sqlserver.yaml Creates the SQL Server deployment
mailserver.yaml Creates the Mailserver deployment
invoiceservice.yaml Creates the InvoiceService deployment
timeservice.yaml Creates the TimeService deployment
notificationservice.yaml Creates the NotificationService deployment
workshopmanagementeventhandler.yaml Creates the WorkshopManagementEventHandler deployment
auditlogservice.yaml Creates the AuditLogService deployment
customermanagementapi-v1.yaml Creates the CustomerManagement v1 deployment
customermanagementapi-v2.yaml Creates the CustomerManagement v2 deployment
customermanagementapi-svc.yaml Creates the CustomerManagement service
vehiclemanagementapi.yaml Creates the VehicleManagement deployment and service
workshopmanagementapi.yaml Creates the WorkshopManagement deployment and service
webapp.yaml Creates the WebApp deployment and service

On the Kubernetes cluster, the following setup will be running:

Checking the status of the application

You can check whether or not the application was started successfully using the Kubernetes CLI. Execute the following command: kubectl get pods -n pitstop. This will show you an overview of all the pods that are started in the Pitstop namespace. You should see something like this:

It could take some time for pods to get up & running so you could see some other statuses in the list.

Next steps:

  • Follow the steps described in Testing the application to test the application functionality.
  • See Logging to learn how to get to the application logging.
  • In the logging you might see some errors during start-up. See Resiliency to learn where these errors are coming from.

Kubernetes Dashboard

You can get a deep insight into what's running on the Kubernetes cluster by using the Kubernetes dashboard. In order to view this dashboard, you first need to install it on the cluster. This is a one-time activity.

Install the dashboard

Execute the following steps to install the dasboard:

  • Install the dashboard components on the Kubernetes cluster:

    kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.6.1/aio/deploy/recommended.yaml
    

    Make sure you use the latest version of the Dashboard. See the Kubernetes Dashboard releases page on Github to see what's the latest release.

  • Create an admin user for accessing the dashboard:

    kubectl apply -f .\dashboard-adminuser.yaml
    
  • Retrieve the list of secrets installed in the cluster:

    kubectl -n kube-system get secret
    
  • Find the secret with the name that starts with admin-user-token- and copy the entire name.

  • Get information about this secret:

    kubectl -n kube-system describe secret admin-user-token-?????
    

    The output should look something like this:

  • Copy the token in the output to the clipboard and save it somewhere. You need this every time you access the dashboard to authenticate.

Access the dashboard

Stopping the application

To stop all the Pitstop components, execute the script stop-all.ps1 or stop-all.sh. This script will use kubectl to delete all the Pitstop components from the cluster. Give all the pods some time to terminate. You can check whether or not everything has been deleted by getting all components in the Pitstop namespace: kubectl get pods -n pitstop.