Skip to content

Commit

Permalink
chore: switch to using distroless base image for driver-crds
Browse files Browse the repository at this point in the history
Switches to using distroless base image for the driver-crds. The entrypoint
is set to kubectl to prevent shell access. Enabled image scan for the
driver-crds image.

Signed-off-by: Anish Ramasekar <anish.ramasekar@gmail.com>
  • Loading branch information
aramase committed Jul 20, 2021
1 parent 651990f commit 8bd82ef
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 13 deletions.
13 changes: 8 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,10 @@ sanity-test:
image-scan: $(TRIVY)
# show all vulnerabilities
$(TRIVY) --severity MEDIUM,HIGH,CRITICAL $(IMAGE_TAG)
$(TRIVY) --severity MEDIUM,HIGH,CRITICAL $(CRD_IMAGE_TAG)
# show vulnerabilities that have been fixed
$(TRIVY) --exit-code 1 --ignore-unfixed --severity MEDIUM,HIGH,CRITICAL $(IMAGE_TAG)
$(TRIVY) --exit-code 1 --ignore-unfixed --severity MEDIUM,HIGH,CRITICAL $(CRD_IMAGE_TAG)

## --------------------------------------
## Tooling Binaries
Expand Down Expand Up @@ -267,11 +269,12 @@ container: crd-container

.PHONY: crd-container
crd-container: build-crds
docker build --no-cache -t $(CRD_IMAGE_TAG) -f docker/crd.Dockerfile _output/crds/
docker build --no-cache --build-arg ARCH=$(ARCH) -t $(CRD_IMAGE_TAG) -f docker/crd.Dockerfile _output/crds/

.PHONY: crd-container-linux
crd-container-linux: build-crds docker-buildx-builder
docker buildx build --no-cache --output=type=$(OUTPUT_TYPE) --platform="linux/$(ARCH)" -t $(CRD_IMAGE_TAG)-linux-$(ARCH) -f docker/crd.Dockerfile _output/crds/
docker buildx build --no-cache --output=type=$(OUTPUT_TYPE) --platform="linux/$(ARCH)" \
--build-arg ARCH=$(ARCH) -t $(CRD_IMAGE_TAG)-linux-$(ARCH) -f docker/crd.Dockerfile _output/crds/

.PHONY: container-linux
container-linux: docker-buildx-builder
Expand Down Expand Up @@ -364,7 +367,7 @@ e2e-teardown: $(HELM)

.PHONY: e2e-helm-deploy
e2e-helm-deploy:
helm install csi-secrets-store manifest_staging/charts/secrets-store-csi-driver --namespace kube-system --wait --timeout=15m -v=5 --debug \
helm install csi-secrets-store manifest_staging/charts/secrets-store-csi-driver --namespace kube-system --wait --timeout=5m -v=5 --debug \
--set linux.image.pullPolicy="IfNotPresent" \
--set windows.image.pullPolicy="IfNotPresent" \
--set linux.image.repository=$(REGISTRY)/$(IMAGE_NAME) \
Expand All @@ -381,7 +384,7 @@ e2e-helm-deploy:

.PHONY: e2e-helm-upgrade
e2e-helm-upgrade:
helm upgrade csi-secrets-store manifest_staging/charts/secrets-store-csi-driver --namespace kube-system --reuse-values --timeout=15m -v=5 --debug --set filteredWatchSecret=true \
helm upgrade csi-secrets-store manifest_staging/charts/secrets-store-csi-driver --namespace kube-system --reuse-values --timeout=5m -v=5 --debug --set filteredWatchSecret=true \
--set linux.image.repository=$(REGISTRY)/$(IMAGE_NAME) \
--set linux.image.tag=$(IMAGE_VERSION) \
--set windows.image.repository=$(REGISTRY)/$(IMAGE_NAME) \
Expand All @@ -392,7 +395,7 @@ e2e-helm-upgrade:
e2e-helm-deploy-release:
set -x; \
current_release=$(shell (echo ${RELEASE_VERSION} | sed s/"v"//)); \
helm install csi-secrets-store charts/secrets-store-csi-driver-$${current_release}.tgz --namespace kube-system --wait --timeout=15m -v=5 --debug \
helm install csi-secrets-store charts/secrets-store-csi-driver-$${current_release}.tgz --namespace kube-system --wait --timeout=5m -v=5 --debug \
--set linux.image.pullPolicy="IfNotPresent" \
--set windows.image.pullPolicy="IfNotPresent" \
--set windows.enabled=true \
Expand Down
5 changes: 3 additions & 2 deletions docker/cloudbuild.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# See https://cloud.google.com/cloud-build/docs/build-config

# this must be specified in seconds. If omitted, defaults to 600s (10 mins)
# setting it to 3600s to accommodate multi-os image builds.
timeout: 3600s
# setting it to 5400s to accommodate multi-os image builds for driver and
# multi-arch build for driver-crds.
timeout: 5400s
# this prevents errors if you don't use both _GIT_TAG and _PULL_BASE_REF,
# or any new substitutions added in the future.
options:
Expand Down
12 changes: 11 additions & 1 deletion docker/crd.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
FROM bitnami/kubectl:1.21.2
FROM alpine as builder
ARG KUBE_VERSION=v1.21.2
ARG ARCH

RUN apk add --no-cache curl && \
curl -LO https://storage.googleapis.com/kubernetes-release/release/${KUBE_VERSION}/bin/linux/${ARCH}/kubectl && \
chmod +x kubectl

FROM gcr.io/distroless/static
COPY * /crds/
COPY --from=builder /kubectl /kubectl
ENTRYPOINT ["/kubectl"]
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,10 @@ spec:
containers:
- name: crds-upgrade
image: "{{ .Values.linux.crds.image.repository }}:{{ .Values.linux.crds.image.tag }}"
command:
- sh
- -c
- >
kubectl apply -f /crds;
args:
- apply
- -f
- crds/
imagePullPolicy: {{ .Values.linux.crds.image.pullPolicy }}
{{- if .Values.imagePullSecrets }}
imagePullSecrets:
Expand Down

0 comments on commit 8bd82ef

Please sign in to comment.