Refresher on deploying
Deploying to Kubernetes using kubectl
To understand how Tanka works, it is important to know what steps are required for the task of deploying Grafana and Prometheus to Kubernetes:
- Prometheus
- A
Deployment
must be created, to run theprom/prometheus
image - Also a
Service
is needed for Grafana to be able to connect port9090
of Prometheus.
- A
- Grafana
- Another
Deployment
is required for the Grafana server. - To connect to the web interface, we will be using a
Service
of typeNodePort
.
- Another
Before taking a look how Tanka can help doing so, let’s recall how to do it with
plain kubectl
.
Writing the yaml
kubectl
expects the resources it should create in .yaml
format.
For Grafana:
and for Prometheus:
That’s pretty verbose, right?
Even worse, there are labels and matchers (e.g. prometheus
) that need to be
exactly the same scattered across the file. It’s a nightmare to debug and
furthermore harms readability a lot.
Deploying to the cluster
To actually apply those resources, copy them into .yaml
files and use:
Checking it worked
So far so good, but can we tell it actually did what we wanted? Let’s test that Grafana can connect to Prometheus!
Now go to http://localhost:8080 in your browser and login using admin:admin
.
Then navigate to Connections > Data sources > Add new data source
, choose
Prometheus
as type and enter http://prometheus:9090
as URL. Hit
Save & Test
which should yield a big green bar telling you everything is good.
Cool! This worked out well for this small example, but the .yaml
files are
hard to read and maintain. Especially when you need to deploy this exact same
thing in dev
and prod
your choices are very limited.
Let’s explore how Tanka can help us here in the next section!
Cleaning up
Let’s remove everything we created to start fresh with Jsonnet in the next section: