Merge pull request #8342 from hashicorp/rm-externalised-demos
demos: remove externalized demo files
This commit is contained in:
commit
379283d36a
|
@ -1,33 +0,0 @@
|
|||
# countdash
|
||||
|
||||
Nomad makes use of the [demo-consul-101](https://github.com/hashicorp/demo-consul-101)
|
||||
education material throughout our examples for using Consul Connect. There are many
|
||||
example jobs that launch tasks with [counting-service](https://github.com/hashicorp/demo-consul-101/tree/master/services/counting-service)
|
||||
and [dashboard-service](https://github.com/hashicorp/demo-consul-101/tree/master/services/dashboard-service)
|
||||
configured to communicate under various conditions.
|
||||
|
||||
## Publishing
|
||||
|
||||
When making changes to the `countdash` demo, open a PR against the [demo-consul-101](https://github.com/hashicorp/demo-consul-101)
|
||||
project. Be sure to preserve backwards compatibility, as these demo files are used
|
||||
extensively, including with other Consul integrations.
|
||||
|
||||
The docker images specific to Nomad can be rebuilt using [counter-dashboard](counter-dashboard/Dockerfile)
|
||||
and [counter-api](counter-api/Dockerfile).
|
||||
|
||||
#### Testing locally
|
||||
```bash
|
||||
$ docker build -t hashicorpnomad/counter-api:test .
|
||||
$ docker build -t hashicorpnomad/counter-dashboard:test .
|
||||
|
||||
$ docker run --rm --net=host hashicorpnomad/counter-api:test
|
||||
$ docker run --rm --net=host --env COUNTING_SERVICE_URL="http://localhost:9001" hashicorpnomad/counter-dashboard:test
|
||||
```
|
||||
|
||||
#### Upload to Docker Hub
|
||||
```bash
|
||||
# replace <version> with the next version number
|
||||
docker login
|
||||
docker build -t hashicorpnomad/counter-dashboard:<version> .
|
||||
docker push hashicorpnomad/counter-dashboard:<version>
|
||||
```
|
|
@ -1,25 +0,0 @@
|
|||
FROM golang:alpine as builder
|
||||
WORKDIR /build
|
||||
ADD ./Dockerfile /build
|
||||
|
||||
RUN apk add git && \
|
||||
git clone -b 0.0.3 https://github.com/hashicorp/demo-consul-101.git
|
||||
|
||||
WORKDIR /build/demo-consul-101/services/counting-service
|
||||
ADD ./go.mod .
|
||||
|
||||
RUN go version && \
|
||||
go env && \
|
||||
go generate && \
|
||||
GO111MODULE=on CGO_ENABLED=0 GOOS=linux go build
|
||||
|
||||
FROM alpine:latest
|
||||
MAINTAINER nomadproject.io
|
||||
|
||||
WORKDIR /opt
|
||||
COPY --from=builder /build/demo-consul-101/services/counting-service/counter-api /opt
|
||||
|
||||
EXPOSE 9001
|
||||
ENV PORT 9001
|
||||
|
||||
ENTRYPOINT ["/opt/counter-api"]
|
|
@ -1 +0,0 @@
|
|||
module nomadproject.io/demo/counter-api
|
|
@ -1,26 +0,0 @@
|
|||
FROM golang:alpine as builder
|
||||
WORKDIR /build
|
||||
ADD ./Dockerfile /build
|
||||
|
||||
RUN apk add git && \
|
||||
git clone -b 0.0.3 https://github.com/hashicorp/demo-consul-101.git
|
||||
|
||||
WORKDIR /build/demo-consul-101/services/dashboard-service
|
||||
ADD ./go.mod .
|
||||
|
||||
RUN go version && \
|
||||
go env && \
|
||||
go generate && \
|
||||
GO111MODULE=on go run github.com/GeertJohan/go.rice/rice embed-go && \
|
||||
GO111MODULE=on CGO_ENABLED=0 GOOS=linux go build
|
||||
|
||||
FROM alpine:latest
|
||||
MAINTAINER nomadproject.io
|
||||
|
||||
WORKDIR /opt
|
||||
COPY --from=builder /build/demo-consul-101/services/dashboard-service/counter-dashboard /opt
|
||||
|
||||
EXPOSE 9002
|
||||
ENV PORT 9002
|
||||
|
||||
ENTRYPOINT ["/opt/counter-dashboard"]
|
|
@ -1,5 +0,0 @@
|
|||
module nomadproject.io/demo/counter-dashboard
|
||||
|
||||
require (
|
||||
github.com/GeertJohan/go.rice v1.0.0
|
||||
)
|
1
demo/grpc-checks/.gitignore
vendored
1
demo/grpc-checks/.gitignore
vendored
|
@ -1 +0,0 @@
|
|||
grpc-checks
|
|
@ -1,18 +0,0 @@
|
|||
FROM golang:alpine as builder
|
||||
WORKDIR /build
|
||||
ADD . /build
|
||||
RUN apk add protoc && \
|
||||
go get -u github.com/golang/protobuf/protoc-gen-go
|
||||
RUN go version && \
|
||||
go env && \
|
||||
go generate && \
|
||||
CGO_ENABLED=0 GOOS=linux go build
|
||||
|
||||
FROM alpine:latest
|
||||
MAINTAINER nomadproject.io
|
||||
|
||||
WORKDIR /opt
|
||||
COPY --from=builder /build/grpc-checks /opt
|
||||
|
||||
ENTRYPOINT ["/opt/grpc-checks"]
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
# grpc-checks
|
||||
|
||||
An example service that exposes a gRPC healthcheck endpoint
|
||||
|
||||
### generate protobuf
|
||||
|
||||
Note that main.go also includes this as a go:generate directive
|
||||
so that running this by hand is not necessary
|
||||
|
||||
```bash
|
||||
$ protoc -I ./health ./health/health.proto --go_out=plugins=grpc:health
|
||||
```
|
||||
|
||||
### build & run example
|
||||
|
||||
Generate, compile, and run the example server.
|
||||
|
||||
```bash
|
||||
go generate
|
||||
go build
|
||||
go run main.go
|
||||
```
|
||||
|
||||
### publish
|
||||
|
||||
#### Testing locally
|
||||
```bash
|
||||
$ docker build -t hashicorpnomad/grpc-checks:test .
|
||||
$ docker run --rm hashicorpnomad/grpc-checks:test
|
||||
```
|
||||
|
||||
#### Upload to Docker Hub
|
||||
```bash
|
||||
# replace <version> with the next version number
|
||||
docker login
|
||||
$ docker build -t hashicorpnomad/grpc-checks:<version> .
|
||||
$ docker push hashicorpnomad/grpc-checks:<version>
|
||||
```
|
|
@ -1,31 +0,0 @@
|
|||
package example
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
|
||||
ghc "google.golang.org/grpc/health/grpc_health_v1"
|
||||
)
|
||||
|
||||
// Server is a trivial gRPC server that implements the standard grpc.health.v1
|
||||
// interface.
|
||||
type Server struct {
|
||||
}
|
||||
|
||||
func New() *Server {
|
||||
return new(Server)
|
||||
}
|
||||
|
||||
func (s *Server) Check(ctx context.Context, hcr *ghc.HealthCheckRequest) (*ghc.HealthCheckResponse, error) {
|
||||
log.Printf("Check:%s (%s)", hcr.Service, hcr.String())
|
||||
return &ghc.HealthCheckResponse{
|
||||
Status: ghc.HealthCheckResponse_SERVING,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *Server) Watch(hcr *ghc.HealthCheckRequest, hws ghc.Health_WatchServer) error {
|
||||
log.Printf("Watch:%s (%s)", hcr.Service, hcr.String())
|
||||
return hws.Send(&ghc.HealthCheckResponse{
|
||||
Status: ghc.HealthCheckResponse_SERVING,
|
||||
})
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
module github.com/hashicorp/nomad/demo/grpc-checks
|
||||
|
||||
go 1.14
|
||||
|
||||
require (
|
||||
github.com/golang/protobuf v1.3.5
|
||||
google.golang.org/grpc v1.28.1
|
||||
)
|
|
@ -1,53 +0,0 @@
|
|||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
||||
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
||||
github.com/golang/protobuf v1.3.5 h1:F768QJ1E9tib+q5Sc8MkdJi1RxLTbRcTf8LJV56aRls=
|
||||
github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
github.com/hashicorp/nomad v0.11.1 h1:ow411q+bAduxC0X0V3NLx9slQzwG9wiB66yVzpQ0aEg=
|
||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55 h1:gSJIx1SDwno+2ElGhA4+qG2zF97qiUzTM+rQ0klBOcE=
|
||||
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
|
||||
google.golang.org/grpc v1.28.1 h1:C1QC6KzgSiLyBabDi87BbjaGreoRgGUF5nOyvfrAZ1k=
|
||||
google.golang.org/grpc v1.28.1/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
|
@ -1,40 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net"
|
||||
"os"
|
||||
|
||||
"github.com/hashicorp/nomad/demo/grpc-checks/example"
|
||||
"google.golang.org/grpc"
|
||||
ghc "google.golang.org/grpc/health/grpc_health_v1"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
port := os.Getenv("GRPC_HC_PORT")
|
||||
if port == "" {
|
||||
port = "3333"
|
||||
}
|
||||
address := fmt.Sprintf(":%s", port)
|
||||
|
||||
log.Printf("creating tcp listener on %s", address)
|
||||
listener, err := net.Listen("tcp", address)
|
||||
if err != nil {
|
||||
log.Printf("unable to create listener: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
log.Printf("creating grpc server")
|
||||
grpcServer := grpc.NewServer()
|
||||
|
||||
log.Printf("registering health server")
|
||||
ghc.RegisterHealthServer(grpcServer, example.New())
|
||||
|
||||
log.Printf("listening ...")
|
||||
if err := grpcServer.Serve(listener); err != nil {
|
||||
log.Printf("unable to listen: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue