Skip to content

Latest commit

 

History

History
85 lines (75 loc) · 5.32 KB

File metadata and controls

85 lines (75 loc) · 5.32 KB

Containerising the Python application

Setting up a private registry namespace

  1. Log in to IBM Cloud.
  2. In the top left corner, click the three horizontal lines to open the IBM Cloud menu.
  3. Select Kubernetes from the menu.
  4. In the Registry tab, click the Namespaces card.
  5. Hit the Create namespace button in the right side.
  6. In the Create namespace screen, use your username as name.
  7. Click the Create button.

Creating a new Kubernetes-based toolchain

  1. Log in to IBM Cloud.
  2. Click username-python-microservice in the Apps panel on the left.
  3. Click Remove toolchain in the Deployment details card to delete the old Cloud Foundry-based toolchain.
  4. Then click the Configure continuous delivery button to re-enable the Continuous Delivery feature.
  5. In the Choose a deployment environment panel, pick Deploy to Kubernetes and hit Next.
  6. In the Configure toolchain panel, name the toolchain as username-python-microservice-k8s (where k8s refers to "Kubernetes") and click Create.
  7. In the App details tab, click View toolchain.
  8. Delete Git and Eclipse Orion Web IDE by clicking the three vertical dots in the top right corner of their cards.
  9. On the top right, click Add a Tool and choose GitHub from the catalog.
  10. If requested, authorise access from IBM Cloud to your GitHub account by clicking the Authorize button.
  11. Under Repository type, choose Existing from the menu.
  12. Select the username-python-microservice repository from the Repository URL menu.
  13. Make sure the Enable GitHub Issues and Track deployment of code changes boxes are checked.
  14. Click Create Integration.

Deploying a container with Continuous Delivery Pipeline

  1. Log in to IBM Cloud.
  2. Click username-python-microservice in the Apps panel on the left.
  3. In the App details tab, click View toolchain.
  4. In the toolchain Overview tab, click the Delivery Pipeline card.
  5. In the next screen, click the gear icon in the Build Stage card and then Configure Stage.
  6. In the Input tab, choose the option in Git repository that leads to Github as Git URL.
  7. Save your changes and run the Build Stage by clicking the ▶️ icon.

Accessing the containerised application

  1. Log in to IBM Cloud.
  2. Click username-python-microservice in the Apps panel on the left.
  3. In the App details tab, click View toolchain.
  4. In the toolchain Overview tab, click the Delivery Pipeline card.
  5. Track the progress of your latest commit from the Build Stage to the Deploy Stage.
  6. Click the View logs and history link in the Deploy Stage card.
  7. After a successful deploy, at the very bottom of the page, you will find a link like http://IP_ADRESS:PORT.
  8. Click the link and add /apidocs/ to the URL in order to open the Swagger API documentation.

Deploying a container manually using the command-line

  1. Open Visual Studio Code and summon the Command Palette with
  2. Type terminal and choose View: Toggle Integrated Terminal.
  3. In the terminal window, issue ibmcloud login --sso and follow the on-screen instructions to log in to IBM Cloud.
  4. Execute ibmcloud cs init, then ibmcloud cr login. If the second command fails, make sure Docker is running locally.
  5. Configure your Kubernetes cluster by executing the export command that is output by
    ibmcloud cs cluster-config <username>-cluster
  6. Create a Kubernetes namespace.
    kubectl create namespace <username>
  7. Configure your kubectl environment.
    kubectl config set-context <username>-cluster --cluster=<username>-cluster --namespace=<username>
  8. Export your image registry secrets.
    kubectl get secret bluemix-default-secret-regional -n default -o yaml | sed 's/default/<username>/g' | kubectl create -f -
    kubectl get secret bluemix-default-secret-international -n default -o yaml | sed 's/default/<username>/g' | kubectl create -f -
  9. Take note of the Repository URL and image Tag number in the output of ibmcloud cr images.
  10. Create a Pod based on your image and expose it with a NodePort service.
    kubectl run <username>-python-microservice --image=<repository>:<tag> --restart=Never --image-pull-policy=Always --overrides='{ "apiVersion": "v1", "spec": { "imagePullSecrets": [{"name": "bluemix-<username>-secret-regional"}] } }'
    kubectl expose pod <username>-python-microservice --port=3000 --type=NodePort --name=<username>-python-microservice
  11. Take note of the Public IP from the output of ibmcloud cs workers --cluster <username>-cluster.
  12. Take note of the secondary Port number (after the :) in the output of kubectl get all.
  13. Open a browser window and access <http://PUBLIC_IP:PORT/apidocs/>.