> For the complete documentation index, see [llms.txt](https://jeffgthompsons-organization.gitbook.io/yellow-team/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jeffgthompsons-organization.gitbook.io/yellow-team/training/cloud-guru/kubernetes-essentials/deploying-a-microservice-application-to-kubernetes.md).

# Deploying a Microservice Application to Kubernetes

## **Deploy the Stan's Robot Shop app to the cluster.**

**Clone the Git repo that contains the pre-made descriptors:**

```
cd ~/ 
git clone https://github.com/linuxacademy/robot-shop.git
```

**Since this application has many components, it is a good idea to create a separate namespace for the app:**

```
kubectl create namespace robot-shop
```

**Deploy the app to the cluster:**

```
kubectl -n robot-shop create -f ~/robot-shop/K8s/descriptors/
```

**Check the status of the application's pods:**

```
kubectl get pods -n robot-shop
```

<figure><img src="https://2666479439-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBLYaaERPa1yy1Qa8E1NQ%2Fuploads%2FWL1iEQQ4IKIDKGI1SEPW%2Fimage.png?alt=media&amp;token=e6d15255-331f-49bb-aec2-8eda83251319" alt=""><figcaption></figcaption></figure>

**You should be able to reach the robot shop app from your browser using the Kube master node's public IP:**

```
http://$kube_master_public_ip:30080
```

<figure><img src="https://2666479439-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBLYaaERPa1yy1Qa8E1NQ%2Fuploads%2Fqa6mxdwhT75M8YwcrXLN%2Fimage.png?alt=media&amp;token=514ff05e-d1b6-4096-a398-8dd812e640ee" alt=""><figcaption></figcaption></figure>

## Scale up the MongoDB deployment to two replicas instead of just one.

**Edit the deployment descriptor:**

```
kubectl edit deployment mongodb -n robot-shop
```

**You should see some YAML describing the deployment object.**

Under `spec:`, look for the line that says `replicas: 1` and change it to `replicas: 2`.

Save and exit.

<figure><img src="https://2666479439-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBLYaaERPa1yy1Qa8E1NQ%2Fuploads%2FPo7L9fagYs4crYxEymZg%2Fimage.png?alt=media&amp;token=48c91761-3b67-4e2b-a417-121c35a36a67" alt=""><figcaption></figcaption></figure>

**Check the status of the deployment with:**

```
kubectl get deployment mongodb -n robot-shop
```

**After a few moments, the number of available replicas should be 2.**

<figure><img src="https://2666479439-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBLYaaERPa1yy1Qa8E1NQ%2Fuploads%2FaHGuWD1yqL8eQSTcyQxK%2Fimage.png?alt=media&amp;token=4648ace3-e9ba-4939-a08a-49d504af49cd" alt=""><figcaption></figcaption></figure>

```
kubectl get pods -n robot-shop
```

<figure><img src="https://2666479439-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBLYaaERPa1yy1Qa8E1NQ%2Fuploads%2FMXSL1fc9O03aGbO1Sg12%2Fimage.png?alt=media&amp;token=77c3e55a-3ad0-444c-9627-f4372d417105" alt=""><figcaption></figcaption></figure>
