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

Commit

Permalink
Init build
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanprodan committed Oct 29, 2019
1 parent 58e6cbd commit ea2782e
Show file tree
Hide file tree
Showing 7 changed files with 347 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@

# Output of the go coverage tool, specifically when used with LiteIDE
*.out
bin/
27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM golang:1.13 as builder

RUN mkdir -p /kxds/

WORKDIR /kxds

COPY . .

RUN go mod download

RUN CGO_ENABLED=0 GOOS=linux go build -a -o bin/kxds cmd/kxds/*

FROM alpine:3.10

RUN addgroup -S app \
&& adduser -S -g app app \
&& apk --no-cache add \
curl openssl netcat-openbsd

WORKDIR /home/app

COPY --from=builder /kxds/bin/kxds .
RUN chown -R app:app ./

USER app

CMD ["./kxds"]
17 changes: 17 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
TAG?=latest
VERSION?=$(shell grep 'VERSION' cmd/kxds/version.go | awk '{ print $$4 }' | tr -d '"' | head -n1)
NAME:=kxds
DOCKER_REPOSITORY:=stefanprodan
DOCKER_IMAGE_NAME:=$(DOCKER_REPOSITORY)/$(NAME)

run:
go run cmd/kxds/*.go serve --kubeconfig=$$HOME/.kube/config

envoy:
envoy -c envoy.yaml -l info

build-container:
docker build -t $(DOCKER_IMAGE_NAME):$(VERSION) .

push-container: build-container
docker push $(DOCKER_IMAGE_NAME):$(VERSION)
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,16 @@
# kxds
# kxds

KxDS is an Envoy discovery service implementation for Kubernetes services

## Features

* **Service Discovery** KxDS watches Kubernetes for ClusterIP services with a `http` named port
* **Envoy Clusters (CDS)** are generated for each Kubernetes service in the form `<name>-<namespace>-<http-port>`
* **Envoy Routes (RDS)** are generated for each cluster and mapped to the `<name>.<namespace>` domain
* **Envoy Listeners (LDS)** KxDS configures Envoy to listen on port 8080 and sets up retry policies for each route

## Install

```sh
kubectl apply -k github.com/stefanprodan/kxds//kustomize/envoy
```
37 changes: 37 additions & 0 deletions envoy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
node:
cluster: envoy
id: envoy

admin:
access_log_path: /dev/null
address:
socket_address:
address: 0.0.0.0
port_value: 9000

dynamic_resources:
ads_config:
api_type: GRPC
grpc_services:
- envoy_grpc:
cluster_name: xds
cds_config:
ads: {}
lds_config:
ads: {}

static_resources:
clusters:
- name: xds
connect_timeout: 0.30s
type: static
http2_protocol_options: {}
load_assignment:
cluster_name: xds
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: 127.0.0.1
port_value: 18000
19 changes: 19 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module github.com/stefanprodan/kxds

go 1.13

require (
github.com/envoyproxy/go-control-plane v0.9.0
github.com/gogo/protobuf v1.3.1
github.com/golang/protobuf v1.3.2
github.com/googleapis/gnostic v0.3.1 // indirect
github.com/imdario/mergo v0.3.8 // indirect
github.com/spf13/cobra v0.0.5
golang.org/x/time v0.0.0-20191024005414-555d28b269f0 // indirect
google.golang.org/grpc v1.23.0
k8s.io/api v0.0.0-20191025225708-5524a3672fbb
k8s.io/apimachinery v0.0.0-20191025225532-af6325b3a843
k8s.io/client-go v0.0.0-20190620085101-78d2af792bab
k8s.io/klog v1.0.0
k8s.io/utils v0.0.0-20191010214722-8d271d903fe4 // indirect
)
230 changes: 230 additions & 0 deletions go.sum

Large diffs are not rendered by default.

0 comments on commit ea2782e

Please sign in to comment.