Skip to content

Instantly share code, notes, and snippets.

@ParadoxGuitarist
Created January 3, 2020 19:17
Show Gist options
  • Save ParadoxGuitarist/b16044f768b7b21d32fa25e01829bdce to your computer and use it in GitHub Desktop.
Save ParadoxGuitarist/b16044f768b7b21d32fa25e01829bdce to your computer and use it in GitHub Desktop.
Openshift Yaml for a Ephemerial Snipe-IT Template
---
kind: Template
apiVersion: v1
metadata:
name: snipe-it
annotations:
openshift.io/display-name: Snipe-IT
description: Snipe-IT - Open Source Asset Management
openshift.io/provider-display-name: Grokability, Inc.
openshift.io/documentation-url: https://snipeitapp.com/
template.openshift.io/bindable: "false"
message: |-
The following service(s) have been created in your project: ${NAME} - ${DATABASE_SERVICE_NAME}.
labels:
template: snipe-it
app: snipe-it
objects:
- kind: Secret
apiVersion: v1
metadata:
name: "${NAME}"
stringData:
app-key: "${APP_KEY}"
database: "${MYSQL_DATABASE}"
database-user: "${MYSQL_USER}"
database-password: "${MYSQL_PASSWORD}"
database-root-password: "${MYSQL_ROOT_PASSWORD}"
email-user: "${MAIL_ENV_USERNAME}"
email-password: "${MAIL_ENV_PASSWORD}"
- kind: Service
apiVersion: v1
metadata:
name: "${NAME}"
annotations:
description: Snipe-IT frontend, built with Larvel.
service.alpha.openshift.io/dependencies: '[{"name": "${NAME}", "kind": "Service"}]'
spec:
ports:
- name: web
port: 80
targetPort: 80
selector:
name: "${NAME}"
- kind: Service
apiVersion: v1
metadata:
name: "${DATABASE_SERVICE_NAME}"
annotations:
description: MySQL backend for Snipe it.
template.openshift.io/expose-uri: mysql://{.spec.clusterIP}:{.spec.ports[?(.name==\"mysql\")].port}
spec:
ports:
- name: mysql
port: 3306
targetPort: 3306
protocol: TCP
selector:
name: "${DATABASE_SERVICE_NAME}"
- kind: ImageStream
apiVersion: v1
metadata:
name: "${NAME}"
annotations:
description: Stable Snipe-It Docker Image
spec:
tags:
- from:
kind: DockerImage
name: "snipe/snipe-it:latest"
name: latest
- kind: ImageStream
apiVersion: v1
metadata:
name: "${DATABASE_SERVICE_NAME}"
annotations:
description: MySQL 5.6
spec:
tags:
- from:
kind: DockerImage
name: "mysql:5.6"
name: latest
- kind: DeploymentConfig
apiVersion: v1
metadata:
name: "${DATABASE_SERVICE_NAME}"
annotations:
description: Defines how to deploy the mysql container.
template.alpha.openshift.io/wait-for-ready: 'true'
spec:
replicas: 1
selector:
name: "${DATABASE_SERVICE_NAME}"
strategy:
type: Recreate
triggers:
- type: imageChange
imageChangeParams:
automatic: true
containerNames:
- "${DATABASE_SERVICE_NAME}"
from:
kind: ImageStreamTag
name: "${DATABASE_SERVICE_NAME}:latest"
- type: ConfigChange
template:
metadata:
name: "${DATABASE_SERVICE_NAME}"
labels:
name: "${DATABASE_SERVICE_NAME}"
spec:
containers:
- name: "${DATABASE_SERVICE_NAME}"
image: " "
imagePullPolicy: IfNotPresent
env:
- name: APP_KEY
valueFrom:
secretKeyRef:
name: "${NAME}"
key: app-key
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: "${NAME}"
key: database-root-password
- name: MYSQL_DATABASE
valueFrom:
secretKeyRef:
name: "${NAME}"
key: database
- name: MYSQL_USER
valueFrom:
secretKeyRef:
name: "${NAME}"
key: database-user
- name: MYSQL_PASSWORD
valueFrom:
secretKeyRef:
name: "${NAME}"
key: database-password
ports:
- containerPort: 3306
protocol: TCP
volumeMounts:
- mountPath: /var/lib/mysql/data
name: "${DATABASE_SERVICE_NAME}-data"
volumes:
- emptyDir:
medium: ""
name: "${DATABASE_SERVICE_NAME}-data"
- kind: DeploymentConfig
apiVersion: v1
metadata:
name: "${NAME}"
annotations:
description: Defines how to deploy the snipe-it container.
template.alpha.openshift.io/wait-for-ready: 'true'
spec:
strategy:
type: Rolling
rollingParams:
intervalSeconds: 1
maxSurge: 0%
maxUnavailable: 100%
timeoutSeconds: 600
updatePeriodSeconds: 1
triggers:
- type: ImageChange
imageChangeParams:
automatic: true
containerNames:
- "${NAME}"
from:
kind: ImageStreamTag
name: "${NAME}:latest"
- type: ConfigChange
replicas: 1
selector:
name: "${NAME}"
template:
metadata:
name: "${NAME}"
labels:
name: "${NAME}"
spec:
containers:
- name: "${NAME}"
image: " "
ports:
- containerPort: 80
env:
- name: APP_ENV
value: "${APP_ENV}"
- name: APP_DEBUG
value: "${APP_DEBUG}"
- name: APP_URL
value: "${APP_URL}"
- name: APP_TIMEZONE
value: "${APP_TIMEZONE}"
- name: APP_LOCALE
value: "${APP_LOCALE}"
- name: MAIL_PORT_587_TCP_ADDR
value: "${MAIL_PORT_587_TCP_ADDR}"
- name: MAIL_PORT_587_TCP_PORT
value: "${MAIL_PORT_587_TCP_PORT}"
- name: MAIL_ENV_FROM_ADDR
value: "${MAIL_ENV_FROM_ADDR}"
- name: MAIL_ENV_FROM_NAME
value: "${MAIL_ENV_FROM_NAME}"
- name: MAIL_ENV_ENCRYPTION
value: "${MAIL_ENV_ENCRYPTION}"
- name: DATABASE_SERVICE_NAME
value: "${DATABASE_SERVICE_NAME}"
- name: APP_KEY
valueFrom:
secretKeyRef:
name: "${NAME}"
key: app-key
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: "${NAME}"
key: database-root-password
- name: MYSQL_DATABASE
valueFrom:
secretKeyRef:
name: "${NAME}"
key: database
- name: MYSQL_USER
valueFrom:
secretKeyRef:
name: "${NAME}"
key: database-user
- name: MYSQL_PASSWORD
valueFrom:
secretKeyRef:
name: "${NAME}"
key: database-password
- name: MAIL_ENV_USERNAME
valueFrom:
secretKeyRef:
name: "${NAME}"
key: email-user
- name: MAIL_ENV_PASSWORD
valueFrom:
secretKeyRef:
name: "${NAME}"
key: email-password
resources:
limits:
memory: "${MEMORY_LIMIT}"
parameters:
- name: NAME
displayName: Name
description: The name assigned to all of the frontend objects defined in this template.
required: true
value: snipeit
- name: NAMESPACE
displayName: Namespace
required: true
description: The OpenShift Namespace where the ImageStream resides.
value: openshift
- name: MEMORY_LIMIT
displayName: Memory Limit
required: true
description: Maximum amount of memory the Snipe-IT container can use.
value: 512Mi
- name: MYSQL_ROOT_PASSWORD
displayName: Root password that is set for the MySQL container.
generate: expression
from: "[a-zA-Z0-9]{40}"
- name: MYSQL_DATABASE
displayName: Database Name
required: true
value: snipeit
- name: DATABASE_SERVICE_NAME
displayName: Database Service name
required: true
value: snipe-mysql
- name: MYSQL_USER
displayName: Database Username
required: true
value: snipeit
- name: MYSQL_PASSWORD
displayName: Database User Password
required: true
generate: expression
from: "[a-zA-Z0-9]{40}"
- name: APP_ENV
description: Describes what type of environment the application will be running in. ( production | development )
displayName: App Environment
value: production
- name: APP_DEBUG
displayName: Debug Mode
description: If the application should run in debug mode, which consumes additional resources. Boolean
value: "false"
- name: APP_KEY
displayName: Larvel Application Key
description: This must be genertated inside a container with the `php artisan key:generate --show` command. The auto-populated key here should only be used for testing.
value: base64:nh4+xxPhPif9vIonR0vlufp1SOM1Nys2wC3ZbN0AodM=
- name: APP_URL
displayName: Application URL
description: If you use a reverse proxy, it's likely that Snipe-IT will be unable to pick up on the external URL properly. Defaults to the loopback address.
value: http://127.0.0.1
- name: APP_TIMEZONE
displayName: TZ Database Name
description: Please enter the appropriate Timezone name.
value: US/Pacific
- name: APP_LOCALE
displayName: This sets the appropriate locale and language for Snipe-IT.
value: en
- name: MAIL_PORT_587_TCP_ADDR
displayName: SMTP Server address
description: The FDQN or IP address of you mailserver.
value: aspmx.l.google.com
- name: MAIL_PORT_587_TCP_PORT
displayName: SMTP Port
description: The port for the mailserver (probably 587, could be another)
value: "25"
- name: MAIL_ENV_FROM_ADDR
displayName: From Address
description: The email address that the email message will be from
value: [email protected]
- name: MAIL_ENV_FROM_NAME
displayName: Email Name
description: The display name (Full Name) of for the email sender.
value: Asset Management Administrator
- name: MAIL_ENV_ENCRYPTION
displayName: SMTP Encryption
description: Pick 'tls' for SMTP-over-SSL, 'tcp' for Unencrypted
value: tcp
- name: MAIL_ENV_USERNAME
displayName: SMTP Username
- name: MAIL_ENV_PASSWORD
displayName: SMTP Password
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment