Mixer Out of Tree Adapter Walkthrough
This document walks through step-by-step instructions to implement, test and plug a simple out-of-tree Mixer adapter.
- Build an Out-of-Process adapter
- Configure the Out-of-Tree project
- Build the Out-of-Tree Adapter
- Plug the Out-of-Tree Adapter
- Test the Out-of-Tree Adapter
- Cleanup
Follow the steps in the Mixer Out of Process Adapter Walkthrough to build an out-of-process adapter.
First, create the project directory and copy the previously created adapter.
mkdir -p $GOPATH/src/github.com/username/myootadapter
cd $GOPATH/src/github.com/username/myootadapter
cp -R $MIXER_REPO/adapter/mygrpcadapter .
Vendor the necessary packages. For the sake of this walkthrough, let's hack this by copying packages from the $ISTIO/istio
project.
cd $GOPATH/src/github.com/username/myootadapter
cp -R $ISTIO/istio/vendor .
cp -R $ISTIO/istio/ vendor/istio.io/
rm -rf vendor/istio.io/istio/vendor/
We also purge any copies of the mygrpcadapter
within the vendored istio.io/istio
package. We also update the old package paths in the myootadapter/mygrpcadapter
code.
cd $GOPATH/src/github.com/username/myootadapter
rm -rf vendor/istio.io/istio/mixer/adapter/mygrpcadapter/
// Replace istio.io/istio/mixer/adapter/... imports with github.com/username/myootadapter/...
sed -i -e "s/istio.io\/istio\/mixer\/adapter/github.com\/username\/myootadapter/g" mygrpcadapter/mygrpcadapter.go
sed -i -e "s/istio.io\/istio\/mixer\/adapter/github.com\/username\/myootadapter/g" mygrpcadapter/cmd/main.go
The directory structure of the project is shown below.
── myootadapter
├─── mygrpcadapter
│ ├── cmd
│ ├── config
│ └── testdata
└─── vendor
└─ ...
We can now build this adapter and run tests.
cd $GOPATH/src/github.com/username/myootadapter
go build ./...
go test ./...
Start the adapter.
cd $GOPATH/src/github.com/username/myootadapter
go run mygrpcadapter/cmd/main.go
Note the listening address printed on the console and copy the content within quotes. For example, for an output of listening on "[::]:38355"
, the listener address would be [::]:38355
.
On a new terminal export the listener address in an ADDRESS variable.
export ISTIO=$GOPATH/src/istio.io
export ADDRESS=[::]:38355
Configure the address
parameter in the yaml file.
cd $GOPATH/src/github.com/username/myootadapter
cp mygrpcadapter/sample_operator_cfg.yaml mygrpcadapter/testdata/sample_operator_cfg.yaml
sed -i -e "s/{ADDRESS}/${ADDRESS}/g" mygrpcadapter/testdata/sample_operator_cfg.yaml
Build and start the Mixer process.
cd $ISTIO/istio && make mixs
cd $GOPATH/src/github.com/username/myootadapter
// Locate the mixs binary. It should be $GOPATH/out/linux_amd64/release/mixs on Linux
// and $GOPATH/out/darwin_amd64/release/mixs on macOS.
// Choose command below according to your OS:
$GOPATH/out/linux_amd64/release/mixs server --configStoreURL=fs://$(pwd)/mygrpcadapter/testdata
You should see an output like below.
Mixer started with
MaxMessageSize: 1048576
MaxConcurrentStreams: 1024
APIWorkerPoolSize: 1024
AdapterWorkerPoolSize: 1024
...
Build the Mixer client and post metrics.
export ISTIO=$GOPATH/src/istio.io
cd $ISTIO/istio && make mixc
// Locate the mixc binary. It should be $GOPATH/out/linux_amd64/release/mixc on Linux
// and $GOPATH/out/darwin_amd64/release/mixc on macOS.
// Choose command below according to your OS:
$GOPATH/out/linux_amd64/release/mixc report -s destination.service="svc.cluster.local" -i request.size=1235
Inspect the out.txt
file that your adapter would have printed. If you have followed the above steps, then the out.txt
should be in your $GOPATH/src/github.com/username/myootadapter
directory.
tail $GOPATH/src/github.com/username/myootadapter/out.txt
You should see something like:
HandleMetric invoked with:
Adapter config: &Params{FilePath:out.txt,}
Instances: 'i1metric.instance.istio-system':
{
Value = 1235
Dimensions = map[response_code:200]
}
If you have reached this far, congratulate yourself!!. You have successfully created an out-of-tree Mixer adapter. You can close (ctrl + c) on your terminals that were running the Mixer server and your adapter to shut them down.
Delete the $GOPATH/src/github.com/username/myootadapter
directory.
- The Wavefront by VMware adapter
Visit istio.io to learn how to use Istio.
- Preparing for Development Mac
- Preparing for Development Linux
- Troubleshooting Development Environment
- Repository Map
- GitHub Workflow
- Github Gmail Filters
- Using the Code Base
- Developing with Minikube
- Remote Debugging
- Verify your Docker Environment
- Istio Test Framework
- Working with Prow
- Test Grid
- Code Coverage FAQ
- Writing Good Integration Tests
- Test Flakes
- Release Manager Expectations
- Preparing Istio Releases
- 1.5 Release Information
- 1.6 Release Information
- 1.7 Release Information
- 1.8 Release Information
- 1.9 Release Information
- 1.10 Release Information
- 1.11 Release Information
- 1.12 Release Information
- 1.13 Release Information
- 1.14 Release Information
- 1.15 Release Information
- 1.16 Release Information
- 1.17 Release Information
- 1.18 Release Information
- 1.19 Release Information
- 1.20 Release Information
- 1.21 Release Information
- 1.22 Release Information
- Collecting Logs and Debug Info
- Dependency FAQ
- Working with discuss.istio.io
- Developing with and hosting upon OpenShift
- Adapter Dev Guide
- Adapter Walkthrough
- Attribute Generating Adapter Walkthrough
- Route Directive Adapter Development Guide
- Out of Tree Adapter Walkthrough
- Running a Local Instance
- Template Dev Guide
- Using a Custom Adapter
- Publishing Adapters and Templates to istio.io
- Enabling Envoy Authorization Service and gRPC Access Log Service With Mixer