Installing Loki
Loki
Getting started
-
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the
--folder-name
or--folder-id
parameter. -
Make sure that the security groups for the Managed Service for Kubernetes cluster and its node groups are configured correctly. If any rule is missing, add it.
Warning
The configuration of security groups determines the performance and availability of the cluster and the services and applications running in it.
-
Prepare for Loki installation:
-
Create a service account with the
storage.uploader
andstorage.viewer
roles. You need it to access Yandex Object Storage. -
Create a static access key for your service account in JSON format:
yc iam access-key create \ --service-account-name=<service_account_name> \ --format=json > sa-key.json
-
Create a bucket with restricted access in Object Storage.
-
Installation using Yandex Cloud Marketplace
-
Go to the folder page
and select Managed Service for Kubernetes. -
Click the name of the Managed Service for Kubernetes cluster you need and select the
Marketplace tab. -
Under Application available for installation, select Loki and click Go to install.
-
Configure the application:
- Namespace: Select or create a namespace for Loki.
- Application name: Specify the app name.
- Bucket name: Specify the name of the bucket in Object Storage.
- Static access key: Paste the contents of the
sa-key.json
file. - Install Promtail: Leave the option enabled to deliver local logs to the Grafana Loki instance using the Promtail agent
. This agent is usually used for applications that require regular monitoring.
-
Click Install.
-
Wait for the application to change its status to
Deployed
.
Installation using a Helm chart
-
Install Helm
v3.8.0 or higher. -
Install kubectl
and configure it to work with the created cluster. -
To install a Helm chart
with Loki, run the following command:helm pull oci://cr.yandex/yc-marketplace/yandex-cloud/grafana/loki/chart/loki \ --version 1.2.0-7 \ --untar && \ helm install \ --namespace <namespace> \ --create-namespace \ --set global.bucketname=<bucket_name> \ --set-file global.serviceaccountawskeyvalue=<path_to_sa-key.json> \ loki ./loki/
Note
If you are using a Helm version below 3.8.0, append the
export HELM_EXPERIMENTAL_OCI=1 && \
string to the command to enable Open Container Initiative (OCI) support in the Helm client. -
Make sure all Loki pods have entered the
Running
state:kubectl get pods -A -l "app.kubernetes.io/instance=loki"
Connecting to Loki
Once deployed, Loki is available within the Managed Service for Kubernetes cluster at the following address:
http://<Loki_gateway_service_name>.<namespace>.svc.cluster.local
To learn the namespace and name of the Loki gateway service, run this command:
kubectl get service -A | grep distributed-gateway
Result:
test-namespace loki-loki-distributed-gateway ClusterIP 10.96.168.88 <none> 80/TCP 15m