|
| 1 | +# Identity Management |
| 2 | + |
| 3 | +## Identity types |
| 4 | + |
| 5 | +Cluster API Provider vSphere (CAPV) supports multiple methods to provide vCenter credentials and authorize workload clusters to use them. This guide will go through the different types and provide examples for each. The 3 ways to provide credentials: |
| 6 | + |
| 7 | +* CAPV Manager bootstrap credentials: The vCenter username and password provided via `VSPHERE_USERNAME` `VSPHERE_PASSWORD` will be injected into the CAPV manager binary. These credentials will act as the fallback method should the other two credential methods not be utilized by a workload cluster. |
| 8 | +* Credentials via a Secret: Credentials can be provided via a `Secret` that could then be referenced by a `VSphereCluster`. This will create a 1:1 relationship between the VSphereCluster and Secret and the secret cannot be utilized by other clusters. |
| 9 | +* Credentials via a VSphereClusterIdentity: `VSphereClusterIdentity` is a cluster-scoped resource and enables multiple VSphereClusters to share the same set of credentials. The namespaces that are allowed to use the VSphereClusterIdentity can also be configured via a `LabelSelector`. |
| 10 | + |
| 11 | +## Examples |
| 12 | + |
| 13 | +### CAPV Manager Credentials |
| 14 | + |
| 15 | +Setting `VSPHERE_USERNAME` and `VSPHERE_PASSWORD` before initializing the management cluster will ensure the credentials are injected into the manager's binary. More information can be found in the [Cluster API quick start guide](https://cluster-api.sigs.k8s.io/user/quick-start.html) |
| 16 | + |
| 17 | +### Credentials via Secret |
| 18 | + |
| 19 | +Deploy a `Secret` with the credentials in the VSphereCluster's namespace: |
| 20 | + |
| 21 | +```yaml |
| 22 | +apiVersion: v1 |
| 23 | +kind: Secret |
| 24 | +metadata: |
| 25 | + name: secretName |
| 26 | + namespace: <Namespace of VSphereCluster> |
| 27 | +stringData: |
| 28 | + username: <Username> |
| 29 | + password: <Password> |
| 30 | +``` |
| 31 | +
|
| 32 | +`Note: The secret must reside in the same namespace as the VSphereCluster` |
| 33 | + |
| 34 | +Reference the Secret in the VSphereCluster Spec: |
| 35 | + |
| 36 | +```yaml |
| 37 | +apiVersion: infrastructure.cluster.x-k8s.io/v1alpha3 |
| 38 | +kind: VSphereCluster |
| 39 | +metadata: |
| 40 | + name: new-workload-cluster |
| 41 | +spec: |
| 42 | + identityRef: |
| 43 | + kind: Secret |
| 44 | + name: secretName |
| 45 | +... |
| 46 | +``` |
| 47 | + |
| 48 | +Once the VSphereCluster reconciles, it will set itself as the owner of the Secret and no other VSphereClusters will use the same secret. When a cluster is deleted, the secret will also be deleted. |
| 49 | + |
| 50 | +### Credentials via VSphereClusterIdentity |
| 51 | + |
| 52 | +Deploy a `Secret` with the credentials in the CAPV manager namespace (capv-system by default): |
| 53 | + |
| 54 | +```yaml |
| 55 | +apiVersion: v1 |
| 56 | +kind: Secret |
| 57 | +metadata: |
| 58 | + name: secretName |
| 59 | + namespace: capv-system |
| 60 | +stringData: |
| 61 | + username: <Username> |
| 62 | + password: <Password> |
| 63 | +``` |
| 64 | + |
| 65 | +Deploy a `VSphereClusterIdentity` that references the secret. The `allowedNamespaces` LabelSelector can also be used to dictate which namespaces are allowed to use the identity. Setting `allowedNamespaces` to nil will block all namespaces from using the identity, while setting it to an empty selector will allow all namespaces to use the identity. The following example uses an empty selector. |
| 66 | + |
| 67 | +```yaml |
| 68 | +apiVersion: infrastructure.cluster.x-k8s.io/v1alpha3 |
| 69 | +kind: VSphereClusterIdentity |
| 70 | +metadata: |
| 71 | + name: identityName |
| 72 | +spec: |
| 73 | + secretName: secretName |
| 74 | + allowedNamespaces: |
| 75 | + selector: |
| 76 | + matchLabels: {} |
| 77 | +``` |
| 78 | + |
| 79 | +Once the VSphereClusterIdentity reconciles, it will set itself as the owner of the Secret and the Secret cannot be used by other identities or VSphereClusters. The Secret will also be deleted if the VSphereClusterIdentity is deleted. |
| 80 | + |
| 81 | +Reference the VSphereClusterIdentity in the VSphereCluster. |
| 82 | + |
| 83 | +```yaml |
| 84 | +apiVersion: infrastructure.cluster.x-k8s.io/v1alpha3 |
| 85 | +kind: VSphereCluster |
| 86 | +metadata: |
| 87 | + name: new-workload-cluster |
| 88 | +spec: |
| 89 | + identityRef: |
| 90 | + kind: VSphereClusterIdentity |
| 91 | + name: identityName |
| 92 | +... |
| 93 | +``` |
| 94 | + |
| 95 | +`Note: VSphereClusterIdentity cannot be used in conjunction with the WatchNamespace set for the CAPV manager` |
0 commit comments