Skip to content

Commit

Permalink
RC 0.0.3 (#4)
Browse files Browse the repository at this point in the history
* add liveness check for opa

* adds liveness and readiness checks
  • Loading branch information
richardjennings committed Apr 17, 2024
1 parent 4c767ff commit 109e552
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 150 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
.idea
charts/opa-nginx/manifest.yaml

6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 go build -o /bin/ino
RUN CGO_ENABLED=0 go build -o /bin/opa-nginx
RUN echo "nobody:x:65534:65534:nobody:/nonexistent:/bin/nope" > passwd

FROM scratch

COPY --from=builder /bin/ino /bin/ino
COPY --from=builder /bin/opa-nginx /bin/opa-nginx
COPY --from=builder /app/passwd /etc/passwd
USER nobody
ENV OPA_URL=https://127.0.0.1:8181
ENTRYPOINT ["/bin/ino"]
ENTRYPOINT ["/bin/opa-nginx"]
CMD ["serve"]
4 changes: 2 additions & 2 deletions charts/opa-nginx/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ apiVersion: v2
name: opa-nginx
description: OPA Nginx Auth Request Integration
type: application
version: 0.0.2
appVersion: 0.0.2
version: 0.0.3
appVersion: 0.0.3
143 changes: 0 additions & 143 deletions charts/opa-nginx/manifest.yaml

This file was deleted.

38 changes: 38 additions & 0 deletions charts/opa-nginx/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,28 @@ spec:
- --tls-private-key-file=/certs/tls.key
- --addr=localhost:8181
- --log-level={{ .Values.opa.logLevel }}
- --diagnostic-addr=0.0.0.0:8080
- --disable-telemetry
- --log-format=json
- /policy
livenessProbe:
httpGet:
scheme: HTTPS
path: /health
port: 8080
initialDelaySeconds: 10
periodSeconds: 10
successThreshold: 1
failureThreshold: 6
readinessProbe:
httpGet:
scheme: HTTPS
path: /health
port: 8080
initialDelaySeconds: 10
periodSeconds: 10
successThreshold: 1
failureThreshold: 1
volumeMounts:
- mountPath: /certs
name: certs
Expand Down Expand Up @@ -69,6 +89,24 @@ spec:
- name: http
containerPort: 8282
protocol: TCP
livenessProbe:
httpGet:
scheme: HTTPS
path: /healthz
port: 8282
initialDelaySeconds: 10
periodSeconds: 10
successThreshold: 1
failureThreshold: 6
readinessProbe:
httpGet:
scheme: HTTPS
path: /healthz
port: 8282
initialDelaySeconds: 10
periodSeconds: 10
successThreshold: 1
failureThreshold: 1
volumeMounts:
- mountPath: /certs
name: certs
Expand Down
2 changes: 1 addition & 1 deletion charts/opa-nginx/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
nameOverride: ""
replicaCount: 3
opaNginx:
image: richardjennings/opa-nginx:0.0.2
image: richardjennings/opa-nginx:0.0.3
imagePullPolicy: IfNotPresent
#authenticatedKey: "verified"
#authenticatedValue: "true"
Expand Down
9 changes: 8 additions & 1 deletion cmd/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,19 @@ var serveCmd = &cobra.Command{
if err != nil {
log.Fatalln(err)
}

mux := http.NewServeMux()
mux.HandleFunc("/", internal.NewHandler(&internal.OpaProxy{Config: config}))
mux.HandleFunc("/healthz", func(writer http.ResponseWriter, request *http.Request) {
writer.WriteHeader(200)
})
server := &http.Server{
Addr: defaultAddr,
Handler: internal.NewHandler(&internal.OpaProxy{Config: config}),
Handler: mux,
ReadTimeout: 5 * time.Second,
WriteTimeout: 10 * time.Second,
}

if tlsCertFile != "" && tlsPrivateKeyFile != "" {
log.Fatalln(server.ListenAndServeTLS(tlsCertFile, tlsPrivateKeyFile))
}
Expand Down

0 comments on commit 109e552

Please sign in to comment.