Skip to content

Commit

Permalink
Adding instructions to build telemetry server/go client inside docker (
Browse files Browse the repository at this point in the history
…sonic-net#68)

* add telemetry server build

* add empty dump and resolve comments

* add net host in docker run

* add comment to redis
  • Loading branch information
pra-moh authored Feb 10, 2021
1 parent 4fcd5b6 commit 7cd86c5
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 0 deletions.
45 changes: 45 additions & 0 deletions doc/telemetry-dev-env/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
FROM ubuntu:18.04

# fundemantals
RUN apt-get update
RUN apt-get install -y wget
RUN apt-get install -y ssh xinetd rsync patch
RUN apt-get install -y iproute2
RUN apt-get install -y gcc
RUN apt-get install -y cmake
RUN apt-get install -y make
RUN apt-get install -y openssh-server
RUN apt-get install -y python3 python3-pip
RUN apt-get install -y tmux

# install go and configure
RUN wget https://golang.org/dl/go1.14.14.linux-amd64.tar.gz -O /tmp/go1.14.14.linux-amd64.tar.gz
RUN tar -C /usr/local -xzf /tmp/go1.14.14.linux-amd64.tar.gz
RUN mkdir /usr/gopath
ENV GOPATH="/usr/gopath"
ENV GOROOT="/usr/local/go"
ENV PATH="${GOPATH}/bin:${GOROOT}/bin:${PATH}"

# Dev libs required for libyang
RUN apt-get install -y bison
RUN apt-get install -y flex
RUN apt-get install -y libpcre3 libpcre3-dev

# Download libyang and install.
RUN pip3 install pyang
RUN wget https://github.com/CESNET/libyang/archive/v1.0.184.tar.gz -O /tmp/libyang-v1.0.184.tar.gz
RUN tar -C /tmp -xzf /tmp/libyang-v1.0.184.tar.gz
RUN mkdir /tmp/libyang-1.0.184/build && cd /tmp/libyang-1.0.184/build && cmake .. && make && make install

RUN apt-get install -y redis

RUN sed -i "s/bind .*/bind 127.0.0.1/g" /etc/redis/redis.conf
RUN echo "unixsocket /var/run/redis/redis.sock" >> /etc/redis/redis.conf
COPY files/* /tmp

# SSH settings
EXPOSE 22/tcp
# Following will expose 6379 port. Not needed except dugging.
EXPOSE 6379/tcp

ENTRYPOINT service ssh restart && bash
47 changes: 47 additions & 0 deletions doc/telemetry-dev-env/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
Goto doc/telemetry-dev-env
Build the image:
```
docker build -t telemetry-dev .
```

Remove container if it exist already:
```
docker rm telemetry-dev-env
```
Create personal fork repo from sonic-telemetry from git

Create directory '~/src' and Clone git repos in it:
```
git clone https://<your_github_username>@github.com/<your_github_username>/sonic-telemetry.git
git clone https://<your_github_username>@github.com/<your_github_username>/sonic-mgmt-common.git
```

Create a new container using the image:
```
docker run -it -v ~/src:/src --net=host --name telemetry-dev-env telemetry-dev
```

Build and start service (Inside container):
```bash

# Build sources
cd /src/sonic-mgmt-common && make
cd /src/sonic-telemetry && make all

# Bootstrap DB. dump.rdb provided under files/ is empty. Please replace empty rdb file and then restart redis.
mkdir -p /var/run/redis/sonic-db && chown redis /var/run/redis/sonic-db && install testdata/database_config.json -t /var/run/redis/sonic-db
service redis-server stop && cp /files/dump.rdb /var/lib/redis/dump.rdb && service redis-server start

# Start the service
./build/bin/telemetry --port 8080 -insecure --allow_no_client_auth --logtostderr -v 10
```

Make a client query (Inside container):
```bash

# Make another connection to container
docker exec -it telemetry-dev-env bash

# Make a query
/src/sonic-telemetry/build/bin/gnmi_cli -client_types=gnmi -a 127.0.0.1:8080 -t OTHERS -logtostderr -insecure -qt p -pi 10s -q proc/loadavg
```
Empty file.

0 comments on commit 7cd86c5

Please sign in to comment.