Skip to content

Commit

Permalink
feat: Serve data instead of using the nginx container
Browse files Browse the repository at this point in the history
  • Loading branch information
NoUseFreak committed Apr 7, 2024
1 parent 25e69d3 commit ca584da
Show file tree
Hide file tree
Showing 9 changed files with 361 additions and 249 deletions.
15 changes: 10 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.20 AS build-server
FROM golang:1.22 AS build-server

WORKDIR /workspace/server
# Copy the Go Modules manifests
Expand All @@ -19,16 +19,21 @@ RUN CGO_ENABLED=0 GOOS=linux go build -a -o well-known ./

FROM alpine AS downloader

RUN wget -O /usr/local/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.5/dumb-init_1.2.5_x86_64
RUN chmod +x /usr/local/bin/dumb-init
ARG TARGETPLATFORM
ARG TINI_VERSION=v0.19.0
RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then ARCHITECTURE=amd64; elif [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then ARCHITECTURE=arm; elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then ARCHITECTURE=arm64; else ARCHITECTURE=amd64; fi \
&& wget -O /usr/local/bin/tini https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-static-${ARCHITECTURE}
RUN chmod +x /usr/local/bin/tini

#

# 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 /app

COPY --from=downloader /usr/local/bin/dumb-init /app/dumb-init
COPY --from=downloader /usr/local/bin/tini /app/tini
COPY --from=build-server /workspace/server/well-known /app/well-known
USER 65532:65532

ENTRYPOINT ["/app/dumb-init", "--", "/app/well-known"]
ENTRYPOINT ["/app/tini", "--", "/app/well-known"]
50 changes: 0 additions & 50 deletions charts/well-known/templates/configmap.yaml

This file was deleted.

43 changes: 3 additions & 40 deletions charts/well-known/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,36 +30,6 @@ spec:
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: webserver
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.webserver.image.repository }}:{{ .Values.webserver.image.tag }}"
imagePullPolicy: {{ .Values.webserver.image.pullPolicy }}
ports:
- name: http
containerPort: 8080
protocol: TCP
- name: probe
containerPort: 8082
protocol: TCP
livenessProbe:
httpGet:
path: /healthz
port: probe
readinessProbe:
httpGet:
path: /healthz
port: probe
volumeMounts:
- name: config
mountPath: /etc/nginx/conf.d/default.conf
subPath: default.conf
- name: data
mountPath: /usr/share/nginx/html/.well-known
- mountPath: /tmp
name: tmp-volume
resources:
{{- toYaml .Values.webserver.resources | nindent 12 }}
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
Expand All @@ -76,6 +46,9 @@ spec:
apiVersion: v1
fieldPath: metadata.name
ports:
- name: http
containerPort: 8080
protocol: TCP
- name: probe
containerPort: 8081
protocol: TCP
Expand All @@ -101,13 +74,3 @@ spec:
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: config
configMap:
name: {{ include "well-known.fullname" . }}
- name: data
configMap:
name: {{ include "well-known.fullname" . }}-data
optional: true
- name: tmp-volume
emptyDir: {}
19 changes: 2 additions & 17 deletions charts/well-known/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,7 @@ resources:
cpu: 20m
memory: 32Mi

webserver:
image:
repository: nginxinc/nginx-unprivileged
pullPolicy: Always
tag: "1.25"
resources:
limits:
cpu: 50m
memory: 24Mi
requests:
cpu: 10m
memory: 10Mi
config:
accessLogEnabled: false

podDisruptionBudget:
podDisruptionBudget:
maxUnavailable: 1

imagePullSecrets: []
Expand Down Expand Up @@ -94,7 +79,7 @@ autoscaling:
networkpolicies:
enabled: false
kubeApi: [] # kubectl get svc -n default kubernetes -oyaml

Check failure on line 81 in charts/well-known/values.yaml

View workflow job for this annotation

GitHub Actions / chart-testing

81:15 [comments] too few spaces before comment
# - addresses:
# - addresses:
# - 10.0.0.153
# - 10.0.0.90
# ports:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module well-known

go 1.20
go 1.22

require (
k8s.io/api v0.28.3
Expand Down
Loading

0 comments on commit ca584da

Please sign in to comment.