aboutsummaryrefslogtreecommitdiffstats
path: root/node-admin/README.md
blob: bab4c17ffbf055c89a96e3a2196a2ec9dd60f38c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# Node Admin

## Setup

Set up Docker on your machine according to the instructions in [Linux](README_LINUX.md) or [Mac](README_MAC.md), depending on your hardware.

You should have the docker daemon running and the following environment variables set:
```
VESPA_HOME
VESPA_WEB_SERVICE_PORT
```

To update `/etc/hosts` with the required hostnames for the local containers, run
```
sudo ./scripts/etc-hosts.sh
```

## Developing

We will describe how you can build a Docker image for Vespa which will be used
to set up a local Docker container with the Node Admin, and a local container
with the Config Server.

Then, we'll show how you bring up this local zone. And finally, how you can
deploy a local Vespa application to this zone.

[RunVespaLocal.java](src/test/java/com/yahoo/vespa/hosted/node/admin/docker/RunVespaLocal.java) 
implements all of the basic methods you need to get started.

### Starting a Local Zone

To start a local zone, simply run:
```
    DockerImage dockerImage = new DockerImage("docker-registry.domain.tld:8080/vespa/ci:6.111.21");
    Path pathToVespaRoot = Paths.get("/home/valerijf/dev/vespa");
    Path pathToContainerStorage = Paths.get("/home/docker/container-storage");

    RunVespaLocal runVespaLocal = new RunVespaLocal(pathToVespaRoot);
    runVespaLocal.startLocalZoneWithNodes(dockerImage, 5);
    runVespaLocal.startNodeAdminAsContainer(dockerImage, pathToContainerStorage);
```

### Deploying a Local Application

Package and deploy vespa application by running:

```
    Path pathToApp = pathToVespaRoot.resolve("sample-apps/blog-search");
    runVespaLocal.deployApplication(pathToApp);
```
If the deployment is successful, the final log entry should be something like 
```
INFO: Endpoint http://cnode-1:4080/ is now ready
```
use this endpoint URL to feed or query your application.

You can delete application with

```
    runVespaLocal.deleteApplication();
```

### Feed and search
 1. **Feed** the data that is to be searched
 ```sh

 # Feeding two documents
 curl -X POST --data-binary  @music-data-1.json <endpoint url>/document/v1/music/music/docid/1 | python -m json.tool
 curl -X POST --data-binary  @music-data-2.json <endpoint url>/document/v1/music/music/docid/2 | python -m json.tool

  ```

 2. **Visit documents**

 Since we do not have many documents we can list them all
 ```sh

 # All documents
 curl <endpoint url>/document/v1/music/music/docid | python -m json.tool

 # Document with id 1
 curl <endpoint url>/document/v1/music/music/docid/1 | python -m json.tool

  ```

 3. **Search**
 We can also search for documents:
    ```sh

    curl '<endpoint url>/search/?query=bad' | python -m json.tool


    ```

## Troubleshooting

If the container doesn't start, it can be helpful to look at the jdisc log. First, find the container id:
```
docker ps -a
```

Then, find the log files:
```
docker diff <container id>| grep $VESPA_HOME/logs
```

View the log file (`-L` follows the symbolic link):
```
docker cp -L <container id>:$VESPA_HOME/logs/jdisc_core/jdisc_core.log - | less
```