Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ IMAGE_NAME := mysql-operator
SIDECAR_IMAGE_NAME := mysql-operator-sidecar
BUILD_TAG := build
IMAGE_TAGS := $(APP_VERSION)
PKG_NAME := github.com/presslabs/mysql-operator

BINDIR := $(PWD)/bin
KUBEBUILDER_VERSION ?= 1.0.7
Expand Down Expand Up @@ -33,6 +34,18 @@ 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
bin/mysql-operator_linux_amd64: $(shell hack/development/related-go-files.sh $(PKG_NAME) cmd/mysql-operator/main.go)
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o bin/mysql-operator_linux_amd64 github.com/presslabs/mysql-operator/cmd/mysql-operator

bin/mysql-operator-sidecar_linux_amd64: $(shell hack/development/related-go-files.sh $(PKG_NAME) cmd/mysql-operator-sidecar/main.go)
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o bin/mysql-operator-sidecar_linux_amd64 github.com/presslabs/mysql-operator/cmd/mysql-operator-sidecar

skaffold-build: bin/mysql-operator_linux_amd64 bin/mysql-operator-sidecar_linux_amd64

skaffold-run: skaffold-build
skaffold run

# 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
7 changes: 7 additions & 0 deletions hack/development/related-go-files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
# This command outputs a list of go files on which the given go file depends on
# Example: related-go-files.sh <base package name> <go file>

set -e

go list -f '{{ join .Deps "\n" }}' $2 | grep 'pkg' | grep -v 'vendor' | sed -e "s|^$1/||" | xargs -I % find % -name "*.go" -maxdepth 1 -type f 2>/dev/null
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