Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add dotnet template #60

Merged
merged 8 commits into from
Mar 8, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,17 @@ Image name structure
3. Base builder image - rhel7

Example: `dotnet/dotnetcore-10-rhel7`

OpenShift Templates
-------------------

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:

```
oc create -f <template.json>
```

**dotnet**
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"dotnet-example", & update json filename


The dotnet template can be used to create a new .NET Core service in OpenShift. It provides parameters for all the environment
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dotnet example ...

variables of the s2i-dotnetcore builder. It also includes a liveness and a readiness probe.
298 changes: 298 additions & 0 deletions templates/dotnet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,298 @@
{
"kind": "Template",
"apiVersion": "v1",
"metadata": {
"name": "dotnet",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename to "dotnet-example"

"annotations": {
"openshift.io/display-name": ".NET Core",
"description": "Template for creating .NET Core service",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update to: "An example .NET Core application"

"tags": "quickstart,dotnet,.net",
"iconClass": "icon-dotnet",
"template.openshift.io/provider-display-name": "Red Hat, Inc.",
"template.openshift.io/documentation-url": "https://github.com/redhat-developer/s2i-dotnetcore",
"template.openshift.io/support-url": "https://access.redhat.com"
}
},
"objects": [
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "${NAME}",
"annotations": {
"description": "Exposes and load balances the application pods"
}
},
"spec": {
"ports": [
{
"name": "web",
"port": 8080,
"targetPort": 8080
}
],
"selector": {
"name": "${NAME}"
}
}
},
{
"kind": "ImageStream",
"apiVersion": "v1",
"metadata": {
"name": "${NAME}",
"annotations": {
"description": "Keeps track of changes in the application image"
}
}
},
{
"kind": "BuildConfig",
"apiVersion": "v1",
"metadata": {
"name": "${NAME}",
"annotations": {
"description": "Defines how to build the application"
}
},
"spec": {
"source": {
"type": "Git",
"git": {
"uri": "${SOURCE_REPOSITORY_URL}",
"ref": "${SOURCE_REPOSITORY_REF}"
},
"contextDir": "${CONTEXT_DIR}"
},
"strategy": {
"type": "Source",
"sourceStrategy": {
"from": {
"kind": "ImageStreamTag",
"namespace": "${NAMESPACE}",
"name": "${DOTNET_IMAGE_STREAM_TAG}"
},
"env": [
{
"name": "DOTNET_STARTUP_PROJECT",
"value": "${DOTNET_STARTUP_PROJECT}"
},
{
"name": "DOTNET_ASSEMBLY_NAME",
"value": "${DOTNET_ASSEMBLY_NAME}"
},
{
"name": "DOTNET_NPM_TOOLS",
"value": "${DOTNET_NPM_TOOLS}"
},
{
"name": "DOTNET_TEST_PROJECTS",
"value": "${DOTNET_TEST_PROJECTS}"
},
{
"name": "DOTNET_CONFIGURATION",
"value": "${DOTNET_CONFIGURATION}"
}
]
}
},
"output": {
"to": {
"kind": "ImageStreamTag",
"name": "${NAME}:latest"
}
},
"triggers": [
{
"type": "ImageChange"
},
{
"type": "ConfigChange"
},
{
"type": "GitHub",
"github": {
"secret": "${GITHUB_WEBHOOK_SECRET}"
}
},
{
"type": "Generic",
"generic": {
"secret": "${GENERIC_WEBHOOK_SECRET}"
}
}
]
}
},
{
"kind": "DeploymentConfig",
"apiVersion": "v1",
"metadata": {
"name": "${NAME}",
"annotations": {
"description": "Defines how to deploy the application server"
}
},
"spec": {
"strategy": {
"type": "Rolling"
},
"triggers": [
{
"type": "ImageChange",
"imageChangeParams": {
"automatic": true,
"containerNames": [
"dotnet-app"
],
"from": {
"kind": "ImageStreamTag",
"name": "${NAME}:latest"
}
}
},
{
"type": "ConfigChange"
}
],
"replicas": 1,
"selector": {
"name": "${NAME}"
},
"template": {
"metadata": {
"name": "${NAME}",
"labels": {
"name": "${NAME}"
}
},
"spec": {
"containers": [
{
"name": "dotnet-app",
"image": " ",
"ports": [
{
"containerPort": 8080
}
],
"livenessProbe": {
"httpGet": {
"path": "/",
"port": 8080,
"scheme": "HTTP"
},
"initialDelaySeconds": 40,
"timeoutSeconds": 10
},
"readinessProbe": {
"httpGet": {
"path": "/",
"port": 8080,
"scheme": "HTTP"
},
"initialDelaySeconds": 10,
"timeoutSeconds": 30
},
"resources": {
"limits": {
"memory": "${MEMORY_LIMIT}"
}
},
"env": []
}
]
}
}
}
}
],
"parameters": [
{
"name": "NAME",
"displayName": "Name",
"description": "The name assigned to all of the frontend objects defined in this template.",
"required": true,
"value": "dotnet-service"
},
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

value: dotnet-example

{
"name": "MEMORY_LIMIT",
"displayName": "Memory Limit",
"description": "Maximum amount of memory the container can use.",
"required": true,
"value": "512Mi"
},
{
"name": "DOTNET_IMAGE_STREAM_TAG",
"displayName": ".NET builder",
"required": true,
"description": "The image stream tag which is used to build the code.",
"value": "dotnet:1.0"
},
{
"name": "NAMESPACE",
"displayName": "Namespace",
"description": "The OpenShift Namespace where the ImageStream resides.",
"required": true,
"value": "openshift"
},
{
"name": "SOURCE_REPOSITORY_URL",
"displayName": "Git Repository URL",
"description": "The URL of the repository with your application source code.",
"required": true,
"value": "https://github.com/redhat-developer/s2i-dotnetcore-ex.git"
},
{
"name": "SOURCE_REPOSITORY_REF",
"displayName": "Git Reference",
"description": "Set this to a branch name, tag or other ref of your repository if you are not using the default branch."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should perhaps default to "dotnetcore-1.0". That would match "dotnet:1.0" as the default builder image.

},
{
"name": "CONTEXT_DIR",
"displayName": "Context Directory",
"description": "Set this to the relative path to your project if it is not in the root of your repository."
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Set this to use a subdirectory of the source code repository"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should set this to "app" since that would allow one to instantiate the template with all the defaults, and it would build and run. s2i-dotnetcore-ex app sources are in "app"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a preference for setting DOTNET_STARTUP_PROJECT to demonstrate that parameter. I'd do the same for the dotnet+postgre template, if it wasn't for the big restore time of one of the projects we are not using. The postgre template can be update when we support msbuild.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, makes sense. I missed that.

},
{
"name": "GITHUB_WEBHOOK_SECRET",
"displayName": "GitHub Webhook Secret",
"description": "A secret string used to configure the GitHub webhook.",
"generate": "expression",
"from": "[a-zA-Z0-9]{40}"
},
{
"name": "GENERIC_WEBHOOK_SECRET",
"displayName": "Generic Webhook Secret",
"description": "A secret string used to configure the Generic webhook.",
"generate": "expression",
"from": "[a-zA-Z0-9]{40}"
},
{
"name": "DOTNET_STARTUP_PROJECT",
"displayName": "Startup Project",
"description": "Set this to the folder containing your startup project.",
"value": "app"
},
{
"name": "DOTNET_ASSEMBLY_NAME",
"displayName": "Startup Assembly",
"description": "Set this when the assembly name is overridden in the project file."
},
{
"name": "DOTNET_NPM_TOOLS",
"displayName": "Npm Tools",
"description": "Set this to a space separated list of npm tools needed to publish."
},
{
"name": "DOTNET_TEST_PROJECTS",
"displayName": "Test projects",
"description": "Set this to a space separated list of test projects to run before publishing."
},
{
"name": "DOTNET_CONFIGURATION",
"displayName": "Configuration",
"description": "Set this to configuration (Release/Debug).",
"value": "Release"
}
]
}