Skip to content

Making Grafana Changes

csimon-psiphon edited this page May 20, 2020 · 2 revisions

Legend

Never ran grafana before?

Yes, but I don't need to know the details. Use our own grafana build script. This build process clones a fresh grafana repo, checks out the configured branch (subject to change), symlinks the gopath, and builds a new docker image.

Yes, and I want to know more. At the top there is a link to a blog post that expands on this guide as well.

Upgrading the grafana version

Preface

If you're updating the version of Grafana we're using, it's best to fork off of a stable grafana release rather than off of master. Pick a release by looking at the tags on the repo; do not use a beta tag.

Assume you're forking off of grafana version x.y.z.

  1. Clone Psiphon-Inc/grafana.
  2. Create a new branch tagged with the grafana version you'll be working off of (i.e. "x.y.z-psiphon").
  3. Set the remote upstream repo to the grafana version from grafana/grafana.
  4. Sync your fork with upstream grafana. Make sure you're synching with version x.y.z.
  5. Build and run your grafana fork to make sure you have a known-to-work version on the repo.
  6. Make changes while continuing to ensure your fork is in sync with upstream.

Pushing an image

Running make build-docker-full will create a new docker image for the grafana built on your machine (either manually or from the build script). Run the following to view your available images:

docker images

Your fresh grafana image should be in the repo "grafana/grafana" with the tag "dev". Tag and push the image:

docker tag grafana/grafana:dev ${DOCKER_REGISTRY_URL}/${IMAGE_PATH}:${BRANCH}
docker push ${DOCKER_REGISTRY_URL}/${IMAGE_PATH}:${BRANCH}

Deploying in a test environment

  1. Get your kubeconfig from ciphershare
  2. Put it somewhere local, the usual spot is ~/.kube/config but anywhere is fine
  3. Run export KUBECONFIG=/config/file/location
  4. Clone pde
  5. Copy https://github.com/Psiphon-Inc/pde/blob/master/grafana/deploy/04-grafana-psix.yml to a new file (i.e. xx-grafana-test.yml)
  6. Edit that new file to point at the image you want to test (~L62) and drop the first init container block (~L24-30) (that is just there for super safety so I don’t accidentally delete the grafana database when restarting pods, in this case the DB will not exist yet because it’s a new deployment, so that init container will throw an error and stop the deployment)
  7. Edit the “Ingress” spec in that same file to use your test environment instead of psix.psiphon.io
  8. Run kubectl config use-context ${CONTEXT}
  9. Run kubectl apply -f xx-grafana-test.yml
  10. check out your test environment's host, you should be able to login with whatever credentials you use for psix.ca