Using Lostrómos
April 2, 2019 · View on GitHub

Using Lostrómos
Recommended Reading
Quick Start
Dependencies
| Dependency | Version |
|---|---|
Golang | 1.9.0+ |
Minikube | 0.22.3+ |
Docker | 17.09.0+ |
Python | 3.0+ |
Install the above dependencies, then run the following script substituting
your_os_version for darwin/linux/windows depending on your system.
This script will install Go and Python dependencies, build Lostrómos, build a docker image with Lostrómos, then run it in Minikube and perform integration testing.
make install-go-deps
make vendor
make install-python-deps
make build-cross
./out/lostromos-{your_os_version}-amd64 version
minikube start
eval $(minikube docker-env)
make docker-build-test
kubectl create -f test/data/crd.yml
make LOSTROMOS_IP_AND_PORT=`minikube service lostromos --url | cut -c 8-` integration-tests
eval $(minikube docker-env -u) # Unlinks minikube and docker.
Tutorial
To start working with Lostrómos, you should begin by playing around with some
basic CR management. Build Lostrómos via make build, then do the following
steps.
- Setup kubectl against a cluster. (See this guide for setting up Minikube.)
- Set up a Custom Resource Definition (CRD).
- View the CRD config file
- Run
kubectl apply -f test/data/crd.yml
- Create CR objects for thing1 and thing2
- View the CR config file for thing1 and thing2
- Run
kubectl apply -f test/data/cr_things.yml
- Start Lostrómos
- View the Lostromos config file
- Lostrómos is set up to watch the CRD you just defined
- Lostrómos is set up to apply the templates defined here
- Templates are defined for an nginx Deployment and a Configmap
- Run
./lostromos start --config test/data/config.yaml - See that resources were added for thing1 and thing2
{"controller": "template", "resource": "thing1"}{"controller": "template", "resource": "thing2"}
- Verify resources were created (Switch to new shell for the remainder of
the tutorial)
- In another shell run
kubectl get deploymentsand verify thing1 and thing2 nginx deployments - Run
kubectl get configmapsand verify thing1 and thing2 configmaps
- In another shell run
- View the Lostromos config file
- Create new resources
- Run
kubectl apply -f test/data/cr_nemo.yml - Verify that the
nemo-nginxandnemo-configmapwere created
- Run
- Edit existing resources
- Run
kubectl edit character nemoand edit theByfield inspecto say Pixar` - Run
kubectl describe configmap nemo-configmapto verify the change was propagated
- Run
- Delete a resource
- Run
kubectl delete -f test/data/cr_nemo.yml - Verify that the nemo configmap and nginx deployment were deleted
- Run
- Delete all resources
- Run
kubectl delete -f test/data/crd.ymlto cleanup the rest of the test data.
- Run
Customization
Configuration file/flags
crd(Required) Custom Resource information used to determine what Lostrómos will watch for add/update/deletename(Required) The plural name of the Custom Resource Definition (CRD) you want monitored (ex: users)group(Required) The group of the CRD you want monitored (ex: stable.nicolerenee.io)version(Required) The version of the CRD you want monitorednamespaceThe namespace of the CRD you want monitoredfilterFilter to specify if Lostromos will act on a resource create/update/delete. For more detailed information about what events happen on filtered updates, read up on events here.
helmInformation pertaining to helm deployments. Defaults to use the go template controller if no information is givenchartPath to helm chartnamespaceNamespace for resources deployed by helmreleasePrefixPrefix for release names in helmtillerAddress for helm tiller
k8sKubernetes configuration file required to run Lostrómos on a different cluster. Defaults to use local cluster if no config is specifiedconfigPath to configuration file
templatesPath to template directory. If using helm, this is skipped. Defaults to ""
See ./lostromos start --help for more info.
Templates
Helm Templates
From the CR, metadata.name, metadata.namespace, and spec fields are
marshalled. These values are accessible in
Helm as Values.resource.name, Values.resource.namespace, and
Values.resource.spec respectively.
See documentation on Using Helm for more info
Go Templates
CR fields are accessible to the template by using .GetField
Deployment
Docker
We don't deploy a docker image with Lostrómos, but instead only release the binary to github. However, we do build a docker image as part of testing. The Dockerfile we use for test is available here.
Logs
- When Lostrómos is running locally, the logs are outputted to the console.
- When running inside a cluster, the logs can be viewed with the
kubectl log lostromoscommand