Skip to content

Latest commit

 

History

History
46 lines (34 loc) · 1.81 KB

Local-Development.md

File metadata and controls

46 lines (34 loc) · 1.81 KB

Local development

  1. First steps | Local installation
  2. Setup testing env
  3. Test commands locally

First Steps

  1. Install task to setup dependencies.
  2. cd into the repo and run task setup
  3. Build a binary by running cd src and go build -o kubectl-opslevel .

Notice: ./kubectl-opslevel is not the same as kubectl opslevel that you may have installed from brew.

Setup testing env

  1. Get an OpsLevel API Token for a dev (not prod!) environment.
  2. Get access to a cluster to import deployments from.

If you don't have a cluster, you can use kind or minikube to create one.

You should be able to kubectl get deploy in the cluster. If there are no deployments, you can kubectl apply -f our sample deployment (make sure to clean it up after.)

Test commands locally

# test basic functionality
# optional: add '--log-level debug'
./kubectl-opslevel version
./kubectl-opslevel config sample > opslevel-k8s.yaml
./kubectl-opslevel config view

# test detection and create/update services
# REMINDER: use a dev token, not a prod token!
# optional: add '--disable-service-create'
 OPSLEVEL_API_TOKEN=XXXX ./kubectl-opslevel service preview
 OPSLEVEL_API_TOKEN=XXXX ./kubectl-opslevel service import       # runs loop once
 OPSLEVEL_API_TOKEN=XXXX ./kubectl-opslevel service reconcile    # runs continuously

# notice: if you are using 'go run main.go' the exit codes will not be the same as the binary.
ps aux | grep -i 'kubectl-opslevel'
kill -2 <PID>                           # SIGINT - the program should exit gracefully, unlike with SIGTERM.
kill -15 <PID>                          # SIGTERM