Skip to content

Commit e9c594c

Browse files
authored
feat(annotations): Add annotations to rewrite requests (#68)
* feat(annotations): Add annotations to rewrite requests * Upgrade caddy, ingress API version and some other deps * fix graceful shutdown * Upgrade caddy to v2.4.6 and add OCSP Check interval to global config * Add caddy duration parser
1 parent d5b85e5 commit e9c594c

19 files changed

+1097
-458
lines changed

Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.14.2-alpine AS builder
1+
FROM golang:1.16.7-alpine AS builder
22
WORKDIR /app
33

44
COPY go.mod go.sum ./
@@ -13,7 +13,7 @@ RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./bin/ingress-controller .
1313
FROM alpine:latest AS certs
1414
RUN apk --update add ca-certificates
1515

16-
FROM scratch
16+
FROM alpine:latest
1717
COPY --from=builder /app/bin/ingress-controller .
1818
COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
1919
EXPOSE 80 443

README.md

+23-11
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ for monitoring `Ingress` resources on a Kubernetes cluster and includes support
55
for providing automatic HTTPS certificates for all hostnames defined in ingress
66
resources that it is managing.
77

8-
## Cloud Provider Setup (AWS, GCLOUD, ETC...)
8+
## Prerequisites
9+
10+
- Helm 3+
11+
- Kubernetes 1.19+
12+
13+
## Setup
914

1015
In the `charts` folder a Helm Chart is provided to make installing the Caddy
1116
Ingress Controller on a Kubernetes cluster straight forward. To install the
@@ -14,19 +19,19 @@ Caddy Ingress Controller adhere to the following steps:
1419
1. Create a new namespace in your cluster to isolate all Caddy resources.
1520

1621
```sh
17-
kubectl create namespace caddy-system
22+
kubectl create namespace caddy-system
1823
```
1924

2025
2. Install the Helm Chart.
2126

2227
```sh
23-
helm install \
24-
--namespace=caddy-system \
25-
--repo https://caddyserver.github.io/ingress/ \
26-
--atomic \
27-
--set image.tag=latest \
28-
mycaddy \
29-
caddy-ingress-controller
28+
helm install \
29+
--namespace=caddy-system \
30+
--repo https://caddyserver.github.io/ingress/ \
31+
--atomic \
32+
--set image.tag=latest \
33+
mycaddy \
34+
caddy-ingress-controller
3035
```
3136

3237
The helm chart create a service of type `LoadBalancer` in the `caddy-system`
@@ -44,7 +49,7 @@ pod logs of the Caddy Ingress Controller.
4449
Get the pod name with:
4550

4651
```sh
47-
kubectl get pods -n caddy-system
52+
kubectl get pods -n caddy-system
4853
```
4954

5055
View the pod logs:
@@ -61,7 +66,6 @@ the argument `ingressController.autotls=true` and the email to use
6166
chart values.
6267

6368
Example:
64-
6569
- `--set ingressController.autotls=true`
6670
6771

@@ -103,3 +107,11 @@ spec:
103107
- test.com
104108
secretName: mycerts # use mycerts for host test.com
105109
```
110+
111+
### Contribution
112+
113+
Learn how to start contribution on the [Contributing Guidline](CONTRIBUTING.md).
114+
115+
## License
116+
117+
[Apache License 2.0](LICENSE.txt)

charts/caddy-ingress-controller/Chart.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ home: https://github.com/caddyserver/ingress
44
description: A helm chart for the Caddy Kubernetes ingress controller
55
icon: https://caddyserver.com/resources/images/caddy-circle-lock.svg
66
type: application
7-
version: 0.0.1-rc3
7+
version: 0.0.1-rc4
88
keywords:
99
- ingress-controller
1010
- caddyserver

charts/caddy-ingress-controller/README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ This chart bootstraps a caddy-ingress-deployment deployment on a [Kubernetes](ht
1717
## Prerequisites
1818

1919
- Helm 3+
20-
- Kubernetes 1.14+
20+
- Kubernetes 1.19+
2121

2222
## Installing the Chart
2323

@@ -60,6 +60,7 @@ The command removes all the Kubernetes components associated with the chart and
6060
| ingressController.config.proxyProtocol | bool | `false` | |
6161
| ingressController.rbac.create | bool | `true` | |
6262
| ingressController.verbose | bool | `false` | |
63+
| ingressController.leaseId | string | `""` | |
6364
| ingressController.watchNamespace | string | `""` | |
6465
| minikube | bool | `false` | |
6566
| nameOverride | string | `""` | |

charts/caddy-ingress-controller/templates/deployment.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ spec:
7070
{{- if .Values.ingressController.watchNamespace }}
7171
- -namespace={{ .Values.ingressController.watchNamespace }}
7272
{{- end }}
73+
{{- if .Values.ingressController.leaseId }}
74+
- -lease-id={{ .Values.ingressController.leaseId }}
75+
{{- end }}
7376
{{- if .Values.ingressController.verbose }}
7477
- -v
7578
{{- end }}

charts/caddy-ingress-controller/values.schema.json

+4
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@
9090
}
9191
}
9292
},
93+
"leaseId": {
94+
"$id": "#/properties/ingressController/properties/leaseId",
95+
"type": "string"
96+
},
9397
"config": {
9498
"$id": "#/properties/ingressController/properties/config",
9599
"type": "object",

charts/caddy-ingress-controller/values.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ ingressController:
2222
rbac:
2323
create: true
2424

25+
leaseId: ""
2526
config:
2627
# -- Acme Server URL
2728
acmeCA: ""

cmd/caddy/main.go

+10-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ import (
99
"k8s.io/apimachinery/pkg/version"
1010
"k8s.io/client-go/kubernetes"
1111
"k8s.io/client-go/tools/clientcmd"
12+
"os"
13+
"os/signal"
14+
"syscall"
1215
"time"
1316
)
1417

@@ -49,15 +52,20 @@ func main() {
4952
}
5053

5154
stopCh := make(chan struct{}, 1)
52-
defer close(stopCh)
5355

5456
c := controller.NewCaddyController(logger, kubeClient, cfg, caddy.Converter{}, stopCh)
5557

5658
// start the ingress controller
5759
logger.Info("Starting the caddy ingress controller")
5860
go c.Run()
5961

60-
// TODO :- listen to sigterm
62+
// Listen for SIGINT and SIGTERM signals
63+
sigs := make(chan os.Signal, 1)
64+
signal.Notify(sigs, os.Interrupt, syscall.SIGTERM)
65+
<-sigs
66+
close(stopCh)
67+
68+
// Let controller exit the process
6169
select {}
6270
}
6371

go.mod

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
module github.com/caddyserver/ingress
22

3-
go 1.14
3+
go 1.16
44

55
require (
6-
github.com/caddyserver/caddy/v2 v2.3.0-rc.1
7-
github.com/caddyserver/certmagic v0.12.1-0.20201209195841-b726d1ed13c3
8-
github.com/google/uuid v1.1.1
9-
github.com/mitchellh/mapstructure v1.1.2
6+
github.com/caddyserver/caddy/v2 v2.4.6
7+
github.com/caddyserver/certmagic v0.15.2
8+
github.com/google/uuid v1.3.0
9+
github.com/mitchellh/mapstructure v1.4.3
1010
github.com/pires/go-proxyproto v0.3.1
1111
github.com/pkg/errors v0.9.1
12-
go.uber.org/multierr v1.6.0 // indirect
13-
go.uber.org/zap v1.16.0
12+
go.uber.org/zap v1.19.0
1413
gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
1514
gopkg.in/go-playground/pool.v3 v3.1.1
1615
k8s.io/api v0.19.4

0 commit comments

Comments
 (0)