Quick Start on OpenShift

How to quickly setup FSM on Redhat OpenShift

If you already have running OpenShift platform, follow these steps to get started quickly.

Prerequisites

Helm Chart Repository

OpenShift starting with version 4.8 comes with Helm Chart Repository installed, and if you are using an older version of OpenShift, you can add the repo via helm command:

# curl -L https://mirror.openshift.com/pub/openshift-v4/clients/helm/latest/helm-linux-amd64 -o /usr/local/bin/helm

# chmod +x /usr/local/bin/helm

helm repo add openshift-helm-charts https://charts.openshift.io/

To install the repo to be used from the OpenShift console run the following command as and OpenShift admin:

oc apply -f https://charts.openshift.io/openshift-charts-repo.yaml

The Permissions

The account to deploy the charts need to be bound to clusterrole cluster-admin, you could achieve by the command:

oc adm policy add-cluster-role-to-user cluster-admin <your OCP account name>

Installation

Install via Helm Cli

Run the following helm command to install FSM

helm install \
        --devel \
        --namespace fsm-system \
        --create-namespace \
        --set=fsm.controllerLogLevel=warn \
        FSM \
        openshift-helm-charts/flomesh-FSM

Install via OpenShift Console

  1. Create project named fsm-system

  2. Find and search FSM in the Developer Catalog

  3. Before starting install the chart, switch configuration style to YAML view, as the JSON Schema version is much newer than OpenShift console supported version. You could change the configs as well if needed.

  4. Click Install to start installation and wait the pods to be ready.

Deploy Applications

In this section we will deploy 5 different Pods, and we will apply policies to control the traffic between them.

  • bookbuyer is an HTTP client making requests to bookstore. This traffic is permitted.
  • bookthief is an HTTP client and much like bookbuyer also makes HTTP requests to bookstore. This traffic should be blocked.
  • bookstore is a server, which responds to HTTP requests. It is also a client making requests to the bookwarehouse service. This traffic is permitted.
  • bookwarehouse is a server and should respond only to bookstore. Both bookbuyer and bookthief should be blocked.
  • mysql is a MySQL database only reachable by bookwarehouse.

Use below script to install:

kubectl create namespace bookstore
kubectl create namespace bookbuyer
kubectl create namespace bookthief
kubectl create namespace bookwarehouse
fsm namespace add bookstore bookbuyer bookthief bookwarehouse
kubectl apply -f https://raw.githubusercontent.com/flomesh-io/fsm-docs/main/manifests/apps/bookbuyer.yaml
kubectl apply -f https://raw.githubusercontent.com/flomesh-io/fsm-docs/main/manifests/apps/bookthief.yaml
kubectl apply -f https://raw.githubusercontent.com/flomesh-io/fsm-docs/main/manifests/apps/bookstore.yaml
kubectl apply -f https://raw.githubusercontent.com/flomesh-io/fsm-docs/main/manifests/apps/bookwarehouse.yaml
kubectl apply -f https://raw.githubusercontent.com/flomesh-io/fsm-docs/main/manifests/apps/mysql.yaml

Expose the GUI ports of each service, so that with a browser we can access these ports of demo application.

git clone https://github.com/flomesh-io/fsm.git -b main
cd FSM
cp .env.example .env
./scripts/port-forward-all.sh #可以忽略错误信息

In a browser, open the following URL.

_Note: If you need to access from the host, you need to replace localhost with the IP address of the virtual machine; or run the port-forward-all.sh script on the host. _

Access Control

By installing FSM with the above command, all services are without access control (permissive traffic policy mode), or all access is allowed. The situation when there is no access control can be seen by looking at the growth in the number of books counts per service in the browser.

The counts in the bookbuyer, bookthief UI correspond to the number of books purchased and stolen, respectively, while in bookstore-v1 these should be increasing by.

The count for book sales in the bookstore UI should also be increasing.

The following demonstrates denying access to the bookstore service by disabling the permissive traffic policy mode.

kubectl patch meshconfig fsm-mesh-config -n fsm-system -p '{"spec":{"traffic":{"enablePermissiveTrafficPolicyMode":false}}}'  --type=merge

You will see that the count is no longer increasing.

Execute below command to allow bookbuyer privileges to access bookstore:

kubectl apply -f https://raw.githubusercontent.com/flomesh-io/fsm-docs/main/manifests/access/traffic-access-v1.yaml

Here we go back to the bookbuyer and bookstore UI and see that the count resumes increasing while the count for the bookthief UI remains stopped.

With access control, we have successfully prevented bookthief from stealing books from bookstore, while normal purchases are unaffected.

Observability

Metrics

Use below command to enable namespace metrics generation and capturing, or else metrics generated by Pods won’t be gathered.

fsm metrics enable --namespace "bookstore,bookbuyer,bookthief,bookwarehouse"

After running port-forwarding script, open url http://localhost:3000 in browser to access Grafan console. Dashboard default username and passwords are admin, admin.

FSM has several built-in dashboards to provide visualization of metrics in the control plane and data plane. For example, the following figure shows the metrics of pod http://localhost:3000 of the bookthief service accessing other services.

image

The following figure shows the metrics of bookthief accessing other services at the granularity of deployment. The difference from the previous figure is that if bookthief has multiple replicas, the aggregate data for all replicas is shown here: !

image

The next metrics for the FSM component, and for the mesh base information are shown here.

image

Tracing

Jaeger’s dashboard can be accessed by typing http://localhost:16686/search in your browser: !

image

The dashboard allows you to look up service-related tracing information: !

image

Show service topology diagram.

image

Logging

The FSM control plane outputs diagnostic logs to the standard output for service mesh management, and the output of logging information can be controlled by adjusting the level of logging. The logs output to the standard output can be aggregated and stored by the log collection tool.

Feedback

Was this page helpful?