Skip to content

Latest commit

 

History

History
270 lines (200 loc) · 9.96 KB

01_setup_Lab.adoc

File metadata and controls

270 lines (200 loc) · 9.96 KB

Lab Setup

Prerequisites
  1. The ssh utility installed on your laptop.

    Note
    If your network connection is intermittent, consider installing the mosh utility (yum install mosh) as an alternative to the ssh utility.
  2. Web browser installed on your laptop.

  3. Broadband internet connectivity.

1. Overview

The project to be developed will contain 2 Spring Boot applications where one is a client consuming the service exposed by a backend application connected to a PostgreSQL database.

The client will be called fruit-client-sb and the backend fruit-backend-sb as depicted here after.

halkyon operator demo

Legend:

  • Blue: Spring Boot microservice (aka component)

  • Yellow: Link used to inject METADATA

  • Green: A capability such as a database

2. Course Lab Environment

Your lab environment is remote and can be accessed via ssh as well as through your local browser.

2.1. Order Lab Environment

This section guides you through the procedure to order a virtual machine (VM) for this course.

2.2. Command Line Utilities

Your lab environment comes pre-installed with the following utilities:

  1. java (version 1.8.0)

  2. javac (version 1.8.0)

  3. maven (version 3.5.4)

  4. git

  5. jq

  6. podman

  7. buildah

  8. oc (version: 3.11.82; This corresponds to the version of OpenShift running in your lab environment).

  9. hal

    This is a new command line utility that assists in scaffolding of microservice applications running in OpenShift, link them or to create a service such as a Database.

    More information about this utility is found throughout the remainder of this lab.

2.2.1. Refresh hal utility for Linux

To ensure that your lab environment uses the latest tag of the hal utility, execute the following command in the terminal of you remote lab environment to fetch the latest released version:

hal_version=$(curl --silent "https://api.github.com/repos/halkyonio/hal/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
  1. Download and install latest tag of hal:

    sudo curl -L https://github.com/halkyonio/hal/releases/download/${hal_version}/hal_${hal_version:1}_Linux_x86_64.tar.gz \
      -o /usr/local/bin/hal_${hal_version:1}_Linux_x86_64.tar.gz && \
      sudo tar -xzf /usr/local/bin/hal_${hal_version:1}_Linux_x86_64.tar.gz \
      -C /usr/local/bin && sudo chmod +x /usr/local/bin/hal
  2. Verify the version:

    hal version
    
    hal 0.1.12 built with ❤️ by the Halkyon team on '2019-10-11T12:42:13Z' (commit: 1a6c948) running on top of 'oc'

3. OpenShift Container Platform

Your lab environment includes Red Hat’s OpenShift Container Platform (OCP).

Access to your OCP resources can be gained via both the oc CLI utility and the OCP web console.

3.1. OpenShift Namespaces

  1. In the terminal of your remote lab environment, authenticate into OpenShift as a non cluster admin user (user1) using the oc utility

    oc login https://master00.example.com -u user1 -p r3dh4t1!
  2. View existing projects:

    $ oc get projects --as=system:admin
    
    ...
    
    kubedb                             Active
    
    ...
    
    operators                          Active
    tekton-pipelines                   Active
    1. kubedb

      This OCP project contains an operator that manages the lifecycle of the databases in OpenShift.

    2. operators

      This OCP project contains the halkyon operator.

    3. tekton-pipelines

      This OCP project contains operators that provide CI/CD infrastructure to build your SpringBoot applications using by example a S2i build task.

3.2. OpenShift Web Console

  1. Set an environment variable called: OCP_REGION :

    echo "export OCP_REGION=`echo $HOSTNAME | cut -d'.' -f1 | cut -d'-' -f2`" >> $HOME/.bashrc
    
    source $HOME/.bashrc

    REMARK: This command should be executed within the ssh vm !

  2. Point your browser to the URL created by executing the following :

    $ echo -en "\nhttps://master00-$OCP_REGION.generic.opentlc.com\n\n"
  3. Authenticate using the following user credentials

    1. Username: user1

    2. Password: r3dh4t1!

3.3. Refresh OpenShift components

From time to time, some components in your OpenShift based lab environment tend not to start-up cleanly. So as to ensure all components work as expected, execute the following in your remote lab environment:

# Switch to root operating system user
sudo -i


mkdir -p $HOME/lab && \
  wget \
  https://raw.githubusercontent.com/halkyonio/rhte_lab_2019/master/scripts/lab_state_refresh.sh \
  -O $HOME/lab/lab_state_refresh.sh \
  && chmod 755 $HOME/lab/lab_state_refresh.sh \
  && $HOME/lab/lab_state_refresh.sh


# Exit back to non-root operating system user
exit

4. Operators

Your lab environment comes pre-installed with various OpenShift operators.

In this section of the lab, you review these operators.

  1. KubeDB

    This operator is responsible for the lifecycle of the PostgreSQL database that will be used in your application. In particular, the operator will create the database and configure its parameters.

    The source code for this operator can be found here.

    You can view the log file of the operator as follows:

    oc logs `oc get pod -lapp=kubedb -n kubedb --as=system:admin -o name` -n kubedb --as=system:admin
    
    ...
    
    I0924 05:56:29.851996       1 run.go:24] Starting kubedb-server...
    I0924 05:56:30.922031       1 lib.go:112] Kubernetes version: &version.Info{Major:"1", Minor:"13+", GitVersion:"v1.13.4+4b86cc5", GitCommit:"4b86cc5", GitTreeState:"clean", BuildDate:"2019-07-24T19:42:25Z", GoVersion:"go1.11.6", Compiler:"gc", Platform:"linux/amd64"}
    I0924 05:56:30.926676       1 controller.go:72] Ensuring CustomResourceDefinition...
    I0924 05:56:35.745740       1 run.go:36] Starting KubeDB controller
    I0924 05:56:35.748846       1 secure_serving.go:116] Serving securely on [::]:8443
  2. Halkyon Operator

    This operator manages the lifecycle of the OpenShift resources from the Component, Link and Capability custom resource definitions.

    The source code for this operator is found here.

    You can view the log file of this operator as follows:

    oc logs `oc get pod -lname=halkyon-operator -n operators --as=system:admin -o name` -n operators --as=system:admin | more
    
    ...
    
    Log stream paused.
    |
    69 lines
    2019-09-23T15:39:50.342Z	INFO	cmd	Go Version: go1.12.5
    2019-09-23T15:39:50.342Z	INFO	cmd	Go OS/Arch: linux/amd64
    2019-09-23T15:39:50.342Z	INFO	cmd	Version of operator-sdk: v0.8.1
    2019-09-23T15:39:50.342Z	INFO	cmd	halkyon-operator version: unset
    2019-09-23T15:39:50.342Z	INFO	cmd	halkyon-operator git commit: 58dbd885
    2019-09-23T15:39:50.342Z	INFO	cmd	watching namespace
    2019-09-23T15:39:50.482Z	INFO	cmd	Registering Components
    2019-09-23T15:39:50.482Z	INFO	cmd	Registering 3rd party resources
    
    ...
    
    2019-09-23T15:39:50.687Z	INFO	kubebuilder.controller	Starting workers	{"controller": "component-controller", "worker count": 1}
    2019-09-23T15:39:50.687Z	INFO	kubebuilder.controller	Starting workers	{"controller": "capability-controller", "worker count": 1}
  3. Tekton Operator

    Tekton Pipeline is the building technology deployed on the cluster and responsible to perform s2i builds.

    The source code for this operator is found here here.

    You can view the log file of this operator as follows:

    oc logs `oc get pod -lapp=tekton-pipelines-controller -n tekton-pipelines --as=system:admin -o name` -n tekton-pipelines --as=system:admin | more
    
    ...
    
    {"level":"info","caller":"logging/config.go:100","msg":"Successfully created the logger.","knative.dev/jsonconfig":"{\n  \"level\": \"info\",\n  \"development\": false,\n  \"sampling\": {\n    \"initial\": 100,\n    \"thereafter\": 100\n  },\n  \"outputPaths\": [\"stdout\"],\n  \"errorOutputPaths\": [\"stderr\"],\n  \"encoding\": \"json\",\n  \"encoderConfig\": {\n    \"timeKey\": \"\",\n    \"levelKey\": \"level\",\n    \"nameKey\": \"logger\",\n    \"callerKey\": \"caller\",\n    \"messageKey\": \"msg\",\n    \"stacktraceKey\": \"stacktrace\",\n    \"lineEnding\": \"\",\n    \"levelEncoder\": \"\",\n    \"timeEncoder\": \"\",\n    \"durationEncoder\": \"\",\n    \"callerEncoder\": \"\"\n  }\n}\n"}
    {"level":"info","caller":"logging/config.go:101","msg":"Logging level set to info"}
    {"level":"warn","caller":"logging/config.go:69","msg":"Fetch GitHub commit ID from kodata failed: open /var/run/ko/HEAD: permission denied"}
    {"level":"info","logger":"controller","caller":"controller/main.go:72","msg":"Starting the Pipeline Controller"}
    W0924 07:42:06.233565       1 client_config.go:549] Neither --kubeconfig nor --master was specified.  Using the inClusterConfig.  This might not work.
    {"level":"info","logger":"controller.taskrun-controller","caller":"taskrun/taskrun.go:100","msg":"Setting up event handlers","knative.dev/controller":"taskrun-controller"}
    {"level":"info","logger":"controller.taskrun-controller","caller":"taskrun/taskrun.go:113","msg":"Setting up Entrypoint cache","knative.dev/controller":"taskrun-controller"}
    {"level":"info","logger":"controller.pipeline-controller","caller":"pipelinerun/pipelinerun.go:126","msg":"Setting up event handlers","knative.dev/controller":"pipeline-controller"}
    {"level":"info","logger":"controller.pipeline-controller","caller":"pipelinerun/pipelinerun.go:138","msg":"Setting up ConfigMap receivers","knative.dev/controller":"pipeline-controller"}

Congratulations! Your lab environment is now ready to use. Please proceed to the next lab.