Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update operator sdk #52

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,5 @@ tags
# End of https://www.gitignore.io/api/go,vim,emacs,visualstudiocode

.idea
vendor
bin
31 changes: 31 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Build the manager binary
FROM golang:1.16 as builder

WORKDIR /workdir
# ENV GOPATH=/go
# Copy the Go Modules manifests
COPY go.mod go.sum /workdir/
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go mod download

RUN cat go.mod

# Copy the go source
COPY cmd cmd
COPY pkg pkg
COPY version version

RUN ls -la /workdir

# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o /workspace/manager ./cmd/manager/main.go

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
FROM gcr.io/distroless/static:nonroot
WORKDIR /
COPY --from=builder /workspace/manager .
USER 65532:65532

ENTRYPOINT ["/manager"]
26 changes: 20 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
SHELL=/bin/bash
SHELL=/usr/bin/env bash -o pipefail
NAMESPACE=default
KUBECONFIG=/tmp/kubeconfig
VERSION ?= latest
IMAGE_TAG_BASE ?= quay.io/mittwald/kubernetes-secret-generator
IMG ?= secret-generator:${VERSION}

.PHONY: install
install: ## Install all resources (RBAC and Operator)
Expand Down Expand Up @@ -52,11 +55,22 @@ fmt:
go fmt $$(go list ./...)

.PHONY: kind
kind: ## Create a kind cluster to test against
kind create cluster --name kind-k8s-secret-generator
kind get kubeconfig --name kind-k8s-secret-generator | tee ${KUBECONFIG}
kind: ## Create a kind cluster to tefmt: ## Run go fmt against code.
go fmt ./...

vet: ## Run go vet against code.
go vet ./...

.PHONY: build
build:
operator-sdk build --go-build-args "-ldflags -X=version.Version=${SECRET_OPERATOR_VERSION}" ${DOCKER_IMAGE}
build: fmt vet ## Build manager binary.
go build -o bin/manager ./cmd/manager/main.go
@exit $(.SHELLSTATUS)

.PHONY: docker-build
docker-build: ## Build docker image with the manager.
docker build -t ${IMG} .
@exit $(.SHELLSTATUS)

docker-push: ## Push docker image with the manager.
docker tag ${IMG} ${IMAGE_TAG_BASE}:${VERSION}
docker push ${IMAGE_TAG_BASE}