Logo
OpenScaler

Kubernetes Sample App

This guide will walk you through deploying a "Online Boutique" sample application to a Kubernetes cluster.

Prerequisites

Ensure you have the following requirements:

Important

By default, only worker nodes run your services. If you're using a single node or two nodes with 4GB RAM each, make sure to enable task scheduling on all nodes:

kubectl taint nodes --all node-role.kubernetes.io/control-plane-

Deploying the Sample Application

Clone the sample app

Clone the latest major version of the sample application

git clone --depth 1 --branch openscaler https://github.com/OpenScalerEngineeringTeam/kubernetes-demo.git
cd kubernetes-demo/

The --depth 1 argument skips downloading git history.

Deploy the sample app

From the root folder of this repository, navigate to the kustomize/ directory.

cd kustomize/

See what the default Kustomize configuration defined by kustomize/kustomization.yaml will generate (without actually deploying them yet).

kubectl kustomize .

Apply the default Kustomize configuration (kustomize/kustomization.yaml).

kubectl apply -k .

Wait for the pods to be ready.

kubectl get pods

After a few minutes, you should see the Pods in a Running state:

NAME                                     READY   STATUS    RESTARTS   AGE
adservice-76bdd69666-ckc5j               1/1     Running   0          2m58s
cartservice-66d497c6b7-dp5jr             1/1     Running   0          2m59s
checkoutservice-666c784bd6-4jd22         1/1     Running   0          3m1s
currencyservice-5d5d496984-4jmd7         1/1     Running   0          2m59s
emailservice-667457d9d6-75jcq            1/1     Running   0          3m2s
frontend-6b8d69b9fb-wjqdg                1/1     Running   0          3m1s
loadgenerator-665b5cd444-gwqdq           1/1     Running   0          3m
paymentservice-68596d6dd6-bf6bv          1/1     Running   0          3m
productcatalogservice-557d474574-888kr   1/1     Running   0          3m
recommendationservice-69c56b74d4-7z8r5   1/1     Running   0          3m1s
redis-cart-5f59546cdd-5jnqf              1/1     Running   0          2m58s
shippingservice-6ccc89f8fd-v686r         1/1     Running   0          2m58s

Access your Online Boutique application

You now have two options to access your Online Boutique application

Access Application locally with port forwarding

  1. Forward the frontend service to your local machine

    kubectl port-forward svc/frontend 8080:80   # --address 0.0.0.0  flag to make accessible in all your local network
  2. Done! You may now access your Online Boutique application at http://localhost:8080 (or http://<your-local-ip>:8080 if you used the --address 0.0.0.0 flag)

Access Application with Ingress

Since the application already has an Ingress resource configured, all you need to do is to create a LoadBalancer :

  1. Head to your Kubernetes cluster page choose your cluster from the list
  2. Create a LoadBalancer for your cluster from the "Network" tab and install your Ingress Controller (as described in the "Network" tab)
  3. Find your load balancer's HTTP port (for example 9039) (follow guide in the "Network" tab)
  4. Done! you can now access your Online Boutique application at http://k8s.alpha.openscaler.net:YOUR_INGRESS_PORT (replace YOUR_INGRESS_PORT with the port you found in the previous step)

On this page