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

Fix e2e tests and cleanup build #67

Merged
merged 6 commits into from
Oct 17, 2020
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
5 changes: 4 additions & 1 deletion .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
schedule:
- cron: '0 10 * * *' # everyday at 10am
push:
branches: master
tags:
- 'v*.*.*'
paths:
Expand All @@ -29,7 +30,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Go 1.15
uses: actions/setup-go@v1
uses: actions/setup-go@v2
with:
go-version: '~1.15.0'
- name: Setup Kubebuilder
Expand Down Expand Up @@ -73,6 +74,8 @@ jobs:
tags: ${{ steps.prep.outputs.tags }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
with:
platforms: ${{ env.PLATFORMS }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
with:
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
-->

## [Unreleased](https://github.com/itscontained/secret-manager/compare/v0.2.0...HEAD)
- Fix double base64 encoding of secrets ([#59](https://github.com/itscontained/secret-manager/pull/59) [@devth](https://github.com/devth))
- Fix incorrect service account token path for vault store authentication ([#66](https://github.com/itscontained/secret-manager/pull/66) [@huguesalary](https://github.com/huguesalary))
- Fix nil pointer panic on an error during vault store authentication([#65](https://github.com/itscontained/secret-manager/pull/65) [@huguesalary](https://github.com/huguesalary))
- Fix Vault API path for v1 secret engine ([#42](https://github.com/itscontained/secret-manager/pull/42) [@c35sys](https://github.com/c35sys))
- Add E2E testing structure and tests for AWS Secret Manager ([#39](https://github.com/itscontained/secret-manager/pull/39) [@moolen](https://github.com/moolen))
- Fix logging flag registration ([#46](https://github.com/itscontained/secret-manager/pull/46) [@mcavoyk](https://github.com/mcavoyk))
- Change base docker image from `gcr.io/distroless/static` to `alpine:3.12` ([#67](https://github.com/itscontained/secret-manager/pull/67) [@mcavoyk](https://github.com/mcavoyk))

## [0.2.0](https://github.com/itscontained/secret-manager/compare/v0.1.0...v0.2.0) - 2020-09-17
- Add GCP Secret Manager store backend ([#36](https://github.com/itscontained/secret-manager/pull/36) [@DirtyCajunRice](https://github.com/DirtyCajunRice))
22 changes: 15 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Build the manager binary
FROM golang:1.15.2-buster as builder
ARG BUILDPLATFORM=linux/amd64
ARG GO_VERSION=1.15.3
FROM --platform=$BUILDPLATFORM golang:$GO_VERSION-buster as builder

WORKDIR /workspace
# Copy the Go Modules manifests
Expand All @@ -19,11 +21,14 @@ COPY build build/
COPY .git .git/

# Build
RUN make build
ARG ARCHS
RUN make build-multiarch

FROM alpine:3.12

ARG TARGETOS=linux
ARG TARGETARCH=amd64

# 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-amd64
WORKDIR /
LABEL maintainer="DirtyCajunRice,mcavoyk" \
org.opencontainers.image.created=$BUILD_DATE \
Expand All @@ -35,7 +40,10 @@ LABEL maintainer="DirtyCajunRice,mcavoyk" \
org.opencontainers.image.title="secret-manager" \
org.opencontainers.image.description="Secret Manager is a set of Kubernetes CRDs and controllers which define a common method of interacting with External SecretStores." \
org.opencontainers.image.licenses="APACHE"
COPY --from=builder /workspace/bin/manager .
USER nonroot:nonroot
COPY --from=builder "/workspace/bin/manager-$TARGETOS-$TARGETARCH" /manager

# Run as UID for nobody since k8s pod securityContext runAsNonRoot can't resolve the user ID:
# https://github.com/kubernetes/kubernetes/issues/40958
USER 65534

ENTRYPOINT ["/manager"]
14 changes: 10 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
MAKEFLAGS += --warn-undefined-variables
SHELL := /bin/bash
.SHELLFLAGS := -euo pipefail -c
MAKEFLAGS += --warn-undefined-variables
SHELL := /bin/bash
.SHELLFLAGS := -euo pipefail -c
.DEFAULT_GOAL := all
ARCHS ?= arm64 amd64 arm

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
Expand All @@ -24,7 +25,7 @@ IMG_TAG ?= ${GIT_TAG}
IMG ?= itscontained/secret-manager:${IMG_TAG}
HELM_DIR ?= deploy/charts/secret-manager

DOCKER_BUILD_FLAGS =
DOCKER_BUILD_FLAGS ?=

all: docker-build

Expand Down Expand Up @@ -61,6 +62,11 @@ test: ## Run tests
build: generate ## Build manager binary
CGO_ENABLED=0 go build -a -ldflags '$(LDFLAGS)' -o bin/manager ./cmd/controller/main.go

build-multiarch: ## Build multi-arch manager binary
for arch in $(ARCHS); do \
CGO_ENABLED=0 GOOS=linux GOARCH=$${arch} go build -a -ldflags '$(LDFLAGS)' -o "bin/manager-linux-$${arch}" ./cmd/controller/main.go ;\
done ;\

manifests: controller-gen ## Generate CRD manifests
$(CONTROLLER_GEN) "crd:crdVersions=v1" paths="./pkg/apis/..." output:crd:artifacts:config=deploy/crds
$(CONTROLLER_GEN) "crd:crdVersions=v1beta1,preserveUnknownFields=false" paths="./pkg/apis/..." output:crd:artifacts:config=deploy/crds/legacy
Expand Down
9 changes: 5 additions & 4 deletions e2e/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM golang:1.15 as BASE
ARG GO_VERSION=1.15.3
FROM golang:$GO_VERSION-buster as builder

ENV KUBECTL_VERSION="v1.19.2"
ENV HELM_VERSION="v3.3.4"
Expand All @@ -18,9 +19,9 @@ RUN apk add -U --no-cache \
libc6-compat \
openssl

COPY --from=BASE /go/bin/ginkgo /usr/local/bin/
COPY --from=BASE /usr/local/bin/kubectl /usr/local/bin/
COPY --from=BASE /usr/local/bin/helm /usr/local/bin/
COPY --from=builder /go/bin/ginkgo /usr/local/bin/
COPY --from=builder /usr/local/bin/kubectl /usr/local/bin/
COPY --from=builder /usr/local/bin/helm /usr/local/bin/

COPY entrypoint.sh /entrypoint.sh
COPY e2e.test /e2e.test
Expand Down
24 changes: 17 additions & 7 deletions e2e/Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
IMG=secret-manager-e2e:test
MAKEFLAGS += --warn-undefined-variables
SHELL := /bin/bash
.SHELLFLAGS := -euo pipefail -c

start-kind:
IMG_TAG=test
IMG=itscontained/secret-manager-e2e:test

start-kind: ## Start kind cluster
kind create cluster \
--name secret-manager \
--config kind.yaml \
--retain \
--image "kindest/node:v1.19.1"

test: e2e-image
$(MAKE) -C ../ docker-build IMG=secret-manager:test
kind load docker-image --name="secret-manager" secret-manager:test
kind load docker-image --name="secret-manager" secret-manager-e2e:test
test: e2e-image ## Run e2e tests against current kube context
$(MAKE) -C ../ docker-build IMG_TAG=$(IMG_TAG) DOCKER_BUILD_FLAGS="--build-arg ARCHS=amd64"
kind load docker-image --name="secret-manager" itscontained/secret-manager:$(IMG_TAG)
kind load docker-image --name="secret-manager" $(IMG)
./run.sh

e2e-bin:
Expand All @@ -21,4 +26,9 @@ e2e-image: e2e-bin
mkdir -p k8s
$(MAKE) -C ../ crds-to-chart
cp -r ../deploy ./k8s
docker build -t ${IMG} .
docker build -t $(IMG) .

help: ## displays this help message
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_\/-]+:.*?## / {printf "\033[34m%-18s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | \
sort | \
grep -v '#'
4 changes: 2 additions & 2 deletions e2e/tests/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ var _ = ginkgo.Describe("[aws]", func() {
gomega.Expect(f.KubeClient.Get(context.Background(), key, fetchedSecret)).Should(gomega.Succeed())
return fetchedSecret.Data
}, framework.DefaultTimeout, framework.Poll).Should(gomega.Equal(map[string][]byte{
"username-from-aws": []byte(b64enc("bob")),
"password-from-aws": []byte(b64enc("abc123xyz456")),
"username-from-aws": []byte("bob"),
"password-from-aws": []byte("abc123xyz456"),
}), "The generated secret should be created")
})
})
23 changes: 0 additions & 23 deletions e2e/tests/common.go

This file was deleted.

2 changes: 2 additions & 0 deletions pkg/apis/meta/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.