Skip to content
This repository has been archived by the owner on Jan 19, 2024. It is now read-only.

Commit

Permalink
chore: Enable skaffold to build and deploy initcontainer (#139)
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Kreuzberger <[email protected]>
  • Loading branch information
christian-kreuzberger-dtx authored Jan 11, 2022
1 parent b89be8b commit 1783653
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 19 deletions.
5 changes: 4 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ README.md
.idea
skaffold.yaml
reviewdog.yml
charts/
chart/
deploy/
.github/
installer/
bin/
test-data/
test-events/
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# This is based on Debian and sets the GOPATH to /go.
# https://hub.docker.com/_/golang
FROM golang:1.16.2-alpine as builder

RUN apk add --no-cache gcc libc-dev git

ARG version=develop
Expand Down
5 changes: 3 additions & 2 deletions chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ spec:
{{- include "job-executor-service.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
rollme: {{ randAlphaNum 5 | quote }} # forces pod restart (e.g., when updating helm values)
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
labels:
{{- include "job-executor-service.labels" . | nindent 8 }}
spec:
Expand Down
4 changes: 1 addition & 3 deletions chart/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@
"properties": {
"image": {
"properties": {
"repository": {
"pattern": "^[a-z0-9-./]{2,127}$"
}
"repository": {}
}
}
}
Expand Down
14 changes: 3 additions & 11 deletions initcontainer.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,14 @@ COPY go.mod go.sum ./
# Download dependencies
RUN go mod download

ARG debugBuild

# set buildflags for debug build
RUN if [ ! -z "$debugBuild" ]; then export BUILDFLAGS='-gcflags "all=-N -l"'; fi

# Copy local code to the container image.
COPY . .

# `skaffold debug` sets SKAFFOLD_GO_GCFLAGS to disable compiler optimizations
ARG SKAFFOLD_GO_GCFLAGS
# Build the command inside the container.
# (You may fetch or manage dependencies here, either manually or with a tool like "godep".)
RUN GOOS=linux go build -ldflags '-linkmode=external' $BUILDFLAGS -v -o job-executor-service-initcontainer cmd/job-executor-service-initcontainer/main.go
RUN GOOS=linux go build -ldflags '-linkmode=external' -gcflags="${SKAFFOLD_GO_GCFLAGS}" -v -o job-executor-service-initcontainer cmd/job-executor-service-initcontainer/main.go

# Use a Docker multi-stage build to create a lean production image.
# https://docs.docker.com/develop/develop-images/multistage-build/#use-multi-stage-builds
Expand All @@ -58,10 +55,5 @@ EXPOSE 8080
# required for external tools to detect this as a go binary
ENV GOTRACEBACK=all

# KEEP THE FOLLOWING LINES COMMENTED OUT!!! (they will be included within the travis-ci build)
#build-uncomment ADD MANIFEST /
#build-uncomment COPY entrypoint.sh /
#build-uncomment ENTRYPOINT ["/entrypoint.sh"]

# Run the web service on container startup.
CMD ["/job-executor-service-initcontainer"]
11 changes: 9 additions & 2 deletions skaffold.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,29 @@ build:
local:
useBuildkit: true
artifacts:
# job executor service
- image: keptncontrib/job-executor-service
docker:
dockerfile: Dockerfile
# init container for actual jobs (will be used for every job that is started)
- image: keptncontrib/job-executor-service-initcontainer
docker:
dockerfile: initcontainer.Dockerfile
# Before executing this, install job-executor-service manually:
# helm install -n keptn job-executor-service https://github.com/keptn-contrib/job-executor-service/releases/download/0.1.4/job-executor-service-0.1.4.tgz
deploy:
helm:
flags:
upgrade: ["--reuse-values"]
upgrade: ["--reuse-values"] # keep configuration (e.g., Keptn API Token)
releases:
- name: job-executor-service # needs to be the same name as currently used (check via helm ls -n keptn)
namespace: keptn # needs to be the same namespace as where the helm-chart is currently deployed
# upgradeOnChange: true
# recreatePods: false # don't recreate all pods
artifactOverrides:
image: keptncontrib/job-executor-service
jobexecutorserviceinitcontainer:
image: keptncontrib/job-executor-service-initcontainer
imageStrategy:
helm: { }
overrides:
Expand All @@ -28,5 +35,5 @@ deploy:
tag: 0.10.0
resources:
limits:
memory: 512Mi
memory: 512Mi # increase memory limit such that debugging using delve works
chartPath: chart

0 comments on commit 1783653

Please sign in to comment.