Skip to content

Commit d7df1e2

Browse files
feat(video): Traefik + Cert-manager + cloudflare
1 parent fda20c1 commit d7df1e2

File tree

1 file changed

+265
-0
lines changed

1 file changed

+265
-0
lines changed
Lines changed: 265 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,265 @@
1+
---
2+
layout: post
3+
title: "Wildcard Certificates with Traefik + cert-manager + Let's Encrypt in Kubernetes Tutorial"
4+
date: 2022-08-06 10:00:00 -0500
5+
categories: kubernetes
6+
tags: kubernetes grafana prometheus alert-manager k3s
7+
---
8+
9+
[![Wildcard Certificates with Traefik + cert-manager + Let's Encrypt in Kubernetes Tutorial](https://img.youtube.com/vi/G4CmbYL9UPg/0.jpg)](https://www.youtube.com/watch?v=G4CmbYL9UPg "Wildcard Certificates with Traefik + cert-manager + Let's Encrypt in Kubernetes Tutorial")
10+
11+
Traefik, cert-manager, Cloudflare, and Let's Encrypt are a winning combination when it comes to securing your services with certificates in Kubernetes. Today, we'll install and configure Traefik, the cloud native proxy and load balancer, as our Kubernetes Ingress Controller. We'll then install and configure cert-manager to manage certificates for our cluster. We'll set up Let's Encrypt as our Cluster Issuer so that cert-manager can automatically provision TLS certificates and even wildcard certificates using Cloudflare DNS challenge absolutely free. We'll walk through all of this, step by step, so you can help secure your cluster today.
12+
13+
📺 [Watch Video](https://www.youtube.com/watch?v=G4CmbYL9UPg)
14+
15+
A HUGE thanks to Datree for sponsoring this video!
16+
17+
Combat misconfigurations. Empower engineers.
18+
19+
<https://www.datree.io>
20+
21+
## Getting Started
22+
23+
If you need to install a new kubernetes cluster you can use my [Ansible Playbook](https://docs.technotim.live/posts/k3s-etcd-ansible/) to install one.
24+
25+
### helm
26+
27+
```bash
28+
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
29+
chmod 700 get_helm.sh
30+
./get_helm.sh
31+
```
32+
33+
## Installing
34+
35+
Verify you can communicate with your cluster
36+
37+
```bash
38+
kubectl get nodes
39+
```
40+
41+
```console
42+
NAME STATUS ROLES AGE VERSION
43+
k3s-01 Ready control-plane,etcd,master 10h v1.23.4+k3s1
44+
k3s-02 Ready control-plane,etcd,master 10h v1.23.4+k3s1
45+
k3s-03 Ready control-plane,etcd,master 10h v1.23.4+k3s1
46+
k3s-04 Ready <none> 10h v1.23.4+k3s1
47+
k3s-05 Ready <none> 10h v1.23.4+k3s1
48+
```
49+
50+
Verify helm is installed
51+
52+
```bash
53+
helm version
54+
```
55+
56+
```console
57+
version.BuildInfo{Version:"v3.8.0", GitCommit:"d14138609b01886f544b2025f5000351c9eb092e", GitTreeState:"clean", GoVersion:"go1.17.5"}
58+
```
59+
60+
## Traefik
61+
62+
```bash
63+
helm repo add traefik https://helm.traefik.io/traefik
64+
```
65+
66+
```bash
67+
helm repo update
68+
```
69+
70+
```bash
71+
helm install --namespace=traefik traefik traefik/traefik --values=values.yaml
72+
```
73+
74+
Check the status of the Traefik ingress controller service
75+
76+
```bash
77+
kubectl get svc --all-namespaces -o wide
78+
```
79+
80+
should see traefik with the specified IP
81+
82+
```console
83+
NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
84+
default kubernetes ClusterIP 10.43.0.1 <none> 443/TCP 16h <none>
85+
kube-system kube-dns ClusterIP 10.43.0.10 <none> 53/UDP,53/TCP,9153/TCP 16h k8s-app=kube-dns
86+
kube-system metrics-server ClusterIP 10.43.182.24 <none> 443/TCP 16h k8s-app=metrics-server
87+
metallb-system webhook-service ClusterIP 10.43.205.142 <none> 443/TCP 16h component=controller
88+
traefik traefik LoadBalancer 10.43.156.161 192.168.30.80 80:30358/TCP,443:31265/TCP 22s app.kubernetes.io/instance=traefik,app.kubernetes.io/name=traefik
89+
```
90+
91+
```bash
92+
kubectl get pods --namespace traefik
93+
```
94+
95+
should see
96+
97+
```console
98+
NAME READY STATUS RESTARTS AGE
99+
traefik-76474c4d47-l5z74 1/1 Running 0 11m
100+
traefik-76474c4d47-xb282 1/1 Running 0 11m
101+
traefik-76474c4d47-xx5lw 1/1 Running 0 11m
102+
```
103+
104+
### middleware
105+
106+
```bash
107+
kubectl apply -f default-headers.yaml
108+
```
109+
110+
```bash
111+
kubectl get middleware
112+
```
113+
114+
should see
115+
116+
```console
117+
NAME AGE
118+
default-headers 25s
119+
```
120+
121+
### dashboard
122+
123+
install `htpassword`
124+
125+
```bash
126+
sudo apt-get update
127+
sudo apt-get install apache2-utils
128+
```
129+
130+
generate password
131+
132+
```bash
133+
htpasswd -nb techno password | openssl base64
134+
```
135+
136+
apply secret
137+
138+
```bash
139+
kubectl apply -f secret
140+
```
141+
142+
get secret
143+
144+
```bash
145+
kubectl get secrets --namespace traefik
146+
```
147+
148+
apply dashboard
149+
150+
```bash
151+
kubectl apply -f dashboard.yaml
152+
```
153+
154+
visit
155+
156+
<https://traefik.local.technotim.live/>
157+
158+
159+
## sample workload
160+
161+
```bash
162+
kubectl apply -f deployment.yaml
163+
kubectl apply -f service.yaml
164+
kubectl apply -f ingress.yaml
165+
```
166+
167+
or folder
168+
169+
```bash
170+
kubectl apply -f nginx
171+
```
172+
173+
## cert-manager
174+
175+
add repo
176+
177+
```bash
178+
helm repo add jetstack https://charts.jetstack.io
179+
```
180+
181+
```bash
182+
update
183+
```
184+
185+
```bash
186+
kubectl create namespace cert-manager
187+
```
188+
189+
```bash
190+
kubectl get namespaces
191+
```
192+
193+
should see
194+
195+
```console
196+
NAME STATUS AGE
197+
cert-manager Active 12s
198+
default Active 21h
199+
kube-node-lease Active 21h
200+
kube-public Active 21h
201+
kube-system Active 21h
202+
metallb-system Active 21h
203+
traefik Active 4h35m
204+
```
205+
206+
apply crds (1.9.1)
207+
208+
```bash
209+
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.9.1/cert-manager.crds.yaml
210+
```
211+
212+
```bash
213+
helm install cert-manager jetstack/cert-manager --namespace cert-manager --values=values.yaml --version v1.9.1
214+
```
215+
216+
secrets
217+
218+
```bash
219+
kubectl apply -f secret-cf-token.yaml
220+
kubectl apply -f secret-cf-email.yaml
221+
```
222+
223+
issuers
224+
225+
226+
```bash
227+
kubectl apply -f letsencrypt-staging.yaml
228+
```
229+
230+
create certs
231+
232+
staging
233+
234+
from staging folder
235+
236+
```bash
237+
kubectl apply -f technotim-live-cert.yaml
238+
```
239+
240+
looks at logs
241+
242+
can tail with
243+
244+
```bash
245+
kubectl logs -n cert-manager -f cert-manager-877fd747c-fjwhp
246+
```
247+
248+
get challenges
249+
250+
```bash
251+
kubectl get challenges
252+
```
253+
254+
or more details with
255+
256+
```bash
257+
kubectl describe order local-technotim-live-frm2z-1836084675
258+
```
259+
260+
261+
## Links
262+
263+
⚙️ See all the hardware I recommend at <https://l.technotim.live/gear>
264+
265+
🚀 Don't forget to check out the [🚀Launchpad repo](https://l.technotim.live/quick-start) with all of the quick start source files

0 commit comments

Comments
 (0)