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

Commit 36a01e8

Browse files
author
Rizchel Dayao
committed
Add markdown files and yaml file
1 parent 3f935cd commit 36a01e8

File tree

4 files changed

+149
-25
lines changed

4 files changed

+149
-25
lines changed

CONTRIBUTING.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Contributing
2+
3+
This is an open source project, and we appreciate your help!
4+
5+
We use the GitHub issue tracker to discuss new features and non-trivial bugs.
6+
7+
To contribute code, documentation, or tests, please submit a pull request to
8+
the GitHub repository. Generally, we expect two maintainers to review your pull
9+
request before it is approved for merging. For more details, see the
10+
[MAINTAINERS](MAINTAINERS.md) page.
11+
12+
<br />

README1.md

Lines changed: 109 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,57 @@ In this Code Pattern, we will deploy a React application using Kubernetes.
44

55
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.
66

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. The OMDb API is used to get movie information based on user input. It handles all of the state management within the application. Docker is an open source tool that is used to package the application into a container. Kubernetes handles the management and deployment of the containerized application.
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. The OMDb API is called to get movie information based on user input. It handles all of the state management within the application. 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.
88

99
When the reader has completed this Code Pattern, they will understand how to:
1010
* Containerize a React application using Docker
1111
* Deploy and manage an application using Kubernetes
1212

1313
## Flow
1414

15+
![Flow](docs/source/images/architecture.png)
16+
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.
20+
1521
## Included components
1622
* IBM Cloud Container Service: IBM Bluemix Container Service manages highly available apps inside Docker containers and Kubernetes clusters on the IBM Cloud.
1723
* Kubernetes Cluster: Create and manage your own cloud infrastructure and use Kubernetes as your container orchestration engine.
1824

1925
## Featured technologies
2026
* Node.js: An open-source JavaScript run-time environment for executing server-side JavaScript code.
2127
* Cloud: Accessing computer and information technology resources through the Internet.
22-
* Containers: Virtual software objects that include all the elements that an app needs to run.
2328
* Container Orchestration: Automating the deployment, scaling and management of containerized applications.
2429

2530
# Watch the video
2631

2732
# Steps
2833
Use the ``Deploy to IBM Cloud`` button **OR** run locally.
2934

35+
## Prerequisites
36+
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
37+
38+
2. Create an environment variable for your docker username
39+
```
40+
$ export docker_username="YOUR_DOCKER_USERNAME"
41+
```
42+
43+
## Deploy to IBM Cloud
44+
[![Deploy to IBM Cloud](https://metrics-tracker.mybluemix.net/stats/527357940ca5e1027fbf945add3b15c4/button.svg)](https://bluemix.net/deploy?repository=https://github.com/IBM/watson-banking-chatbot.git)
45+
46+
1. Press the above ``Deploy to IBM Cloud`` button and then click on ``Deploy``.
47+
48+
<!--optional step-->
49+
2. In Toolchains, click on Delivery Pipeline to watch while the app is deployed. Once deployed, the app can be viewed by clicking 'View app'.
50+
![](doc/source/images/toolchain-pipeline.png)
51+
52+
3053
## Run locally
3154
> NOTE: These steps are only needed when running locally instead of using the ``Deploy to IBM Cloud`` button.
3255
3356
1. [Clone the repo](#1-clone-the-repo)
34-
2. [Retrieve an api key for OMDb API](#2-retrieve-an-api-key-for-omdb-api)
35-
3. [Containerize the application using Docker](#3-containerize-the-application-using-docker)
36-
4. [Deploy the application on Kubernetes](#3-deploy-the-application-on-kubernetes)
57+
2. [Run the application](#2-run-the-application)
3758

3859
### 1. Clone the repo
3960

@@ -43,39 +64,102 @@ Clone the `react-redux-api-example` locally. In a terminal, run:
4364
$ git clone https://github.com/rizcheldayao/react-redux-api-example.git
4465
```
4566

46-
### 2. Retrieve an auth key for OMDb API
67+
### 2. Run the application
4768

48-
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/index.js on line 42
69+
1. Install [Node.js](https://nodejs.org/en/)
70+
2. Run the following commands in a terminal:
4971

50-
### 3. Containerize the application using Docker
72+
`$ npm install`
5173

52-
In a terminal, run the following commands:
74+
`$ npm run build-css`
5375

54-
```
55-
$ docker build -t <your_docker_username>/react-redux-api-example .
56-
```
76+
`$ npm run start`
5777

58-
```
59-
$ docker run -p 3000:3000 -d <your_docker_username>/react-redux-api-example
60-
```
78+
## Run the application using Docker
79+
1. [Build the image](#1-build-the-image)
80+
2. [Run the image](#2-run-the-image)
6181

62-
### 4. Deploy the application on Kubernetes
82+
### 1. Build the image
6383

64-
In a terminal, run the following commands:
84+
In a terminal, run:
6585

66-
```
67-
$ bx cr namespace-add <your_namespace>
68-
```
86+
`$ docker build -t $docker_username/deploy-react-kubernetes .`
6987

70-
```
71-
$ bx cr build -t registry.<region>.bluemix.net/<your_namespace>/react-redux-api-example:v1 .
72-
```
88+
Your image should be listed by running:
89+
90+
`$ docker images`
91+
92+
### 1. Run the image
93+
94+
In a terminal, run:
7395

96+
`docker run -p 3000:3000 -d $docker_username/deploy-react-kubernetes`
97+
98+
You can now access the application at http://localhost:3000
99+
100+
### 2. Run the application on Kubernetes
101+
102+
1. [Modify the react-app.yaml yaml file to use your image.](#1-modify-the-yaml-file-to-use-your-image)
103+
2. [Deploy the application](#2-deploy-the-application)
104+
105+
### 1. Modify the yaml file to use your image.
106+
107+
Make the following changes to react-app.yaml
74108
```
75-
$ docker tag react-redux-api-example registry.<region>.bluemix.net/<your_namespace>/react-redux-api-example:v2
109+
...
110+
containers:
111+
- name: react-app
112+
image: <docker_username>/react-app
76113
```
77114

115+
### 2. Deploy the application.
116+
117+
``` $ kubectl apply -f react-app.yaml```
118+
119+
* To access your application. You would need the public IP address of your cluster. If you don't have a load balancer, you can use the Node Port.
120+
78121
```
79-
$ docker push registry.<region>.bluemix.net/<your_namespace>/react-redux-api-example:v2
122+
# For clusters provisioned with Bluemix
123+
$ bx cs workers YOUR_CLUSTER_NAME
80124
```
81125

126+
You can now access the application at http://localhost:3000
127+
128+
# Sample output
129+
130+
<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">
131+
132+
133+
# Privacy Notice
134+
If using the `Deploy to IBM Cloud` button some metrics are tracked, the following
135+
information is sent to a [Deployment Tracker](https://github.com/IBM/cf-deployment-tracker-service) service
136+
on each deployment:
137+
138+
* Node.js package version
139+
* Node.js repository URL
140+
* Application Name (`application_name`)
141+
* Application GUID (`application_id`)
142+
* Application instance index number (`instance_index`)
143+
* Space ID (`space_id`)
144+
* Application Version (`application_version`)
145+
* Application URIs (`application_uris`)
146+
* Labels of bound services
147+
* Number of instances for each bound service and associated plan information
148+
149+
This data is collected from the `package.json` file in the sample application and the `VCAP_APPLICATION` and `VCAP_SERVICES` environment variables in IBM Cloud and other Cloud Foundry platforms. This data is used by IBM to track metrics around deployments of sample applications to IBM Cloud to measure the usefulness of our examples, so that we can continuously improve the content we offer to you. Only deployments of sample applications that include code to ping the Deployment Tracker service will be tracked.
150+
151+
## Disabling Deployment Tracking
152+
153+
To disable tracking, simply remove ``require("cf-deployment-tracker-client").track();`` from the ``app.js`` file in the top level directory.
154+
155+
# Links
156+
* [Demo on Youtube](https://www.youtube.com/watch?v=Jxi7U7VOMYg)
157+
* [Blog post](https://medium.com/@rizchel.a.dayao/my-journey-to-deploying-my-first-react-application-with-kubernetes-95e6d25f434d)
158+
159+
# Learn more
160+
161+
* **Container Orchestration Code Patterns**: Enjoyed this Code Pattern? Check out our other [Container Orchestration Code Patterns](https://developer.ibm.com/code/technologies/container-orchestration/).
162+
* **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)
163+
164+
# License
165+
[Apache 2.0](LICENSE)
55.5 KB
Loading

react-app.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: react-app
5+
labels:
6+
app: app
7+
spec:
8+
type: NodePort
9+
ports:
10+
- port: 3000
11+
name: http
12+
nodePort: 30080
13+
selector:
14+
app: app
15+
---
16+
spec:
17+
replicas: 1
18+
template:
19+
metadata:
20+
labels:
21+
app: app
22+
spec:
23+
containers:
24+
- name: react-app
25+
image: <docker_username>/rotisserie-app
26+
imagePullPolicy: Always
27+
ports:
28+
- containerPort: 3000

0 commit comments

Comments
 (0)