diff --git a/.github/workflows/goreleaser.yml b/.github/workflows/goreleaser.yml new file mode 100644 index 0000000..ca3370b --- /dev/null +++ b/.github/workflows/goreleaser.yml @@ -0,0 +1,33 @@ +name: goreleaser + +on: + push: + tags: + - v* + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Set up environment variables + run: | + echo "VERSION=$(git describe --tags $(git rev-list --tags --max-count=1))" >> $GITHUB_ENV + + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.15 + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v2 + with: + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a46707c --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +vendor/ +docker-cni +dist/ diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..3e78870 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,37 @@ +before: + hooks: + - go mod download + +builds: + - binary: docker-cni + env: + - CGO_ENABLED=0 + ldflags: + - -X main.REVISION={{.Commit}} + - -X main.VERSION={{.Env.VERSION}} + - -X main.BUILTAT={{.Date}} + goos: + - linux + goarch: + - amd64 + +archives: + - replacements: + linux: Linux + amd64: x86_64 + +checksum: + name_template: 'checksums.txt' + +release: + prerelease: auto + +snapshot: + name_template: "{{ .Tag }}-next" + +changelog: + sort: asc + filters: + exclude: + - '^docs:' + - '^test:' diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3055f79 --- /dev/null +++ b/Makefile @@ -0,0 +1,17 @@ +.PHONY: binary + +REVISION := $(shell git rev-parse HEAD || unknown) +BUILTAT := $(shell date +%Y-%m-%dT%H:%M:%S) +VERSION := $(shell git describe --tags $(shell git rev-list --tags --max-count=1)) +GO_LDFLAGS ?= -X main.REVISION=$(REVISION) \ + -X main.BUILTAT=$(BUILTAT) \ + -X main.VERSION=$(VERSION) + +deps: + env GO111MODULE=on go mod download + env GO111MODULE=on go mod vendor + +binary: + CGO_ENABLED=0 go build -ldflags "$(GO_LDFLAGS)" -o docker-cni + +build: deps binary diff --git a/README.md b/README.md index 0ea3e66..3a8c427 100644 --- a/README.md +++ b/README.md @@ -2,12 +2,78 @@ This repo aims to integrate [CNI](https://github.com/containernetworking/cni) with Dockerd. -There is, [according to CNI repo](https://github.com/containernetworking/cni/blob/master/scripts/docker-run.sh), an approach to integrate by running a [pause] equivalent container ahead of the application container, but that's too pod-like for those who resent pod models. +There is, [according to CNI repo](https://github.com/containernetworking/cni/blob/master/scripts/docker-run.sh), an approach to integrate by running a [pause](https://groups.google.com/g/kubernetes-users/c/jVjv0QK4b_o) equivalent container ahead of the application container, but that's too pod-like for those who resent pod models. Let's figure out yet another solution. # Usage +## 0. Prepare your CNI plugin + +Make sure you have everything ready: + +1. CNI binaries in the right place: for example, `/opt/cni/bin/calico` and `/opt/cni/bin/calico-ipam` binaries +2. CNI configures in the right place: for exmaple, `/etc/cni/net.d/10-calico.conf` +3. Other services needed: for example, `calico-node` container + +Notes: + +1. Provided there are multiple CNI configures in the dir, `docker-cni` will only use the first config in alphabet order. + ## 1. Configure docker-cni +### 1.1 install docker-cni binary + +Download the latest binary from [release](https://github.com/projecteru2/docker-cni/releases). + +### 1.2 docker-cni configuration + +```shell +mkdir -p /etc/docker/ +cat <