forked from sonic-net/sonic-gnmi
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding instructions to build telemetry server/go client inside docker (…
…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
Showing
3 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.