-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: Certificate Defaulting with Kyverno
- Add a turotial using Kyverno to override Certificate defaults - YAML resources with public links for easy downloading - Add tutorial to main page list - Rewritten from the original draft to ensure it is a tutorial and flows well Signed-off-by: Peter Fiddes <[email protected]>
- Loading branch information
Showing
12 changed files
with
768 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -634,6 +634,8 @@ v1.13. | |
v1.12.5 | ||
v1.12.6 | ||
v1.12.7 | ||
v1.14.0 | ||
v1.14.X | ||
liveness | ||
apiservices | ||
arm64 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
public/docs/tutorials/certificate-defaults/cert-test-minimal.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
apiVersion: cert-manager.io/v1 | ||
kind: Certificate | ||
metadata: | ||
name: test-minimal | ||
namespace: default | ||
spec: | ||
dnsNames: | ||
- example.com |
19 changes: 19 additions & 0 deletions
19
public/docs/tutorials/certificate-defaults/cert-test-revision-override.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
apiVersion: cert-manager.io/v1 | ||
kind: Certificate | ||
metadata: | ||
name: test-revision-override | ||
namespace: default | ||
spec: | ||
dnsNames: | ||
- example.com | ||
issuerRef: | ||
group: cert-manager.io | ||
kind: ClusterIssuer | ||
name: not-my-corp-issuer | ||
privateKey: | ||
algorithm: RSA | ||
encoding: PKCS8 | ||
rotationPolicy: Never | ||
size: 4096 | ||
revisionHistoryLimit: 44 | ||
secretName: test-revision-override-cert |
13 changes: 13 additions & 0 deletions
13
public/docs/tutorials/certificate-defaults/cert-test-revision.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
apiVersion: cert-manager.io/v1 | ||
kind: Certificate | ||
metadata: | ||
name: test-revision | ||
namespace: default | ||
spec: | ||
dnsNames: | ||
- example.com | ||
issuerRef: | ||
group: cert-manager.io | ||
kind: ClusterIssuer | ||
name: not-my-corp-issuer | ||
secretName: test-revision-cert |
45 changes: 45 additions & 0 deletions
45
public/docs/tutorials/certificate-defaults/cpol-mutate-certificate-defaults.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
apiVersion: kyverno.io/v1 | ||
kind: ClusterPolicy | ||
metadata: | ||
name: 0-mutate-certificate-defaults | ||
spec: | ||
failurePolicy: Fail | ||
rules: | ||
# Set a sane default for the history field if not already present | ||
- name: set-revisionHistoryLimit | ||
match: | ||
any: | ||
- resources: | ||
kinds: | ||
- Certificate | ||
mutate: | ||
patchStrategicMerge: | ||
spec: | ||
# +(...) This is the clever syntax for if not already set | ||
+(revisionHistoryLimit): 2 | ||
# Set rotation to always if not already set | ||
- name: set-privateKey-rotationPolicy | ||
match: | ||
any: | ||
- resources: | ||
kinds: | ||
- Certificate | ||
mutate: | ||
patchStrategicMerge: | ||
spec: | ||
privateKey: | ||
+(rotationPolicy): Always | ||
# Set private key details for algorithm an size | ||
- name: set-privateKey-details | ||
match: | ||
any: | ||
- resources: | ||
kinds: | ||
- Certificate | ||
mutate: | ||
patchStrategicMerge: | ||
spec: | ||
privateKey: | ||
+(algorithm): ECDSA | ||
+(size): 521 | ||
+(encoding): PKCS1 |
31 changes: 31 additions & 0 deletions
31
public/docs/tutorials/certificate-defaults/cpol-mutate-certificate-required.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
apiVersion: kyverno.io/v1 | ||
kind: ClusterPolicy | ||
metadata: | ||
name: 1-mutate-certificate-required | ||
spec: | ||
rules: | ||
# Test if we can set a secretName when one is not provided | ||
- name: set-default-secret-name | ||
match: | ||
any: | ||
- resources: | ||
kinds: | ||
- Certificate | ||
mutate: | ||
patchStrategicMerge: | ||
spec: | ||
+(secretName): "{{request.object.metadata.name}}-cert" | ||
# Test if we can set a default issuerRef | ||
- name: set-default-issuer-ref | ||
match: | ||
any: | ||
- resources: | ||
kinds: | ||
- Certificate | ||
mutate: | ||
patchStrategicMerge: | ||
spec: | ||
+(issuerRef): | ||
name: our-corp-issuer | ||
kind: ClusterIssuer | ||
group: cert-manager.io |
24 changes: 24 additions & 0 deletions
24
public/docs/tutorials/certificate-defaults/cpol-validate-certificate.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
apiVersion: kyverno.io/v1 | ||
kind: ClusterPolicy | ||
metadata: | ||
name: validate-certificate | ||
spec: | ||
rules: | ||
# Test from the kyverno examples to validate any subdomain of corp.com applied the correct issuer | ||
- name: restrict-corp-cert-issuer | ||
match: | ||
any: | ||
- resources: | ||
kinds: | ||
- Certificate | ||
validate: | ||
message: When requesting a cert for this domain, you must use our corporate issuer. | ||
pattern: | ||
spec: | ||
(dnsNames): ["*.corp.com"] | ||
issuerRef: | ||
name: our-corp-issuer | ||
kind: ClusterIssuer | ||
group: cert-manager.io | ||
validationFailureAction: Enforce | ||
background: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
apiVersion: networking.k8s.io/v1 | ||
kind: Ingress | ||
metadata: | ||
annotations: | ||
cert-manager.io/cluster-issuer: "our-corp-issuer" | ||
name: defaults-example | ||
namespace: default | ||
spec: | ||
ingressClassName: nginx | ||
rules: | ||
- host: app.example.com | ||
http: | ||
paths: | ||
- backend: | ||
service: | ||
name: app | ||
port: | ||
number: 80 | ||
path: / | ||
pathType: ImplementationSpecific | ||
tls: | ||
- hosts: | ||
- app.example.com | ||
secretName: defaults-example-certificate-tls |
16 changes: 16 additions & 0 deletions
16
public/docs/tutorials/certificate-defaults/mutatingwebhookconfiguration-patch.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
webhooks: | ||
- name: webhook.cert-manager.io | ||
namespaceSelector: {} | ||
objectSelector: {} | ||
reinvocationPolicy: Never | ||
rules: | ||
- apiGroups: | ||
- cert-manager.io | ||
apiVersions: | ||
- v1 | ||
operations: | ||
- CREATE | ||
resources: | ||
- 'certificaterequests' | ||
scope: '*' | ||
|