Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

build: using egoscale dev branch #13

Merged
merged 29 commits into from
Apr 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
6bcf32a
doc: add example on how to setup using cloud-init (#15)
greut Dec 20, 2017
37e18e9
CoreOS or Container Linux is moving away from cloud-init
Dec 20, 2017
8f06ef5
install using godep for management (#16)
greut Jan 3, 2018
32e821e
add down to ifconfig
Jan 4, 2018
ed76b16
fix: golint issues
Jan 8, 2018
5da9615
travis: enable codeclimate
Jan 5, 2018
9bc4def
adapt to egoscale@dev
Jan 8, 2018
3ff037b
cli: fix codeclimate
Jan 8, 2018
aac1a5e
travis: exoip doesn't need any darwin/win test
Jan 8, 2018
8a79093
egoscale: update vendor
Jan 11, 2018
a84ecc7
metadata: do not call `ip route`
Mar 22, 2018
1943103
adapt to latest egoscale
Apr 3, 2018
4836630
go back to linuxkit/ca-certificates
Apr 3, 2018
dd82811
make: add internal registry
Apr 4, 2018
599356a
attempt to fix stuff
Apr 5, 2018
1454fc2
update list-vms
Apr 6, 2018
c21f21c
makefile: index generated files
Apr 6, 2018
43c848f
global: refactor to feel like reading the godoc
Apr 6, 2018
2580f9c
global: change everything...
Apr 6, 2018
e2d6edb
engine: loading peers from SecurityGroup
Apr 6, 2018
fd16d42
codeclimate: be quiet
Apr 6, 2018
7033836
engine: fix tests
Apr 9, 2018
0b31e1e
cmd: listen to SIGTERM,SIGINT
Apr 9, 2018
c75da06
protect the list of Peers with a RWMutex
Apr 10, 2018
9e627ed
upgrade egoscale
Apr 10, 2018
f3dff43
engine: remove peers when doing the update
Apr 10, 2018
3cc97ba
remplace int64 by time.Time and time.Duration
Apr 10, 2018
4137b65
upgrade egoscale
Apr 13, 2018
56fc8af
readme: move cmd to a nicer location
Apr 13, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
version: "2"

checks:
argument-count:
enabled: false
complex-logic:
enabled: false
file-lines:
enabled: false
method-complexity:
enabled: false
method-count:
enabled: false
method-lines:
enabled: false
nested-control-flow:
enabled: false
return-statements:
enabled: false
similar-code:
enabled: false
identical-code:
enabled: false

plugins:
gofmt:
enabled: true
golint:
enabled: true
govet:
enabled: true
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ README.md
bin
src
pkg
vendor
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
bin
build
pkg
src
vendor
.gopath
13 changes: 8 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ go:

cache: apt

before_install:
- go get -u github.com/golang/dep/cmd/dep
- npm i -g codeclimate-test-reporter

install:
- go get -u github.com/golang/lint/golint
- make deps

script:
- make
- test `gofmt -s -d . | tee -a /dev/fd/2 | wc -l` -eq 0
- # test `bin/golint . | tee -a /dev/fd/2 | wc -l` -eq 0
- go tool vet .
- # go test -v .
- go test -race -coverprofile=coverage.out -covermode=atomic .

after_success:
- codeclimate-test-reporter < coverage.out
27 changes: 15 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
FROM golang:1.9-alpine3.7 as build
FROM golang:1.10-alpine as build

RUN mkdir -p /app
ADD . /app
WORKDIR /app
LABEL org.label-schema.name="ExoIP" \
org.label-schema.description="IP watchdog" \
org.label-schema.url="https://github.com/exoscale/exoip" \
org.label-schema.schema-version="1.0"

RUN mkdir -p /go/src/github.com/exoscale/exoip
ADD . /go/src/github.com/exoscale/exoip
WORKDIR /go/src/github.com/exoscale/exoip

RUN apk add --no-cache \
--update \
--virtual build-dependencies \
make \
git \
&& cd /app \
&& make deps \
&& make build/exoip-static
&& go get github.com/golang/dep/cmd/dep \
&& cd /go/src/github.com/exoscale/exoip \
&& dep ensure \
&& CGO_ENABLED=0 GOOS=linux go install -ldflags "-s" github.com/exoscale/exoip/cmd/exoip


FROM alpine:3.7
COPY --from=build /app/build/exoip-static exoip
RUN apk add --no-cache \
ca-certificates \
iproute2
FROM linuxkit/ca-certificates:v0.2
COPY --from=build /go/bin/exoip exoip

ENTRYPOINT ["./exoip", "-O"]
42 changes: 42 additions & 0 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[[constraint]]
name = "github.com/exoscale/egoscale"
version = "0.9.20"

[[constraint]]
name = "github.com/vishvananda/netlink"
version = "1.0.0"
72 changes: 54 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,27 +1,65 @@
VERSION=0.3.5-snapshot
PKG=exoip
PKG=github.com/exoscale/exoip

MAIN=cmd/$(PKG).go
GIMME_OS?=linux
GIMME_ARCH?=amd64


MAIN=exoip
CLI=cmd/$(MAIN)/main.go
SRCS=$(wildcard *.go)

DEST=build
BIN=$(DEST)/$(PKG)
BIN=$(DEST)/$(MAIN)
BINS=\
$(BIN) \
$(BIN)-static

RM?=rm -f
LN=ln -s
GOPATH=$(CURDIR)/.gopath
DEP=$(GOPATH)/bin/dep

export GOPATH := $(PWD)
export GOPATH
export PATH := $(PATH):$(GOPATH)/bin

RM?=rm -f

all: $(BIN)

$(BIN): $(MAIN) $(SRCS)
go build -o $@ $<
$(GOPATH)/src/$(PKG):
mkdir -p $(GOPATH)
go get -u github.com/golang/dep/cmd/dep
mkdir -p $(shell dirname $(GOPATH)/src/$(PKG))
ln -sf ../../../.. $(GOPATH)/src/$(PKG)

.phony: deps
deps: $(GOPATH)/src/$(PKG)
(cd $(GOPATH)/src/$(PKG) && \
$(DEP) ensure)

.phony: deps-status
deps-status: $(GOPATH)/src/$(PKG)
(cd $(GOPATH)/src/$(PKG) && \
$(DEP) status)

.phony: deps-update
deps-update: deps
(cd $(GOPATH)/src/$(PKG) && \
$(DEP) ensure -update)

.phony: generate
generate: deps
go get -u golang.org/x/tools/cmd/stringer
(cd $(GOPATH)/src/$(PKG) && \
go generate)

$(BIN): $(CLI) $(SRCS)
(cd $(GOPATH)/src/$(PKG) && \
go build -o $@ $<)

$(BIN)-static: $(MAIN) $(SRCS)
CGO_ENABLED=0 GOOS=linux go build -ldflags "-s" -o $@ $<
$(BIN)-static: $(CLI) $(SRCS)
(cd $(GOPATH)/src/$(PKG) && \
CGO_ENABLED=0 GOOS=$(GIMME_OS) GOARCH=$(GIMME_ARCH) \
go build -ldflags "-s" -o $@ $<)

clean:
$(RM) -r $(DEST)
Expand All @@ -33,12 +71,10 @@ signature: $(BINS)
$(RM) $(bin).asc; \
gpg -a --sign -u ops@exoscale.ch --detach $(bin);)

.PHONY: cleandeps
cleandeps: clean
$(RM) -r src
.PHONY: docker
docker:
docker build --tag exoscale/exoip:$(VERSION) .

.PHONY: deps
deps:
go get github.com/exoscale/egoscale
$(RM) src/github.com/exoscale/$(PKG)
$(LN) $(GOPATH) src/github.com/exoscale/$(PKG)
.PHONY: internal-docker
internal-docker:
docker build --tag registry.internal.exoscale.ch/exoscale/exoip:$(VERSION) .
61 changes: 54 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ least two peers will participate in the election process.


**exoip** uses a protocol very similar to
[CARP](http://en.wikipedia.org/wiki/Common_Addresss_Redundancy_Protocol)
[CARP](http://en.wikipedia.org/wiki/Common_Address_Redundancy_Protocol)
and to some extent
[VRRP](http://en.wikipedia.org/wiki/Virtual_Router_Redundancy_Protocol).

Expand Down Expand Up @@ -77,9 +77,56 @@ environment variable:

## Building

If you wish to inspect **exoip** and build it by yourself, you may do so
by cloning [this repository](https://github.com/exoscale/exoip) and
peforming the following steps:

make deps
make
If you wish to inspect **exoip** and build it by yourself, you can install it by using `go get`.

go get -u github.com/exoscale/exoip/cmd/exoip

### Updating

It uses [godep](https://github.com/golang/dep), so it should be easy.

dep status
dep ensure -update

## Setup using Cloud Init

As shown in the [HAProxy Elastic IP Automatic
failover](https://www.exoscale.ch/syslog/2017/02/07/haproxy-elastic-ip-automatic-failover/)
article, `exoip` can be setup as a _dummy_ net interface. Below is the article
configuration described using [Cloud Init](http://cloudinit.readthedocs.io/)
(supported by Ubuntu, Debian, RHEL, CentOS, etc.)

```yaml
#cloud-config

package_update: true
package_upgrade: true

packages:
- ifupdown

write_files:
- path: /etc/network/interfaces
content: |
source /etc/network/interfaces.d/*.cfg
- path: /etc/network/interfaces.d/51-exoip.cfg
content: |
auto lo:1
iface lo:1 inet static
address 198.51.100.50 # change me
netmask 255.255.255.255
exoscale-peer-group load-balancer # change me
exoscale-api-key EXO.... # change me
exoscale-api-secret LZ... # change me
up /usr/local/bin/exoip -W &
down killall exoip

runcmd:
- wget https://github.com/exoscale/exoip/releases/download/0.3.5/exoip
- wget https://github.com/exoscale/exoip/releases/download/0.3.5/exoip.asc
- gpg --recv-keys E458F9F85608DF5A22ECCD158B58C61D4FFE0C86
- gpg --verify --trust-model always exoip.asc
- sudo chmod +x exoip
- sudo mv exoip /usr/local/bin/
- sudo ifup lo:1
```
Loading