Skip to content

Commit e7aaafb

Browse files
committed
Documentation of local execution using the standalone binary
1 parent dabd9d7 commit e7aaafb

File tree

1 file changed

+56
-24
lines changed

1 file changed

+56
-24
lines changed

README.md

+56-24
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ A simple static analysis tool to explore and diagnosticate network policies decl
66

77
![demo](docs/assets/demo.gif)
88

9-
## How to use
9+
## Main features
1010

1111
The left part of the screen contains the controls for the main view:
1212
- Filters: filter pods by namespace, labels and name
@@ -30,10 +30,18 @@ Hover over a route to investigate allowed traffic:
3030
- Ports
3131
- Explanation (lack of isolation or network policies allowing traffic)
3232

33+
## Installation
3334

34-
## Run inside your cluster
35+
There are two ways to install and run Karto:
36+
- To deploy it inside the Kubernetes cluster to analyze, proceed to the
37+
[Run inside a cluster](#run-inside-a-cluster) section.
38+
- To run it on any machine outside the Kubernetes cluster to analyze, refer to the
39+
[Run outside a cluster](#run-outside-a-cluster) section.
40+
41+
### Run inside a cluster
42+
43+
#### Deployment
3544

36-
### Deployment
3745
Simply apply the provided descriptor:
3846
```shell script
3947
kubectl apply -f deploy/k8s.yml
@@ -44,7 +52,8 @@ This will:
4452
policies in the cluster
4553
- deploy an instance of the application in this namespace with this service account
4654

47-
### Exposition
55+
#### Exposition
56+
4857
Once deployed, the application must be exposed. For a quick try, use `port-forward`:
4958
```shell script
5059
kubectl -n karto port-forward <pod name> 8000:8000
@@ -55,49 +64,72 @@ For a long-term solution, investigate the use of a [LoadBalancer service](
5564
https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types) or an [Ingress](
5665
https://kubernetes.io/docs/concepts/services-networking/ingress/).
5766

58-
Remember to always secure the access to the application as it obviously displays sensitive data about your cluster.
67+
*Remember to always secure the access to the application as it obviously displays sensitive data about your cluster.*
68+
69+
#### Cleanup
5970

60-
### Cleanup
6171
Delete everything using the same descriptor:
6272
```shell script
6373
kubectl delete -f deploy/k8s.yml
6474
```
6575

76+
### Run outside a cluster
77+
78+
For this to work, a local `kubeconfig` file with existing connection information to the target cluster must be present
79+
on the machine (if you already use `kubectl` locally, you are good to go!).
80+
81+
Simply download the Karto binary from the [releases page](https://github.com/Zenika/karto/releases) and run it!
6682

67-
## Run locally
83+
## Development
6884

6985
### Prerequisites
86+
7087
The following tools must be available locally:
71-
- [Go](https://golang.org/doc/install)
72-
- [NodeJS](https://nodejs.org/en/download/)
88+
- [Go](https://golang.org/doc/install) (tested with Go 1.14)
89+
- [NodeJS 10+](https://nodejs.org/en/download/) (tested with NodeJS 10)
90+
91+
### Run the frontend in dev mode:
7392

74-
### Frontend
75-
To run in development mode:
93+
In the `front` folder, execute:
7694
```shell script
7795
npm start
7896
```
7997
This will expose the app in dev mode on `localhost:3000` with a proxy to `localhost:8000` for the API calls.
8098

81-
To compile:
99+
### Run the backend locally:
100+
101+
Simply execute:
82102
```shell script
83-
npm run build
103+
go build karto
104+
./karto
84105
```
85-
This will generate a `build` folder in `/front` that can be served statically.
86106

87-
### Backend
88-
To build the main executable:
107+
### Test suites
108+
109+
To run the entire backend test suite:
89110
```shell script
90-
go build karto
111+
go test ./...
91112
```
92-
This executable runs on port 8080 and serves the content of `./front/build` on the `/` route and the API on the `/api`
93-
route. If you choose not to run the frontend in development mode, remember to always refresh the frontend content (if
94-
modified) using the npm `build` command described above.
95113

114+
### Compile the go binary from source
96115

97-
## Test suites
116+
In production mode, the frontend is packaged in the go binary using [pkger](https://github.com/markbates/pkger). In this
117+
configuration, the frontend is served on the `/` route and the API on the `/api` route.
98118

99-
### Backend
100-
To run the entire test suite:
119+
To compile the Karto binary from source, first compile the frontend source code. In the `front` folder, execute:
101120
```shell script
102-
go test ./...
121+
npm run build
122+
```
123+
This will generate a `build` folder in `/front`.
124+
125+
Then, package it inside the backend:
126+
```shell script
127+
go install github.com/markbates/pkger/cmd/pkger
128+
pkger
129+
```
130+
This will generate a `pkged.go` file at the root with a binary content equivalent to the generated `build` folder.
131+
132+
Finally, compile the go binary:
133+
```shell script
134+
go build karto
103135
```

0 commit comments

Comments
 (0)