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

Update IBM Cloud docs #13

@ghost

Description

Below is a list of steps that I followed to deploy the React app to Kubernetes. There was quite a bit to install to get things working. I had to install Docker, Node.js and the IBM CLIs. The https://github.com/IBM/container-service-getting-started-wt/tree/master/Lab%201 helped me to configure the cluster. The README.md docs on https://github.com/IBM/deploy-react-kubernetes needs to be updated with some of the steps below.

Step 0:

Create an account with IBM Bluemix at https://console.bluemix.net/registration/

Step 1:

You must get an API key from OMDb API in order to get a response from the API. You will insert your API key in /src/actions/index.js on line 42 OMDb API by Brian Fitz is licensed under CC BY-NC 4.0

Create an environment variable for your docker username
$ export docker_username="YOUR_DOCKER_USERNAME"

Step 2:
Clone the repo locally. In a terminal, run:
$ git clone https://github.com/IBM/deploy-react-kubernetes

Step 3:
Run the application

Install Node.js Run the following commands in a terminal: 

$ npm install

$ npm run build-css

$ npm run start

Verify app is running and working correctly.

Step 4:

Get the Docker User Id.

https://cloud.docker.com/

Save your Docker User Id.

Install Docker

https://www.docker.com/community-edition

Step 5:
Run the application using Docker

Build the image Run the image 
  1. Build the image
    In a terminal, run:
    $ docker build -t <your_namespace>/deploy-react-kubernetes .
    Your image should be listed by running:
    $ docker images
  2. Run the image
    In a terminal, run:
    $ docker run -p 3000:3000 -d <your_namespace>/deploy-react-kubernetes

You can now access the application at http://localhost:3000

Step 6:
Run the application on Kubernetes
Go to : https://console.bluemix.net/containers-kubernetes/registry/start

Install, Set Up, and Log In

  1. Install the IBM Cloud CLI.
  2. Install the Docker CLI.
  3. Install the Container Registry plug-in.
    bx plugin install container-registry -r Bluemix
  4. Log in to your IBM Cloud account.
    bx login -a https://api.au-syd.bluemix.net
    If you have a federated ID, use bx login --sso to log in to the IBM Cloud CLI.
  5. Choose a name for your first namespace, and create that namespace. Use this namespace for the rest of the Quick Start.
    bx cr namespace-add

To list namespaces use command: bx cr namespaces

Step 7:
Build the Docker Image

bx cr build -t registry.au-syd.bluemix.net/<your_namespace>/deploy-react-kubernetes .

To view the Docker Image run the command: docker images

Step 8:
Deploy the app to Kubernetes

To create a cluster run command: bx cs cluster-create --name mycluster

This will take 5 minutes so in the meantime run: bx cs workers mycluster

OK
ID Public IP Private IP Machine Type State Status Zone Version
kube-mel01-pa055d203a2cc4451da75e187339112542-w1 168.1.145.167 10.118.181.226 free provisioning Waiting for master to be deployed mel01 1.8.11_1509

Step 9:
Configure Kubernetes cluster
Once the cluster is active run the command: bx cs cluster-config mycluster

You should get a response like:

OK
The configuration for mycluster was downloaded successfully. Export environment variables to start using Kubernetes.

export KUBECONFIG=/Users//.bluemix/plugins/container-service/clusters/mycluster/kube-config-mel01-mycluster.yml

Then run the command to set the env variable: export KUBECONFIG=/Users//.bluemix/plugins/container-service/clusters/mycluster/kube-config-mel01-mycluster.yml

Step 10:
Run the app in Kubernetes

kubectl run deploy-react-kubernetes-deployment --image**=**registry.au-syd.bluemix.net/<your_namespace>/deploy-react-kubernetes

To check how many pods are running on Kubernetes run the command: kubectl get pods
Expose the app to the web by setting the port. Run the command:

kubectl expose deployment/deploy-react-kubernetes-deployment --type="NodePort" --port=3000

Find the public IP address of Kubernetes:

bx cs workers mycluster

kubectl get services

Check the app is deployed, go to IP address:3000.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions