Skip to content

Commit 14369c7

Browse files
authored
Merge pull request #71 from phillc/examples
Examples
2 parents 41c6c4b + 5a80e66 commit 14369c7

File tree

6 files changed

+126
-35
lines changed

6 files changed

+126
-35
lines changed

README.md

Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -70,41 +70,62 @@ For annotations with bool value types, `"1"`, `"t"`, `"T"`, `"True"`, `"true"`
7070
#### Example usage
7171

7272
```yaml
73-
apiVersion: v1
7473
kind: Service
74+
apiVersion: v1
7575
metadata:
76-
name: wordpress-lsmnl-wordpress
77-
namespace: wordpress-lsmnl
76+
name: https-lb
7877
annotations:
7978
service.beta.kubernetes.io/linode-loadbalancer-throttle: "4"
8079
service.beta.kubernetes.io/linode-loadbalancer-default-protocol: "http"
8180
service.beta.kubernetes.io/linode-loadbalancer-port-443: |
8281
{
83-
"tls-secret-name": "prod-app-tls",
82+
"tls-secret-name": "example-secret",
8483
"protocol": "https"
8584
}
86-
labels:
87-
app: wordpress-lsmnl-wordpress
8885
spec:
8986
type: LoadBalancer
90-
clusterIP: 10.97.58.169
91-
externalTrafficPolicy: Cluster
87+
selector:
88+
app: nginx-https-example
9289
ports:
93-
- name: http
94-
nodePort: 32660
95-
port: 80
96-
protocol: TCP
97-
targetPort: http
98-
- name: https
99-
nodePort: 30806
100-
port: 443
101-
protocol: TCP
102-
targetPort: https
90+
- name: http
91+
protocol: TCP
92+
port: 80
93+
targetPort: http
94+
- name: https
95+
protocol: TCP
96+
port: 443
97+
targetPort: https
98+
99+
---
100+
apiVersion: apps/v1
101+
kind: Deployment
102+
metadata:
103+
name: nginx-https-deployment
104+
spec:
105+
replicas: 2
103106
selector:
104-
app: wordpress-lsmnl-wordpress
105-
sessionAffinity: None
107+
matchLabels:
108+
app: nginx-https-example
109+
template:
110+
metadata:
111+
labels:
112+
app: nginx-https-example
113+
spec:
114+
containers:
115+
- name: nginx
116+
image: nginx
117+
ports:
118+
- name: http
119+
containerPort: 80
120+
protocol: TCP
121+
- name: https
122+
containerPort: 80
123+
protocol: TCP
124+
106125
```
107126

127+
See more in the [examples directory](examples)
128+
108129
## Why `stickiness` and `algorithm` annotations don't exit
109130

110131
As kube-proxy will simply double-hop the traffic to a random backend Pod anyway, it doesn't matter which backend Node traffic is forwarded-to for the sake of session stickiness.

examples/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
example.key
2+
example.crt

examples/http-nginx.yaml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ apiVersion: v1
44
metadata:
55
name: http-lb
66
annotations:
7-
service.beta.kubernetes.io/linode-loadbalancer-protocol: "http"
7+
service.beta.kubernetes.io/linode-loadbalancer-default-protocol: "http"
88
spec:
99
type: LoadBalancer
1010
selector:
11-
app: nginx-example
11+
app: nginx-http-example
1212
ports:
1313
- name: http
1414
protocol: TCP
@@ -19,22 +19,20 @@ spec:
1919
apiVersion: apps/v1
2020
kind: Deployment
2121
metadata:
22-
name: nginx-example
23-
labels:
24-
app: nginx
22+
name: nginx-http-deployment
2523
spec:
2624
replicas: 2
2725
selector:
2826
matchLabels:
29-
app: nginx
27+
app: nginx-http-example
3028
template:
3129
metadata:
3230
labels:
33-
app: nginx-example
31+
app: nginx-http-example
3432
spec:
3533
containers:
3634
- name: nginx
3735
image: nginx
3836
ports:
3937
- containerPort: 80
40-
protocol: TCP
38+
protocol: TCP

examples/https-nginx.yaml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
kind: Service
3+
apiVersion: v1
4+
metadata:
5+
name: https-lb
6+
annotations:
7+
service.beta.kubernetes.io/linode-loadbalancer-throttle: "4"
8+
service.beta.kubernetes.io/linode-loadbalancer-default-protocol: "http"
9+
service.beta.kubernetes.io/linode-loadbalancer-port-443: |
10+
{
11+
"tls-secret-name": "example-secret",
12+
"protocol": "https"
13+
}
14+
spec:
15+
type: LoadBalancer
16+
selector:
17+
app: nginx-https-example
18+
ports:
19+
- name: http
20+
protocol: TCP
21+
port: 80
22+
targetPort: http
23+
- name: https
24+
protocol: TCP
25+
port: 443
26+
targetPort: https
27+
28+
---
29+
apiVersion: apps/v1
30+
kind: Deployment
31+
metadata:
32+
name: nginx-https-deployment
33+
spec:
34+
replicas: 2
35+
selector:
36+
matchLabels:
37+
app: nginx-https-example
38+
template:
39+
metadata:
40+
labels:
41+
app: nginx-https-example
42+
spec:
43+
containers:
44+
- name: nginx
45+
image: nginx
46+
ports:
47+
- name: http
48+
containerPort: 80
49+
protocol: TCP
50+
- name: https
51+
containerPort: 80
52+
protocol: TCP

examples/tcp-nginx.yaml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ metadata:
66
spec:
77
type: LoadBalancer
88
selector:
9-
app: nginx-example
9+
app: nginx-tcp-example
1010
ports:
1111
- name: http
1212
protocol: TCP
@@ -17,22 +17,20 @@ spec:
1717
apiVersion: apps/v1
1818
kind: Deployment
1919
metadata:
20-
name: nginx-example
21-
labels:
22-
app: nginx
20+
name: nginx-tcp-deployment
2321
spec:
2422
replicas: 2
2523
selector:
2624
matchLabels:
27-
app: nginx
25+
app: nginx-tcp-example
2826
template:
2927
metadata:
3028
labels:
31-
app: nginx-example
29+
app: nginx-tcp-example
3230
spec:
3331
containers:
3432
- name: nginx
3533
image: nginx
3634
ports:
3735
- containerPort: 80
38-
protocol: TCP
36+
protocol: TCP

examples/test.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
set -euxo pipefail
4+
5+
kubectl apply -f ./http-nginx.yaml
6+
kubectl apply -f ./tcp-nginx.yaml
7+
8+
openssl req -newkey rsa:4096 \
9+
-x509 \
10+
-sha256 \
11+
-days 3650 \
12+
-nodes \
13+
-out example.crt \
14+
-keyout example.key \
15+
-subj "/C=na/ST=na/L=na/O=na/OU=na/CN=na"
16+
17+
kubectl delete secret example-secret || true
18+
kubectl create secret tls example-secret --cert=example.crt --key=example.key
19+
kubectl apply -f ./https-nginx.yaml
20+

0 commit comments

Comments
 (0)