forked from hetznercloud/hcloud-cloud-controller-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hetzner Cloud Load Balancer support (hetznercloud#49)
Closes hetznercloud#48 Co-authored-by: Lukas Kämmerling <[email protected]>
- Loading branch information
1 parent
e9e21be
commit df90212
Showing
45 changed files
with
5,977 additions
and
412 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,23 @@ | ||
--- | ||
name: Run tests | ||
on: [push] | ||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/setup-go@v1 | ||
with: | ||
go-version: '1.12' | ||
- uses: actions/checkout@master | ||
- name: Run tests | ||
run: | | ||
docker pull lkdevelopment/hetzner-cloud-api-mock | ||
docker run -d -p 127.0.0.1:4000:8080 lkdevelopment/hetzner-cloud-api-mock | ||
docker ps -a | ||
go vet ./... | ||
go test ./... | ||
- uses: actions/setup-go@v1 | ||
with: | ||
go-version: '1.14' | ||
- uses: actions/checkout@master | ||
- name: Run tests | ||
run: | | ||
docker pull lkdevelopment/hetzner-cloud-api-mock | ||
docker run -d -p 127.0.0.1:4000:8080 lkdevelopment/hetzner-cloud-api-mock | ||
docker ps -a | ||
go vet ./... | ||
go test ./... | ||
env: | ||
API_MOCK_PORT: 4000 | ||
API_MOCK_SOURCE: https://docs-internal.staging.hc-k8s.de/hc_public_internal.apib | ||
HCLOUD_ENDPOINT: http://127.0.0.1:4000/v1 | ||
HCLOUD_TOKEN: "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
/bin | ||
/vendor | ||
/vendor | ||
.coverage.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--- | ||
include: | ||
- project: "hc/backend/deploy-tools" | ||
file: "ci/release/image.yml" | ||
- project: "hc/backend/deploy-tools" | ||
file: "ci/build/image.yml" | ||
|
||
|
||
stages: | ||
- test | ||
- build | ||
- release | ||
|
||
variables: | ||
GOPROXY: goproxy.prodext.hcinfra.de | ||
GONOSUMDB: hetzner.cloud | ||
|
||
test:lint: | ||
stage: test | ||
image: golangci/golangci-lint:v1.27.0 | ||
allow_failure: true | ||
script: | ||
- golangci-lint run -v | ||
except: | ||
- tags | ||
- master | ||
tags: | ||
- hc-bladerunner | ||
|
||
test:unit: | ||
stage: test | ||
image: golang:1.14 | ||
services: | ||
- name: lkdevelopment/hetzner-cloud-api-mock:latest | ||
alias: api-mock | ||
variables: | ||
API_MOCK_PORT: 4000 | ||
API_MOCK_SOURCE: https://docs-internal.staging.hc-k8s.de/hc_public_internal.apib | ||
HCLOUD_ENDPOINT: http://api-mock:4000/v1 | ||
HCLOUD_TOKEN: "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" | ||
NODE_NAME: "test" | ||
script: | ||
- GO_PACKAGES=$(command go list ./... | tr "\n" ",") | ||
- go test -race -covermode=atomic -coverprofile=.coverage.out ./... 2> /dev/null | ||
- go tool cover -func=.coverage.out | tail -n1 | ||
coverage: '/total:[^\d]+(\d+\.\d+%)/' | ||
tags: | ||
- hc-bladerunner |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
--- | ||
linters-settings: | ||
errcheck: | ||
exclude: ./.errcheck_excludes.txt | ||
gocyclo: | ||
min-complexity: 15 | ||
misspell: | ||
locale: "US" | ||
|
||
linters: | ||
disable-all: true | ||
enable: | ||
- bodyclose | ||
- deadcode | ||
- depguard | ||
- errcheck | ||
- gocritic | ||
- gocyclo | ||
- goimports | ||
- golint | ||
- gosec | ||
- gosimple | ||
- govet | ||
- ineffassign | ||
- misspell | ||
- prealloc | ||
- rowserrcheck | ||
- scopelint | ||
- staticcheck | ||
- structcheck | ||
- typecheck | ||
- unparam | ||
- unused | ||
- varcheck | ||
- whitespace | ||
|
||
issues: | ||
include: | ||
- EXC0002 # disable excluding of issues about comments from golint | ||
|
||
exclude-rules: | ||
- path: _test\.go | ||
linters: | ||
- gosec | ||
- linters: | ||
- gosec | ||
text: "G204:" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* @LKaemmerling @fhofherr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,8 @@ | ||
FROM golang:1.12 as builder | ||
FROM golang:1.14 as builder | ||
WORKDIR /maschine-controller/src | ||
ADD . . | ||
RUN go mod download | ||
RUN CGO_ENABLED=0 go build -o hcloud-maschine-controller.bin . | ||
|
||
|
||
FROM alpine:3.9 | ||
FROM alpine:3.11 | ||
RUN apk add --no-cache ca-certificates bash | ||
COPY --from=builder /maschine-controller/src/hcloud-maschine-controller.bin /bin/hcloud-cloud-controller-manager | ||
ENTRYPOINT ["/bin/hcloud-cloud-controller-manager"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Load Balancers | ||
|
||
Load Balancer support is implemented in the Cloud Controller as of | ||
version v1.6.0. For using the Hetzner Cloud Load Balancers you need to | ||
deploy a `Service` of type `LoadBalancer`. | ||
|
||
## Sample Service: | ||
|
||
``` | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: example-service | ||
annotations: | ||
load-balancer.hetzner.cloud/location: hel1 | ||
spec: | ||
selector: | ||
app: example | ||
ports: | ||
- port: 80 | ||
targetPort: 8080 | ||
type: LoadBalancer | ||
``` | ||
|
||
The sample service will create a Load Balancer in the location `hel1` | ||
with a service with `listen_port = 80` and `destination_port = 8080`. So | ||
every traffic that arrives at the Load Balancer on Port 80 will be | ||
routed to the public interface of the targets on port 8080. You can | ||
change the behavior of the Load Balancer by specifying more annotations. | ||
A list of all available annotations can be found on | ||
[pkg.go.dev](https://pkg.go.dev/github.com/hetznercloud/hcloud-cloud-controller-manager/internal/annotation). | ||
If you have the cloud controller deployed with Private Network Support, | ||
we attach the Load Balancer to the specific network automatically. You | ||
can specifiy with an annotation that the Load Balancer should use the | ||
private network instead of the public network. | ||
|
||
## Sample Service with Networks: | ||
|
||
``` | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: example-service | ||
annotations: | ||
load-balancer.hetzner.cloud/location: hel1 | ||
load-balancer.hetzner.cloud/use-private-ip: "true" | ||
spec: | ||
selector: | ||
app: example | ||
ports: | ||
- port: 80 | ||
targetPort: 8080 | ||
type: LoadBalancer | ||
``` | ||
|
||
|
Oops, something went wrong.