Skip to content

Instantly share code, notes, and snippets.

@lee-zhg
Forked from jzaccone/Kubernetes-Setup.md
Last active June 11, 2019 19:42
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 lee-zhg/b12c19dafa1fd07ceb56a826a42eb790 to your computer and use it in GitHub Desktop.
Save lee-zhg/b12c19dafa1fd07ceb56a826a42eb790 to your computer and use it in GitHub Desktop.

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

  7. Install Istio https://istio.io/docs/setup/kubernetes/download/

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

If you have done the tasks in this section and are still using the same terminal/command window, you may start the lab by following the lab repo link 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:              John.Zaccone@ibm.com   
    Account:           Eric Andersen's Account (7d4e885b10101b041e651b1ff087a387) <-> 1757519     
    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. Note $USER automatically resolves to the user logged into the terminal environment.

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

    Note: if the above command produced syntax error in your environment, you may manually execute command ibmcloud ks cluster-config --cluster $USER-cluster first. Then, take its output as the next command and execute it in the same window.

  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
    Listing images...
    
    REPOSITORY                                    TAG        DIGEST         NAMESPACE    CREATED        SIZE     SECURITY STATUS   
    us.icr.io/appmod_sst/user001/guestbook        v1         d4777e5bfffd   appmod_sst   2 months ago   7.5 MB   No Issues   
    us.icr.io/appmod_sst/user001/pbw-mariadb-web  1.0.0      1a21d270342c   appmod_sst   2 days ago     282 MB   11 Issues   
    
    
    OK

That's it!

Lab Repo URL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment