Giter Site home page Giter Site logo

hashicorp / demo-consul-101 Goto Github PK

View Code? Open in Web Editor NEW
80.0 274.0 54.0 10.93 MB

Tutorial code and binaries for the HashiCorp Consul beginner course.

License: Mozilla Public License 2.0

Shell 19.54% Go 33.77% JavaScript 9.02% HTML 4.42% CSS 7.79% Dockerfile 2.07% Makefile 6.93% HCL 16.46%

demo-consul-101's Introduction

Demo Consul 101

Demo code and microservices for the HashiCorp Consul 101 course.

Email [email protected] or see https://www.hashicorp.com/training for details.

Quickstart: Docker Compose

To run both microservices with Docker Compose (but without Consul), run docker compose up.

$ cd demo-consul-101
$ docker-compose up

You can view the operational application dashboard at http://localhost:8080

A subsequent evolution of the application would involve registering each service with Consul and using Consul DNS to configure services to discover each other.

Quickstart: Consul service mesh

If you have the Consul binary installed locally, you can use the following sequence of commands to run a demo mesh on your local laptop.

Start a local Consul dev agent with:

consul agent -dev -config-dir="./demo-config-localhost" -node=laptop

Start the dashboard-service in a separate shell session.

PORT=9002 go run ./services/dashboard-service/main.go

Start the counting-service in a separate shell session.

PORT=9003 go run ./services/counting-service/main.go

Start a second instance of the counting-service in a separate shell session.

PORT=9004 go run ./services/counting-service/main.go

Start the sidecar proxy for the counting-1 service instance in a separate shell session.

consul connect proxy -sidecar-for counting-1

Start the sidecar proxy for the counting-2 service instance in a separate shell session.

consul connect proxy -sidecar-for counting-2

Start the sidecar proxy for the dashboard service in a separate shell session.

consul connect proxy -sidecar-for dashboard

Now visit the application at localhost:9002.

demo-consul-101's People

Contributors

angrycub avatar calebalbers avatar derekstrickland avatar hashicorp-copywrite[bot] avatar marcaurele avatar ramramhariram avatar roncodingenthusiast avatar shoenig avatar topfunky avatar tryan225 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

demo-consul-101's Issues

Publish ARM64 Docker images

The tutorials that use dashboard and counting don't run on machines running on the arm architecture. Request to publish ARM docker images to docker hub.

Unable to connect to counting service

Env: IBM Cloud Private just running one node.

# kubectl version --short
Client Version: v1.12.4+icp
Server Version: v1.12.4+icp

Installed Consul 0.8.1 in Kubernetes. I had difficulty in installing as port 8500 and 8600 are in use if using ICP. But, after I modified the targetPort in service and daemonset, the pods came up and I can see the service in UI.

I followed your example step by step but I can't seem to connect with the counting service from the dashboard.

The tutorial did not mention anything about creating dns stub but readme says it.

So as per this link https://www.consul.io/docs/platform/k8s/dns.html I created this.

This was my coredns:

apiVersion: v1
kind: ConfigMap
metadata:
  labels:
    addonmanager.kubernetes.io/mode: EnsureExists
  name: coredns
  namespace: kube-system
data:
  Corefile: |
    .:53 {
      errors
      health
      kubernetes cluster.local in-addr.arpa ip6.arpa {
         pods insecure
         upstream
         fallthrough in-addr.arpa ip6.arpa
      }
      prometheus :9153
      proxy . /etc/resolv.conf
      cache 30
      reload
      loadbalance
    }
    consul {
      errors
      cache 30
      proxy . 10.0.0.111
    }

The consul dns is running on IP 10.0.0.111. I tried DNS test and I did not succeed for consul.service.consul and I do not know from where this name comes.

This is my setup for consul.

# k get all
NAME                                   READY   STATUS    RESTARTS   AGE
pod/consul-consul-bgt6d                1/1     Running   0          6h42m
pod/consul-consul-server-0             1/1     Running   0          6h42m
pod/consul-consul-server-1             1/1     Running   0          6h42m
pod/consul-consul-server-2             1/1     Running   0          6h42m
pod/counting                           1/1     Running   0          68m
pod/dashboard                          1/1     Running   0          68m
pod/emojify-api-c9dcb8c8c-xdsb8        2/2     Running   15         46m
pod/emojify-cache-594dbc9cb6-mrj7n     2/2     Running   0          46m
pod/emojify-facebox-6b995cb9bd-smz49   2/2     Running   0          46m
pod/emojify-ingress-79bf696c95-qxqxq   2/2     Running   0          46m
pod/emojify-website-6f45f44fd5-z7csg   2/2     Running   0          46m

NAME                                      TYPE           CLUSTER-IP   EXTERNAL-IP       PORT(S)                                                                   AGE
service/consul-consul-dns                 ClusterIP      10.0.0.111   <none>            53/TCP,53/UDP                                                             6h42m
service/consul-consul-server              ClusterIP      None         <none>            8500/TCP,8301/TCP,8301/UDP,8302/TCP,8302/UDP,8300/TCP,8611/TCP,8611/UDP   6h42m
service/consul-consul-ui                  ClusterIP      10.0.0.198   <none>            80/TCP                                                                    6h42m
service/dashboard-service-load-balancer   LoadBalancer   10.0.0.62    192.168.142.249   80:31574/TCP                                                              68m
service/emojify-ingress                   NodePort       10.0.0.26    <none>            80:30000/TCP                                                              46m

NAME                           DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR   AGE
daemonset.apps/consul-consul   1         1         1       1            1           <none>          6h42m

NAME                              DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/emojify-api       1         1         1            1           46m
deployment.apps/emojify-cache     1         1         1            1           46m
deployment.apps/emojify-facebox   1         1         1            1           46m
deployment.apps/emojify-ingress   1         1         1            1           46m
deployment.apps/emojify-website   1         1         1            1           46m

NAME                                         DESIRED   CURRENT   READY   AGE
replicaset.apps/emojify-api-c9dcb8c8c        1         1         1       46m
replicaset.apps/emojify-cache-594dbc9cb6     1         1         1       46m
replicaset.apps/emojify-facebox-6b995cb9bd   1         1         1       46m
replicaset.apps/emojify-ingress-79bf696c95   1         1         1       46m
replicaset.apps/emojify-website-6f45f44fd5   1         1         1       46m

NAME                                    DESIRED   CURRENT   AGE
statefulset.apps/consul-consul-server   3         3         6h42m

The counting service responds.

# k exec -it counting -- curl http://localhost:9001
{"count":1,"hostname":"counting"}

The logs from dashboard.

# k logs dashboard
Starting server on http://0.0.0.0:9002
(Pass as PORT environment variable)
Using counting service at http://localhost:9001
Starting websocket server...
New client connected
Fetched count -1
Fetched count -1
New client connected
Fetched count -1
Fetched count -1
New client connected

The UI shows -1 and it says Counting service is unreachable.

What did I miss? And how to test dns stub and if services are discoverable. I do not see counting and dashboard in the UI except consul.

Support darwin/arm64

Feature request

This image does not support arm64 / apple silicon. I would want to have support for more than amd64 architecture.

Why is it needed?

It is needed for step of running a count service completing the toturial "Consul with containers"

Suggestion

I am not familiar with how to convert an image to a new architecture.

Definition of done

  • Image supports arm64

Can't start envoy with instruction from Secure Service Communication tutorial

Hey, so I was trying to run the environment described in this tutorial . However , I wasn't able to start envoy with this command

consul connect envoy -sidecar-for counting-1 -admin-bind localhost:19001 > counting-proxy.log &

The error output was [external/envoy/source/server/server.cc:594] exiting cannot bind '127.0.0.1:21000': Address already in use
After checking the documentation I found that sidecar chooses random port starting from 21000, I tried to reconfigure counting and dashboard by specifying a port explicitly
counting.json

{
    "service": {
        "name": "counting",
        "id": "counting-1",
        "port": 9003,
        "check": {
            "http": "http://localhost:9003/health",
            "method": "GET",
            "interval": "1s",
            "timeout": "1s"
        },
        "connect": {
            "sidecar_service": {
                "port": 21250
            }
        }
    }
}

dashbord.json

{
    "service": {
        "name": "dashboard",
        "port": 9002,
        "connect": {
            "sidecar_service": {
                "port": 21100,
                "proxy": {
                    "upstreams": [
                        {
                            "destination_name": "counting",
                            "local_bind_port": 5000
                        }
                    ]
                }
            }
        },
        "check": {
            "id": "dashboard-check",
            "http": "http://localhost:9002/health",
            "method": "GET",
            "interval": "1s",
            "timeout": "1s"
        }
    }
}

And after that envoy was able to start proxies. I am not sure is it a bug in consul or developers are supposed to explicitly specify sidecar ports ?
My consul version is 1.10.0 and envoy is '1.18.3'

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.