Skip to content
Open

wip #282

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
22 changes: 20 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,33 @@ ARG BUILD_SNAPSHOT=true
ARG SKIP_LICENSES_REPORT=false
ARG VERSION=unknown
ARG REVISION=unknown
ARG RUNC_VERSION=v1.1.15
ARG CRUN_VERSION=1.21

WORKDIR /app

RUN echo 'deb [trusted=yes] https://repo.goreleaser.com/apt/ /' > /etc/apt/sources.list.d/goreleaser.list \
&& apt-get -qq update \
&& apt-get -qq install -y --no-install-recommends build-essential libcap2-bin goreleaser
&& apt-get -qq install -y --no-install-recommends build-essential libcap2-bin goreleaser gpg curl

COPY . .

#Ambient set of capabilities are not really working, therefore we set the capabilities on the binary directly. More on this: https://github.com/kubernetes/kubernetes/issues/56374
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH goreleaser build --snapshot="${BUILD_SNAPSHOT}" --single-target -o extension \
&& setcap "cap_setuid,cap_setgid,cap_sys_admin,cap_dac_override,cap_sys_ptrace+eip" ./extension

# As of today the runc binary from debian is built using golang 1.19.8 and will be flagged by CVE scanners as vulnerable to several CVEs.
# We are dowonloading the runc binary from the official github release page and will use it instead of the one from the debian package.
RUN curl --proto "=https" -sfL https://github.com/opencontainers/runc/releases/download/$RUNC_VERSION/runc.$TARGETARCH -o ./runc \
&& curl --proto "=https" -sfL -o - https://raw.githubusercontent.com/opencontainers/runc/refs/heads/main/runc.keyring | gpg --import \
&& curl --proto "=https" -sfL -o - https://github.com/opencontainers/runc/releases/download/$RUNC_VERSION/runc.$TARGETARCH.asc | gpg --verify - ./runc \
&& chmod a+x ./runc

RUN curl --proto "=https" -sfL https://github.com/containers/crun/releases/download/$CRUN_VERSION/crun-$CRUN_VERSION-linux-$TARGETARCH -o ./crun \
&& curl --proto "=https" -sfL -o - https://github.com/giuseppe.gpg | gpg --import \
&& curl --proto "=https" -sfL -o - https://github.com/containers/crun/releases/download/$CRUN_VERSION/crun-$CRUN_VERSION-linux-$TARGETARCH.asc | gpg --verify - ./crun \
&& chmod a+x ./crun

##
## Runtime
##
Expand All @@ -50,10 +65,13 @@ RUN groupadd --gid $USER_GID $USERNAME \
RUN apt-get -qq update \
&& apt-get -qq upgrade -y \
&& apt-get -y autoremove \
&& apt-get -qq install -y --no-install-recommends runc procps \
&& apt-get -qq install -y --no-install-recommends procps \
&& apt-get -y autoremove \
&& rm -rf /var/lib/apt/lists/*

COPY --from=build /app/runc /usr/sbin/runc
COPY --from=build /app/crun /usr/bin/crun

USER $USER_UID

WORKDIR /
Expand Down
2 changes: 1 addition & 1 deletion charts/steadybit-extension-jvm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
name: steadybit-extension-jvm
description: Steadybit jvm extension Helm chart for Kubernetes.
version: 1.1.21
version: 1.2.0
appVersion: v1.2.4
home: https://www.steadybit.com/
icon: https://steadybit-website-assets.s3.amazonaws.com/logo-symbol-transparent.png
Expand Down
46 changes: 15 additions & 31 deletions charts/steadybit-extension-jvm/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,26 @@
{{/*
checks the .Values.containerRuntime for valid values
*/}}
{{- define "containerRuntime.valid" -}}
{{- $valid := keys .Values.containerRuntimes | sortAlpha -}}
{{- $runtime := .Values.container.runtime -}}
{{- if has $runtime $valid -}}
{{- $runtime -}}
{{- define "containerEngine.valid" -}}
{{- $valid := keys .Values.containerEngines | sortAlpha -}}
{{- if has .Values.container.runtime $valid -}}
{{- .Values.container.runtime -}}
{{- else if has .Values.container.engine $valid -}}
{{- .Values.container.engine -}}
{{- else -}}
{{- fail (printf "unknown container runtime: %v (must be one of %s)" $runtime (join ", " $valid)) -}}
{{- fail (printf "unknown container.engine: %v (must be one of %s)" .Values.container.engine (join ", " $valid)) -}}
{{- end -}}
{{- end -}}


{{- /*
containerRuntime.volumeMounts will render pod volume mounts(without indentation) for the selected container runtime
ociRuntime.root will render the root for the selected container runtime
*/}}
{{- define "containerRuntime.volumeMounts" -}}
{{- $runtime := (include "containerRuntime.valid" . ) -}}
{{- $runtimeValues := get .Values.containerRuntimes $runtime -}}
- name: "runtime-socket"
mountPath: "{{ $runtimeValues.socket }}"
- name: "runtime-runc-root"
mountPath: "{{ $runtimeValues.runcRoot }}"
{{- end -}}

{{- /*
containerRuntime.volumes will render pod volumes (without indentation) for the selected container runtime
*/}}
{{- define "containerRuntime.volumes" -}}
{{- $runtime := (include "containerRuntime.valid" . ) -}}
{{- $runtimeValues := get .Values.containerRuntimes $runtime -}}
- name: "runtime-socket"
hostPath:
path: "{{ $runtimeValues.socket }}"
type: Socket
- name: "runtime-runc-root"
hostPath:
path: "{{ $runtimeValues.runcRoot }}"
type: Directory
{{- define "ociRuntime.get" -}}
{{- $top := index . 0 -}}
{{- $field := index . 1 -}}
{{- $engine := (include "containerEngine.valid" $top ) -}}
{{- $engineValues := get $top.Values.containerEngines $engine -}}
{{- index $engineValues.ociRuntime $field -}}
{{- end -}}

{{- /*
Expand All @@ -54,3 +37,4 @@ will omit attribute from the passed in object depending on the KubeVersion
{{- end -}}
{{- $dict | toYaml -}}
{{- end -}}

28 changes: 19 additions & 9 deletions charts/steadybit-extension-jvm/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ metadata:
name: {{ include "extensionlib.names.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "extensionlib.labels" (list .) | nindent 4 }}
{{- range $key, $value := .Values.extraLabels }}
{{ $key }}: {{ $value }}
{{- end }}
{{- include "extensionlib.labels" (list .) | nindent 4 }}
spec:
selector:
matchLabels:
app.kubernetes.io/name: {{ include "extensionlib.names.name" . }}
app: {{ include "extensionlib.names.name" . }}
updateStrategy:
# updateStrategy.type -- Specifies the strategy used to replace old Pods by new ones.
type: RollingUpdate
type: {{ .Values.updateStrategy.type }}
{{- if eq .Values.updateStrategy.type "RollingUpdate" }}
rollingUpdate:
# updateStrategy.rollingUpdate.maxSurge -- The maximum number of DaemonSet pods that can be unavailable during the update.
maxUnavailable: 1
maxUnavailable: {{ .Values.updateStrategy.rollingUpdate.maxUnavailable }}
{{- end }}
template:
metadata:
labels:
Expand All @@ -33,7 +33,7 @@ spec:
{{- end }}
annotations:
{{- if semverCompare "<1.30-0" .Capabilities.KubeVersion.Version}}
"container.apparmor.security.beta.kubernetes.io/{{ include "extensionlib.names.name" . }}": unconfined
"container.apparmor.security.beta.kubernetes.io/steadybit-extension-jvm": unconfined
{{- end }}
{{- include "extensionlib.annotation" (list . .Values.containerPorts.http (.Values.daemonSet.extensionlib.list) ) | nindent 8 }}
oneagent.dynatrace.com/injection: "false"
Expand Down Expand Up @@ -61,7 +61,7 @@ spec:
limits:
memory: {{ .Values.resources.limits.memory }}
cpu: {{ .Values.resources.limits.cpu }}
name: {{ include "extensionlib.names.name" . }}
name: steadybit-extension-jvm
ports:
- name: http
containerPort: {{ .Values.containerPorts.http }}
Expand All @@ -82,6 +82,12 @@ spec:
- name: STEADYBIT_EXTENSION_DISCOVERY_ATTRIBUTES_EXCLUDES_JVM
value: {{ join "," .Values.discovery.attributes.excludes.jvm | quote }}
{{- end }}
- name: STEADYBIT_EXTENSION_OCIRUNTIME_DEBUG
value: {{ include "ociRuntime.get" (list . "debug") | quote }}
- name: STEADYBIT_EXTENSION_OCIRUNTIME_ROOT
value: {{ include "ociRuntime.get" (list . "root") | quote }}
- name: STEADYBIT_EXTENSION_OCIRUNTIME_PATH
value: {{ include "ociRuntime.get" (list . "path") | quote }}
{{- include "extensionlib.deployment.env" (list .) | nindent 12 }}
{{- with .Values.extraEnv }}
{{- toYaml . | nindent 12 }}
Expand All @@ -95,7 +101,8 @@ spec:
mountPath: /tmp
- name: cgroup-root
mountPath: /sys/fs/cgroup
{{- include "containerRuntime.volumeMounts" . | nindent 12 }}
- name: "ociruntime-root"
mountPath: {{ include "ociRuntime.get" (list . "root") | quote }}
{{- include "extensionlib.deployment.volumeMounts" (list .) | nindent 12 }}
livenessProbe:
initialDelaySeconds: {{ .Values.probes.liveness.initialDelaySeconds }}
Expand Down Expand Up @@ -126,7 +133,10 @@ spec:
hostPath:
path: /sys/fs/cgroup
type: Directory
{{- include "containerRuntime.volumes" . | nindent 8 }}
- name: "ociruntime-root"
hostPath:
path: {{ include "ociRuntime.get" (list . "root") | quote }}
type: Directory
{{- include "extensionlib.deployment.volumes" (list .) | nindent 8 }}
serviceAccountName: {{ .Values.serviceAccount.name }}
{{- with .Values.nodeSelector }}
Expand Down
Loading
Loading