Skip to content

Commit c350a5e

Browse files
authored
Merge pull request #48 from ricsanfre/feature/linkerd
Feature/linkerd
2 parents a459b60 + e6238f8 commit c350a5e

86 files changed

Lines changed: 42021 additions & 4139 deletions

File tree

Some content is hidden

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

docs/_data/docs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
- title: Cluster Backup
3030
docs:
3131
- backup
32+
- title: Service Mesh
33+
docs:
34+
- service-mesh
3235
- title: Reference Docs
3336
docs:
3437
- k8s-networking

docs/_docs/ansible-instructions.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Quick Start Instructions
33
permalink: /docs/ansible/
44
description: Quick Start guide to deploy our Raspberry Pi Kuberentes Cluster using cloud-init and ansible playbooks.
5-
last_modified_at: "25-02-2022"
5+
last_modified_at: "05-04-2022"
66
---
77

88
This are the instructions to quickly deploy Kuberentes Pi-cluster using cloud-init and Ansible Playbooks
@@ -217,7 +217,7 @@ ansible-playbook k3s_install.yml
217217

218218
### K3S basic services deployment
219219

220-
To deploy and configure basic services (metallb, traefik, certmanager, longhorn, EFK, Prometheus, Velero) run the playbook:
220+
To deploy and configure basic services (metallb, traefik, certmanager, linkerd, longhorn, EFK, Prometheus, Velero) run the playbook:
221221

222222
```shell
223223
ansible-playbook k3s_deploy.yml
@@ -229,15 +229,19 @@ Different ansible tags can be used to select the componentes to deploy:
229229
ansible-playbook k3s_deploy.yml --tags <ansible_tag>
230230
```
231231

232-
| Ansible Tag | Component to configure/deploy |
232+
The following table shows the different components and their dependencies.
233+
234+
| Ansible Tag | Component to configure/deploy | Dependencies
233235
|---|---|
234-
| `metallb` | Metal LB |
235-
| `traefik` | Traefik |
236-
| `certmanager` | Cert-manager |
237-
| `longhorn` | Longhorn |
238-
| `logging` | EFK Stack |
239-
| `monitoring` | Prometheus Stack |
240-
| `backup` | Velero |
236+
| `metallb` | Metal LB | - |
237+
| `certmanager` | Cert-manager | - |
238+
| `linkerd` | Linkerd | Cert-manager |
239+
| `traefik` | Traefik | Linkerd |
240+
| `longhorn` | Longhorn | Linkerd |
241+
| `monitoring` | Prometheus Stack | Longhorn, Linkerd |
242+
| `linkerd-viz` | Linkerd Viz | Prometheus Stack, Linkerd |
243+
| `logging` | EFK Stack | Longhorn, Linkerd |
244+
| `backup` | Velero | Linkerd |
241245
{: .table }
242246

243247
### K3s Cluster reset

docs/_docs/certmanager.md

Lines changed: 145 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,112 @@
22
title: SSL Certificates (Cert-Manager)
33
permalink: /docs/certmanager/
44
description: How to deploy a centralized SSL certification management solution based on Cert-manager in our Raspberry Pi Kuberentes cluster.
5-
last_modified_at: "25-02-2022"
5+
last_modified_at: "08-03-2022"
66
---
77

88
In the Kubernetes cluster, [Cert-Manager](https://cert-manager.io/docs/) can be used to automate the certificate management tasks (issue certificate request, renewals, etc.). Cert-manager adds certificates and certificate issuers as resource types in Kubernetes clusters, and simplifies the process of obtaining, renewing and using those certificates.
99

10-
It can issue certificates from a variety of supported sources, including support for auto-signed certificates or use [Let's Encrypt](https://letsencrypt.org/) service to obtain validated SSL certificates. It will ensure certificates are valid and up to date, and attempt to renew certificates at a configured time before expiry.
10+
It can issue certificates from a variety of supported sources, including support for auto-signed certificates or use [Let's Encrypt](https://letsencrypt.org/) service to obtain validated SSL certificates. It will ensure certificates are valid and up to date, and attempt to renew certificates at a configured time before expiry. It also keep up to date the associated Kuberentes Secrets storing key pairs used by Ingress resources when securing the incoming communications.
1111

12-
{{site.data.alerts.note}}
13-
CertManager integration with Let's Encryp has not been configured since my DNS provider does not suppport yet the API for automating DNS challenges. See open issue [#16](https://github.com/ricsanfre/pi-cluster/issues/16).
12+
![picluster-certmanager](/assets/img/cert-manager.png)
13+
14+
## Cert-Manager certificates issuers
15+
16+
In cert-manager different kind of certificate issuer can be configured to generate signed SSL certificates
17+
18+
### Self-signed Issuer
19+
20+
The SelfSigned issuer doesn’t represent a certificate authority as such, but instead denotes that certificates will “sign themselves” using a given private key. In other words, the private key of the certificate will be used to sign the certificate itself.
21+
22+
This Issuer type is useful for bootstrapping a root certificate (CA) for a custom PKI (Public Key Infrastructure).
23+
24+
We will use this Issuer for bootstrapping our custom CA.
25+
26+
### CA Issuer
27+
28+
The CA issuer represents a Certificate Authority whereby its certificate and private key are stored inside the cluster as a Kubernetes Secret, and will be used to sign incoming certificate requests. This internal CA certificate can then be used to trust resulting signed certificates.
29+
30+
This issuer type is typically used in a private Public Key Infrastructure (PKI) setup to secure your infrastructure components to establish mTLS or otherwise provide a means to issue certificates where you also own the private key. Signed certificates with this custom CA will not be trusted by clients, such a web browser, by default.
31+
32+
### ACME issuers (Lets Encrypt)
33+
34+
The ACME Issuer type represents a single account registered with the Automated Certificate Management Environment (ACME) Certificate Authority server. See section [Let's Encrypt certificates](#lets-encrypt-certificates).
35+
36+
37+
{{site.data.alerts.important}}
38+
39+
CertManager has been configured to have in the cluster a private PKI (Public Key Infrastructure) using a self-signed CA to issue auto-signed certificates.
40+
41+
CertManager integration with Let's Encrypt has not been configured since my DNS provider does not suppport yet the API for automating DNS challenges. See open issue [#16](https://github.com/ricsanfre/pi-cluster/issues/16).
1442

15-
CertManager has been configured to issue selfsigned certificates.
1643
{{site.data.alerts.end}}
1744

45+
46+
## Cert Manager Usage
47+
48+
Cert-manager add a set of Kubernetes custom resource (CRD):
49+
50+
- `Issuer` and `ClusterIssuer`: resources that represent certificate authorities (CA) able to genertate signed certificates in response to certificate signed request (CSR). `Issuer` is a namespaced resource, able to issue certificates only for the namespace where the issuer is located. `ClusterIssuer` is able to issue certificates across all namespaces.
51+
52+
- `Certificate`, resources that represent a human readable definition of a certificate request that need to be generated and keep up to date by an issuer.
53+
54+
In order to generate new SSL certificates a `Certificate` resource can be created.
55+
56+
Once the Certificate resource is created, Cert-manager signed the certificate issued by the specified issuer and stored it in a `kubernetes.io/tls Secret` resource, which is the one used to secure Ingress resource. See kuberentes [Ingress TLS documentation](https://kubernetes.io/docs/concepts/services-networking/ingress/#tls)
57+
58+
```yml
59+
apiVersion: v1
60+
kind: Secret
61+
metadata:
62+
name: testsecret-tls
63+
namespace: default
64+
data:
65+
tls.crt: base64 encoded cert
66+
tls.key: base64 encoded key
67+
type: kubernetes.io/tls
68+
```
69+
70+
See further details in the [cert-manager documentation](https://cert-manager.io/docs/usage/certificate/)
71+
72+
73+
### Securing Ingress resources
74+
75+
`Ingress` resources can be configured using annotations, so cert-manager can automatically generate the needed self-signed certificates to secure the incoming communications using HTTPS/TLS
76+
77+
As stated in the [documentation](https://cert-manager.io/docs/usage/ingress/), cert-manager can be used to automatically request TLS signed certificates to secure any `Ingress` resources. By means of annotations cert-manager can generate automatically the needed certificates and store them in corresponding secrets used by Ingress resource
78+
79+
Ingress annotation `cert-manager.io/cluster-issuer` indicates the `ClusterIssuer` to be used.
80+
81+
Ingress rule example:
82+
83+
```yml
84+
apiVersion: networking.k8s.io/v1
85+
kind: Ingress
86+
metadata:
87+
annotations:
88+
# add an annotation indicating the issuer to use.
89+
cert-manager.io/cluster-issuer: nameOfClusterIssuer
90+
name: myIngress
91+
namespace: myIngress
92+
spec:
93+
rules:
94+
- host: example.com
95+
http:
96+
paths:
97+
- pathType: Prefix
98+
path: /
99+
backend:
100+
service:
101+
name: myservice
102+
port:
103+
number: 80
104+
tls: # < placing a host in the TLS config will determine what ends up in the cert's subjectAltNames
105+
- hosts:
106+
- example.com
107+
secretName: myingress-cert # < cert-manager will store the created certificate in this secret.
108+
```
109+
110+
18111
## Cert Manager Installation
19112

20113
Installation using `Helm` (Release 3):
@@ -37,18 +130,25 @@ Installation using `Helm` (Release 3):
37130
- Step 3: Install Cert-Manager
38131

39132
```shell
40-
helm install cert-manager jetstack/cert-manager --namespace certmanager-system --version v1.5.3 --set installCRDs=true
133+
helm install cert-manager jetstack/cert-manager --namespace certmanager-system --set installCRDs=true
41134
```
42135
- Step 4: Confirm that the deployment succeeded, run:
43136

44137
```shell
45138
kubectl -n certmanager-system get pod
46139
```
47140

48-
## Self-signed Certificates
141+
## Cert-Manager Configuration
142+
143+
A PKI (Public Key Infrastructure) with a custom CA will be created in the cluster and all certificates will be auto-signed by this CA. For doing so, A CA `ClusterIssuer` resource need to be created.
144+
145+
Root CA certificate is needed for generated this CA Issuer. A selfsigned `ClusterIssuer` resource will be used to generate that root CA certificate (self-signed root CA).
49146

50-
- Step 1: Create `ClusterIssuer`
51-
In order to obtain certificates from cert-manager, we need to create an issuer to act as a certificate authority. We have the option of creating an `Issuer` which is a namespaced resource, or a `ClusterIssuer` which is a global resource. We’ll create a self-signed `ClusterIssuer` using the following definition:
147+
- Step 1: Create selfsigned `ClusterIssuer`
148+
149+
First step is to create the self-signed issuer for being able to selfsign a custom root certificate of the PKI (CA certificate).
150+
151+
In order to obtain certificates from cert-manager, we need to create an issuer to act as a certificate authority. We have the option of creating an `Issuer` which is a namespaced resource, or a `ClusterIssuer` which is a global resource. We’ll create a self-signed `ClusterIssuer` using the following definition:
52152

53153
```yml
54154
apiVersion: cert-manager.io/v1
@@ -59,44 +159,50 @@ In order to obtain certificates from cert-manager, we need to create an issuer t
59159
selfSigned: {}
60160
```
61161

62-
- Step 2: Configure Ingress rule to automatically use cert-manager to issue self-signed certificates
63-
64-
As stated in the [documentation](https://cert-manager.io/docs/usage/ingress/), cert-manager can be used to automatically request TLS signed certificates to secure any `Ingress` resources. By means of annotations cert-manager can generate automatically the needed certificates
162+
- Step 2: Bootstrapping CA Issuers
65163

66-
Ingress annotation `cert-manager.io/cluster-issuer` indicates the `ClusterIssuer` to be used
67-
68-
Ingress rule example:
164+
Bootstrap a custom root certificate for a private PKI (custom CA) and create the corresponding cert-manager CA issuer
69165

70166
```yml
71-
apiVersion: networking.k8s.io/v1
72-
kind: Ingress
167+
---
168+
apiVersion: cert-manager.io/v1
169+
kind: Certificate
170+
metadata:
171+
name: my-selfsigned-ca
172+
namespace: sandbox
173+
spec:
174+
isCA: true
175+
commonName: my-selfsigned-ca
176+
secretName: root-secret
177+
privateKey:
178+
algorithm: ECDSA
179+
size: 256
180+
issuerRef:
181+
name: selfsigned-issuer
182+
kind: ClusterIssuer
183+
group: cert-manager.io
184+
---
185+
apiVersion: cert-manager.io/v1
186+
kind: ClusterIssuer
73187
metadata:
74-
annotations:
75-
# add an annotation indicating the issuer to use.
76-
cert-manager.io/cluster-issuer: nameOfClusterIssuer
77-
name: myIngress
78-
namespace: myIngress
188+
name: my-ca-issuer
189+
namespace: sandbox
79190
spec:
80-
rules:
81-
- host: example.com
82-
http:
83-
paths:
84-
- pathType: Prefix
85-
path: /
86-
backend:
87-
service:
88-
name: myservice
89-
port:
90-
number: 80
91-
tls: # < placing a host in the TLS config will determine what ends up in the cert's subjectAltNames
92-
- hosts:
93-
- example.com
94-
secretName: myingress-cert # < cert-manager will store the created certificate in this secret.
191+
ca:
192+
secretName: root-secret
95193
```
96194

195+
{{site.data.alerts.important}}
196+
197+
Algorithm used for creating private keys is ECDSA P-256. The use of this algorithm is required by the service mesh implementation I have selected for the cluster, Linkerd. RootCa and Linkerd identity issuer certificate must used ECDSA P-256 algorithm.
198+
199+
{{site.data.alerts.end}}
200+
201+
202+
97203
## Lets Encrypt Certificates
98204

99-
Lets Encrypt provide publicly validated TLS certificates for free. Not need to generate auti-signed SSL Certificates for the websites that are not automatic validated by HTTP browsers.
205+
Lets Encrypt provide publicly validated TLS certificates for free. Not need to generate auto-signed SSL Certificates for the websites that are not automatic validated by HTTP browsers.
100206

101207
The process is the following, we issue a request for a certificate to Let's Encrypt for a domain name that we own. Let's Encrypt verifies that we own that domain by using an ACME DNS or HTTP validation mechanism. If the verification is successful, Let's Encrypt provides us with certificates that cert-manager installs in our website (or other TLS encrypted endpoint). These certificates are good for 90 days before the process needs to be repeated. Cert-manager, however, will automatically keep the certificates up-to-date for us.
102208

@@ -121,7 +227,7 @@ Since Dec 2020, IONOS launched an API for remotelly configure DNS, and so the in
121227

122228
Unfortunally IONOS API is part of a beta program that it is not available yet in my location (Spain).
123229

124-
### Let`s Encrypt HTTP validation method
230+
### Lets Encrypt HTTP validation method
125231

126232
HTTP validation method requires to actually expose a "challenge URL" in the Public Internet using the DNS domain associated to the SSL certificate.
127233

docs/_docs/index.md

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
title: What is this project about?
33
permalink: /docs/home/
44
redirect_from: /docs/index.html
5-
description: The scope of this project is to create a kubernetes cluster at home using Raspberry Pis and to use Ansible to automate the deployment and configuration. How to automatically deploy K3s baesed kubernetes cluster, Longhorn as distributed block storage for PODs' persisten volumes, Prometheus as monitoring solution, EFK stack as centralized log management solution and Velero and Restic as backup solution.
6-
last_modified_at: "25-02-2022"
5+
description: The scope of this project is to create a kubernetes cluster at home using Raspberry Pis and to use Ansible to automate the deployment and configuration. How to automatically deploy K3s baesed kubernetes cluster, Longhorn as distributed block storage for PODs' persisten volumes, Prometheus as monitoring solution, EFK stack as centralized log management solution, Velero and Restic as backup solution and Linkerd as service mesh architecture.
6+
last_modified_at: "05-04-2022"
77
---
88

99

@@ -12,7 +12,7 @@ The scope of this project is to create a kubernetes cluster at home using **Rasp
1212

1313
This is an educational project to explore kubernetes cluster configurations using an ARM architecture and its automation using Ansible.
1414

15-
As part of the project the goal is to use a lightweight Kubernetes flavor based on [K3S](https://ks3.io/) and deploy cluster basic services such as: 1) distributed block storage for POD's persistent volumes, [LongHorn](https://longhorn.io/), 2) centralized monitoring tool, [Prometheus](https://prometheus.io/) 3) centralized log managemeent, EFK stack ([Elasticsearch](https://www.elastic.co/elasticsearch/)-[Fluentbit](https://fluentbit.io/)-[Kibana](https://www.elastic.co/kibana/) and 3) backup/restore solution for the cluster, [Velero](https://velero.io/) and [Restic](https://restic.net/).
15+
As part of the project the goal is to use a lightweight Kubernetes flavor based on [K3S](https://ks3.io/) and deploy cluster basic services such as: 1) distributed block storage for POD's persistent volumes, [LongHorn](https://longhorn.io/), 2) centralized monitoring tool, [Prometheus](https://prometheus.io/) 3) centralized log managemeent, EFK stack ([Elasticsearch](https://www.elastic.co/elasticsearch/)-[Fluentbit](https://fluentbit.io/)-[Kibana](https://www.elastic.co/kibana/), 3) backup/restore solution for the cluster, [Velero](https://velero.io/) and [Restic](https://restic.net/) and 4) service mesh architecture, [Linkerd](https://linkerd.io/)
1616

1717

1818
The following picture shows the set of opensource solutions used for building this cluster:
@@ -94,21 +94,23 @@ The software used and the latest version tested of each component
9494
| OS | Ubuntu | 20.04.3 | OS need to be tweaked for Raspberry PI when booting from external USB |
9595
| Control | Ansible | 2.12.1 | |
9696
| Control | cloud-init | 21.4 | version pre-integrated into Ubuntu 20.04 |
97-
| Kubernetes | K3S | v1.22.6 | K3S version|
97+
| Kubernetes | K3S | v1.22.7 | K3S version|
9898
| Kubernetes | Helm | v3.6.3 ||
9999
| Computing | containerd | v1.5.9-k3s1 | version pre-integrated into K3S |
100-
| Networking | Flannel | v0.15.1 | version pre-integrated into K3S |
100+
| Networking | Flannel | v0.16.13 | version pre-integrated into K3S |
101101
| Networking | CoreDNS | v1.8.6 | version pre-integrated into K3S |
102-
| Networking | Metal LB | v0.11.0 | Helm chart version: metallb-0.11.0 |
103-
| Service Proxy | Traefik | v2.5.6 | Helm chart: traefik-10.9.100 version pre-integrated into K3S |
104-
| Storage | Longhorn | v1.2.3 | Helm chart version: longhorn-1.2.3 |
105-
| SSL Certificates | Certmanager | v1.7.1 | Helm chart version: cert-manager-v1.7.1 |
106-
| Logging | ECK Operator | 2.0.0 | Helm chart version: eck-operator-2.0.0 |
102+
| Networking | Metal LB | v0.12.1 | Helm chart version: metallb-0.12.1 |
103+
| Service Mesh | Linkerd | v2.11.1 | Helm chart version: linkerd2-2.11.1 |
104+
| Service Proxy | Traefik | v2.6.1 | Helm chart: traefik-10.14.100 version pre-integrated into K3S |
105+
| Storage | Longhorn | v1.2.4 | Helm chart version: longhorn-1.2.4 |
106+
| SSL Certificates | Certmanager | v1.7.2 | Helm chart version: cert-manager-v1.7.2 |
107+
| Logging | ECK Operator | 2.1.0 | Helm chart version: eck-operator-2.1.0 |
107108
| Logging | Elastic Search | 7.15 | Deployed with ECK Operator |
108109
| Logging | Kibana | 7.15 | Deployed with ECK Operator |
109-
| Logging | Fluentbit | 1.8.12 | Helm chart version: fluent-bit-0.19.19 |
110-
| Monitoring | Kube Prometheus Stack | 0.54.0 | Helm chart version: kube-prometheus-stack-32.2.1 |
110+
| Logging | Fluentbit | 1.8.15 | Helm chart version: fluent-bit-0.19.23 |
111+
| Monitoring | Kube Prometheus Stack | 0.55.0 | Helm chart version: kube-prometheus-stack-34.6.0 |
111112
| Backup | Minio | 2021-12-29T06:49:06Z | |
112113
| Backup | Restic | 0.12.1 | |
113-
| Backup | Velero |1.7.1 | Helm chart version: velero-2.27.2 |
114+
| Backup | Velero | 1.8.1 | Helm chart version: velero-2.29.4 |
115+
114116
{: .table }

0 commit comments

Comments
 (0)