|
| 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` |
0 commit comments