Skip to content

Latest commit

 

History

History
135 lines (109 loc) · 2.55 KB

deploy-nginx-service.md

File metadata and controls

135 lines (109 loc) · 2.55 KB

Deploy Nginx Service

We will now deploy Nginx service on Nomad.

Prerequisite

SSH into a Nomad Server

gcloud compute ssh nomad-1

Deploy Envoy

cd envoy-consul-sds
nomad plan jobs/nginx.nomad
+ Job: "nginx"
+ Task Group: "webserver" (1 create)
  + Task: "nginx" (forces create)
Scheduler dry-run:
- All tasks successfully allocated.
Job Modify Index: 0
To submit the job with version verification run:
nomad run -check-index 0 jobs/nginx.nomad
When running the job with the check-index flag, the job will only be run if the
server side version matches the job modify index returned. If the index has
changed, another user has modified the job and the plan's results are
potentially invalid.
nomad run jobs/nginx.nomad

Check if the service is up and running

nomad status nginx
dig +noall +answer nginx.service.dc1.consul

Call Nginx using Consul service discovery

curl nginx.service.dc1.consul
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>

SSH into nomad-worker-1

exit
gcloud compute ssh nomad-worker-1

Call Nginx using Envoy proxy

curl localhost:1010
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>

Congratulations! We made it. You are now hitting Nginx using Envoy proxy using Consul SDS Service.

Exit nomad-worker-1

exit

Next Clean up