feat: add cert-manager
This commit is contained in:
18 files changed
+189
-11
No files matched your search
@@ -1,13 +1,15 @@
|
|||||||
# cluster-k3s
|
# cluster-k3s
|
||||||
|
|
||||||
Template for creating a k3s cluster with [k3sup](https://github.com/alexellis/k3sup), [Flux](https://toolkit.fluxcd.io/) and [SOPS](https://github.com/mozilla/sops)
|
Template for creating a [k3s](https://k3s.io/) cluster with [k3sup](https://github.com/alexellis/k3sup), [Flux](https://toolkit.fluxcd.io/) and [SOPS](https://github.com/mozilla/sops)
|
||||||
|
|
||||||
This template will bootstrap the nodes you want with the following components
|
This template will bootstrap the nodes you want with the following components:
|
||||||
|
|
||||||
- k3s
|
- [k3s](https://k3s.io/)
|
||||||
- flux
|
- [flannel](https://github.com/flannel-io/flannel)
|
||||||
- metallb
|
- [local-path-provisioner](https://github.com/rancher/local-path-provisioner)
|
||||||
- flannel
|
- [flux](https://toolkit.fluxcd.io/)
|
||||||
|
- [metallb](https://metallb.universe.tf/)
|
||||||
|
- [cert-manager](https://cert-manager.io/) with Cloudflare DNS challenge
|
||||||
|
|
||||||
## :memo: Prerequisites
|
## :memo: Prerequisites
|
||||||
|
|
||||||
@@ -112,8 +114,8 @@ k3sup join \
|
|||||||
```sh
|
```sh
|
||||||
kubectl --kubeconfig=./kubeconfig get nodes
|
kubectl --kubeconfig=./kubeconfig get nodes
|
||||||
# NAME STATUS ROLES AGE VERSION
|
# NAME STATUS ROLES AGE VERSION
|
||||||
# k8s-master-a Ready control-plane,master 4d14h v1.20.5+k3s1
|
# k8s-master-a Ready control-plane,master 4d20h v1.20.5+k3s1
|
||||||
# k8s-worker-a Ready worker 4d14h v1.20.5+k3s1
|
# k8s-worker-a Ready worker 4d20h v1.20.5+k3s1
|
||||||
```
|
```
|
||||||
|
|
||||||
### GitOps with Flux
|
### GitOps with Flux
|
||||||
@@ -137,21 +139,25 @@ kubectl --kubeconfig=./kubeconfig create secret generic sops-gpg \
|
|||||||
|
|
||||||
```sh
|
```sh
|
||||||
export BOOTSTRAP_GITHUB_REPOSITORY="k8s-at-home/home-cluster"
|
export BOOTSTRAP_GITHUB_REPOSITORY="k8s-at-home/home-cluster"
|
||||||
export BOOTSTRAP_DOMAIN="k8s-at-home.com"
|
|
||||||
export BOOTSTRAP_METALLB_LB_RANGE="169.254.1.10-169.254.1.20"
|
export BOOTSTRAP_METALLB_LB_RANGE="169.254.1.10-169.254.1.20"
|
||||||
|
export BOOTSTRAP_DOMAIN="k8s-at-home.com"
|
||||||
|
export BOOTSTRAP_CLOUDFLARE_TOKEN="dsKq41iLAbXE37GV"
|
||||||
|
|
||||||
envsubst < ./.sops.yaml
|
envsubst < ./.sops.yaml
|
||||||
envsubst < ./cluster/cluster-secrets.yaml
|
envsubst < ./cluster/cluster-secrets.yaml
|
||||||
envsubst < ./cluster/cluster-settings.yaml
|
envsubst < ./cluster/cluster-settings.yaml
|
||||||
envsubst < ./cluster/base/flux-system/gotk-sync.yaml
|
envsubst < ./cluster/base/flux-system/gotk-sync.yaml
|
||||||
|
envsubst < ./cluster/core/infrastructure/cert-manager/secret.enc.yaml
|
||||||
```
|
```
|
||||||
|
|
||||||
4. **Verify** all the above files have the correct information present
|
4. **Verify** all the above files have the correct information present
|
||||||
|
|
||||||
5. Encrypt `cluster-settings.yaml` with SOPS
|
5. Encrypt `cluster-settings.yaml` and `secret.enc.yaml` with SOPS
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
export GPG_TTY=$(tty)
|
||||||
sops --encrypt --in-place ./cluster/base/cluster-secrets.yaml
|
sops --encrypt --in-place ./cluster/base/cluster-secrets.yaml
|
||||||
|
sops --encrypt --in-place ./cluster/core/infrastructure/cert-manager/secret.enc.yaml
|
||||||
```
|
```
|
||||||
|
|
||||||
6. **Verify** this file **is encrypted** with SOPS
|
6. **Verify** this file **is encrypted** with SOPS
|
||||||
@@ -180,4 +186,4 @@ pre-commit install-hooks
|
|||||||
|
|
||||||
## :handshake: Thanks
|
## :handshake: Thanks
|
||||||
|
|
||||||
A lot of inspiration for my cluster came from the people that have shared their clusters over at [awesome-home-kubernetes](https://github.com/k8s-at-home/awesome-home-kubernetes)
|
Big shout out to all the authors and contributors to the projects that we are using in this repository.
|
||||||
@@ -6,3 +6,4 @@ metadata:
|
|||||||
namespace: flux-system
|
namespace: flux-system
|
||||||
stringData:
|
stringData:
|
||||||
SECRET_DOMAIN: $BOOTSTRAP_DOMAIN
|
SECRET_DOMAIN: $BOOTSTRAP_DOMAIN
|
||||||
|
SECRET_CLOUDFLARE_EMAIL: $BOOTSTRAP_CLOUDFLARE_EMAIL
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
resources:
|
||||||
|
# renovate: registryUrl=https://charts.jetstack.io chart=cert-manager
|
||||||
|
- https://github.com/jetstack/cert-manager/releases/download/v1.3.0/cert-manager.crds.yaml
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
resources:
|
||||||
|
- cert-manager
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
resources:
|
||||||
|
- letsencrypt-production.yaml
|
||||||
|
- letsencrypt-staging.yaml
|
||||||
|
- secret.enc.yaml
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
---
|
||||||
|
apiVersion: cert-manager.io/v1
|
||||||
|
kind: ClusterIssuer
|
||||||
|
metadata:
|
||||||
|
name: letsencrypt-production
|
||||||
|
spec:
|
||||||
|
acme:
|
||||||
|
server: https://acme-v02.api.letsencrypt.org/directory
|
||||||
|
email: "${SECRET_CLOUDFLARE_EMAIL}"
|
||||||
|
privateKeySecretRef:
|
||||||
|
name: letsencrypt-production
|
||||||
|
solvers:
|
||||||
|
- dns01:
|
||||||
|
cloudflare:
|
||||||
|
email: "${SECRET_CLOUDFLARE_EMAIL}"
|
||||||
|
apiKeySecretRef:
|
||||||
|
name: cloudflare-token-secret
|
||||||
|
key: cloudflare-token
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
---
|
||||||
|
apiVersion: cert-manager.io/v1
|
||||||
|
kind: ClusterIssuer
|
||||||
|
metadata:
|
||||||
|
name: letsencrypt-staging
|
||||||
|
spec:
|
||||||
|
acme:
|
||||||
|
server: https://acme-staging-v02.api.letsencrypt.org/directory
|
||||||
|
email: "${SECRET_CLOUDFLARE_EMAIL}"
|
||||||
|
privateKeySecretRef:
|
||||||
|
name: letsencrypt-staging
|
||||||
|
solvers:
|
||||||
|
- dns01:
|
||||||
|
cloudflare:
|
||||||
|
email: "${SECRET_CLOUDFLARE_EMAIL}"
|
||||||
|
apiKeySecretRef:
|
||||||
|
name: cloudflare-token-secret
|
||||||
|
key: cloudflare-token
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
# yamllint disable
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Secret
|
||||||
|
metadata:
|
||||||
|
name: cloudflare-token-secret
|
||||||
|
namespace: cert-manager
|
||||||
|
stringData:
|
||||||
|
cloudflare-token: ${BOOTSTRAP_CLOUDFLARE_TOKEN}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
resources:
|
||||||
|
- cert-manager
|
||||||
|
- metallb
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
---
|
||||||
|
apiVersion: helm.toolkit.fluxcd.io/v2beta1
|
||||||
|
kind: HelmRelease
|
||||||
|
metadata:
|
||||||
|
name: metallb
|
||||||
|
namespace: networking
|
||||||
|
spec:
|
||||||
|
interval: 5m
|
||||||
|
chart:
|
||||||
|
spec:
|
||||||
|
chart: metallb
|
||||||
|
version: 2.3.5
|
||||||
|
sourceRef:
|
||||||
|
kind: HelmRepository
|
||||||
|
name: bitnami-charts
|
||||||
|
namespace: flux-system
|
||||||
|
interval: 10m
|
||||||
|
values:
|
||||||
|
controller:
|
||||||
|
image:
|
||||||
|
repository: metallb/controller
|
||||||
|
tag: v0.9.6
|
||||||
|
speaker:
|
||||||
|
image:
|
||||||
|
repository: metallb/speaker
|
||||||
|
tag: v0.9.6
|
||||||
|
prometheus:
|
||||||
|
serviceMonitor:
|
||||||
|
enabled: false
|
||||||
|
prometheusRule:
|
||||||
|
enabled: false
|
||||||
|
configInline:
|
||||||
|
address-pools:
|
||||||
|
- name: default
|
||||||
|
protocol: layer2
|
||||||
|
addresses:
|
||||||
|
- "${METALLB_LB_RANGE}"
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
resources:
|
||||||
|
- helm-release.yaml
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
resources:
|
||||||
|
- crds
|
||||||
|
- infrastructure
|
||||||
|
- namespaces
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Namespace
|
||||||
|
metadata:
|
||||||
|
name: cert-manager
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
resources:
|
||||||
|
- cert-manager.yaml
|
||||||
|
- networking.yaml
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Namespace
|
||||||
|
metadata:
|
||||||
|
name: networking
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
---
|
||||||
|
apiVersion: helm.toolkit.fluxcd.io/v2beta1
|
||||||
|
kind: HelmRelease
|
||||||
|
metadata:
|
||||||
|
name: cert-manager
|
||||||
|
namespace: cert-manager
|
||||||
|
spec:
|
||||||
|
interval: 5m
|
||||||
|
chart:
|
||||||
|
spec:
|
||||||
|
# renovate: registryUrl=https://charts.jetstack.io/
|
||||||
|
chart: cert-manager
|
||||||
|
version: v1.3.0
|
||||||
|
sourceRef:
|
||||||
|
kind: HelmRepository
|
||||||
|
name: jetstack-charts
|
||||||
|
namespace: flux-system
|
||||||
|
interval: 5m
|
||||||
|
values:
|
||||||
|
installCRDs: false
|
||||||
|
webhook:
|
||||||
|
enabled: true
|
||||||
|
extraArgs:
|
||||||
|
- --dns01-recursive-nameservers=1.1.1.1:53
|
||||||
|
- --dns01-recursive-nameservers-only
|
||||||
|
cainjector:
|
||||||
|
replicaCount: 1
|
||||||
|
podDnsPolicy: "None"
|
||||||
|
podDnsConfig:
|
||||||
|
nameservers:
|
||||||
|
- "1.1.1.1"
|
||||||
|
- "8.8.8.8"
|
||||||
|
prometheus:
|
||||||
|
enabled: false
|
||||||
|
servicemonitor:
|
||||||
|
enabled: false
|
||||||
|
prometheusInstance: monitoring
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
resources:
|
||||||
|
- helm-release.yaml
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
resources:
|
||||||
|
- cert-manager
|
||||||
Reference in new issue
Block a user