diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/examples/httpd/httpd-proxy.conf b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/examples/httpd/httpd-proxy.conf new file mode 100644 index 0000000..d214938 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/examples/httpd/httpd-proxy.conf @@ -0,0 +1,8 @@ + + BalancerMember http://httpd-0.${SERVICE_NAME}.${USER}.${DOMAIN}:8080 + BalancerMember http://httpd-1.${SERVICE_NAME}.${USER}.${DOMAIN}:8080 + ProxySet lbmethod=bytraffic + + +ProxyPass "/" "balancer://test/" +ProxyPassReverse "/" "balancer://test/" diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/examples/httpd/httpd.json b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/examples/httpd/httpd.json new file mode 100644 index 0000000..e63376d --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-core/examples/httpd/httpd.json @@ -0,0 +1,55 @@ +{ + "name": "httpd-service", + "lifetime": "3600", + "components": [ + { + "name": "httpd", + "number_of_containers": 2, + "artifact": { + "id": "centos/httpd-24-centos7:latest", + "type": "DOCKER" + }, + "launch_command": "/usr/bin/run-httpd", + "resource": { + "cpus": 1, + "memory": "1024" + }, + "configuration": { + "files": [ + { + "type": "ENV", + "dest_file": "/var/www/html/index.html", + "props": { + "content": "
Title
Hello from ${COMPONENT_INSTANCE_NAME}!" + } + } + ] + } + }, + { + "name": "httpd-proxy", + "number_of_containers": 1, + "artifact": { + "id": "centos/httpd-24-centos7:latest", + "type": "DOCKER" + }, + "launch_command": "/usr/bin/run-httpd", + "resource": { + "cpus": 1, + "memory": "1024" + }, + "configuration": { + "files": [ + { + "type": "TEMPLATE", + "dest_file": "/etc/httpd/conf.d/httpd-proxy.conf", + "src_file": "httpd-proxy.conf" + } + ] + } + } + ], + "quicklinks": { + "Apache HTTP Server": "http://httpd-proxy-0.${SERVICE_NAME}.${USER}.${DOMAIN}:8080" + } +} diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-site/src/site/markdown/yarn-service/Examples.md b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-site/src/site/markdown/yarn-service/Examples.md new file mode 100644 index 0000000..49d0f67 --- /dev/null +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-site/src/site/markdown/yarn-service/Examples.md @@ -0,0 +1,97 @@ + + +# YARN Service Examples + +This document describes some example service definitions (`Yarnfile`). + + + +## Apache web server - httpd +Below is the `Yarnfile` for a service called `httpd-service` with two `httpd` instances. +There is also an httpd proxy instance (httpd-proxy-0) that proxies between the other two httpd instances (httpd-0 and httpd-1). + +Note this example requires registry DNS. +``` +{ + "name": "httpd-service", + "lifetime": "3600", + "components": [ + { + "name": "httpd", + "number_of_containers": 2, + "artifact": { + "id": "centos/httpd-24-centos7:latest", + "type": "DOCKER" + }, + "launch_command": "/usr/bin/run-httpd", + "resource": { + "cpus": 1, + "memory": "1024" + }, + "configuration": { + "files": [ + { + "type": "ENV", + "dest_file": "/var/www/html/index.html", + "props": { + "content": "
Title
Hello from ${COMPONENT_INSTANCE_NAME}!" + } + } + ] + } + }, + { + "name": "httpd-proxy", + "number_of_containers": 1, + "artifact": { + "id": "centos/httpd-24-centos7:latest", + "type": "DOCKER" + }, + "launch_command": "/usr/bin/run-httpd", + "resource": { + "cpus": 1, + "memory": "1024" + }, + "configuration": { + "files": [ + { + "type": "TEMPLATE", + "dest_file": "/etc/httpd/conf.d/httpd-proxy.conf", + "src_file": "httpd-proxy.conf" + } + ] + } + } + ], + "quicklinks": { + "Apache HTTP Server": "http://httpd-proxy-0.${SERVICE_NAME}.${USER}.${DOMAIN}:8080" + } +} +``` +This `Yarnfile` is already included in the Hadoop distribution, along with the required configuration template `httpd-proxy.conf`. +First upload the configuration template file to HDFS: +``` +hdfs dfs -copyFromLocal ${HADOOP_YARN_HOME}/share/hadoop/yarn/yarn-service-examples/httpd/httpd-proxy.conf . +``` +Then run the service with the command: +``` +yarn service create [service-name] --example httpd +``` +where `service-name` is optional. If omitted, it uses the name defined in the `Yarnfile`. + +Once the service is running, navigate to `http://httpd-proxy-0.${SERVICE_NAME}.${USER}.${DOMAIN}:8080` to see the root page. +The pages should alternately show "Hello from httpd-0!" or "Hello from httpd-1!" + +The individual httpd URLs can also be visited, `http://httpd-0.${SERVICE_NAME}.${USER}.${DOMAIN}:8080` and `http://httpd-1.${SERVICE_NAME}.${USER}.${DOMAIN}:8080`. diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-site/src/site/markdown/yarn-service/Overview.md b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-site/src/site/markdown/yarn-service/Overview.md index 3dd4d8c..407fbc0 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-site/src/site/markdown/yarn-service/Overview.md +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-site/src/site/markdown/yarn-service/Overview.md @@ -52,7 +52,8 @@ The benefits of combining these workloads are two-fold: * [Concepts](Concepts.md): Describes the internals of the framework and some features in YARN core to support running services on YARN. * [Service REST API](YarnServiceAPI.md): The API doc for deploying/managing services on YARN. -* [Service Discovery](ServiceDiscovery.md): Deep dives into the YARN DNS internals +* [Service Discovery](ServiceDiscovery.md): Deep dives into the YARN DNS internals. +* [Examples](Examples.md): List some example service definitions (`Yarnfile`).