Installing Loki
Loki
Getting started
-
If you do not have the Yandex Cloud CLI installed yet, install and initialize it.
By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the
yc config set folder-id <folder_ID>command. You can also set a different folder for any specific command using the--folder-nameor--folder-idparameter. -
Make sure the security groups for the Managed Service for Kubernetes cluster and its node groups are configured correctly. If a rule is missing, add it.
Warning
The configuration of security groups determines performance and availability of the cluster and the services and applications running in it.
-
Get ready to install Loki:
-
Create a service account with the
storage.uploaderandstorage.viewerroles. 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 from Yandex Cloud Marketplace
-
Navigate to the folder dashboard
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: Create a new namespace, e.g.,
loki-space. If you leave the default namespace, Loki may work incorrectly. - Application name: Specify the application name.
- Bucket name: Specify the name of the bucket in Object Storage.
- Static access key: Paste the contents of the
sa-key.jsonfile. - Install Promtail: Leave the option enabled to deliver local logs to the Grafana Loki instance using the Promtail agent
. This agent is used for applications that require regular monitoring.
- Namespace: Create a new namespace, e.g.,
-
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 kubect
and configure it to work with the new cluster. -
To install a Helm chart
with Loki, run the following command, specifying the parameters of the resources you created earlier: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/If you set
namespaceto the default namespace, Loki may work incorrectly. We recommend specifying a value different from all the existing namespaces, e.g.,loki-space.Note
If you are using a Helm version below 3.8.0, add the
export HELM_EXPERIMENTAL_OCI=1 && \string at the beginning of the command to enable Open Container Initiative (OCI) support in the Helm client. -
Make sure all Loki pods switched to
Running: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 find out 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