Skip to content

Commit 3a5579e

Browse files
committed
Easy development with skaffold
1 parent a67e898 commit 3a5579e

File tree

6 files changed

+61
-4
lines changed

6 files changed

+61
-4
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
.git
22
bin/*
3+
!bin/mysql-operator_linux_amd64
4+
!bin/mysql-operator-sidecar_linux_amd64

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ SIDECAR_IMAGE_NAME := mysql-operator-sidecar
55
BUILD_TAG := build
66
IMAGE_TAGS := $(APP_VERSION)
77

8-
BINDIR := $(PWD)/bin
8+
BINDIR := bin
99
KUBEBUILDER_VERSION ?= 1.0.7
1010
HELM_VERSION ?= 2.11.0
1111

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

23-
all: test build
23+
all: test skaffold-build
2424

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

36+
skaffold-build:
37+
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o $(BINDIR)/mysql-operator_linux_amd64 github.com/presslabs/mysql-operator/cmd/mysql-operator
38+
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
39+
3640
# Run against the configured Kubernetes cluster in ~/.kube/config
3741
run: generate fmt vet
3842
go run ./cmd/mysql-operator/main.go
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM scratch
2+
3+
# set expiration time for dev images
4+
# https://support.coreos.com/hc/en-us/articles/115001384693-Tag-Expiration
5+
LABEL quay.expires-after=2d
6+
7+
COPY ./bin/mysql-operator_linux_amd64 /mysql-operator
8+
ENTRYPOINT ["/mysql-operator"]
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Copy the mysql-operator-sidecar into it's own image
2+
FROM debian:stretch as sidecar
3+
4+
RUN apt-get update \
5+
&& apt-get install -y --no-install-recommends \
6+
apt-transport-https ca-certificates wget \
7+
gnupg1 dirmngr \
8+
&& rm -rf /var/lib/apt/lists/*
9+
10+
RUN apt-key adv --keyserver ha.pool.sks-keyservers.net --recv-keys 9334A25F8507EFA5
11+
12+
RUN echo 'deb https://repo.percona.com/apt stretch main' > /etc/apt/sources.list.d/percona.list
13+
14+
RUN apt-get update \
15+
&& apt-get install -y --no-install-recommends \
16+
percona-toolkit percona-xtrabackup-24 unzip \
17+
&& wget https://github.com/maxbube/mydumper/releases/download/v0.9.5/mydumper_0.9.5-2.stretch_amd64.deb \
18+
&& dpkg -i mydumper_0.9.5-2.stretch_amd64.deb \
19+
&& rm -rf mydumper_0.9.5-2.stretch_amd64.deb /var/lib/apt/lists/* \
20+
&& wget https://downloads.rclone.org/rclone-current-linux-amd64.zip \
21+
&& unzip rclone-current-linux-amd64.zip \
22+
&& mv rclone-*-linux-amd64/rclone /usr/local/bin/ \
23+
&& rm -rf rclone-*-linux-amd64 rclone-current-linux-amd64.zip \
24+
&& chmod 755 /usr/local/bin/rclone
25+
26+
# set expiration time for dev images
27+
# https://support.coreos.com/hc/en-us/articles/115001384693-Tag-Expiration
28+
LABEL quay.expires-after=2d
29+
30+
COPY ./hack/docker/sidecar-entrypoint.sh /usr/local/bin/sidecar-entrypoint.sh
31+
COPY ./bin/mysql-operator-sidecar_linux_amd64 /usr/local/bin/mysql-operator-sidecar
32+
ENTRYPOINT ["/usr/local/bin/sidecar-entrypoint.sh"]

hack/development/dev-values.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
extraArgs:
2+
- --debug
3+
4+
installCRDs: false
5+
6+
orchestrator:
7+
topologyPassword: password1
8+
antiAffinity: soft
9+
replicas: 1

skaffold.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ kind: Config
33
build:
44
artifacts:
55
- image: quay.io/presslabs/mysql-operator
6+
docker:
7+
dockerfile: hack/development/Dockerfile.operator
68
- image: quay.io/presslabs/mysql-operator-sidecar
79
docker:
8-
dockerfile: Dockerfile.sidecar
10+
dockerfile: hack/development/Dockerfile.sidecar
911
local:
1012
push: true
1113
deploy:
@@ -14,7 +16,7 @@ deploy:
1416
- name: test
1517
chartPath: hack/charts/mysql-operator
1618
valuesFiles:
17-
- hack/dev-values.yaml
19+
- hack/development/dev-values.yaml
1820
values:
1921
image: quay.io/presslabs/mysql-operator
2022
sidecarImage: quay.io/presslabs/mysql-operator-sidecar

0 commit comments

Comments
 (0)