Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

Commit ec6519c

Browse files
author
Rizchel Dayao
committed
Update README.md
1 parent a766b97 commit ec6519c

File tree

3 files changed

+110
-187
lines changed

3 files changed

+110
-187
lines changed

README.md

Lines changed: 110 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,138 @@
1-
# Movie Finder
1+
# Deploy a React application on Kubernetes
22

3-
This project calls the OMDb API to get information about a movie the user entered using React and Redux.
3+
In this Code Pattern, we will deploy a React application using Kubernetes.
44

5-
Tools used:
6-
- React
7-
- Redux
8-
- OMDB API
9-
- Webpack
10-
- Babel
11-
- Sass
5+
There are many choices when looking for the right solution to manage and deploy our applications. It can often be overwhelming when we're trying to pick the right solution. One of our many choices is Kubernetes. This pattern will take you through how to get a front end application deployed on Kubernetes. After implementing the code, you will have the knowledge to deploy your own applications on Kubernetes.
126

13-
## Prerequisites
7+
This repository uses the React JavaScript library to build out the front end of the application. Redux is a predictable state container used hand in hand with React. It handles all of the state management within the application. The OMDb API is called to get movie information based on user input. Docker is an open source tool that is used to package the application into a container. IBM Cloud provides one to use with Kubernetes deployments called IBM Cloud Container Service. Kubernetes handles the management and deployment of the containerized application.
148

15-
You must get an API key from http://www.omdbapi.com/ in order to get a response from the API. You will insert your API key in /src/actions/action.js
9+
When the reader has completed this Code Pattern, they will understand how to:
10+
* Containerize a React application using Docker
11+
* Deploy and manage an application using Kubernetes
1612

17-
## Running the project locally
13+
## Flow
1814

19-
In the project directory run:
15+
![Flow](docs/source/images/architecture.png)
2016

21-
`npm install`
17+
1. The user accesses the application through the web interface. The user enters a movie title into the input.
18+
2. The React application is rendered to the user on access.
19+
3. The application calls the OMDb API and receives a JSON object of the response to show the user.
2220

23-
`npm run build-css`
21+
## Included components
22+
* IBM Cloud Container Service: IBM Bluemix Container Service manages highly available apps inside Docker containers and Kubernetes clusters on the IBM Cloud.
23+
* Kubernetes Cluster: Create and manage your own cloud infrastructure and use Kubernetes as your container orchestration engine.
2424

25-
`npm run start`
25+
## Featured technologies
26+
* Node.js: An open-source JavaScript run-time environment for executing server-side JavaScript code.
27+
* Cloud: Accessing computer and information technology resources through the Internet.
28+
* Container Orchestration: Automating the deployment, scaling and management of containerized applications.
2629

27-
You can now access the application at http://localhost:3000 🎉🎉🎉
30+
# Watch the video
2831

29-
## Running the project in a container
32+
# Steps
3033

31-
Build your image:
34+
## Prerequisites
35+
1. You must get an API key from [OMDb API](http://www.omdbapi.com/) in order to get a response from the API. You will insert your API key in /src/actions/index.js on line 42
3236

33-
`docker build -t <your username>/react-redux-api-example .`
37+
2. Create an environment variable for your docker username
38+
```
39+
$ export docker_username="YOUR_DOCKER_USERNAME"
40+
```
41+
42+
## Run locally
43+
1. [Clone the repo](#1-clone-the-repo)
44+
2. [Run the application](#2-run-the-application)
45+
46+
### 1. Clone the repo
47+
48+
Clone the `react-redux-api-example` locally. In a terminal, run:
49+
50+
```
51+
$ git clone https://github.com/rizcheldayao/react-redux-api-example.git
52+
```
53+
54+
### 2. Run the application
55+
1. Install [Node.js](https://nodejs.org/en/)
56+
2. Run the following commands in a terminal:
57+
58+
`$ npm install`
59+
60+
`$ npm run build-css`
61+
62+
`$ npm run start`
63+
64+
## Run the application using Docker
65+
1. [Build the image](#1-build-the-image)
66+
2. [Run the image](#2-run-the-image)
67+
68+
### 1. Build the image
69+
70+
In a terminal, run:
71+
72+
`$ docker build -t $docker_username/deploy-react-kubernetes .`
3473

3574
Your image should be listed by running:
3675

37-
`docker images`
76+
`$ docker images`
3877

39-
Run the image:
78+
### 1. Run the image
4079

41-
`docker run -p 3000:3000 -d <your username>/react-redux-api-example`
80+
In a terminal, run:
4281

43-
You can now access the application at http://localhost:3000 🎉🎉🎉
82+
`$ docker run -p 3000:3000 -d $docker_username/deploy-react-kubernetes`
4483

45-
Check the output of the app:
84+
You can now access the application at http://localhost:3000
4685

47-
Get container id:
86+
### 2. Run the application on Kubernetes
4887

49-
`docker ps`
88+
1. [Build Docker image.](#1-build-docker-image)
89+
2. [Deploy the application](#2-deploy-the-application)
5090

51-
`docker logs <container id>`
91+
## Prerequisites
92+
* Create a namespace `bx cr namespace-add <your_namespace>`
5293

53-
## Running the project in Kubernetes
94+
### 1. Build Docker image
5495

55-
https://medium.com/@rizchel.a.dayao/my-journey-to-deploying-my-first-react-application-with-kubernetes-95e6d25f434d
96+
In a terminal, run:
97+
```
98+
$ bx cr build -t registry.<ibm_cloud_region>.bluemix.net/<your_namespace>/deploy-react-kubernetes .
99+
```
56100

57-
## Results
101+
### 2. Deploy the application.
102+
103+
```
104+
$ kubectl run deploy-react-kubernetes-deployment —-image= registry.<ibm_cloud_region>.bluemix.net/<your_namespace>/deploy-react-kubernetes
105+
106+
$ kubectl expose deployment/deploy-react-kubernetes-deployment
107+
—-type=NodePort —-name=deploy-react-kubernetes-service —-port=3000
108+
```
109+
110+
* To access your application. You would need the public IP address of your cluster and NodePort of the service.
111+
112+
```
113+
# For clusters provisioned with IBM Cloud
114+
$ bx cs workers YOUR_CLUSTER_NAME
115+
```
116+
117+
```
118+
# For details on a specific Kubernetes service
119+
$ kubectl describe service deploy-react-kubernetes-service
120+
```
121+
122+
You can now access the application at http://IP_ADDRESS:NODE_PORT
123+
124+
# Sample output
58125

59126
<img width="1415" alt="screen shot 2017-03-13 at 6 14 10 pm" src="https://cloud.githubusercontent.com/assets/18426780/23879083/fa0df756-0818-11e7-8569-469367b84280.png">
127+
128+
# Links
129+
* [Demo on Youtube](https://www.youtube.com/watch?v=Jxi7U7VOMYg)
130+
* [Blog post](https://medium.com/@rizchel.a.dayao/my-journey-to-deploying-my-first-react-application-with-kubernetes-95e6d25f434d)
131+
132+
# Learn more
133+
134+
* **Container Orchestration Code Patterns**: Enjoyed this Code Pattern? Check out our other [Container Orchestration Code Patterns](https://developer.ibm.com/code/technologies/container-orchestration/).
135+
* **Kubernetes on IBM Cloud**: Deliver your apps with the combined the power of [Kubernetes and Docker on IBM Cloud](https://www.ibm.com/cloud-computing/bluemix/containers)
136+
137+
# License
138+
[Apache 2.0](LICENSE)

README1.md

Lines changed: 0 additions & 128 deletions
This file was deleted.

react-app.yaml

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)