github.com/yankunsam/loki/v2@v2.6.3-0.20220817130409-389df5235c27/tools/dev/k3d/Makefile (about)

     1  .PHONY: loki-distributed down add-repos update-repos prepare build-latest-image
     2  
     3  IMAGE_TAG := $(shell ../../../tools/image-tag)
     4  REGISTRY_PORT ?= 45629
     5  CLUSTER_NAME := "loki-distributed"
     6  
     7  loki-distributed: prepare
     8  	$(CURDIR)/scripts/create_cluster.sh $(CLUSTER_NAME)
     9  
    10  down:
    11  	k3d cluster delete loki-distributed
    12  
    13  add-repos:
    14  	helm repo add --force-update prometheus-community https://prometheus-community.github.io/helm-charts
    15  	helm repo add --force-update grafana https://grafana.github.io/helm-charts
    16  	helm repo add --force-update minio https://helm.min.io
    17  
    18  update-repos: add-repos
    19  	helm repo update
    20  	tk tool charts vendor
    21  	jb update
    22  
    23  create-registry:
    24  	@if ! k3d registry list | grep -q -m 1 grafana; then \
    25  		echo "Creating registry"; \
    26  		k3d registry create grafana --port $(REGISTRY_PORT); \
    27  	else \
    28  		echo "Registry already exists"; \
    29  	fi
    30  
    31  create-cluster:
    32  	@if ! k3d cluster list | grep -q -m 1 $(CLUSTER_NAME); then \
    33  		echo "Creating cluster"; \
    34  		k3d cluster create $(CLUSTER_NAME) \
    35  			--servers 1 \
    36  			--agents 3 \
    37  			--registry-use "k3d-grafana:$(REGISTRY_PORT)" \
    38  			--wait; \
    39  	else \
    40  		echo "Cluster already exists"; \
    41  	fi
    42  
    43  prepare: create-registry create-cluster update-repos build-latest-image
    44  
    45  build-latest-image:
    46  	make -C $(CURDIR)/../../.. loki-image
    47  	docker tag grafana/loki:$(IMAGE_TAG) k3d-grafana:$(REGISTRY_PORT)/loki:latest
    48  	docker push k3d-grafana:$(REGISTRY_PORT)/loki:latest