You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/en/docs/tasks/configure-pod-container/configure-gmsa.md
+28-60Lines changed: 28 additions & 60 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,20 +10,19 @@ weight: 20
10
10
11
11
This page shows how to configure [Group Managed Service Accounts](https://docs.microsoft.com/en-us/windows-server/security/group-managed-service-accounts/group-managed-service-accounts-overview) (GMSA) for Pods and containers that will run on Windows nodes. Group Managed Service Accounts are a specific type of Active Directory account that provides automatic password management, simplified service principal name (SPN) management, and the ability to delegate the management to other administrators across multiple servers.
12
12
13
-
In Kubernetes, GMSA credential specs are configured at a Kubernetes cluster-wide scope as Custom Resources. Windows Pods, as well as individual containers within a Pod, can be configured to use a GMSA for domain based functions (e.g. Kerberos authentication) when interacting with other Windows services. As of v1.16, the Docker runtime supports GMSA for Windows workloads.
14
-
15
-
13
+
In Kubernetes, GMSA credential specs are configured at a Kubernetes cluster-wide scope as Custom Resources. Windows Pods, as well as individual containers within a Pod, can be configured to use a GMSA for domain based functions (e.g. Kerberos authentication) when interacting with other Windows services.
16
14
17
15
## {{% heading "prerequisites" %}}
18
16
19
-
20
17
You need to have a Kubernetes cluster and the `kubectl` command-line tool must be configured to communicate with your cluster. The cluster is expected to have Windows worker nodes. This section covers a set of initial steps required once for each cluster:
21
18
22
19
### Install the GMSACredentialSpec CRD
20
+
23
21
A [CustomResourceDefinition](/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/)(CRD) for GMSA credential spec resources needs to be configured on the cluster to define the custom resource type `GMSACredentialSpec`. Download the GMSA CRD [YAML](https://github.com/kubernetes-sigs/windows-gmsa/blob/master/admission-webhook/deploy/gmsa-crd.yml) and save it as gmsa-crd.yaml.
24
22
Next, install the CRD with `kubectl apply -f gmsa-crd.yaml`
25
23
26
24
### Install webhooks to validate GMSA users
25
+
27
26
Two webhooks need to be configured on the Kubernetes cluster to populate and validate GMSA credential spec references at the Pod or container level:
28
27
29
28
1. A mutating webhook that expands references to GMSAs (by name from a Pod specification) into the full credential spec in JSON form within the Pod spec.
@@ -36,38 +35,38 @@ Installing the above webhooks and associated objects require the steps below:
36
35
37
36
1. Install a secret with the certificate from above.
38
37
39
-
1. Create a deployment for the core webhook logic.
38
+
1. Create a deployment for the core webhook logic.
40
39
41
-
1. Create the validating and mutating webhook configurations referring to the deployment.
40
+
1. Create the validating and mutating webhook configurations referring to the deployment.
42
41
43
42
A [script](https://github.com/kubernetes-sigs/windows-gmsa/blob/master/admission-webhook/deploy/deploy-gmsa-webhook.sh) can be used to deploy and configure the GMSA webhooks and associated objects mentioned above. The script can be run with a ```--dry-run=server``` option to allow you to review the changes that would be made to your cluster.
44
43
45
44
The [YAML template](https://github.com/kubernetes-sigs/windows-gmsa/blob/master/admission-webhook/deploy/gmsa-webhook.yml.tpl) used by the script may also be used to deploy the webhooks and associated objects manually (with appropriate substitutions for the parameters)
46
45
47
-
48
-
49
46
<!-- steps -->
50
47
51
48
## Configure GMSAs and Windows nodes in Active Directory
49
+
52
50
Before Pods in Kubernetes can be configured to use GMSAs, the desired GMSAs need to be provisioned in Active Directory as described in the [Windows GMSA documentation](https://docs.microsoft.com/en-us/windows-server/security/group-managed-service-accounts/getting-started-with-group-managed-service-accounts#BKMK_Step1). Windows worker nodes (that are part of the Kubernetes cluster) need to be configured in Active Directory to access the secret credentials associated with the desired GMSA as described in the [Windows GMSA documentation](https://docs.microsoft.com/en-us/windows-server/security/group-managed-service-accounts/getting-started-with-group-managed-service-accounts#to-add-member-hosts-using-the-set-adserviceaccount-cmdlet)
53
51
54
52
## Create GMSA credential spec resources
55
-
With the GMSACredentialSpec CRD installed (as described earlier), custom resources containing GMSA credential specs can be configured. The GMSA credential spec does not contain secret or sensitive data. It is information that a container runtime can use to describe the desired GMSA of a container to Windows. GMSA credential specs can be generated in YAML format with a utility [PowerShell script](https://github.com/kubernetes-sigs/windows-gmsa/tree/master/scripts/GenerateCredentialSpecResource.ps1).
53
+
54
+
With the GMSACredentialSpec CRD installed (as described earlier), custom resources containing GMSA credential specs can be configured. The GMSA credential spec does not contain secret or sensitive data. It is information that a container runtime can use to describe the desired GMSA of a container to Windows. GMSA credential specs can be generated in YAML format with a utility [PowerShell script](https://github.com/kubernetes-sigs/windows-gmsa/tree/master/scripts/GenerateCredentialSpecResource.ps1).
56
55
57
56
Following are the steps for generating a GMSA credential spec YAML manually in JSON format and then converting it:
58
57
59
58
1. Import the CredentialSpec [module](https://github.com/MicrosoftDocs/Virtualization-Documentation/blob/live/windows-server-container-tools/ServiceAccounts/CredentialSpec.psm1): `ipmo CredentialSpec.psm1`
60
59
61
60
1. Create a credential spec in JSON format using `New-CredentialSpec`. To create a GMSA credential spec named WebApp1, invoke `New-CredentialSpec -Name WebApp1 -AccountName WebApp1 -Domain $(Get-ADDomain -Current LocalComputer)`
62
61
63
-
1. Use `Get-CredentialSpec` to show the path of the JSON file.
62
+
1. Use `Get-CredentialSpec` to show the path of the JSON file.
64
63
65
-
1. Convert the credspec file from JSON to YAML format and apply the necessary header fields `apiVersion`, `kind`, `metadata` and `credspec` to make it a GMSACredentialSpec custom resource that can be configured in Kubernetes.
64
+
1. Convert the credspec file from JSON to YAML format and apply the necessary header fields `apiVersion`, `kind`, `metadata` and `credspec` to make it a GMSACredentialSpec custom resource that can be configured in Kubernetes.
66
65
67
66
The following YAML configuration describes a GMSA credential spec named `gmsa-WebApp1`:
68
67
69
68
```yaml
70
-
apiVersion: windows.k8s.io/v1alpha1
69
+
apiVersion: windows.k8s.io/v1
71
70
kind: GMSACredentialSpec
72
71
metadata:
73
72
name: gmsa-WebApp1 #This is an arbitrary name but it will be used as a reference
@@ -92,6 +91,7 @@ credspec:
92
91
The above credential spec resource may be saved as `gmsa-Webapp1-credspec.yaml` and applied to the cluster using: `kubectl apply -f gmsa-Webapp1-credspec.yml`
93
92
94
93
## Configure cluster role to enable RBAC on specific GMSA credential specs
94
+
95
95
A cluster role needs to be defined for each GMSA credential spec resource. This authorizes the `use` verb on a specific GMSA resource by a subject which is typically a service account. The following example shows a cluster role that authorizes usage of the `gmsa-WebApp1` credential spec from above. Save the file as gmsa-webapp1-role.yaml and apply using `kubectl apply -f gmsa-webapp1-role.yaml`
96
96
97
97
```yaml
@@ -108,6 +108,7 @@ rules:
108
108
```
109
109
110
110
## Assign role to service accounts to use specific GMSA credspecs
111
+
111
112
A service account (that Pods will be configured with) needs to be bound to the cluster role create above. This authorizes the service account to use the desired GMSA credential spec resource. The following shows the default service account being bound to a cluster role `webapp1-role` to use `gmsa-WebApp1` credential spec resource created above.
112
113
113
114
```yaml
@@ -127,6 +128,7 @@ roleRef:
127
128
```
128
129
129
130
## Configure GMSA credential spec reference in Pod spec
131
+
130
132
The Pod spec field `securityContext.windowsOptions.gmsaCredentialSpecName` is used to specify references to desired GMSA credential spec custom resources in Pod specs. This configures all containers in the Pod spec to use the specified GMSA. A sample Pod spec with the annotation populated to refer to `gmsa-WebApp1`:
131
133
132
134
```yaml
@@ -197,55 +199,17 @@ As Pod specs with GMSA fields populated (as described above) are applied in a cl
197
199
198
200
1. The container runtime configures each Windows container with the specified GMSA credential spec so that the container can assume the identity of the GMSA in Active Directory and access services in the domain using that identity.
199
201
200
-
## Containerd
201
-
202
-
On Windows Server 2019, in order to use GMSA with containerd, you must be running OS Build 17763.1817 (or later) which can be installed using the patch [KB5000822](https://support.microsoft.com/en-us/topic/march-9-2021-kb5000822-os-build-17763-1817-2eb6197f-e3b1-4f42-ab51-84345e063564).
203
-
204
-
There is also a known issue with containerd that occurs when trying to connect to SMB shares from Pods. Once you have configured GMSA, the pod will be unable to connect to the share using the hostname or FQDN, but connecting to the share using an IP address works as expected.
202
+
## Authenticating to network shares usinig hostname of FQDN
205
203
206
-
```PowerShell
207
-
ping adserver.ad.local
208
-
```
209
-
and correctly resolves the hostname to an IPv4 address. The output is similar to:
204
+
If you are experiencing issues connecting to SMB shares from Pods using hostname or FQDN, but are able to access the shares via their IPv4 address then make sure the following registry key is set on the Windows nodes.
210
205
211
-
```
212
-
Pinging adserver.ad.local [192.168.111.18] with 32 bytes of data:
213
-
Reply from 192.168.111.18: bytes=32 time=6ms TTL=124
214
-
Reply from 192.168.111.18: bytes=32 time=5ms TTL=124
215
-
Reply from 192.168.111.18: bytes=32 time=5ms TTL=124
216
-
Reply from 192.168.111.18: bytes=32 time=5ms TTL=124
To correct the behaviour you must run the following on the node `reg add "HKLM\SYSTEM\CurrentControlSet\Services\hns\State" /v EnableCompartmentNamespace /t REG_DWORD /d 1` to add the required registry key. This node change will only take effect in newly created pods, meaning you must now recreate any running pods which require access to SMB shares.
210
+
Running Pods will then need to be recreated to pick up the behavior changes.
211
+
More information on how this registry key is used can be found [here](
0 commit comments