This is working version with completed documentation
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
# Templates
|
||||
|
||||
Os templates são um dos recursos mais interessantes do Openshift, pois facilitam o provisionamento de objetos pré-definidos. Podendo ser pods, deployments, serviços, rotas ou todos eles juntos.
|
||||
Dentro de cada template existem vários outros objetos definidos. Isso pode ser facilmente notado pelas várias chaves **kind** que se repetem.
|
||||
|
||||
Mais fácil do que criar um template do zero, é escolher um que se pareça com aquilo que quer e então modificá-lo. Vamos utilizar o template **httpd-example** do catálogo para criar um template para o **lighttpd**:
|
||||
|
||||
```
|
||||
oc get templates -n openshift
|
||||
oc get templates -n openshift httpd-example -o yaml > lighttpd.yml
|
||||
```
|
||||
|
||||
Faça as modificações que achar pertinente e então adicione o novo template no cluster:
|
||||
|
||||
```
|
||||
oc apply -f lighttpd.yml
|
||||
```
|
||||
|
||||
Os ícones utilizados podem ser do próprio **Openshift**:
|
||||
|
||||
[https://rawgit.com/openshift/openshift-logos-icon/master/demo.html](https://rawgit.com/openshift/openshift-logos-icon/master/demo.html)
|
||||
|
||||
Ou do **font awesome** versão 4:
|
||||
|
||||
[https://fontawesome.com/v4.7.0/icons/](https://fontawesome.com/v4.7.0/icons/)
|
||||
@@ -0,0 +1,210 @@
|
||||
apiVersion: template.openshift.io/v1
|
||||
kind: Template
|
||||
labels:
|
||||
app: lighttpd-example
|
||||
template: lighttpd-example
|
||||
message: |-
|
||||
The following service(s) have been created in your project: ${NAME}.
|
||||
|
||||
For more information about using this template, including OKD considerations, see https://raw.githubusercontent.com/hector-vido/lighttpd-ex/master/README.md.
|
||||
metadata:
|
||||
annotations:
|
||||
description: An example Lighttpd HTTP Server application that serves static
|
||||
content. For more information about using this template, including OpenShift
|
||||
considerations, see https://raw.githubusercontent.com/hector-vido/lighttpd-ex/master/README.md.
|
||||
iconClass: "fa fa-paper-plane-o"
|
||||
openshift.io/display-name: Lighttpd Server
|
||||
openshift.io/documentation-url: https://github.com/hector-vido/lighttpd-ex
|
||||
openshift.io/long-description: This template defines resources needed to develop
|
||||
a static application served by Lighttpd Server, including a build
|
||||
configuration, application deployment configuration and HPA.
|
||||
openshift.io/provider-display-name: $Linux
|
||||
openshift.io/support-url: https://www.hector-vido.com.br
|
||||
tags: quickstart,lighttpd
|
||||
template.openshift.io/bindable: "false"
|
||||
name: lighttpd-example
|
||||
namespace: openshift
|
||||
objects:
|
||||
- apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
annotations:
|
||||
description: Exposes and load balances the application pods
|
||||
name: ${NAME}
|
||||
spec:
|
||||
ports:
|
||||
- name: web
|
||||
port: 8080
|
||||
targetPort: 8080
|
||||
selector:
|
||||
name: ${NAME}
|
||||
- apiVersion: v1
|
||||
kind: Route
|
||||
metadata:
|
||||
name: ${NAME}
|
||||
spec:
|
||||
host: ${APPLICATION_DOMAIN}
|
||||
to:
|
||||
kind: Service
|
||||
name: ${NAME}
|
||||
- apiVersion: v1
|
||||
kind: ImageStream
|
||||
metadata:
|
||||
annotations:
|
||||
description: Keeps track of changes in the application image
|
||||
name: ${NAME}
|
||||
- apiVersion: v1
|
||||
kind: BuildConfig
|
||||
metadata:
|
||||
annotations:
|
||||
description: Defines how to build the application
|
||||
template.alpha.openshift.io/wait-for-ready: "true"
|
||||
name: ${NAME}
|
||||
spec:
|
||||
output:
|
||||
to:
|
||||
kind: ImageStreamTag
|
||||
name: ${NAME}:latest
|
||||
source:
|
||||
contextDir: ${CONTEXT_DIR}
|
||||
git:
|
||||
ref: ${SOURCE_REPOSITORY_REF}
|
||||
uri: ${SOURCE_REPOSITORY_URL}
|
||||
type: Git
|
||||
strategy:
|
||||
sourceStrategy:
|
||||
from:
|
||||
kind: ImageStreamTag
|
||||
name: lighttpd-centos7:latest
|
||||
namespace: ${NAMESPACE}
|
||||
type: Source
|
||||
triggers:
|
||||
- type: ImageChange
|
||||
- type: ConfigChange
|
||||
- github:
|
||||
secret: ${GITHUB_WEBHOOK_SECRET}
|
||||
type: GitHub
|
||||
- generic:
|
||||
secret: ${GENERIC_WEBHOOK_SECRET}
|
||||
type: Generic
|
||||
- apiVersion: v1
|
||||
kind: DeploymentConfig
|
||||
metadata:
|
||||
annotations:
|
||||
description: Defines how to deploy the application server
|
||||
template.alpha.openshift.io/wait-for-ready: "true"
|
||||
name: ${NAME}
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
name: ${NAME}
|
||||
strategy:
|
||||
type: Rolling
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
name: ${NAME}
|
||||
name: ${NAME}
|
||||
spec:
|
||||
containers:
|
||||
- env: []
|
||||
image: ' '
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
port: 8080
|
||||
initialDelaySeconds: 30
|
||||
timeoutSeconds: 3
|
||||
name: lighttpd
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
port: 8080
|
||||
initialDelaySeconds: 3
|
||||
timeoutSeconds: 3
|
||||
resources:
|
||||
limits:
|
||||
cpu: ${CPU_LIMIT}
|
||||
memory: ${MEMORY_LIMIT}
|
||||
requests:
|
||||
cpu: ${CPU_LIMIT}
|
||||
memory: ${MEMORY_LIMIT}
|
||||
triggers:
|
||||
- imageChangeParams:
|
||||
automatic: true
|
||||
containerNames:
|
||||
- lighttpd
|
||||
from:
|
||||
kind: ImageStreamTag
|
||||
name: ${NAME}:latest
|
||||
type: ImageChange
|
||||
- type: ConfigChange
|
||||
- apiVersion: autoscaling/v1
|
||||
kind: HorizontalPodAutoscaler
|
||||
metadata:
|
||||
creationTimestamp: null
|
||||
name: ${NAME}
|
||||
spec:
|
||||
maxReplicas: 5
|
||||
minReplicas: 1
|
||||
scaleTargetRef:
|
||||
apiVersion: apps.openshift.io/v1
|
||||
kind: DeploymentConfig
|
||||
name: ${NAME}
|
||||
targetCPUUtilizationPercentage: ${CPU_PERCENT}
|
||||
parameters:
|
||||
- description: The name assigned to all of the frontend objects defined in this template.
|
||||
displayName: Name
|
||||
name: NAME
|
||||
required: true
|
||||
value: lighttpd-example
|
||||
- description: The OpenShift Namespace where the ImageStream resides.
|
||||
displayName: Namespace
|
||||
name: NAMESPACE
|
||||
required: true
|
||||
value: openshift
|
||||
- description: Maximum amount of memory the container can use.
|
||||
displayName: Memory Limit
|
||||
name: MEMORY_LIMIT
|
||||
required: true
|
||||
value: 128Mi
|
||||
- description: Maximum % of vcore the container can use.
|
||||
displayName: CPU Limit
|
||||
name: CPU_LIMIT
|
||||
required: true
|
||||
value: 200m
|
||||
- description: Maximum % usage to activate autoscaling.
|
||||
displayName: CPU Percent
|
||||
name: CPU_PERCENT
|
||||
required: true
|
||||
value: "80"
|
||||
- description: The URL of the repository with your application source code.
|
||||
displayName: Git Repository URL
|
||||
name: SOURCE_REPOSITORY_URL
|
||||
required: true
|
||||
value: https://github.com/hector-vido/lighttpd-ex.git
|
||||
- description: Set this to a branch name, tag or other ref of your repository if you
|
||||
are not using the default branch.
|
||||
displayName: Git Reference
|
||||
name: SOURCE_REPOSITORY_REF
|
||||
- description: Set this to the relative path to your project if it is not in the root
|
||||
of your repository.
|
||||
displayName: Context Directory
|
||||
name: CONTEXT_DIR
|
||||
- description: The exposed hostname that will route to the httpd service, if left
|
||||
blank a value will be defaulted.
|
||||
displayName: Application Hostname
|
||||
name: APPLICATION_DOMAIN
|
||||
- description: Github trigger secret. A difficult to guess string encoded as part
|
||||
of the webhook URL. Not encrypted.
|
||||
displayName: GitHub Webhook Secret
|
||||
from: '[a-zA-Z0-9]{40}'
|
||||
generate: expression
|
||||
name: GITHUB_WEBHOOK_SECRET
|
||||
- description: A secret string used to configure the Generic webhook.
|
||||
displayName: Generic Webhook Secret
|
||||
from: '[a-zA-Z0-9]{40}'
|
||||
generate: expression
|
||||
name: GENERIC_WEBHOOK_SECRET
|
||||
Reference in New Issue
Block a user