Skip to content

Commit

Permalink
Merge pull request #12 from ibuildthecloud/master
Browse files Browse the repository at this point in the history
Initial development
  • Loading branch information
ibuildthecloud authored May 7, 2020
2 parents 735b38e + 1af745f commit 7a9a9c9
Show file tree
Hide file tree
Showing 19 changed files with 702 additions and 349 deletions.
15 changes: 10 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@ FROM golang:1.14.2 AS build
# Shell used for debugging
FROM build AS shell
RUN apt-get update && \
apt-get install -y iptables socat vim
apt-get install -y iptables socat vim bash-completion less psmisc libseccomp-dev sudo
RUN cp -f /etc/skel/.bashrc /etc/skel/.profile /root/ && \
echo 'alias abort="echo -e '\''q\ny\n'\'' | ./bin/dlv connect :2345"' >> /root/.bashrc
ENV PATH=/var/lib/rancher/rke2/bin:$PATH
ENV KUBECONFIG=/etc/rancher/k3s/k3s.yaml
VOLUME /var/lib/rancher/rke2
# This makes it so we can run and debug k3s too
VOLUME /var/lib/rancher/k3s

# Dapper/Drone/CI environment
FROM build AS dapper
Expand All @@ -18,18 +24,17 @@ 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
# rke-runtime image
# 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
ENV CONTAINERD_URL=https://github.com/containerd/containerd/releases/download/v${CONTAINERD_VERION}/containerd-${CONTAINERD_VERION}.linux-amd64.tar.gz

RUN apt-get update && \
apt-get install -y curl
Expand Down
24 changes: 17 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,10 @@ RELEASE=${PROG}-$(VERSION).${GOOS}-${GOARCH}
ifdef BUILDTAGS
GO_BUILDTAGS = ${BUILDTAGS}
endif
# Build tags seccomp, apparmor and selinux are needed by CRI plugin.
GO_BUILDTAGS ?= todo
GO_BUILDTAGS ?= no_embedded_executor
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)'
GO_LDFLAGS=-ldflags '-X $(PKG)/version.Program=$(PROG) -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)
Expand Down Expand Up @@ -87,17 +86,21 @@ validate: ## Run go fmt/vet
validate-ci: validate bin/golangci-lint ## Run more validation for CI
./bin/golangci-lint run

COMMAND ?= "server"
run: build-debug
./bin/${PROG} server
./bin/${PROG} ${COMMAND} ${ARGS}

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
CATTLE_DEV_MODE=true ./bin/dlv --listen=:2345 --headless=true --api-version=2 --accept-multiclient exec -- ./bin/${PROG} ${COMMAND} ${ARGS}

remote-debug-exit: bin/dlv ## Kill dlv started with make remote-debug
echo exit | ./bin/dlv connect :2345 --init /dev/stdin

.dev-shell-build:
docker build -t ${PROG}-dev --target shell -f Dockerfile --target dapper .
docker build -t ${PROG}-dev --target shell .

clean-cache: ## Clean up docker base caches used for development
docker rm -fv ${PROG}-dev-shell
Expand All @@ -107,11 +110,18 @@ 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
docker run --rm --name ${PROG}-dev-shell --hostname ${PROG}-server -ti -e WORKSPACE=$$(pwd) -p 127.0.0.1:2345:2345 -v $${HOME}:$${HOME} -v ${PROG} -w $$(pwd) --privileged -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

PEER ?= 1
dev-peer: .dev-shell-build ## Launch a server peer to run test builds
docker run --rm --link ${PROG}-dev-shell:${PROG}-server --name ${PROG}-peer${PEER} --hostname ${PROG}-peer${PEER} -p 127.0.0.1:234${PEER}:2345 -ti -e WORKSPACE=$$(pwd) -v $${HOME}:$${HOME} -v ${PROG} -w $$(pwd) --privileged -v ${PROG}-pkg:/go/pkg -v ${PROG}-cache:/root/.cache/go-build ${PROG}-dev bash

dev-peer-enter: ## Enter the peer shell on another terminal
docker exec -it ${PROG}-peer${PEER} bash

artifacts: build
mkdir -p dist/artifacts
cp bin/${PROG} dist/artifacts/${RELEASE}
Expand Down
15 changes: 7 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ module github.com/rancher/rke2
go 1.14

replace (
github.com/Azure/go-autorest => github.com/Azure/go-autorest v14.0.0+incompatible

github.com/Microsoft/hcsshim => github.com/Microsoft/hcsshim v0.8.7-0.20190926181021-82c7525d98c8
github.com/containerd/btrfs => github.com/containerd/btrfs v0.0.0-20181101203652-af5082808c83
github.com/containerd/cgroups => github.com/containerd/cgroups v0.0.0-20190717030353-c4b9ac5c7601
github.com/containerd/console => github.com/containerd/console v0.0.0-20181022165439-0650fd9eeb50
github.com/containerd/containerd => github.com/rancher/containerd v1.3.3-k3s2
github.com/containerd/continuity => github.com/containerd/continuity v0.0.0-20190815185530-f2a389ac0a02
github.com/containerd/cri => github.com/rancher/cri v1.3.0-k3s.5
github.com/containerd/cri => github.com/rancher/cri v1.3.0-k3s.6
github.com/containerd/fifo => github.com/containerd/fifo v0.0.0-20190816180239-bda0ff6ed73c
github.com/containerd/go-runc => github.com/containerd/go-runc v0.0.0-20190911050354-e029b79d8cda
github.com/containerd/typeurl => github.com/containerd/typeurl v0.0.0-20180627222232-a93fcdb778cd
Expand All @@ -34,10 +32,7 @@ replace (
github.com/prometheus/client_model => github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910
github.com/prometheus/common => github.com/prometheus/common v0.0.0-20181126121408-4724e9255275
github.com/prometheus/procfs => github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a
github.com/rancher/helm-controller => github.com/ibuildthecloud/helm-controller-1 v0.1.2-0.20200427180043-a4b3f2c320ef

github.com/rancher/k3s => github.com/ibuildthecloud/k3s-dev v0.1.0-rc6.0.20200427184827-21712abb0a8a

github.com/rancher/k3s => github.com/ibuildthecloud/k3s-dev v0.1.0-rc6.0.20200507231729-5cf25b189e0e
k8s.io/api => github.com/rancher/kubernetes/staging/src/k8s.io/api v1.18.2-k3s.1
k8s.io/apiextensions-apiserver => github.com/rancher/kubernetes/staging/src/k8s.io/apiextensions-apiserver v1.18.2-k3s.1
k8s.io/apimachinery => github.com/rancher/kubernetes/staging/src/k8s.io/apimachinery v1.18.2-k3s.1
Expand Down Expand Up @@ -68,11 +63,15 @@ replace (

require (
github.com/google/go-containerregistry v0.0.0-20200424115305-087a4bdef7c4
github.com/pkg/errors v0.9.1
github.com/rancher/k3s v0.0.0
github.com/rancher/wrangler v0.6.2-0.20200427172034-da9b142ae061
github.com/rancher/wrangler v0.6.1
github.com/sirupsen/logrus v1.4.2
github.com/urfave/cli v1.22.2
google.golang.org/grpc v1.26.0
k8s.io/api v0.18.0
k8s.io/apimachinery v0.18.0
k8s.io/apiserver v0.0.0
k8s.io/client-go v11.0.1-0.20190409021438-1a26190bd76a+incompatible
sigs.k8s.io/yaml v1.2.0
)
Loading

0 comments on commit 7a9a9c9

Please sign in to comment.