Skip to content

Commit

Permalink
Merge pull request #184 from kanisterio/sync
Browse files Browse the repository at this point in the history
AWS EFS blockstorage; Update Release: Support gomod; Build docker images; Replace minikube with kind
  • Loading branch information
Ilya Kislenko committed Jul 31, 2019
2 parents 17b5e03 + f79d7b2 commit 2dc827a
Show file tree
Hide file tree
Showing 34 changed files with 1,246 additions and 457 deletions.
31 changes: 0 additions & 31 deletions .goreleaser.yaml

This file was deleted.

86 changes: 86 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
project_name: kanister
before:
hooks:
- go mod download
builds:
- id: kanctl
binary: kanctl
main: cmd/kanctl/main.go
ldflags: &ldflags
- -s -w
-X github.com/kanisterio/kanister/pkg/version.VERSION={{.Version}}
-X github.com/kanisterio/kanister/pkg/version.GIT_COMMIT={{.Commit}}
-X github.com/kanisterio/kanister/pkg/version.BUILD_DATE={{.Date}}
env: &env
- GO111MODULE=on
- CGO_ENABLED=0
- GO_EXTLINK_ENABLED=0
goos:
- darwin
- linux
goarch: &goarch
- amd64
- id: kando
binary: kando
main: cmd/kando/main.go
ldflags: *ldflags
env: *env
goos: &goos
- linux
goarch: *goarch
- id: controller
binary: controller
main: cmd/controller/main.go
ldflags: *ldflags
env: *env
goos: *goos
goarch: *goarch
dockers:
- binaries:
- kando
image_templates:
- 'kanisterio/kanister-tools:{{ .Tag }}'
dockerfile: 'docker/tools/Dockerfile'
- binaries:
- controller
image_templates:
- 'kanisterio/kanister-controller:{{ .Tag }}'
dockerfile: 'docker/controller/Dockerfile'
- binaries:
- kando
image_templates:
- 'kanisterio/postgres-kanister-tools:{{ .Tag }}'
dockerfile: 'docker/postgres-kanister-tools/Dockerfile'
- binaries:
- kando
image_templates:
- 'kanisterio/es-sidecar:{{ .Tag }}'
dockerfile: 'examples/helm/kanister/kanister-elasticsearch/image/Dockerfile'
extra_files:
- 'examples/helm/kanister/kanister-elasticsearch/image/esdump-setup.sh'
- binaries:
- kando
image_templates:
- 'kanisterio/mysql-sidecar:{{ .Tag }}'
dockerfile: 'examples/helm/kanister/kanister-mysql/image/Dockerfile'
- binaries:
- kando
image_templates:
- 'kanisterio/mongo-sidecar:{{ .Tag }}'
dockerfile: 'examples/helm/kanister/kanister-mongodb-replicaset/image/Dockerfile'
extra_files:
- 'examples/helm/kanister/kanister-mongodb-replicaset/image/install.sh'
- 'examples/helm/kanister/kanister-mongodb-replicaset/image/90forceyes'
- 'examples/helm/kanister/kanister-mongodb-replicaset/image/config'
- 'examples/helm/kanister/kanister-mongodb-replicaset/image/gbl_env.sh'

snapshot:
name_template: '{{ .Tag }}'
checksum:
name_template: 'checksums.txt'
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
12 changes: 7 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@ env:
- CHANGE_MINIKUBE_NONE_USER=true GO111MODULE=on

before_install:
- sudo bash build/local_kubernetes.sh get_minikube
- wget --progress=dot:mega https://storage.googleapis.com/kubernetes-release/release/v1.8.4/bin/linux/amd64/kubectl
- wget --progress=dot:mega https://storage.googleapis.com/kubernetes-release/release/v1.15.0/bin/linux/amd64/kubectl
- sudo chmod +x kubectl
- sudo mv kubectl /usr/local/bin/kubectl

script:
- go mod download
- make build DOCKER_BUILD=false
- sudo make build
- make docs
- sudo bash build/local_kubernetes.sh start_minikube
- make test DOCKER_BUILD=false
- docker run -ti --rm --net host -e GOPATH=/go -v ${GOPATH}:/go -v /var/run/docker.sock:/var/run/docker.sock -v ${HOME}/.kube:/root/.kube -v $(pwd):/data -w /data --entrypoint="bash" kanisterio/build:v0.0.1 -c "bash build/local_kubernetes.sh start_localkube"
- sudo make test

after_script:
- docker run -ti --rm --net host -e GOPATH=/go -v ${GOPATH}:/go -v /var/run/docker.sock:/var/run/docker.sock -v ${HOME}/.kube:/root/.kube -v $(pwd):/data -w /data --entrypoint="bash" kanisterio/build:v0.0.1 -c "bash build/local_kubernetes.sh stop_localkube"

10 changes: 6 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ all-push: $(addprefix push-, $(ALL_ARCH))

build: bin/$(ARCH)/$(BIN)

bin/$(ARCH)/$(BIN):
bin/$(ARCH)/$(BIN):
@echo "building: $@"
@$(MAKE) run CMD='-c " \
GOARCH=$(ARCH) \
Expand All @@ -105,14 +105,15 @@ shell: build-dirs
-ti \
--rm \
--privileged \
-v "$(PWD)/.go/pkg:/go/pkg" \
--net host \
-v "$(PWD)/.go/pkg:/go/pkg" \
-v "$(PWD):/go/src/$(PKG)" \
-v "$(PWD)/bin/$(ARCH):/go/bin" \
-v "$(PWD)/bin/$(ARCH):/go/bin/$$(go env GOOS)_$(ARCH)" \
-v /var/run/docker.sock:/var/run/docker.sock \
-w /go/src/$(PKG) \
$(BUILD_IMAGE) \
/bin/sh
/bin/sh

DOTFILE_IMAGE = $(subst :,_,$(subst /,_,$(IMAGE))-$(VERSION))

Expand Down Expand Up @@ -193,6 +194,7 @@ ifeq ($(DOCKER_BUILD),"true")
@echo "running CMD in the containerized build environment"
@docker run \
--rm \
--net host \
-e GITHUB_TOKEN=$(GITHUB_TOKEN) \
-v "${HOME}/.kube:/root/.kube" \
-v "$(PWD)/.go/pkg:/go/pkg" \
Expand All @@ -206,7 +208,7 @@ else
@/bin/bash $(CMD)
endif

clean: dotfile-clean bin-clean
clean: dotfile-clean bin-clean

dotfile-clean:
rm -rf .container-* .dockerfile-* .push-* .vendor .deploy-*
Expand Down
55 changes: 28 additions & 27 deletions build/local_kubernetes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ export MINIKUBE_WANTREPORTERRORPROMPT=false
export MINIKUBE_HOME=$HOME
export CHANGE_MINIKUBE_NONE_USER=true
export KUBECONFIG=$HOME/.kube/config
export KUBE_VERSION=${KUBE_VERSION:-v1.9.0}
export MINIKUBE_VERSION=${MINIKUBE_VERSION:-v0.25.1}
declare -a REQUIRED_BINS=( iptables docker sudo jq )
export KUBE_VERSION=${KUBE_VERSION:-"v1.13.7"}
export KIND_VERSION=${KIND_VERSION:-"v0.4.0"}
export LOCAL_CLUSTER_NAME=${LOCAL_CLUSTER_NAME:-"kanister"}
declare -a REQUIRED_BINS=( docker sudo jq go )

if command -v apt-get
then
Expand Down Expand Up @@ -44,33 +45,33 @@ check_or_get_dependencies() {
done
}

start_minikube() {
if ! command -v minikube
start_localkube() {
if ! command -v kind
then
get_minikube
get_localkube
fi
minikube start --vm-driver=none --mount --kubernetes-version=${KUBE_VERSION} --extra-config=apiserver.GenericServerRunOptions.AuthorizationMode=RBAC
wait_for_minikube_nodes
kind create cluster --name ${LOCAL_CLUSTER_NAME} --image=kindest/node:${KUBE_VERSION}
cp $(kind get kubeconfig-path --name="kanister") ${KUBECONFIG}
wait_for_nodes
wait_for_pods
}

stop_minikube() {
if ! minikube stop
stop_localkube() {
if ! command -v kind
then
systemctl stop localkube
docker rm -f $(docker ps -aq --filter name=k8s)
get_localkube
fi
kind delete cluster --name ${LOCAL_CLUSTER_NAME}
}

get_minikube() {
get_localkube() {
check_or_get_dependencies
mkdir $HOME/.kube || true
touch $HOME/.kube/config
curl -Lo minikube https://storage.googleapis.com/minikube/releases/${MINIKUBE_VERSION}/minikube-linux-amd64 && chmod +x minikube
ln -sf $(pwd)/minikube /usr/bin/minikube
GO111MODULE="on" go get sigs.k8s.io/kind@${KIND_VERSION}
}

wait_for_minikube_nodes() {
wait_for_nodes() {
local nodes_ready=$(kubectl get nodes 2>/dev/null | grep -c Ready)
local retries=20
while [[ ${nodes_ready} -eq 0 ]]
Expand All @@ -94,7 +95,7 @@ wait_for_minikube_nodes() {

wait_for_pods() {
local namespace=${1:-"kube-system"}
local pod_status=$(kubectl get pod --namespace=${namespace} -o json | jq -j ".items | .[] | .status | .containerStatuses | .[] | .ready")
local pod_status=$(kubectl get pod --namespace=${namespace} -o json | jq -j '.items | .[] | .status | .containerStatuses | .[]? | .state.running != null or .state.terminated.reason == "Completed"')
local retries=20

while [[ ${pod_status} == *false* ]] || [[ ${pod_status} == '' ]]
Expand All @@ -106,7 +107,7 @@ wait_for_pods() {
return 1
fi
sleep 5
if ! pod_status=$(kubectl get pod --namespace=${namespace} -o json | jq -j ".items | .[] | .status | .containerStatuses | .[] | .ready")
if ! pod_status=$(kubectl get pod --namespace=${namespace} -o json | jq -j '.items | .[] | .status | .containerStatuses | .[]? | .state.running != null or .state.terminated.reason == "Completed"')
then
pod_status=''
fi
Expand All @@ -119,24 +120,24 @@ usage() {
cat <<EOM
Usage: ${0} <operation>
Where operation is one of the following:
get_minikube: installs minikube
start_minikube : minikube start
stop_minikube : minikube stop
get_localkube: installs kind
start_localkube : localkube start
stop_localkube : localkube stop
EOM
exit 1
}

[ ${#@} -gt 0 ] || usage
case "${1}" in
# Alphabetically sorted
get_minikube)
time -p get_minikube
get_localkube)
time -p get_localkube
;;
start_minikube)
time -p start_minikube
start_localkube)
time -p start_localkube
;;
stop_minikube)
time -p stop_minikube
stop_localkube)
time -p stop_localkube
;;
*)
usage
Expand Down
2 changes: 1 addition & 1 deletion docker/tools/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ COPY --from=restbox /bin/restic /bin/restic
RUN apk -v --update add --no-cache bash curl groff less mailcap ca-certificates && \
rm -f /var/cache/apk/*

RUN curl https://raw.githubusercontent.com/kanisterio/kanister/master/scripts/get.sh | bash
ADD kando /usr/local/bin/

CMD [ "/usr/bin/tail", "-f", "/dev/null" ]
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@

FROM kanisterio/kanister-tools:0.20.0
MAINTAINER Supriya Kharade <supriya@kasten.io>

COPY esdump-setup.sh /esdump-setup.sh
RUN chmod +x /esdump-setup.sh &&\
/esdump-setup.sh
ADD examples/helm/kanister/kanister-elasticsearch/image/esdump-setup.sh /esdump-setup.sh
RUN chmod +x /esdump-setup.sh && sync && /esdump-setup.sh
Loading

0 comments on commit 2dc827a

Please sign in to comment.