Skip to content

Instantly share code, notes, and snippets.

@timroster
Forked from lee-zhg/aa_microservice_lab.md
Created June 16, 2019 22:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timroster/5dcf479d20194ea3a618de362e4c3a40 to your computer and use it in GitHub Desktop.
Save timroster/5dcf479d20194ea3a618de362e4c3a40 to your computer and use it in GitHub Desktop.

Deploying Microservice Hands-on Lab

Lab Pre-requisites

For the hands-on labs of this workshop, you will need to either have tools installed on your workstation or use the IBM-provided web terminal. The web terminal has all tools pre-installed. If you are on a Windows 7 platform, or have not yet installed the tools listed below, you should use the web terminal.

Obtaining and installing the lab tools on non-Windows 7 platform

You have done these installation steps, you may go to the next section. You only do these tasks once.

If you have a Microsoft Windows 7 platform, do not perform these steps. IBM can set up a vm-based environment for your use in the labs.

To install Container/Kubernetes related tools on your local machine,

  1. Docker Toolbox (select your platform from the left-side menu for instructions for Linux, MacOS, Microsoft Windows): https://docs.docker.com/install/

  2. Git scm ( if installing on Windows, the git bash shell can be handy too ) https://git-scm.com/downloads

  3. IBM Cloud stand-alone CLI: https://cloud.ibm.com/docs/cli/reference/ibmcloud?topic=cloud-cli-install-ibmcloud-cli

  4. Installing plugins for the CLI. After installing the IBM Cloud CLI, run these two commands to install the kubernetes and container registry plugins:

    ibmcloud plugin install kubernetes-service -r Bluemix    
    
    ibmcloud plugin install container-registry -r Bluemix
    

    For both of these binaries, copy the code (after unpacking if it is a tarball) to your system path.

  5. Install kubectl (our clusters will be set with 1.13.6 - but latest of 1.14 will be ok) https://kubernetes.io/docs/tasks/tools/install-kubectl/

  6. Install helm https://github.com/helm/helm/releases/tag/v2.14.0

Preparing your lab environment (terminal, command window, powershell and etc)

If you have done the tasks in this section and are still using the same terminal/command window, you may navigate to Lab Environment Setup at the end of this document.

Run these steps inside the console-in-a-browser environment provided by your instructor, or in a terminal/command window on your local machine.

  1. Login to the IBM Cloud. When asked to select an account, select "American Airlines' Account". Select 'us-south' as the region.

    ibmcloud login --sso
    
    API endpoint: https://cloud.ibm.com
    Region: us-south
    
    Get One Time Code from https://identity-3.us-south.iam.cloud.ibm.com/identity/passcode to proceed.
    Open the URL in the default browser? [Y/n]> 
    One Time Code > 
    Authenticating...
    OK
    
    Select an account:
    1. IBM (47b84451ab70b94737518f7640a9ee42) <-> 1323471
    2. American Airlines (67eaa4b4b0b80862fab45beb6b22f002) <-> 1429869
    Enter a number> 2
    Targeted account American Airlines (67eaa4b4b0b80862fab45beb6b22f002) <-> 1429869
    API endpoint: https://cloud.ibm.com
    
    API endpoint:      https://cloud.ibm.com   
    Region:            us-south   
    User:              timro@us.ibm.com   
    Account:           American Airlines (67eaa4b4b0b80862fab45beb6b22f002) <-> 1429869       
    Resource group:    No resource group targeted, use 'ibmcloud target -g RESOURCE_GROUP'   
    CF API endpoint:      
    Org:                  
    Space:                
    
    Tip: If you are managing Cloud Foundry applications and services
    - Use 'ibmcloud target --cf' to target Cloud Foundry org/space interactively, or use 'ibmcloud target --cf-api ENDPOINT -o ORG -s SPACE' to target the org/space.
    - Use 'ibmcloud cf' if you want to run the Cloud Foundry CLI with current IBM Cloud CLI context.
  2. Target the AppMod-AA-RG namespace:

    ibmcloud target -g AppMod-AA-RG
  3. List the clusters and locate the cluster corresponding to the userId you used to login to the console-in-a-browser environment. For example, if you are user028, your cluster will be user028-cluster.

    ibmcloud ks clusters
    Clusters at version 1.11 and later run containerd instead of Docker as the Kubernetes container runtime. For more information and update actions, see <https://ibm.biz/Bd22hF>
    
    OK
    Name              ID                                 State    Created      Workers   Location          Version       Resource Group Name   
    user001-cluster   707f162b19cc4c3bbb28bfbfe85ee873   normal   2 days ago   2         Washington D.C.   1.11.8_1547   IKS-RG1   
    user026-cluster   dcfb22a45c8e410e8d6f7a8269c2d0c3   normal   1 day ago    2         Washington D.C.   1.11.8_1547   IKS-RG1   
    user028-cluster   1b3398b985d84e9b8e9544a91d61428a   normal   1 day ago    2         Washington D.C.   1.11.8_1547   IKS-RG1   
    user029-cluster   6d267a184154407d873f0b02159feb84   normal   1 day ago    2         Washington D.C.   1.11.8_1547   IKS-RG1   
  4. Configure your Kubernetes client using this command. This will also configure your Kubernetes client for future login sessions by adding the command into your .bash_profile. Edit the command before running replacing <your user> with the Username from the instructor. For example, if you have user005, the cluster will be user005-cluster.

    eval $(ibmcloud ks cluster-config --cluster $USER-cluster --export | tee -a ~/.bash_profile) 

    If the command has a syntax error in your terminal (e.g. windows cmd shell), you may instead run the command ibmcloud ks cluster-config --cluster <your user>-cluster. Then, copy the output and execute it in the same terminal.

  5. You should be able to use kubectl to list kubernetes resources. Try getting the list of pods (there should be none yet)

    kubectl get pods
    No resources found.
  6. Verify that you have the appmod_aa namespace.

    ibmcloud cr namespaces
    Listing namespaces...
    
    Namespace   
    appmod_aa
    
    OK
  7. Login to the registry service

    ibmcloud cr login
    Logging in to 'registry.ng.bluemix.net'...
    Logged in to 'registry.ng.bluemix.net'.
    
    IBM Cloud Container Registry is adopting new icr.io domain names to align with the rebranding of IBM Cloud for a better user experience. The existing bluemix.net domain names are deprecated, but you can continue to use them for the time being, as an unsupported date will be announced later. For more information about registry domain names, see https://cloud.ibm.com/docs/services/Registry?topic=registry-registry_overview#registry_regions_local
    
    Logging in to 'us.icr.io'...
    Logged in to 'us.icr.io'.
    
    IBM Cloud Container Registry is adopting new icr.io domain names to align with the rebranding of IBM Cloud for a better user experience. The existing bluemix.net domain names are deprecated, but you can continue to use them for the time being, as an unsupported date will be announced later. For more information about registry domain names, see https://cloud.ibm.com/docs/services/Registry?topic=registry-registry_overview#registry_regions_local
    
    OK
  8. Verify you can list the images in the registry. You should see at least guestbook and mariadb, maybe a couple others.

    ibmcloud cr images --restrict appmod_aa
    Listing images...
    
    REPOSITORY                                    TAG        DIGEST         NAMESPACE    CREATED        SIZE     SECURITY STATUS   
    us.icr.io/appmod_aa/user001/guestbook        v1         d4777e5bfffd   appmod_aa   6 months ago   7.5 MB   No Issues   
    
    OK
  9. Create a workshop folder. For the labs in the workshop you will download several git repositories for the lab exercises. Create a folder (with a name like workshop) and then change into this folder in your terminal. If you are using a web terminal, the home directory is empty and you may skip this step.

Lab Environment Setup

  1. Environmenmt variables

    If you are using a posix compliant shell that supports environment variables, set these for use in later steps in the lab. Note [your username] is the id provide by the instructor.

    export USERNAME=[your username]
    export SETUPURL="https://ibm.biz/app-mod-setup"
    

That's it! Now, you are ready to start the lab.

Lab Repo

https://github.com/IBMAppModernization/app-modernization-microservices-lab-iks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment