Skip to content
Merged
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@
vendor
# Generated pb files
*.pb.go
# vi backups
*.bak

1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ interest in working on it. This helps other people know that the issue is
active, and hopefully prevents duplicated efforts.

To submit a proposed change:
- Setup your [development environment](devel/README.md).
- Fork the repository.
- Create a new branch for your changes.
- Develop the code/fix.
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ decisions to the mixer.
See the [contribution guidelines](CONTRIBUTING.md) for information on how to
participate in the Istio project by submitting pull requests or issues.

You can then check out how to [setup for development](devel/README.md).

## Community and support

There are several [communication channels](https://istio.io/community/) available to get
Expand Down
54 changes: 54 additions & 0 deletions devel/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Developing for Istio

See also the [broker](https://github.com/istio/broker/blob/master/doc/dev/development.md) and [mixer](https://github.com/istio/mixer/blob/master/doc/dev/development.md)
development setup and guidelines

## Collection of scripts and notes for developing for Istio

For local development (building from source and running the major components) on Ubuntu/raw VM:

Assuming you did (once):
1. [Install bazel](https://bazel.build/versions/master/docs/install-ubuntu.html), note that as of this writing Bazel needs the `openjdk-8-jdk` VM (you might need to uninstall or get out of the way the `ibm-java80-jdk` that comes by default with GCE for instance)
2. Install required packages: `sudo apt-get install make openjdk-8-jdk libtool m4 autoconf uuid-dev`
3. Get the source trees
```bash
mkdir github
cd github/
git clone https://github.com/istio/proxy.git
git clone https://github.com/istio/mixer.git
git clone https://github.com/istio/istio.git
# if you want to do load tests:
git clone https://github.com/wg/wrk.git
```
4. You can then use
- [update_all](update_all) : script to build from source
- [setup_run](setup_run) : run locally
- Also found in this directory: [rules.yml](rules.yml) : the version of mixer/testdata/configroot/scopes/global/subjects/global/rules.yml that works locally and [quota.yml](quota.yml) a very simple 1 qps quota example used below.
5. And run things like
```bash
# Test the echo server:
curl -v http://localhost:8080/
# Test through the proxy:
curl -v http://localhost:9090/echo
# Add a rule locally (simply drop the file or exercise the API:)
curl -v http://localhost:9094/api/v1/scopes/global/subjects/foo.svc.cluster.local/rules --data-binary @quota.yaml -X PUT -H "Content-Type: application/yaml"
# Test under some load:
wrk http://localhost:9090/echo

```
Note that this is done for you by [setup_run](setup_run) but to use the correct go environment:
```bash
cd mixer/
source bin/use_bazel_go.sh
```


## MacOs tips

Get GitHub desktop https://desktop.github.com/

If you want to make changes to the [website](https://github.com/istio/istio.github.io), and want to run jekyll locally and natively, without docker):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DO we need this? The docker variation is very stable and avoids dealing with Ruby stuff. I'd rather remove this option from our docs.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well it's much lighter running natively and only 1 paragraph, I had that in my notes and think it may be useful to someone else - I'd like eventually to run everything natively on the mac btw (low pri but still)


You will need a newer ruby than the default: get and install rvm https://rvm.io/

Then rvm install ruby-2.1 (or later) rvm use ruby-2.1 then `gem install jekyll bundler` then `bundle install` and then finally you can run successfully `bundle exec jekyll serve` in the directory you cloned the iostio doc repo. To avoid `GitHub Metadata: No GitHub API authentication could be found. Some fields may be missing or have incorrect data.` errors you need to set a public repo access token at https://github.com/settings/tokens and export it in `JEKYLL_GITHUB_TOKEN` env var (in your `.bash_profile`) - then http://127.0.0.1:4000/docs/ will work and auto update when pulling.
8 changes: 8 additions & 0 deletions devel/quota.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
rules:
- aspects:
- kind: quotas
params:
quotas:
- descriptorName: RequestCount
maxAmount: 1
expiration: 1s
57 changes: 57 additions & 0 deletions devel/rules.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
subject: namespace:ns
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revision: "2022"
rules:
- selector: # must be empty for preprocessing adapters
aspects:
- kind: quotas
params:
quotas:
- descriptorName: RequestCount
maxAmount: 5000
expiration: 1s
- kind: metrics
adapter: prometheus
params:
metrics:
- descriptor_name: request_count
# we want to increment this counter by 1 for each unique (source, target, service, method, response_code) tuple
value: "1"
labels:
source: source.labels["app"] | "unknown"
target: target.service | "unknown"
service: target.labels["app"] | "unknown"
method: request.path | "unknown"
version: target.labels["version"] | "unknown"
response_code: response.code | 200
- descriptor_name: request_duration
value: response.latency | response.duration | "0ms"
labels:
source: source.labels["app"] | "unknown"
target: target.service | "unknown"
service: target.labels["app"] | "unknown"
method: request.path | "unknown"
version: target.labels["version"] | "unknown"
response_code: response.code | 200
- kind: access-logs
params:
logName: access_log
log:
descriptor_name: accesslog.common
template_expressions:
originIp: origin.ip
sourceUser: origin.user
timestamp: request.time
method: request.method
url: request.path
protocol: request.scheme
responseCode: response.code
responseSize: response.size
labels:
originIp: origin.ip
sourceUser: origin.user
timestamp: request.time
method: request.method
url: request.path
protocol: request.scheme
responseCode: response.code
responseSize: response.size
16 changes: 16 additions & 0 deletions devel/setup_run
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# very basic local run
set -x
ulimit -n 16384
cp istio/devel/rules.yml mixer/testdata/configroot/scopes/global/subjects/global/rules.yml
cd mixer; set +x; source bin/use_bazel_go.sh ; set -x; cd ..
( cd proxy/test/backend/echo; go run echo.go > /tmp/echo.log ) &
( cd proxy/src/envoy/mixer; ./start_envoy > /tmp/envoy.log ) &
# add -v=5 for verbose/debug
./mixer/bazel-bin/cmd/server/mixs server --configStoreURL=fs://$(pwd)/mixer/testdata/configroot --logtostderr 2> /tmp/mixs.2.log &
echo "starting everything..."
sleep 3
curl -v http://localhost:9090/echo
curl -v http://localhost:42422/metrics
set +x
export PATH=$PATH:$(pwd)/wrk
echo "you can now run: wrk http://localhost:9090/echo"
19 changes: 19 additions & 0 deletions devel/update_all
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#! /bin/bash
# update and rebuild from source
set -e
set -x
cd istio
git pull
cd ../mixer
git pull
cd ../proxy
git pull
cd ../wrk
git pull
make
cd ../proxy
bazel build src/envoy/mixer:envoy
cd ../mixer
bazel build cmd/server:mixs
set +x
echo "### All done... source istio/devel/setup_run now"