Netflix Prana is a service to make it easy to integrate non-JVM applications into a NetflixOSS environment. In this article we look at how to install Prana.

Eureka

Since Prana interfaces with Eureka, make sure you have a Eureka cluster running. To set Eureka up, see HowTo: Setup Netflix Eureka v1.x.

Install

We’ll make a directory to check Prana out into.

Console - user@hostname ~ $

1
mkdir -p ~/github/Netflix

We’ll change to the directory we just created.

Console - user@hostname ~ $

1
cd ~/github/Netflix

Now we’ll clone Prana repository.

Console - user@hostname ~/github/Netflix $

1
git clone https://github.com/Netflix/Prana.git

And change directory into the repo.

Console - user@hostname ~/github/Netflix $

1
cd Prana

List the tags to pick a version to build.

Console - user@hostname ~/github/Netflix/Prana $

1
git tag

In this article, we’ll build version 0.0.4.

Console - user@hostname ~/github/Netflix/Prana $

1
git checkout 0.0.4

We’ll build the source.

Console - user@hostname ~/github/Netflix/Prana $

1
./gradlew build

The installApp command will package everything into build/install/Prana.

Console - user@hostname ~/github/Netflix/Prana $

1
./gradlew installApp

We’ll copy build/install/Prana to our home directory.

Console - user@hostname ~/github/Netflix/Prana $

1
cp -R build/install/Prana ~/Prana

We’ll go to our Prana directory

Console - user@hostname ~/github/Netflix/Prana $

1
cd ~/Prana

And we’ll make a directory to hold our configuration files.

Console - user@hostname ~/Prana $

1
mkdir -p ~/Prana/conf

Configure

We’ll setup Prana to be a sidecar to apache. Installing apache is outside the scope of this article and is merely being used as an example.

Now we’ll create configuration files for Prana. They can all be put into one file, but here we’ll see how to split them into different files.

We’ll put together the eureka properties that would remain the same in our organization regardless of which app it is. Primarily this would consist of the properties to find the eureka servers.

~/Prana/conf/common-eureka.properties

1
2
3
4
eureka.shouldUseDns=true
eureka.eurekaServer.domainName=eureka.example.com
eureka.eurekaServer.port=80
eureka.eurekaServer.context=eureka/v2

We’ll put together any Kayron properties that would remain the same in our deployments. In this example we’ll mask AWS credentials and JAVA_OPTS that were used to start Prana.

~/Prana/conf/common-karyon.properties

1
netflix.platform.admin.resources.masked.property.names=aws.secretKey,aws.accessKeyId,AWS_SECRET_KEY,AWS_ACCESS_KEY_ID,JAVA_OPTS

Now a configuration file for common Prana options. We’ll allow for gzipping responses.

~/Prana/conf/common-prana.properties

1
prana.proxy.req.acceptencoding=gzip

Finally we’ll create a configuration file for the application we’re having Prana support. For this article, we’ll set it up for an apache server.

~/Prana/conf/apache.properties

1
2
3
4
5
6
7
eureka.name=prana-apache
eureka.vipAddress=prana-apache.example.com
eureka.port=80

prana.host.healthcheck.url=http://127.0.0.1:80/index.html
#prana.host.healthcheck.url=
prana.host.healthcheck.timeout=1500

The properties eureka.name, eureka.vipAddress are used when looking up this service in eureka. eureka.port tells what port our support service (apache in this case) is listening on. prana.host.healthcheck.url is the URL Prana will ping to check if the service is running; make this blank if you want to have the health check always succeed. prana.host.healthcheck.timeout is the number of milliseconds to wait on a health check before timing out.

Run

We’ll go to the Prana directory we created:

Console - user@hostname ~ $

1
cd ~/Prana

Assuming the home directory is /home/ec2-user and that we’re running in the us-east-1 region, we can start Prana like so:

Console - user@hostname ~/Prana $

1
2
3
4
5
6
7
JAVA_OPTS="\
-Deureka.datacenter=cloud \
-Deureka.region=us-east-1 \
-Darchaius.deployment.datacenter=cloud \
-Darchaius.deployment.region=us-east-1 \
-Darchaius.configurationSource.additionalUrls=file:///home/ec2-user/Prana/conf/common-eureka.properties,file:///home/ec2-user/Prana/conf/common-karyon.properties,file:///home/ec2-user/Prana/conf/common-prana.properties \
" bin/Prana -c conf/apache.properties

Ports

By default, Prana will start on port 8078 but can use the -p command line argument, e.g. JAVA_OPTS="..." bin/Prana -c conf/apache.properties -p 8079 will start on port 8079.

Because Prana is a Karyon application, it will open port 8077 for admin services. This can be changed with the property netflix.platform.admin.resources.port. For example in ~/Prana/conf/apache.properties set netflix.platform.admin.resources.port=8076 and the admin services will open on port 8076.

Changing ports can be useful if you decide to run multiple instances of Prana on a single machine.

Start with Supervisord

We can use Supervisord to have Prana start when the system starts up. To install Supervisord on Gentoo Linux, see HowTo: Install Supervisord on Gentoo Linux, for other systems see the Installing page of the Supervisord documentation.

We’ll be assuming Prana was installed in the home directory of the ec2-user and that we’ll be deploying in the us-east-1 region. If this won’t be the case, in the [program:prana-apache] section: make sure to replace /home/ec2-user with the appropriate directory that Prana is installed in; replace ec2-user with the user that should be executing the command; and replace us-east-1 with the desired region. In addition, in the [supervisord] section, it may be desired to change loglevel from debug to info to make the logs less versbose.

/etc/supervisord.conf

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
[unix_http_server]
file=/tmp/supervisor.sock
chmod=0777
chown=nobody:nobody

[supervisorctl]
serverurl=unix:///tmp/supervisor.sock

[supervisord]
logfile = /var/log/supervisord.log
logfile_maxbytes = 50MB
logfile_backups=10
loglevel = debug
pidfile = /tmp/supervisord.pid
nodaemon = False
minfds = 1024
minprocs = 200
umask = 022
identifier = supervisor
directory = /tmp
nocleanup = true
childlogdir = /tmp

[program:prana-apache]
environment=JAVA_OPTS="-Deureka.datacenter=cloud -Deureka.region=us-east-1 -Darchaius.deployment.datacenter=cloud -Darchaius.deployment.region=us-east-1 -Darchaius.configurationSource.additionalUrls=file:///home/ec2-user/Prana/conf/common-eureka.properties,file:///home/ec2-user/Prana/conf/common-karyon.properties,file:///home/ec2-user/Prana/conf/common-prana.properties"
command=/home/ec2-user/Prana/bin/Prana -c /home/ec2-user/Prana/conf/apache.properties
directory=/home/ec2-user/Prana
user=ec2-user
autostart=true
autorestart=true
redirect_stderr=true

References

Parts in this series

Comments