Skip to content

Commit

Permalink
Easy development with skaffold
Browse files Browse the repository at this point in the history
  • Loading branch information
AMecea committed Feb 13, 2019
1 parent 6aff2da commit b2a45e5
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
.git
bin/*
!bin/mysql-operator_linux_amd64
!bin/mysql-operator-sidecar_linux_amd64
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ SIDECAR_IMAGE_NAME := mysql-operator-sidecar
BUILD_TAG := build
IMAGE_TAGS := $(APP_VERSION)

BINDIR := $(PWD)/bin
BINDIR := bin
KUBEBUILDER_VERSION ?= 1.0.7
HELM_VERSION ?= 2.11.0

Expand All @@ -20,7 +20,7 @@ ifeq 'yes' "$(shell test -f $(BINDIR)/kubebuilder && echo -n 'yes')"
KUBEBUILDER_ASSETS ?= $(BINDIR)
endif

all: test build
all: test skaffold-build

# Run tests
test: generate fmt vet manifests
Expand All @@ -33,6 +33,10 @@ build: generate fmt vet
go build -o bin/mysql-operator github.com/presslabs/mysql-operator/cmd/mysql-operator
go build -o bin/mysql-operator-sidecar github.com/presslabs/mysql-operator/cmd/mysql-operator-sidecar

skaffold-build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o $(BINDIR)/mysql-operator_linux_amd64 github.com/presslabs/mysql-operator/cmd/mysql-operator
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o $(BINDIR)/mysql-operator-sidecar_linux_amd64 github.com/presslabs/mysql-operator/cmd/mysql-operator-sidecar

# Run against the configured Kubernetes cluster in ~/.kube/config
run: generate fmt vet
go run ./cmd/mysql-operator/main.go
Expand Down
8 changes: 8 additions & 0 deletions hack/development/Dockerfile.operator
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM scratch

# set expiration time for dev images
# https://support.coreos.com/hc/en-us/articles/115001384693-Tag-Expiration
LABEL quay.expires-after=2d

COPY ./bin/mysql-operator_linux_amd64 /mysql-operator
ENTRYPOINT ["/mysql-operator"]
32 changes: 32 additions & 0 deletions hack/development/Dockerfile.sidecar
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copy the mysql-operator-sidecar into it's own image
FROM debian:stretch as sidecar

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
apt-transport-https ca-certificates wget \
gnupg1 dirmngr \
&& rm -rf /var/lib/apt/lists/*

RUN apt-key adv --keyserver ha.pool.sks-keyservers.net --recv-keys 9334A25F8507EFA5

RUN echo 'deb https://repo.percona.com/apt stretch main' > /etc/apt/sources.list.d/percona.list

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
percona-toolkit percona-xtrabackup-24 unzip \
&& wget https://github.com/maxbube/mydumper/releases/download/v0.9.5/mydumper_0.9.5-2.stretch_amd64.deb \
&& dpkg -i mydumper_0.9.5-2.stretch_amd64.deb \
&& rm -rf mydumper_0.9.5-2.stretch_amd64.deb /var/lib/apt/lists/* \
&& wget https://downloads.rclone.org/rclone-current-linux-amd64.zip \
&& unzip rclone-current-linux-amd64.zip \
&& mv rclone-*-linux-amd64/rclone /usr/local/bin/ \
&& rm -rf rclone-*-linux-amd64 rclone-current-linux-amd64.zip \
&& chmod 755 /usr/local/bin/rclone

# set expiration time for dev images
# https://support.coreos.com/hc/en-us/articles/115001384693-Tag-Expiration
LABEL quay.expires-after=2d

COPY ./hack/docker/sidecar-entrypoint.sh /usr/local/bin/sidecar-entrypoint.sh
COPY ./bin/mysql-operator-sidecar_linux_amd64 /usr/local/bin/mysql-operator-sidecar
ENTRYPOINT ["/usr/local/bin/sidecar-entrypoint.sh"]
9 changes: 9 additions & 0 deletions hack/development/dev-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
extraArgs:
- --debug

installCRDs: false

orchestrator:
topologyPassword: password1
antiAffinity: soft
replicas: 1
6 changes: 4 additions & 2 deletions skaffold.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ kind: Config
build:
artifacts:
- image: quay.io/presslabs/mysql-operator
docker:
dockerfile: hack/development/Dockerfile.operator
- image: quay.io/presslabs/mysql-operator-sidecar
docker:
dockerfile: Dockerfile.sidecar
dockerfile: hack/development/Dockerfile.sidecar
local:
push: true
deploy:
Expand All @@ -14,7 +16,7 @@ deploy:
- name: test
chartPath: hack/charts/mysql-operator
valuesFiles:
- hack/dev-values.yaml
- hack/development/dev-values.yaml
values:
image: quay.io/presslabs/mysql-operator
sidecarImage: quay.io/presslabs/mysql-operator-sidecar

0 comments on commit b2a45e5

Please sign in to comment.