Skip to content

Commit de70b08

Browse files
authored
Merge pull request jetstack#14 from jetstack/feature-ingress-classes
Support for different ingress classes
2 parents 196d432 + 0eba0c1 commit de70b08

File tree

164 files changed

+11185
-471
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

164 files changed

+11185
-471
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,21 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
## [0.1.0] - *not released yet*
6+
7+
### Added
8+
9+
- Support for GCE load balancer ingress controller
10+
- E2E automation scripts for GCE/NGINX ingress controllers on GKE
11+
- Support for ingress-class annotations to distinguish between GCE/NGINX ingress
12+
- Abstracted the ingress controller specific code into separate packages
13+
- Deployment of kube-lego uses readiness checks
14+
15+
### Fixed
16+
17+
- Handle failed certificate request without exiting kube-lego
18+
19+
520
## [0.0.4] - 2016-07-11
621
### Added
722
- Check for expired certificates periodically (default config every 8 hours)

Godeps/Godeps.json

Lines changed: 136 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Makefile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ CONTAINER_DIR=/go/src/${PACKAGE_NAME}
1313

1414
.PHONY: version
1515

16+
codegen:
17+
which mockgen
18+
mockgen -imports .=github.com/jetstack/kube-lego/pkg/kubelego_const -package=mocks -source=pkg/kubelego_const/interfaces.go > pkg/mocks/mocks.go
19+
1620
depend:
1721
rm -rf $(TEST_DIR)/
1822
rm -rf ${BUILD_DIR}/
@@ -25,7 +29,7 @@ version:
2529
$(eval GIT_COMMIT := $(shell git rev-parse HEAD))
2630
$(eval APP_VERSION := $(shell cat VERSION))
2731

28-
test: test_root test_pkg_acme test_pkg_ingress test_pkg_kubelego test_pkg_secret test_pkg_utils
32+
test: test_root test_pkg_acme test_pkg_ingress test_pkg_kubelego test_pkg_secret test_pkg_utils test_pkg_provider_gce test_pkg_provider_nginx
2933

3034
test_prepare: depend
3135
which gocover-cobertura || go get github.com/t-yuki/gocover-cobertura
@@ -37,11 +41,17 @@ test_root: test_prepare
3741
gocover-cobertura < $(TEST_DIR)/coverage.txt > $(TEST_DIR)/coverage.xml
3842
sed -i "s#filename=\"$(PACKAGE_NAME)/#filename=\"#g" $(TEST_DIR)/coverage.xml
3943

44+
test_pkg_provider_%: test_prepare
45+
godep go test -v -coverprofile=$(TEST_DIR)/coverage.$*.txt -covermode count ./pkg/provider/$* | go2xunit > $(TEST_DIR)/test.$*.xml
46+
gocover-cobertura < $(TEST_DIR)/coverage.$*.txt > $(TEST_DIR)/coverage.$*.xml
47+
sed -i "s#filename=\"$(PACKAGE_NAME)/#filename=\"#g" $(TEST_DIR)/coverage.$*.xml
48+
4049
test_pkg_%: test_prepare
4150
godep go test -v -coverprofile=$(TEST_DIR)/coverage.$*.txt -covermode count ./pkg/$* | go2xunit > $(TEST_DIR)/test.$*.xml
4251
gocover-cobertura < $(TEST_DIR)/coverage.$*.txt > $(TEST_DIR)/coverage.$*.xml
4352
sed -i "s#filename=\"$(PACKAGE_NAME)/#filename=\"#g" $(TEST_DIR)/coverage.$*.xml
4453

54+
4555
build: depend version
4656
CGO_ENABLED=0 GOOS=linux godep go build \
4757
-a -tags netgo \

README.md

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,30 @@
1111

1212
## Features
1313

14-
- Recognizes the need of new certificates for this cases
15-
- domain name missing
16-
- certificate expired
17-
- certificate unparseable
18-
- Obtains certificates per TLS object in ingress resources and stores it in Kubernetes secrets using `HTTP-01` challenge
14+
- Recognizes the need of a new certificate for this cases:
15+
- No certificate existing
16+
- Existing certificate is not containing all domain names
17+
- Existing certificate is expired or near to it's expiry date (cf. option `LEGO_MINIMUM_VALIDITY`)
18+
- Existing certificate is unparseable, invalid or not matching the secret key
1919
- Creates a user account (incl. private key) for Let's Encrypt and stores it in Kubernetes secrets (secret name is configurable via `LEGO_SECRET_NAME`)
20-
- Watches changes of ingress resources and reevaluate certificates
21-
- Configures endpoints for `HTTP-01` challenge in a separate ingress resource (ingress name is configurable in `LEGO_INGRESS_NAME`)
20+
- Obtains the missing certificates from Let's Encrypt and authorizes the request with the `HTTP-01` challenge
21+
- Makes sure that the specific Kubernetes objects (Services, Ingress) contain the rights configuration for the `HTTP-01` challenge to succeed
2222

2323
## Requirements
2424

2525
- Kubernetes 1.2+
26-
- Compatible ingress controller (cf. [here](#ingress))
26+
- Compatible ingress controller (nginx or GCE see [here](#ingress))
2727
- Non-production use case :laughing:
2828

2929
## Usage
3030

3131
### run kube-lego
3232

33-
- [deployment](examples/kube-lego-deployment.yaml) for *kube-lego*
34-
- don't forget to configure `LEGO_EMAIL` with your mail address
35-
- the default value of `LEGO_URL` is the Let's Encrypt staging environment. If you want to get "real" certificates you have to configure their production env.
36-
- [service](examples/kube-lego-svc.yaml) pointing to *kube-lego* pods
33+
- [deployment](examples/gce/50-kube-lego-deployment.yaml) for *kube-lego*
34+
- don't forget to configure
35+
- `LEGO_EMAIL` with your mail address
36+
- `LEGO_POD_IP` with the pod IP address using the downward API
37+
- the default value of `LEGO_URL` is the Let's Encrypt **staging environment**. If you want to get "real" certificates you have to configure their production env.
3738

3839
### how kube-lego works
3940

@@ -47,7 +48,7 @@ metadata:
4748
4849
Every ingress resource that has this annotations will be monitored by *kube-lego* (cluster-wide in all namespaces). The only part that is watched is the list `spec.tls`. Every element will get their own certificate through Let's encrypt.
4950

50-
Let's take a look at this ingress controller:
51+
Let's take a look at this ingress resource:
5152

5253
```yaml
5354
spec:
@@ -66,33 +67,42 @@ spec:
6667
- The `secretName` statements have to be unique per namespace
6768
- `secretName` is required (even if no secret exists with that name, as it will be created by *kube-lego*)
6869

69-
###
7070

7171
##<a name="ingress"></a>Ingress controllers
7272

7373
### [Nginx Ingress Controller](https://github.com/kubernetes/contrib/tree/master/ingress/controllers/nginx)
7474

7575
- available through image `gcr.io/google_containers/nginx-ingress-controller`
76-
- fully supports kube-lego from version 0.8
76+
- fully supports kube-lego from version 0.8 onwards
77+
78+
### [GCE Loadbalancers](https://github.com/kubernetes/contrib/tree/master/ingress/controllers/gce)
79+
80+
- you don't have to maintain the ingress controller yourself, you pay GCE to do that for you
81+
- every ingress resource creates one GCE load balancer
82+
- all service that you want to expose, have to be `Type=NodePort`
7783

7884
## Environment variables
7985

8086
| Name | Required | Default | Description |
8187
|------|----------|---------|-------------|
8288
| `LEGO_EMAIL` | y | `-` | E-Mail address for the ACME account, used to recover from lost secrets |
89+
| `LEGO_POD_IP` | y | `-` | Pod IP address (use the [downward API](http://kubernetes.io/docs/user-guide/downward-api/))|
8390
| `LEGO_NAMESPACE` | n | `default` | Namespace where kube-lego is running in |
8491
| `LEGO_URL` | n | `https://acme-staging.api.letsencrypt.org/directory` | URL for the ACME server |
8592
| `LEGO_SECRET_NAME` | n | `kube-lego-account` | Name of the secret in the same namespace that contains ACME account secret |
86-
| `LEGO_SERVICE_NAME` | n | `kube-lego` | Service name that connects to this pod |
87-
| `LEGO_INGRESS_NAME` | n | `kube-lego` | Ingress name which contains the routing for HTTP verification |
93+
| `LEGO_SERVICE_NAME_NGINX` | n | `kube-lego-nginx` | Service name for NGINX ingress |
94+
| `LEGO_SERVICE_NAME_GCE` | n | `kube-lego-gce` | Service name for GCE ingress |
95+
| `LEGO_INGRESS_NAME_NGINX` | n | `kube-lego-nginx` | Ingress name which contains the routing for HTTP verification for nginx ingress |
8896
| `LEGO_PORT` | n | `8080` | Port where this daemon is listening for verifcation calls (HTTP method)|
8997
| `LEGO_CHECK_INTERVAL` | n | `8h` | Interval for periodically certificate checks (to find expired certs)|
9098
| `LEGO_MINIMUM_VALIDITY` | n | `720h` (30 days) | Request a renewal when the remaining certificate validitiy falls below that value|
99+
| `LEGO_DEFAULT_INGRESS_CLASS` | n | `nginx` | Default ingress class for resources without specification|
91100

92101

93-
## Full example
102+
## Full deployment examples
94103

95-
See the [examples](examples/README.md) directory.
104+
- [Nginx Ingress Controller](examples/nginx/README.md)
105+
- [GCE Load Balancers](examples/gce/README.md)
96106

97107
## Authors
98108

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
apiVersion: v1
2+
kind: Namespace
3+
metadata:
4+
name: echoserver
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
apiVersion: v1
2+
kind: Namespace
3+
metadata:
4+
name: kube-lego

examples/gce/20-echoserver-svc.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: echoserver
5+
namespace: echoserver
6+
spec:
7+
ports:
8+
- port: 80
9+
targetPort: 8080
10+
protocol: TCP
11+
type: NodePort
12+
selector:
13+
app: echoserver

examples/kube-lego-configmap.yaml renamed to examples/gce/20-kube-lego-configmap.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
apiVersion: v1
22
metadata:
33
name: kube-lego
4+
namespace: kube-lego
45
data:
56
# modify this to specify your address
67
lego.email: "[email protected]"

examples/echoserver-deployment.yaml renamed to examples/gce/50-echoserver-deployment.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ apiVersion: extensions/v1beta1
22
kind: Deployment
33
metadata:
44
name: echoserver
5+
namespace: echoserver
56
spec:
67
replicas: 1
78
template:

examples/kube-lego-deployment.yaml renamed to examples/gce/50-kube-lego-deployment.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ apiVersion: extensions/v1beta1
22
kind: Deployment
33
metadata:
44
name: kube-lego
5+
namespace: kube-lego
56
spec:
67
replicas: 1
78
template:
@@ -30,3 +31,13 @@ spec:
3031
valueFrom:
3132
fieldRef:
3233
fieldPath: metadata.namespace
34+
- name: LEGO_POD_IP
35+
valueFrom:
36+
fieldRef:
37+
fieldPath: status.podIP
38+
readinessProbe:
39+
httpGet:
40+
path: /healthz
41+
port: 8080
42+
initialDelaySeconds: 5
43+
timeoutSeconds: 1

examples/echoserver-ingress-notls.yaml renamed to examples/gce/70-echoserver-ingress.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,20 @@ apiVersion: extensions/v1beta1
22
kind: Ingress
33
metadata:
44
name: echoserver
5+
namespace: echoserver
6+
annotations:
7+
kubernetes.io/tls-acme: "true"
8+
kubernetes.io/ingress.class: "gce"
59
spec:
10+
tls:
11+
- hosts:
12+
- echo.example.com
13+
secretName: echoserver-tls
614
rules:
715
- host: echo.example.com
816
http:
917
paths:
10-
- path: /
18+
- path: /*
1119
backend:
1220
serviceName: echoserver
1321
servicePort: 80

0 commit comments

Comments
 (0)