In this lab you will explore the logging aggregation capabilities of OpenShift.
An extremely important function of OpenShift is collecting and aggregating logs from the environments and the application pods it is running. OpenShift ships with an elastic log aggregation solution: EFK. (ElasticSearch, Fluentd and Kibana)
The cluster logging components are based upon Elasticsearch, Fluentd, and Kibana (EFK). The collector, Fluentd, is deployed to each node in the OpenShift cluster. It collects all node and container logs and writes them to Elasticsearch (ES). Kibana is the centralized, web UI where users and administrators can create rich visualizations and dashboards with the aggregated data. Administrators can see and search through all logs. Application owners and developers can allow access to logs that belong to their projects. The EFK stack runs on top of OpenShift.
OpenShift Container Platform cluster logging is designed to be used with the default configuration, which is tuned for small to medium sized OpenShift Container Platform clusters. The installation instructions that follow include a sample Cluster Logging Custom Resource (CR), which you can use to create a cluster logging instance and configure your cluster logging deployment.
If you want to use the default cluster logging install, you can use the sample CR directly.
If you want to customize your deployment, make changes to the sample CR as needed. The following describes the configurations you can make when installing your cluster logging instance or modify after installtion. See the Configuring sections for more information on working with each component, including modifications you can make outside of the Cluster Logging Custom Resource.
In order to install and configure the EFK
stack into the cluster,
additional operators need to be installed. These can be installed from the
Operator Hub
from within the cluster via the GUI.
When using operators in OpenShift, it is important to understand the basics
of some of the underlying principles that make up the Operators.
CustomResourceDefinion (CRD)
and CustomResource (CR)
are two Kubernetes
objects that we will briefly describe.CRDs
are generic pre-defined
structures of data. The operator understands how to apply the data that is
defined by the CRD
. In terms of programming, CRDs
can be thought as being
similar to a class. CustomResource (CR)
is an actual implementations of the
CRD
, where the structured data has actual values. These values are what the
operator will use when configuring it's service. Again, in programming terms,
CRs
would be similar to an instantiated object of the class.
The general pattern for using Operators is first, install the Operator, which
will create the necessary CRDs
. After the CRDs
have been created, we can
create the CR
which will tell the operator how to act, what to install,
and/or what to configure. For installing openshift-logging
, we will follow
this pattern.
To begin, click on the Console
tab or use the following link to log-in
to the OpenShift Cluster's GUI.
{{ MASTER_URL }}
Then follow the following steps:
-
Install the Elasticsearch Operator:
1.1. In the OpenShift console, click
Operators
→OperatorHub
.1.2. Type
Elasticsearch Operator
in the search field and click theOpenShift Elasticsearch Operator
card from the list of available Operators, and then clickInstall
.1.3. On the
Create Operator Subscription
page, select Update Channelstable
, leave all other defaults and then clickInstall
.
This makes the Operator available to all users and projects that use this OpenShift Container Platform cluster.
The Cluster Logging
operator needs to be installed in the
openshift-logging
namespace. Please ensure that the openshift-logging
namespace was created from the previous steps
-
Install the Cluster Logging Operator:
2.1. In the OpenShift console, click
Operators
→OperatorHub
.2.2. Type
OpenShift Logging
in the search box and click theRed Hat OpenShift Logging
card from the list of available Operators, and clickInstall
.2.3. On the
Install Operator
page, select Update Channelstable
. Under ensureInstallation Mode
ensure thatA specific namespace on the cluster
is selected, and chooseOperator recommended Namespace: openshift-logging
underInstalled Namespace
. Leave all other defaults and then clickInstall
. -
Verify the operator installations:
3.1. Switch to the
Operators
→Installed Operators
page.3.2. Make sure the
openshift-logging
project is selected.3.3. In the Status column you should see green checks with either
InstallSucceeded
orCopied
and the text Up to date.
During installation an operator might display a Failed
status. If the
operator then installs with an InstallSucceeded
message, you can safely
ignore the Failed
message. Also, if you're using the Console
tab, you may
or maynot see the Status
column. When in doubt, visit the console via the
link.
Now that we have the operators installed, along with the CRDs
, we can now
kick off the logging install by creating a Logging CR
. This will define how
we want to install and configure logging.
-
In the OpenShift Console, switch to the the
Administration
→Custom Resource Definitions
page. -
On the
Custom Resource Definitions
page, search forLogging
in the search field and clickClusterLogging
. -
On the
Custom Resource Definition Overview
page, selectInstances
from theActions
menu. -
On the
Cluster Loggings
page, clickCreate Cluster Logging
. -
In the
YAML
editor, replace the code with the following:
oc apply -f 01-logging.yaml
oc get pods -n openshift-logging
oc get daemonset -n openshift-logging
oc get pvc -n openshift-logging