fix: Probes

This commit is contained in:
Dries De Peuter 2023-03-12 00:06:42 +01:00
parent a215b46906
commit 70390d0389
No known key found for this signature in database
4 changed files with 60 additions and 13 deletions

View file

@ -26,3 +26,18 @@ data:
return 200 '{"code":"1", "message": "Unknown Error"}'; return 200 '{"code":"1", "message": "Unknown Error"}';
} }
} }
server {
listen 8082;
server_name localhost;
root /usr/share/nginx/html;
access_log off;
allow 127.0.0.1;
deny all;
location /healthz {
allow 127.0.0.1;
stub_status;
server_tokens on;
}
}

View file

@ -37,6 +37,17 @@ spec:
- name: http - name: http
containerPort: 8080 containerPort: 8080
protocol: TCP protocol: TCP
- name: probe
containerPort: 8082
protocol: TCP
livenessProbe:
httpGet:
path: /healthz
port: probe
readinessProbe:
httpGet:
path: /healthz
port: probe
volumeMounts: volumeMounts:
- name: config - name: config
mountPath: /etc/nginx/conf.d/default.conf mountPath: /etc/nginx/conf.d/default.conf
@ -62,6 +73,18 @@ spec:
fieldRef: fieldRef:
apiVersion: v1 apiVersion: v1
fieldPath: metadata.name fieldPath: metadata.name
ports:
- name: probe
containerPort: 8081
protocol: TCP
livenessProbe:
httpGet:
path: /healthz
port: probe
readinessProbe:
httpGet:
path: /healthz
port: probe
resources: resources:
{{- toYaml .Values.resources | nindent 12 }} {{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }} {{- with .Values.nodeSelector }}

View file

@ -6,26 +6,22 @@ replicaCount: 2
image: image:
repository: ghcr.io/stenic/well-known repository: ghcr.io/stenic/well-known
pullPolicy: IfNotPresent pullPolicy: Always
# Overrides the image tag whose default is the chart appVersion. # Overrides the image tag whose default is the chart appVersion.
tag: "" tag: ""
resources: {} resources:
# We usually recommend not to specify default resources and to leave this as a conscious limits:
# choice for the user. This also increases chances charts run on environments with little cpu: 50m
# resources, such as Minikube. If you do want to specify resources, uncomment the following memory: 64Mi
# lines, adjust them as necessary, and remove the curly braces after 'resources:'. requests:
# limits: cpu: 20m
# cpu: 100m memory: 32Mi
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi
webserver: webserver:
image: image:
repository: nginxinc/nginx-unprivileged repository: nginxinc/nginx-unprivileged
pullPolicy: IfNotPresent pullPolicy: Always
tag: "1.23" tag: "1.23"
resources: resources:
limits: limits:

View file

@ -4,6 +4,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"flag" "flag"
"net/http"
"os" "os"
"os/signal" "os/signal"
"path/filepath" "path/filepath"
@ -86,6 +87,18 @@ func main() {
}, },
} }
go func() {
http.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
})
klog.Info("Running /healthz endpoint on :8081")
if err := http.ListenAndServe(":8081", nil); err != nil {
klog.Error(err)
os.Exit(1)
}
}()
// start the leader election code loop // start the leader election code loop
leaderelection.RunOrDie(ctx, leaderelection.LeaderElectionConfig{ leaderelection.RunOrDie(ctx, leaderelection.LeaderElectionConfig{
Lock: lock, Lock: lock,