Important: This documentation is about an older version. It's relevant only to the release noted, many of the features and functions have been updated or replaced. Please view the current version.
Deploy Pyroscope with Jsonnet and Tanka
Grafana Labs publishes a Jsonnet library that you can use to deploy Pyroscope. The Jsonnet files are located in the Pyroscope repository and are using the helm charts as a source.
Install tools and deploy the first cluster
You can use Tanka and jsonnet-bundler to generate Kubernetes YAML manifests from the jsonnet files.
Install
tanka
andjb
:Follow the steps at https://tanka.dev/install. If you have
go
installed locally you can also use:# make sure to be outside of GOPATH or a go.mod project go install github.com/grafana/tanka/cmd/tk@latest go install github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb@latest
Set up a Jsonnet project, based on the example that follows:
- Initialize Tanka
- Install Pyroscope and Kubernetes Jsonnet libraries
- Set up an environment
# Initialize a Tanka directory mkdir jsonnet-example && cd jsonnet-example tk init --k8s=1.21 # Install Pyroscope jsonnet jb install github.com/grafana/pyroscope/operations/pyroscope@main # Install required tanka-util jb install github.com/grafana/jsonnet-libs/tanka-util@master # Setup your current cluster as the server for the default environment tk env set environments/default --server-from-context=$(kubectl config current-context)
Decide if you want to run Pyroscope in the monolithic or the microservices mode
Option A) For monolithic mode the file
environments/default/main.jsonnet
, should look like;local pyroscope = import 'pyroscope/jsonnet/pyroscope/pyroscope.libsonnet'; local tk = import 'tk'; pyroscope.new(overrides={ namespace: tk.env.spec.namespace, })
Option B) For microservices mode the file
environments/default/main.jsonnet
, should look like;local pyroscope = import 'pyroscope/jsonnet/pyroscope/pyroscope.libsonnet'; local valuesMicroServices = import 'pyroscope/jsonnet/values-micro-services.json'; local tk = import 'tk'; pyroscope.new(overrides={ namespace: tk.env.spec.namespace, values+: valuesMicroServices, })
Generate the Kubernetes YAML manifests and store them in the
./manifests
directory:# Take a look at the generated YAML manifests. tk show environments/default # Export the YAML manifests to the folder `./manifests`: tk export ./manifests environments/default
Deploy the manifests to a Kubernetes cluster, in one of two ways:
Use the
tk apply
command.Tanka supports commands to show the
diff
andapply
changes to a Kubernetes cluster:# Show the difference between your Jsonnet definition and your Kubernetes cluster: tk diff environments/default # Apply changes to your Kubernetes cluster: tk apply environments/default
Use the
kubectl apply
command.You generated the Kubernetes manifests and stored them in the
./manifests
directory in the previous step.You can run the following command to directly apply these manifests to your Kubernetes cluster:
# Review the changes that will apply to your Kubernetes cluster: kubectl apply --dry-run=client -k manifests/ # Apply the changes to your Kubernetes cluster: kubectl apply -k manifests/
Note: The generated Kubernetes manifests create resources in the
default
namespace. To use a different namespace, change thenamespace
configuration option in theenvironments/default/main.jsonnet
file, and re-generate the Kubernetes manifests.