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"}';
}
}
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
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
@ -62,6 +73,18 @@ spec:
fieldRef:
apiVersion: v1
fieldPath: metadata.name
ports:
- name: probe
containerPort: 8081
protocol: TCP
livenessProbe:
httpGet:
path: /healthz
port: probe
readinessProbe:
httpGet:
path: /healthz
port: probe
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}

View file

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

View file

@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"flag"
"net/http"
"os"
"os/signal"
"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
leaderelection.RunOrDie(ctx, leaderelection.LeaderElectionConfig{
Lock: lock,