-
Notifications
You must be signed in to change notification settings - Fork 278
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from ibuildthecloud/master
Initial code commit
- Loading branch information
Showing
18 changed files
with
2,407 additions
and
0 deletions.
There are no files selected for viewing
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,3 @@ | ||
./.dapper | ||
./.cache | ||
./dist |
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,157 @@ | ||
--- | ||
kind: pipeline | ||
name: amd64 | ||
|
||
platform: | ||
os: linux | ||
arch: amd64 | ||
|
||
steps: | ||
- name: build | ||
image: rancher/dapper:v0.5.0 | ||
commands: | ||
- dapper -f Dockerfile --target dapper make dapper-ci | ||
volumes: | ||
- name: docker | ||
path: /var/run/docker.sock | ||
|
||
- name: github_binary_release | ||
image: plugins/github-release | ||
settings: | ||
api_key: | ||
from_secret: github_token | ||
prerelease: true | ||
checksum: | ||
- sha256 | ||
checksum_file: CHECKSUMsum-amd64.txt | ||
checksum_flatten: true | ||
files: | ||
- "dist/artifacts/*" | ||
when: | ||
instance: | ||
- drone-publish.rancher.io | ||
ref: | ||
- refs/head/master | ||
- refs/tags/* | ||
event: | ||
- tag | ||
|
||
- name: docker-publish | ||
image: plugins/docker | ||
settings: | ||
dockerfile: Dockerfile | ||
password: | ||
from_secret: docker_password | ||
repo: "rancher/rke2-runtime" | ||
tag: "${DRONE_TAG}-amd64" | ||
username: | ||
from_secret: docker_username | ||
when: | ||
instance: | ||
- drone-publish.rancher.io | ||
ref: | ||
- refs/head/master | ||
- refs/tags/* | ||
event: | ||
- tag | ||
|
||
volumes: | ||
- name: docker | ||
host: | ||
path: /var/run/docker.sock | ||
|
||
--- | ||
kind: pipeline | ||
name: arm64 | ||
|
||
platform: | ||
os: linux | ||
arch: arm64 | ||
|
||
steps: | ||
- name: build | ||
image: rancher/dapper:v0.5.0 | ||
commands: | ||
- dapper -f Dockerfile --target dapper make dapper-ci | ||
volumes: | ||
- name: docker | ||
path: /var/run/docker.sock | ||
|
||
- name: github_binary_release | ||
image: plugins/github-release | ||
settings: | ||
api_key: | ||
from_secret: github_token | ||
prerelease: true | ||
checksum: | ||
- sha256 | ||
checksum_file: CHECKSUMsum-arm64.txt | ||
checksum_flatten: true | ||
files: | ||
- "dist/artifacts/*" | ||
when: | ||
instance: | ||
- drone-publish.rancher.io | ||
ref: | ||
- refs/head/master | ||
- refs/tags/* | ||
event: | ||
- tag | ||
|
||
- name: docker-publish | ||
image: plugins/docker | ||
settings: | ||
dockerfile: Dockerfile | ||
password: | ||
from_secret: docker_password | ||
repo: "rancher/rke2-runtime" | ||
tag: "${DRONE_TAG}-arm64" | ||
username: | ||
from_secret: docker_username | ||
when: | ||
instance: | ||
- drone-publish.rancher.io | ||
ref: | ||
- refs/head/master | ||
- refs/tags/* | ||
event: | ||
- tag | ||
|
||
volumes: | ||
- name: docker | ||
host: | ||
path: /var/run/docker.sock | ||
|
||
--- | ||
kind: pipeline | ||
name: manifest | ||
|
||
platform: | ||
os: linux | ||
arch: amd64 | ||
|
||
steps: | ||
- name: manifest | ||
image: plugins/manifest:1.0.2 | ||
settings: | ||
username: | ||
from_secret: docker_username | ||
password: | ||
from_secret: docker_password | ||
platforms: | ||
- linux/amd64 | ||
- linux/arm64 | ||
target: "rancher/rke2-runtime:${DRONE_TAG}" | ||
template: "rancher/rke2-runtime:${DRONE_TAG}-ARCH" | ||
when: | ||
instance: | ||
- drone-publish.rancher.io | ||
ref: | ||
- refs/head/master | ||
- refs/tags/* | ||
event: | ||
- tag | ||
|
||
depends_on: | ||
- amd64 | ||
- arm64 |
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,6 @@ | ||
/.dapper | ||
/.cache | ||
/bin | ||
/dist | ||
*.swp | ||
.idea |
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,19 @@ | ||
{ | ||
"linters": { | ||
"disable-all": true, | ||
"enable": [ | ||
"govet", | ||
"golint", | ||
"goimports", | ||
"misspell", | ||
"ineffassign", | ||
"gofmt" | ||
] | ||
}, | ||
"run": { | ||
"skip-files": [ | ||
"/zz_generated_" | ||
], | ||
"deadline": "5m" | ||
} | ||
} |
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,54 @@ | ||
# Build environment | ||
FROM golang:1.14.2 AS build | ||
# Yep nothing special here yet | ||
|
||
# Shell used for debugging | ||
FROM build AS shell | ||
RUN apt-get update && \ | ||
apt-get install -y iptables socat vim | ||
VOLUME /var/lib/rancher/rke2 | ||
|
||
# Dapper/Drone/CI environment | ||
FROM build AS dapper | ||
ENV DAPPER_ENV REPO TAG DRONE_TAG | ||
ENV DAPPER_OUTPUT ./bin ./dist | ||
ENV DAPPER_DOCKER_SOCKET true | ||
ENV DAPPER_TARGET dapper | ||
ENV DAPPER_RUN_ARGS "-v rke2-pkg:/go/pkg -v rke2-cache:/root/.cache/go-build" | ||
WORKDIR /source | ||
# End Dapper stuff | ||
|
||
# rke-runtime Dockerfile. This image includes any host level programs that we might need. All binaries | ||
# must be placed in bin/ of the file image and subdirectories of bin/ will be flattened during installation. | ||
# This means bin/foo/bar will become bin/bar when rke2 installs this to the host | ||
|
||
FROM k8s.gcr.io/hyperkube:v1.18.2 AS k8s | ||
FROM rancher/k3s:v1.18.2-rc2-k3s1 AS k3s | ||
|
||
FROM ubuntu:18.04 AS containerd | ||
|
||
ENV CONTAINERD_VERION=1.3.4 | ||
ENV CONTAINERD_URL=https://github.com/containerd/containerd/releases/download/v${CONTAINERD_VERION}/containerd-${CONTAINERD_VERION}.linux-amd64.tar.gz | ||
ENV CONTAINERD_HASH=61e65c9589e5abfded1daa353e6dfb4b8c2436199bbc5507fc45809a3bb80c1d | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y curl | ||
RUN curl -O -fL ${CONTAINERD_URL} | ||
RUN echo "${CONTAINERD_HASH} $(basename $CONTAINERD_URL)" | sha256sum -c - | ||
RUN tar xvf $(basename ${CONTAINERD_URL}) -C /usr/local | ||
|
||
FROM scratch AS release | ||
COPY --from=k8s \ | ||
/usr/local/bin/kubectl \ | ||
/usr/local/bin/kubelet \ | ||
/bin/ | ||
COPY --from=k3s \ | ||
/bin/runc \ | ||
/bin | ||
COPY --from=containerd \ | ||
/usr/local/bin/containerd-shim-runc-v2 \ | ||
/usr/local/bin/containerd \ | ||
/usr/local/bin/containerd-shim \ | ||
/usr/local/bin/ctr \ | ||
/usr/local/bin/containerd-shim-runc-v1 \ | ||
/bin |
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,131 @@ | ||
PROG=rke2 | ||
GOLANGCI_VERSION=v1.25.1 | ||
REPO ?= rancher | ||
IMAGE=${REPO}/rke2-runtime | ||
PKG=github.com/rancher/rke2 | ||
|
||
ifneq "$(strip $(shell command -v go 2>/dev/null))" "" | ||
GOOS ?= $(shell go env GOOS) | ||
GOARCH ?= $(shell go env GOARCH) | ||
else | ||
ifeq ($(GOOS),) | ||
# approximate GOOS for the platform if we don't have Go and GOOS isn't | ||
# set. We leave GOARCH unset, so that may need to be fixed. | ||
ifeq ($(OS),Windows_NT) | ||
GOOS = windows | ||
else | ||
UNAME_S := $(shell uname -s) | ||
ifeq ($(UNAME_S),Linux) | ||
GOOS = linux | ||
endif | ||
ifeq ($(UNAME_S),Darwin) | ||
GOOS = darwin | ||
endif | ||
ifeq ($(UNAME_S),FreeBSD) | ||
GOOS = freebsd | ||
endif | ||
endif | ||
else | ||
GOOS ?= $$GOOS | ||
GOARCH ?= $$GOARCH | ||
endif | ||
endif | ||
|
||
ifndef GODEBUG | ||
EXTRA_LDFLAGS += -s -w | ||
DEBUG_GO_GCFLAGS := | ||
DEBUG_TAGS := | ||
else | ||
DEBUG_GO_GCFLAGS := -gcflags=all="-N -l" | ||
endif | ||
|
||
VERSION=$(shell git describe --match 'v[0-9]*' --dirty='.m' --always) | ||
REVISION=$(shell git rev-parse HEAD)$(shell if ! git diff --no-ext-diff --quiet --exit-code; then echo .m; fi) | ||
RELEASE=${PROG}-$(VERSION:v%=%).${GOOS}-${GOARCH} | ||
|
||
ifdef BUILDTAGS | ||
GO_BUILDTAGS = ${BUILDTAGS} | ||
endif | ||
# Build tags seccomp, apparmor and selinux are needed by CRI plugin. | ||
GO_BUILDTAGS ?= todo | ||
GO_BUILDTAGS += ${DEBUG_TAGS} | ||
GO_TAGS=$(if $(GO_BUILDTAGS),-tags "$(GO_BUILDTAGS)",) | ||
GO_LDFLAGS=-ldflags '-X $(PKG)/version.Version=$(VERSION) -X $(PKG)/version.Revision=$(REVISION) -X $(PKG)/version.Package=$(PACKAGE) $(EXTRA_LDFLAGS)' | ||
|
||
|
||
default: in-docker-build ## Build using docker environment (default target) | ||
@echo "Run make help for info about other make targets" | ||
|
||
ci: in-docker-.ci ## Run CI locally | ||
|
||
ci-shell: clean .dapper ## Launch a shell in the CI environment to troubleshoot. Runs clean first | ||
@echo | ||
@echo '######################################################' | ||
@echo '# Run "make dapper-ci" to reproduce CI in this shell #' | ||
@echo '######################################################' | ||
@echo | ||
./.dapper -f Dockerfile --target dapper -s | ||
|
||
dapper-ci: .ci ## Used by Drone CI, does the same as "ci" but in a Drone way | ||
|
||
build: ## Build using host go tools | ||
go build ${DEBUG_GO_GCFLAGS} ${GO_GCFLAGS} ${GO_BUILD_FLAGS} -o bin/${PROG} ${GO_LDFLAGS} ${GO_TAGS} | ||
|
||
build-debug: ## Debug build using host go tools | ||
$(MAKE) GODEBUG=y build | ||
|
||
image: ## Build final docker image for push | ||
docker build -t ${REPO}/rke2-runtime:${VERSION} . | ||
|
||
bin/golangci-lint: | ||
curl -sL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s ${GOLANGCI_VERSION} | ||
|
||
validate: ## Run go fmt/vet | ||
go fmt ./... | ||
go vet ./... | ||
|
||
validate-ci: validate bin/golangci-lint ## Run more validation for CI | ||
./bin/golangci-lint run | ||
|
||
run: build-debug | ||
./bin/${PROG} server | ||
|
||
bin/dlv: | ||
go build -o bin/dlv github.com/go-delve/delve/cmd/dlv | ||
|
||
remote-debug: build-debug bin/dlv ## Run with remote debugging listening on :2345 | ||
./bin/dlv --listen=:2345 --headless=true --api-version=2 --accept-multiclient exec ./bin/${PROG} server | ||
|
||
.dev-shell-build: | ||
docker build -t ${PROG}-dev --target shell -f Dockerfile --target dapper . | ||
|
||
clean-cache: ## Clean up docker base caches used for development | ||
docker rm -fv ${PROG}-dev-shell | ||
docker volume rm ${PROG}-cache ${PROG}-pkg | ||
|
||
clean: ## Clean up workspace | ||
rm -rf bin dist | ||
|
||
dev-shell: .dev-shell-build ## Launch a development shell to run test builds | ||
docker run --rm --name ${PROG}-dev-shell -ti -v $${HOME}:$${HOME} -v ${PROG} -w $$(pwd) --privileged --net=host -v ${PROG}-pkg:/go/pkg -v ${PROG}-cache:/root/.cache/go-build ${PROG}-dev bash | ||
|
||
dev-shell-enter: ## Enter the development shell on another terminal | ||
docker exec -it ${PROG}-dev-shell bash | ||
|
||
.ci: validate-ci build | ||
mkdir -p dist/artifacts | ||
cp bin/${PROG} dist/artifacts/${RELEASE} | ||
|
||
in-docker-%: .dapper ## Advanced: wraps any target in Docker environment, for example: in-docker-build-debug | ||
mkdir -p bin/ dist/ | ||
./.dapper -f Dockerfile --target dapper make $* | ||
|
||
./.dapper: | ||
@echo Downloading dapper | ||
@curl -sL https://releases.rancher.com/dapper/v0.5.0/dapper-$$(uname -s)-$$(uname -m) > .dapper.tmp | ||
@@chmod +x .dapper.tmp | ||
@./.dapper.tmp -v | ||
@mv .dapper.tmp .dapper | ||
|
||
help: ## this help | ||
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) |
Oops, something went wrong.