forked from pivotal-cf/docs-pks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy-windows-workloads-beta.html.md.erb
299 lines (233 loc) · 9.7 KB
/
deploy-windows-workloads-beta.html.md.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
---
title: Deploying and Exposing Windows Workloads (Beta)
owner: PKS
---
<strong><%= modified_date %></strong>
This topic describes how to deploy Windows-based workloads in <%= vars.product_full %>.
<p class="note warning"> <strong>IMPORTANT: </strong> Support for Windows-based Kubernetes clusters is in beta and works only on vSphere with Flannel.
Please use the link at the bottom of this topic to provide feedback to the Windows product team.</p>
## <a id='overview'></a>Overview
In <%= vars.product_short %>, you can deploy Windows-based workloads to Kubernetes clusters.
To deploy a new Windows-based workload to a new pod, do the following:
1. [Access Your Windows-Based Cluster](#access-cluster)
1. [Configure a Pod Deployment Manifest](#configure-pod)
1. [Deploy the Pod](#deploy-pod-steps)
1. [Configure a Service Manifest](#configure-service)
1. [Deploy the Service](#deploy-service-steps)
## <a id='prerequisites'></a>Prerequisites
You can deploy Windows workloads only to Windows-based clusters.
Before you can use Windows-based clusters, you must configure the <%= vars.product_tile %> tile.
For instructions on configuring the <%= vars.product_tile %> tile, see [Configuring Windows Worker-Based Clusters (Beta)](windows-pks-beta.html).
## <a id='access-cluster'></a>Access Your Windows-Based Cluster
Your command line must have access to your Windows-based cluster to deploy Windows VMs and workloads to the cluster.
1. To determine which of your existing clusters is Windows-based, use the following command:
```
pks clusters
```
For example:
<pre class='terminal'>
$ pks clusters
Name Plan Name UUID Status Action
windows-k8s Plan-11-Windows-Beta 881543kd-64fg-7826-hea6-3h7g1o04kh0e succeeded Create
second-windows-k8s Plan-11-Windows-Beta 951547dl-67kg-9631-bju8-7h9s3o98br0q succeeded Create
</pre>
Only clusters configured on Plans 11, 12, or 13 are Windows-based.
1. To access your Windows-based cluster, run the following command:
```
pks get-credentials CLUSTER-NAME
```
Where `CLUSTER-NAME` is the name of your Windows-based cluster.
</br>
For example:
<pre class="terminal">$ pks get-credentials windows-k8s
Fetching credentials for cluster windows-k8s.
Context set for cluster windows-k8s.
You can now switch between clusters by using:
$kubectl config use-context <cluster-name>
</pre>
The `pks get-credentials` command creates a local `kubeconfig`, allowing you to manage the cluster from the command line.
For more information about the `pks get-credentials` command, see [Retrieving Cluster Credentials and Configuration](cluster-credentials.html).
1. To verify you have established access to the correct cluster, run the following command:
```
kubectl cluster-info
```
1. (Optional) To review the cluster's existing pods, run the following command:
```
kubectl get pods
```
## <a id='deploy-pod'></a> Deploy a Windows Worker Pod
A pod deployment manifest file configures the VMs deployed to a pod.
### <a id='configure-pod'></a> Configure a Pod Deployment Manifest
You must create a Windows worker deployment manifest before deploying your new Windows worker pod.
1. To create a Windows worker deployment manifest, create a new YAML file containing the following:
```
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata
labels:
app: POD-NAME
name: POD-NAME
spec:
replicas: 1
template:
metadata:
labels:
app: POD-NAME
name: POD-NAME
spec:
containers:
- name: CONTAINER-NAME
image: CONTAINER-FILE:latest
env:
- name: PORT
value: "80"
ports:
- name: http
containerPort: 80
nodeSelector:
kubernetes.io/os: windows
tolerations:
- key: "windows"
operator: "Equal"
value: "2019"
effect: "NoSchedule"
```
Where:
* `POD-NAME` is your pod's name.
* `CONTAINER-NAME` is your container's internal name.
* `CONTAINER-FILE` is your container's filename.
For example:
```
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata
labels:
app: win-webserver
name: win-webserver
spec:
replicas: 1
template:
metadata:
labels:
app: win-webserver
name: win-webserver
spec:
containers:
- name: windowswebserver
image: stefanscherrer/webserver-windows:latest
env:
- name: PORT
value: "80"
ports:
- name: http
containerPort: 80
nodeSelector:
kubernetes.io/os: windows
tolerations:
- key: "windows"
operator: "Equal"
value: "2019"
effect: "NoSchedule"
```
### <a id='deploy-pod-steps'></a> Deploy the Pod
1. To deploy a new Windows worker pod, run the following command:
```
kubectl apply -f POD-CONFIG-FILE
```
Where `POD-CONFIG-FILE` is the filename of the Windows worker deployment manifest created above.
1. To confirm the new pod's status, and the creation of new Windows worker nodes, run the following commands:
```
kubectl get pods
kubectlr get nodes -o wide
```
For example:
<pre class="terminal">
$ kubectl apply -f first-k8s.yml
deployment.extensions/win-webserver created
$ kubectl get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
win-webserver-795g866cd7-58oct 1/1 Running 0 88s 10.200.42.4 0983934a-6d69-8e5g-g3k1-98r8r56l345j <none> <none>
$ kubectlr get nodes -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
0983934a-6d69-8e5g-g3k1-98r8r56l345j Ready <none> 19d v1.14.1 10.85.41.118 10.85.41.118 Windows Server 2019 Datacenter 10.0.17763.503 docker://18.9.0
6d69934a-7d43-9g3g-h4d1-54r9r97l395j Ready <none> 19d v1.14.1 10.85.41.115 10.85.41.115 Ubuntu 16.04.6 LTS 4.15.0-50-generic docker://18.9.0
7636d69a-2e75-5l0g-k6m1-76r3r37l729k Ready <none> 19d v1.14.1 10.85.41.117 10.85.41.117 Windows Server 2019 Datacenter 10.0.17763.503 docker://18.9.0
406d694a-9g96-2d3g-f3j1-32r1r44l342x Ready <none> 19d v1.14.1 10.85.41.116 10.85.41.116 Windows Server 2019 Datacenter 10.0.17763.503 docker://18.9.0
</pre>
In the preceding example a new pod is created, and creation and status of the new pod and new nodes verified.
## <a id='deploy-service'></a> Deploy a Service to a Windows Worker Pod
A service deployment manifest file configures your service, defining how your service will run and how it will be exposed.
### <a id='configure-service'></a> Configure a Service Manifest
You must create a Windows service deployment manifest before deploying your Windows worker workload.
1. To create a Windows service deployment manifest, create a new YAML file containing the following:
```
---
apiVersion: v1
kind: Service
metadata:
name: APP-NAME
labels:
app: APP-NAME
spec:
ports:
# the port that this service should serve on
- port: 80
targetPort: 80
selector:
app: APP-NAME
type: NodePort
```
Where `APP-NAME` is your Windows service's name.
<br>
For example:
```
---
apiVersion: v1
kind: Service
metadata:
name: win-webserver
labels:
app: win-webserver
spec:
ports:
# the port that this service should serve on
- port: 80
targetPort: 80
selector:
app: win-webserver
type: NodePort
```
### <a id='deploy-service-steps'></a> Deploy the Service
1. To expose the specified service on a NodePort, run the following command:
```
kubectl apply -f SERVICE-CONFIG-FILE
```
Where `SERVICE-CONFIG-FILE` is the filename of your Windows service deployment manifest created above.
<br>
For example:
<pre class="terminal">
$ kubectl get services
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.100.200.1 <none> 443/TCP 20d
$ kubectl apply -f first-k8s-service.yml
service/win-webserver created
$ kubectl get services
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.100.200.1 <none> 443/TCP 20d
win-webserver NodePort 10.100.200.221 <none> 80:32073/TCP 5s
$ curl 10.85.41.118:32073
<pre>
<a href="License.txt">License.txt</a>
<a href="ProgramData/">ProgramData/</a>
<a href="Users/">Users/</a>
<a href="WcSandboxState/">WcSandboxState/</a>
<a href="Windows/">Windows/</a>
<a href="var/">var/</a>
<a href="webserver.exe">webserver.exe</a>
</pre>
</pre>
In the preceding example a new service is created, verified and validated.
## <a id='feedback'></a>Feedback
We are actively looking for feedback on this beta feature. To submit feedback, send an email to [email protected].