Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Commit 232a61a

Browse files
authored
Merge pull request #45 from kennjason/master
add stage directories
2 parents 2ecaa8a + a1c44f6 commit 232a61a

26 files changed

+1129
-0
lines changed

Stage1/Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM node:6
2+
COPY app.js .
3+
COPY package.json .
4+
RUN npm install
5+
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y upgrade &&\
6+
apt-get clean &&\
7+
rm -Rf /var/cache/*
8+
EXPOSE 8080
9+
CMD node app.js

Stage1/README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Stage 1 - Initial Application Deployment
2+
3+
This stage of the tutorial walks through pushing an image of an application to the IBM Containers Registry and deploying a basic application to a cluster
4+
5+
6+
# Pushing an image to the IBM Containers Registry
7+
8+
If you haven't already, provision a cluster (this can take a few minutes, so let it start first). To get the list of data centers, use `bx cs datacenters` - then create your cluster with `bx cs cluster-create --name=<name-of-cluster> --datacenter=<datacenter>`
9+
10+
Download from https://github.com/IBM/container-service-getting-started-wt
11+
12+
cd into IBM-Containers-Demo
13+
14+
Run `bx cr login` and login with your bluemix credentials. This will allow you
15+
to push to the IBM containers registry
16+
17+
Build the example docker image using `docker build --tag registry.ng.bluemix.net/<namespace>/hello-world .`
18+
19+
Verify the image is built using `docker images`
20+
21+
Now push that image up to the IBM registry: `docker push registry.ng.bluemix.net/<namespace>/hello-world`
22+
23+
If you created your cluster at the beginning of this, make sure it's ready for use. Run `bx cs clusters` and make sure that your cluster is in state "deployed". Then use `bx cs workers <yourclustername>` and make sure that all workers are in state "deployed" with Status "Deploy Automation Successful". Make a note of the public ip of the worker!
24+
25+
You are now ready to use kubernetes.
26+
27+
# Deploying an App to a Cluster
28+
29+
Run `bx cs cluster-config <yourclustername>` and set the variables based on the output of the command.
30+
31+
Start by running your image as a deployment: `kubectl run hello-world --image=registry.ng.bluemix.net/<namespace>/hello-world`
32+
33+
This will take a bit of time. To check the status of your deployment, you can use `kubectl get pods`
34+
35+
You should see output similar to the following:
36+
37+
```
38+
=> kubectl get pods
39+
NAME READY STATUS RESTARTS AGE
40+
hello-world-562211614-0g2kd 0/1 ContainerCreating 0 1m
41+
```
42+
Once the status reads `Running`, expose that deployment as a service, accessed through the ip of the workers. Our example listens on port 8080. run `kubectl expose deployment/hello-world --type="NodePort" --port=8080`
43+
44+
To find the port used on that node, now examine your new service: `kubectl describe service <name-of-deployment>`, take note of the "NodePort:" line as `<nodeport>`
45+
46+
Run `bx cs workers <name-of-cluster>` and note the public IP as `<public-IP>`
47+
48+
You can now access your container/service via `curl <public-IP>:<nodeport>` (or your favorite web browser). If you see a "Hello world! Your app is up and running in a cluster!" you're done!
49+
50+
When you're all done, you can either use this deployment in the Stage 2 of this demo or you can remove the deployment. To remove the deployment, use `kubectl delete deployment hello-world`, to remove the service use `kubectl delete service hello-world`

Stage1/Stage1/Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM node:6
2+
COPY app.js .
3+
COPY package.json .
4+
RUN npm install
5+
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y upgrade &&\
6+
apt-get clean &&\
7+
rm -Rf /var/cache/*
8+
EXPOSE 8080
9+
CMD node app.js

Stage1/Stage1/README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Stage 1 - Initial Application Deployment
2+
3+
This stage of the tutorial walks through pushing an image of an application to the IBM Containers Registry and deploying a basic application to a cluster
4+
5+
6+
# Pushing an image to the IBM Containers Registry
7+
8+
If you haven't already, provision a cluster (this can take a few minutes, so let it start first). To get the list of data centers, use `bx cs datacenters` - then create your cluster with `bx cs cluster-create --name=<name-of-cluster> --datacenter=<datacenter>`
9+
10+
Download from https://github.com/IBM/container-service-getting-started-wt
11+
12+
cd into IBM-Containers-Demo
13+
14+
Run `bx cr login` and login with your bluemix credentials. This will allow you
15+
to push to the IBM containers registry
16+
17+
Build the example docker image using `docker build --tag registry.ng.bluemix.net/<namespace>/hello-world .`
18+
19+
Verify the image is built using `docker images`
20+
21+
Now push that image up to the IBM registry: `docker push registry.ng.bluemix.net/<namespace>/hello-world`
22+
23+
If you created your cluster at the beginning of this, make sure it's ready for use. Run `bx cs clusters` and make sure that your cluster is in state "deployed". Then use `bx cs workers <yourclustername>` and make sure that all workers are in state "deployed" with Status "Deploy Automation Successful". Make a note of the public ip of the worker!
24+
25+
You are now ready to use kubernetes.
26+
27+
# Deploying an App to a Cluster
28+
29+
Run `bx cs cluster-config <yourclustername>` and set the variables based on the output of the command.
30+
31+
Start by running your image as a deployment: `kubectl run hello-world --image=registry.ng.bluemix.net/<namespace>/hello-world`
32+
33+
This will take a bit of time. To check the status of your deployment, you can use `kubectl get pods`
34+
35+
You should see output similar to the following:
36+
37+
```
38+
=> kubectl get pods
39+
NAME READY STATUS RESTARTS AGE
40+
hello-world-562211614-0g2kd 0/1 ContainerCreating 0 1m
41+
```
42+
Once the status reads `Running`, expose that deployment as a service, accessed through the ip of the workers. Our example listens on port 8080. run `kubectl expose deployment/hello-world --type="NodePort" --port=8080`
43+
44+
To find the port used on that node, now examine your new service: `kubectl describe service <name-of-deployment>`, take note of the "NodePort:" line as `<nodeport>`
45+
46+
Run `bx cs workers <name-of-cluster>` and note the public IP as `<public-IP>`
47+
48+
You can now access your container/service via `curl <public-IP>:<nodeport>` (or your favorite web browser). If you see a "Hello world! Your app is up and running in a cluster!" you're done!
49+
50+
When you're all done, you can either use this deployment in the Stage 2 of this demo or you can remove the deployment. To remove the deployment, use `kubectl delete deployment hello-world`, to remove the service use `kubectl delete service hello-world`

Stage1/Stage1/app.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
var express = require('express')
2+
var app = express()
3+
4+
app.get('/', function(req, res) {
5+
res.send('Hello world! Your app is up and running in a cluster!\n')
6+
})
7+
app.listen(8080, function() {
8+
console.log('Sample app is listening on port 8080.')
9+
})

Stage1/Stage1/package.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "hello-world-demo",
3+
"private": false,
4+
"version": "0.0.1",
5+
"description": "Basic hello world application for Node.js",
6+
"dependencies": {
7+
"express": "3.x"
8+
}
9+
}

Stage1/Stage2/Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM node:6
2+
COPY app.js .
3+
COPY package.json .
4+
RUN npm install
5+
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y upgrade &&\
6+
apt-get clean &&\
7+
rm -Rf /var/cache/*
8+
EXPOSE 8080
9+
CMD node app.js

0 commit comments

Comments
 (0)