- Install task to setup dependencies.
cd
into the repo and runtask setup
- Build a binary by running
cd src
andgo build -o kubectl-opslevel .
Notice: ./kubectl-opslevel
is not the same as kubectl opslevel
that you may have installed from brew.
- Get an OpsLevel API Token for a dev (not prod!) environment.
- 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 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