Coder Social home page Coder Social logo

container-patterns-with-nomad's People

Contributors

lastlegion avatar mpolinowski avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

container-patterns-with-nomad's Issues

Wrong port assignment

In the example "ambassador/service.nomad" you have a dynamic port for "http" but are configuring the service for static port :8080.

some deprecations (sidecar pattern)

Hi,

thank you for sharing - this helped me a lot ๐Ÿ˜ƒ

But I ran into a couple of deprecation warnings for the sidecar example. I believe the easiest way to get to the same result now - with the latest version of Nomad/Consul - is:

job "ssl-proxy" {
  datacenters=["mydc"]
  group "ssl-proxy" {
        
    network {
        port "http" {
            static = 8080
        }
        port "https" {
            static = 8015
        }
    }

    service {
      name = "app-server"
      port = "http"

      check {
        type     = "http"
        port     = "http"
        path     = "/"
        interval = "2s"
        timeout  = "2s"
      }
    }

    task "app-server" {
      driver = "docker"

      config {
        image = "hashicorp/http-echo:latest"
        ports = [
          "http",
        ]
        args  = [
          "-listen", ":${NOMAD_PORT_http}",
          "-text", "Hello World!",
        ]
      }
    }

    task "ssl-proxy-sidecar" {
      driver = "docker"
      config {
        image = "nginx"
        ports = [
          "https",
        ]
        volumes = [
          "config/nginx.conf:/etc/nginx/nginx.conf",
          "secrets/certificate.crt:/secrets/certificate.crt",
          "secrets/certificate.key:/secrets/certificate.key",
        ]
      }
      
      template {
        data = <<EOF
          worker_processes  1;
          events {
              worker_connections  1024;
          }
          http {
              include       mime.types;
              default_type  application/octet-stream;
              sendfile        on;
              keepalive_timeout  65;
              upstream backend {
                {{ range service "app-server" }}
                server {{ .Address }}:{{ .Port }};
                {{ else }}server 127.0.0.1:65535; # force a 502
                {{ end }}
              }
              server {
                listen       8015 ssl;
                server_name  localhost;
                ssl_certificate      /secrets/certificate.crt;
                ssl_certificate_key  /secrets/certificate.key;
                location / {
                  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                  proxy_set_header Host $http_host;
                  proxy_pass http://backend;
                }
              }
          }
        EOF
        destination = "config/nginx.conf"
      }
      template {
        # Warning: Fetch certificate from a secret store like vault in a production setting
        data = <<EOF
-----BEGIN CERTIFICATE-----
MIIDajCCAlKgAwIBAgITPAgZrdQO2jRhM/KkR8Czc1iC+jANBgkqhkiG9w0BAQsF
...
jlw8JveeVvRFTvdwW23+JHnTvqpremm5PhmvPPnRNOhR1WhKxvJWWdeYDBjBoaPo
vAIDwNat6MpbCNH6pSs=
-----END CERTIFICATE-----
        EOF
        destination = "secrets/certificate.crt"
      }
      template {
        # Warning: Fetch certificate from a secret store like vault in a production setting
        data = <<EOF
-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDtReLnMCGfM6jI
...
EFG7bYgACbS289cpWA2nmcfhhGn7tV26xLuMFma0GQhr6jpQbuqONbrnlyRJGvMr
7iyk7nrNu9Ez3yM9zVMuvIJH
-----END PRIVATE KEY-----
        EOF
        destination = "secrets/certificate.key"
      }
    }
  }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.