Skip to content

Commit 70afc5b

Browse files
committed
add docs
On-behalf-of: @SAP [email protected]
1 parent 73b2428 commit 70afc5b

File tree

10 files changed

+95
-10
lines changed

10 files changed

+95
-10
lines changed

config/crd/bases/operator.kcp.io_frontproxies.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ spec:
210210
DNS names determined automatically by the kcp-operator.
211211
If DNSNames is used together with IssuerRef, DNSNames will be uses as-is and not merged.
212212
If IssuerRef is not set, DNSNames will be merged with the defaults. This is to avoid
213-
trying to guess what DNSNames configued issuer might support.
213+
trying to guess what DNSNames configured issuer might support.
214214
items:
215215
type: string
216216
type: array

config/crd/bases/operator.kcp.io_kubeconfigs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ spec:
9898
DNS names determined automatically by the kcp-operator.
9999
If DNSNames is used together with IssuerRef, DNSNames will be uses as-is and not merged.
100100
If IssuerRef is not set, DNSNames will be merged with the defaults. This is to avoid
101-
trying to guess what DNSNames configued issuer might support.
101+
trying to guess what DNSNames configured issuer might support.
102102
items:
103103
type: string
104104
type: array

config/crd/bases/operator.kcp.io_rootshards.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ spec:
296296
DNS names determined automatically by the kcp-operator.
297297
If DNSNames is used together with IssuerRef, DNSNames will be uses as-is and not merged.
298298
If IssuerRef is not set, DNSNames will be merged with the defaults. This is to avoid
299-
trying to guess what DNSNames configued issuer might support.
299+
trying to guess what DNSNames configured issuer might support.
300300
items:
301301
type: string
302302
type: array
@@ -1766,7 +1766,7 @@ spec:
17661766
DNS names determined automatically by the kcp-operator.
17671767
If DNSNames is used together with IssuerRef, DNSNames will be uses as-is and not merged.
17681768
If IssuerRef is not set, DNSNames will be merged with the defaults. This is to avoid
1769-
trying to guess what DNSNames configued issuer might support.
1769+
trying to guess what DNSNames configured issuer might support.
17701770
items:
17711771
type: string
17721772
type: array

config/crd/bases/operator.kcp.io_shards.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ spec:
280280
DNS names determined automatically by the kcp-operator.
281281
If DNSNames is used together with IssuerRef, DNSNames will be uses as-is and not merged.
282282
If IssuerRef is not set, DNSNames will be merged with the defaults. This is to avoid
283-
trying to guess what DNSNames configued issuer might support.
283+
trying to guess what DNSNames configured issuer might support.
284284
items:
285285
type: string
286286
type: array

docs/content/architecture/.pages

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ nav:
22
- index.md
33
- basics.md
44
- front-proxy.md
5+
- kubeconfig.md
56
- Certificate Management: pki.md

docs/content/architecture/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This section describes how the kcp-operator is designed and meant to be used.
77
- [Basics](basics.md) – A general overview over the resources provided by the kcp-operator.
88
- [front-proxy](front-proxy.md) – Explains how the kcp front-proxy can be used to ingest traffic.
99
- [Certificate Management](pki.md) – This page describes the various CAs and certificates used in a kcp installation.
10+
- [Kubeconfig](kubeconfig.md) – Shows how `Kubeconfig` objects can be used to provide credentials to kcp.
1011
<!--
1112
- [Sharding](sharding.md) – How `RootShards` and `Shards` work together to create a scalable kcp setup.
12-
- [Kubeconfigs](kubeconfigs.md) – Shows how `Kubeconfig` objects can be used to provide credentials to kcp.
1313
-->
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
description: >
3+
Shows how `Kubeconfig` objects can be used to provide credentials to kcp.
4+
---
5+
6+
# Kubeconfigs
7+
8+
Besides provisioning kcp itself, the kcp-operator can also provide [kubeconfigs](https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/) to access kcp. Each kubeconfig will internally be backed by a dedicated client certificate.
9+
10+
## Basics
11+
12+
A minimal `Kubeconfig` object typically looks like this:
13+
14+
```yaml
15+
apiVersion: operator.kcp.io/v1alpha1
16+
kind: Kubeconfig
17+
metadata:
18+
name: susan
19+
namespace: my-kcp
20+
spec:
21+
# Required: the username inside Kubernetes;
22+
# this will be the client certificate's common name.
23+
username: susan
24+
25+
# required: groups to attach to the user;
26+
# this will be the organizations in the client cert.
27+
groups:
28+
- system:kcp:admin
29+
30+
# Required: in what Secret the generated kubeconfig should be stored.
31+
secretRef:
32+
name: susan-kubeconfig
33+
34+
# Required: a Kubeconfig must target either a FrontProxy, Shard or RootShard.
35+
target:
36+
frontProxyRef:
37+
name: my-front-proxy
38+
39+
# Required: how long the certificate should be valid for;
40+
# the operator will automatically renew the certificate, after which the
41+
# Secret will be renewed and have to be re-downloaded.
42+
validity: 8766h
43+
```
44+
45+
`Kubeconfig` objects must exist in the same namespace as the kcp installation they are meant for.
46+
47+
Once the `Kubeconfig` has been created, you can observe its status to wait for it to be ready. After that, retrieve the Secret mentioned in the `secretRef` to find the finished kubeconfig, ready to use.
48+
49+
!!! warning
50+
Deleting a `Kubeconfig` will also delete the underlying Secret from the hosting cluster, however this will not invalidate the existing certificate that is embedded in the kubeconfig. This means anyone with a copy of the kubeconfig can keep using it until the certificate expires.
51+
52+
To disarm an old kubeconfig, make sure to revoke any permissions granted through RBAC for the user and/or their groups.
53+
54+
!!! note
55+
The `Kubeconfig`'s name is embedded into the certificate in form of a group (organization) named `kubeconfig:<name>`. This is to allow a unique mapping from RBAC rules to `Kubeconfig` objects for the authorization (see further down). Take note that this means the `Kubeconfig`' name is leaked to whoever gets the kubeconfig.
56+
57+
## Authorization
58+
59+
Without any further configuration than shown in the basics section above, the created identity (username + groups) will not get any permissions in kcp. So while the kubeconfig is valid and allows proper authentication, pretty much no actions will be permitted yet.
60+
61+
The administrator has to either rely on externally-managed RBAC rules to provide permissions, or use the kcp-operator to provision such RBAC in a workspace.
62+
63+
To make the kcp-operator manage RBAC, use `spec.authorization` inside a `Kubeconfig`:
64+
65+
```yaml
66+
apiVersion: operator.kcp.io/v1alpha1
67+
kind: Kubeconfig
68+
metadata:
69+
name: susan
70+
namespace: my-kcp
71+
spec:
72+
#...snip...
73+
74+
authorization:
75+
clusterRoleBindings:
76+
# This can be a workspace path (root:something) or a cluster name (ID).
77+
cluster: root:initech:teamgibbons
78+
clusterRoles:
79+
- cluster-admin
80+
```
81+
82+
This configuration would bind the group `kubeconfig:susan` to the ClusterRole `cluster-admin` inside the given workspace. Note that this is specifically not bound to the user (common name), so that two `Kubeconfig` objects that both have the same `spec.name` to not have colliding RBAC.
83+
84+
When deleting a `Kubeconfig` with authorization settings, the kcp-operator will first unprovision (delete) the `ClusterRoleBindings` before the `Kubeconfig` can be deleted.

internal/resources/utils/certificates.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ func applyCertificateSpecTemplate(cert *certmanagerv1.Certificate, tpl *operator
7171
return cert
7272
}
7373

74-
// If DNSNames is provided in the template and issuer is overrided,
74+
// If DNSNames is provided in the template and issuer is overridden,
7575
// it will replace any existing DNSNames.
7676
// We don't merge as we don't know if issuer supports our default names.
77-
// Its users responsibility to add them back if needed.
77+
// It's user responsibility to add them back if needed.
7878
if len(tpl.DNSNames) > 0 && tpl.IssuerRef != nil {
7979
cert.Spec.DNSNames = tpl.DNSNames
8080
} else if len(tpl.DNSNames) > 0 {

internal/resources/utils/logging_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func TestGetLogLevelArgs(t *testing.T) {
2929
expected []string
3030
}{
3131
{
32-
name: "no config at alll",
32+
name: "no config at all",
3333
logging: nil,
3434
expected: []string{},
3535
},

sdk/apis/operator/v1alpha1/common.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ type CertificateSpecTemplate struct {
146146
// DNS names determined automatically by the kcp-operator.
147147
// If DNSNames is used together with IssuerRef, DNSNames will be uses as-is and not merged.
148148
// If IssuerRef is not set, DNSNames will be merged with the defaults. This is to avoid
149-
// trying to guess what DNSNames configued issuer might support.
149+
// trying to guess what DNSNames configured issuer might support.
150150
//
151151
// +optional
152152
DNSNames []string `json:"dnsNames,omitempty"`

0 commit comments

Comments
 (0)