Skip to content

ake-persson/grpc-exec-example

Repository files navigation

Install Go

First install Go and then configure Go environment.

Mac OS X

brew install go

RedHat/CentOS/Fedora

yum install golang

Setup Go environment

mkdir -p ~/go/{src,bin}
cat << EOF >>~/.bash_profile
export GOPATH=~/go
export PATH=\$PATH:\$GOPATH/bin
EOF
source ~/.bash_profile

Clone code

mkdir -p $GOPATH/src/github.com/mickep76
cd $GOPATH/src/github.com/mickep76
git clone https://github.com/mickep76/grpc-exec-example.git

Create TLS Certificates

First generate TLS Certificates for localhost and RSA public/private key.

cd $GOPATH/src/github.com/mickep76/grpc-exec-example/tls_setup
make preq ca req

Setup OpenLDAP server inside Docker

cd $GOPATH/src/github.com/mickep76/grpc-exec-example/ldap-server
make build run

Download/update deps

cd $GOPATH/src/github.com/mickep76/grpc-exec-example
go get -u ./...

Build auth-server

Configure auth-server LDAP/AD settings in ~/.auth-server.toml.

cat << EOF >~/.auth-server.toml
addr = "localhost:389"
base = "dc=example,dc=com"
ou = "ou=users"
ca = "../tls_setup/certs/ca.pem"
verify = true
EOF

Build auth-server.

cd $GOPATH/src/github.com/mickep76/grpc-exec-example/auth-server
go build
./auth-server

You can find the settings for auth-server using ./auth-server --help or ./auth-server -print-conf.

Build info-server

cd $GOPATH/src/github.com/mickep76/grpc-exec-example/info-server
go build
./info-server

Build exec-server

cd $GOPATH/src/github.com/mickep76/grpc-exec-example/exec-server
go build
./exec-server

Build client

Build the client so you can interact with the services.

cd $GOPATH/src/github.com/mickep76/grpc-exec-example/client
go build

Generate a JWT token by logging in.

For user "jdoe" use password "secret".

./client login -user jdoe
./client verify

Query host info from one or more hosts.

./client info localhost
./client info localhost,localhost

Execute command on one or more hosts.

./client exec localhost /bin/ls -la /
./client exec localhost,localhost /bin/ls -la /

Build catalog-server

Catalog server will allow each info-server to register and send a keep-alive.

cd $GOPATH/src/github.com/mickep76/grpc-exec-example/catalog-server
go build
./catalog-server

Restart info-server

Stop info-server CTRL+C then start it with the option -register. This requires that you have created a token.

cd $GOPATH/src/github.com/mickep76/grpc-exec-example/info-server
./info-server -register

List hosts registered in catalog-server

cd $GOPATH/src/github.com/mickep76/grpc-exec-example/client
./client list