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
tankaandjb:Follow the steps at https://tanka.dev/install. If you have
goinstalled 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@latestSet 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
./manifestsdirectory:# Take a look at the generated YAML manifests. tk show environments/default # Export the YAML manifests to the folder `./manifests`: tk export ./manifests environments/defaultDeploy the manifests to a Kubernetes cluster, in one of two ways:
Use the
tk applycommand.Tanka supports commands to show the
diffandapplychanges 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/defaultUse the
kubectl applycommand.You generated the Kubernetes manifests and stored them in the
./manifestsdirectory 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
defaultnamespace. To use a different namespace, change thenamespaceconfiguration option in theenvironments/default/main.jsonnetfile, and re-generate the Kubernetes manifests.


