Skip to content

Commit f23e012

Browse files
authored
add dotnet-example template
The dotnet-example template can be used to create a new .NET Core service in OpenShift. It provides parameters for all the environment variables of the s2i-dotnetcore builder. It also includes a liveness and a readiness probe. Implements #56
1 parent 4a8f3c6 commit f23e012

File tree

2 files changed

+338
-0
lines changed

2 files changed

+338
-0
lines changed

README.md

+14
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,17 @@ Image name structure
4545
3. Base builder image - rhel7
4646

4747
Example: `dotnet/dotnetcore-10-rhel7`
48+
49+
OpenShift Templates
50+
-------------------
51+
52+
The `templates` folder contains OpenShift templates. Some of these will be shipped with OpenShift. If a template is not on your OpenShift installation, you can import it:
53+
54+
```
55+
oc create -f <template.json>
56+
```
57+
58+
**dotnet-example**
59+
60+
The dotnet-example template can be used to create a new .NET Core service in OpenShift. It provides parameters for all the environment
61+
variables of the s2i-dotnetcore builder. It also includes a liveness and a readiness probe.

templates/dotnet-example.json

+324
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,324 @@
1+
{
2+
"kind": "Template",
3+
"apiVersion": "v1",
4+
"metadata": {
5+
"name": "dotnet-example",
6+
"annotations": {
7+
"openshift.io/display-name": ".NET Core",
8+
"description": "An example .NET Core application.",
9+
"tags": "quickstart,dotnet,.net",
10+
"iconClass": "icon-dotnet",
11+
"template.openshift.io/provider-display-name": "Red Hat, Inc.",
12+
"template.openshift.io/documentation-url": "https://github.com/redhat-developer/s2i-dotnetcore",
13+
"template.openshift.io/support-url": "https://access.redhat.com"
14+
}
15+
},
16+
"objects": [
17+
{
18+
"kind": "Route",
19+
"apiVersion": "v1",
20+
"metadata": {
21+
"name": "${NAME}"
22+
},
23+
"spec": {
24+
"host": "${APPLICATION_DOMAIN}",
25+
"to": {
26+
"kind": "Service",
27+
"name": "${NAME}"
28+
}
29+
}
30+
},
31+
{
32+
"kind": "Service",
33+
"apiVersion": "v1",
34+
"metadata": {
35+
"name": "${NAME}",
36+
"annotations": {
37+
"description": "Exposes and load balances the application pods"
38+
}
39+
},
40+
"spec": {
41+
"ports": [
42+
{
43+
"name": "web",
44+
"port": 8080,
45+
"targetPort": 8080
46+
}
47+
],
48+
"selector": {
49+
"name": "${NAME}"
50+
}
51+
}
52+
},
53+
{
54+
"kind": "ImageStream",
55+
"apiVersion": "v1",
56+
"metadata": {
57+
"name": "${NAME}",
58+
"annotations": {
59+
"description": "Keeps track of changes in the application image"
60+
}
61+
}
62+
},
63+
{
64+
"kind": "BuildConfig",
65+
"apiVersion": "v1",
66+
"metadata": {
67+
"name": "${NAME}",
68+
"annotations": {
69+
"description": "Defines how to build the application"
70+
}
71+
},
72+
"spec": {
73+
"source": {
74+
"type": "Git",
75+
"git": {
76+
"uri": "${SOURCE_REPOSITORY_URL}",
77+
"ref": "${SOURCE_REPOSITORY_REF}"
78+
},
79+
"contextDir": "${CONTEXT_DIR}"
80+
},
81+
"strategy": {
82+
"type": "Source",
83+
"sourceStrategy": {
84+
"from": {
85+
"kind": "ImageStreamTag",
86+
"namespace": "${NAMESPACE}",
87+
"name": "${DOTNET_IMAGE_STREAM_TAG}"
88+
},
89+
"env": [
90+
{
91+
"name": "DOTNET_STARTUP_PROJECT",
92+
"value": "${DOTNET_STARTUP_PROJECT}"
93+
},
94+
{
95+
"name": "DOTNET_ASSEMBLY_NAME",
96+
"value": "${DOTNET_ASSEMBLY_NAME}"
97+
},
98+
{
99+
"name": "DOTNET_NPM_TOOLS",
100+
"value": "${DOTNET_NPM_TOOLS}"
101+
},
102+
{
103+
"name": "DOTNET_TEST_PROJECTS",
104+
"value": "${DOTNET_TEST_PROJECTS}"
105+
},
106+
{
107+
"name": "DOTNET_CONFIGURATION",
108+
"value": "${DOTNET_CONFIGURATION}"
109+
},
110+
{
111+
"name": "DOTNET_PUBLISH",
112+
"value": "true"
113+
}
114+
]
115+
}
116+
},
117+
"output": {
118+
"to": {
119+
"kind": "ImageStreamTag",
120+
"name": "${NAME}:latest"
121+
}
122+
},
123+
"triggers": [
124+
{
125+
"type": "ImageChange"
126+
},
127+
{
128+
"type": "ConfigChange"
129+
},
130+
{
131+
"type": "GitHub",
132+
"github": {
133+
"secret": "${GITHUB_WEBHOOK_SECRET}"
134+
}
135+
},
136+
{
137+
"type": "Generic",
138+
"generic": {
139+
"secret": "${GENERIC_WEBHOOK_SECRET}"
140+
}
141+
}
142+
]
143+
}
144+
},
145+
{
146+
"kind": "DeploymentConfig",
147+
"apiVersion": "v1",
148+
"metadata": {
149+
"name": "${NAME}",
150+
"annotations": {
151+
"description": "Defines how to deploy the application server"
152+
}
153+
},
154+
"spec": {
155+
"strategy": {
156+
"type": "Rolling"
157+
},
158+
"triggers": [
159+
{
160+
"type": "ImageChange",
161+
"imageChangeParams": {
162+
"automatic": true,
163+
"containerNames": [
164+
"dotnet-app"
165+
],
166+
"from": {
167+
"kind": "ImageStreamTag",
168+
"name": "${NAME}:latest"
169+
}
170+
}
171+
},
172+
{
173+
"type": "ConfigChange"
174+
}
175+
],
176+
"replicas": 1,
177+
"selector": {
178+
"name": "${NAME}"
179+
},
180+
"template": {
181+
"metadata": {
182+
"name": "${NAME}",
183+
"labels": {
184+
"name": "${NAME}"
185+
}
186+
},
187+
"spec": {
188+
"containers": [
189+
{
190+
"name": "dotnet-app",
191+
"image": " ",
192+
"ports": [
193+
{
194+
"containerPort": 8080
195+
}
196+
],
197+
"livenessProbe": {
198+
"httpGet": {
199+
"path": "/",
200+
"port": 8080,
201+
"scheme": "HTTP"
202+
},
203+
"initialDelaySeconds": 40,
204+
"timeoutSeconds": 15
205+
},
206+
"readinessProbe": {
207+
"httpGet": {
208+
"path": "/",
209+
"port": 8080,
210+
"scheme": "HTTP"
211+
},
212+
"initialDelaySeconds": 10,
213+
"timeoutSeconds": 30
214+
},
215+
"resources": {
216+
"limits": {
217+
"memory": "${MEMORY_LIMIT}"
218+
}
219+
},
220+
"env": []
221+
}
222+
]
223+
}
224+
}
225+
}
226+
}
227+
],
228+
"parameters": [
229+
{
230+
"name": "NAME",
231+
"displayName": "Name",
232+
"description": "The name assigned to all of the frontend objects defined in this template.",
233+
"required": true,
234+
"value": "dotnet-example"
235+
},
236+
{
237+
"name": "MEMORY_LIMIT",
238+
"displayName": "Memory Limit",
239+
"description": "Maximum amount of memory the container can use.",
240+
"required": true,
241+
"value": "512Mi"
242+
},
243+
{
244+
"name": "DOTNET_IMAGE_STREAM_TAG",
245+
"displayName": ".NET builder",
246+
"required": true,
247+
"description": "The image stream tag which is used to build the code.",
248+
"value": "dotnet:1.0"
249+
},
250+
{
251+
"name": "NAMESPACE",
252+
"displayName": "Namespace",
253+
"description": "The OpenShift Namespace where the ImageStream resides.",
254+
"required": true,
255+
"value": "openshift"
256+
},
257+
{
258+
"name": "SOURCE_REPOSITORY_URL",
259+
"displayName": "Git Repository URL",
260+
"description": "The URL of the repository with your application source code.",
261+
"required": true,
262+
"value": "https://github.com/redhat-developer/s2i-dotnetcore-ex.git"
263+
},
264+
{
265+
"name": "SOURCE_REPOSITORY_REF",
266+
"displayName": "Git Reference",
267+
"description": "Set this to a branch name, tag or other ref of your repository if you are not using the default branch.",
268+
"value": "dotnetcore-1.0"
269+
},
270+
{
271+
"name": "CONTEXT_DIR",
272+
"displayName": "Context Directory",
273+
"description": "Set this to use a subdirectory of the source code repository"
274+
},
275+
{
276+
"name": "APPLICATION_DOMAIN",
277+
"displayName": "Application Hostname",
278+
"description": "The exposed hostname that will route to the .NET Core service, if left blank a value will be defaulted.",
279+
"value": ""
280+
},
281+
{
282+
"name": "GITHUB_WEBHOOK_SECRET",
283+
"displayName": "GitHub Webhook Secret",
284+
"description": "A secret string used to configure the GitHub webhook.",
285+
"generate": "expression",
286+
"from": "[a-zA-Z0-9]{40}"
287+
},
288+
{
289+
"name": "GENERIC_WEBHOOK_SECRET",
290+
"displayName": "Generic Webhook Secret",
291+
"description": "A secret string used to configure the Generic webhook.",
292+
"generate": "expression",
293+
"from": "[a-zA-Z0-9]{40}"
294+
},
295+
{
296+
"name": "DOTNET_STARTUP_PROJECT",
297+
"displayName": "Startup Project",
298+
"description": "Set this to the folder containing your startup project.",
299+
"value": "app"
300+
},
301+
{
302+
"name": "DOTNET_ASSEMBLY_NAME",
303+
"displayName": "Startup Assembly",
304+
"description": "Set this when the assembly name is overridden in the project file."
305+
},
306+
{
307+
"name": "DOTNET_NPM_TOOLS",
308+
"displayName": "Npm Tools",
309+
"description": "Set this to a space separated list of npm tools needed to publish.",
310+
"value": "bower gulp"
311+
},
312+
{
313+
"name": "DOTNET_TEST_PROJECTS",
314+
"displayName": "Test projects",
315+
"description": "Set this to a space separated list of test projects to run before publishing."
316+
},
317+
{
318+
"name": "DOTNET_CONFIGURATION",
319+
"displayName": "Configuration",
320+
"description": "Set this to configuration (Release/Debug).",
321+
"value": "Release"
322+
}
323+
]
324+
}

0 commit comments

Comments
 (0)