[15.02.20] kubernetes configs and application yamls

This commit is contained in:
andyjk15 2020-02-15 16:51:47 +00:00
parent f2be9dfb4b
commit 4615c1a0c1
4 changed files with 165 additions and 1 deletions

View File

@ -2,5 +2,4 @@ FROM openjdk:8-jre-alpine
MAINTAINER Andrew Sotheran <cryptosky.user@gmail.com> MAINTAINER Andrew Sotheran <cryptosky.user@gmail.com>
COPY /target/cryptosky-db-gateway.jar /home COPY /target/cryptosky-db-gateway.jar /home
EXPOSE 9090 EXPOSE 9090
CMD ["/bin/bash"]
CMD ["java", "-jar", "/home/cryptosky-db-gateway.jar"] CMD ["java", "-jar", "/home/cryptosky-db-gateway.jar"]

View File

@ -26,6 +26,28 @@ String get_application_version() {
"${pom.version}-b${env.BUILD_NUMBER}" "${pom.version}-b${env.BUILD_NUMBER}"
} }
@NonCPS
def applyResource(String environment, String resourcePath, Map<String, Object> parameters) {
String command = "kubectl apply --filename ${resourcePath}"
parameters.each { String key, Object value ->
command += " --param=${key}='${value}'"
}
command += "| oc --namespace ${environment} apply --filename -"
sh "${command}"
}
def updateBuildResources(String environment) {
Map<String, Object> buildConfigParameters = [
RESOURCE_NAME : env.APPLICATION_NAME,
APP_LABEL : env.APPLICATION_LABEL,
DOCKER_REGISTRY: env.DOCKER_REGISTRY,
IMAGE_VERSION : env.APPLICATION_VERSION
]
applyResource(environment, 'configuration/templates/build-config.yaml', buildConfigParameters)
}
def deploy( Integer replicas ) { def deploy( Integer replicas ) {
// rollout latest // rollout latest
// get rollout status // get rollout status
@ -61,6 +83,7 @@ try {
stage('Build Image') { stage('Build Image') {
mvn 'clean package -DskipTests' mvn 'clean package -DskipTests'
sh "sed -i 's/BUILD_NUMBER/${env.APPLICATION_VERSION}/g' deploy-config.yaml"
// Update build config for kubernetes // Update build config for kubernetes
// Update Service yaml for kubernetes // Update Service yaml for kubernetes
// Update route yaml for kubernetes // Update route yaml for kubernetes

View File

@ -0,0 +1,118 @@
apiVersion: v1
kind: Deployment
metadata:
labels:
name: db-gateway
name: db-gateway
spec:
replicas: 1
selector:
app: db-gateway
strategy:
type: Rolling
rollingParams:
updatePeriodSeconds: 1
intervalSeconds: 1
timeoutSeconds: 300
maxSurge: 1
maxUnavailable: 0
template:
metadata:
labels:
app: db-gateway
spec:
containers:
- name: db-gateway
image: registry.cryptosky.me:4243/
env:
- name: KUBERNETES_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: CONTAINER_CORE_LIMIT
valueFrom:
resourceFieldRef:
resource: limits.cpu
- name: CONTAINER_MAX_MEMORY
valueFrom:
resourceFieldRef:
resource: limits.memory
- name: JDBC_URL
valueFrom:
secretKeyRef:
name: jdbc
key: jdbc.url
- name: JDBC_USERNAME
valueFrom:
secretKeyRef:
name: jdbc
key: jdbc.username
- name: JDBC_PASSWORD
valueFrom:
secretKeyRef:
name: jdbc
key: jdbc.password
- name: TZ
value: Europe/London
image: ${IMAGE}:${IMAGE_VERSION}
imagePullPolicy: Always
name: db-gateway
livenessProbe:
httpGet:
path: ${LIVENESS_PATH}
port: 9090
initialDelaySeconds: 90
periodSeconds: 30
timeoutSeconds: 1
successThreshold: 1
failureThreshold: 3
readinessProbe:
httpGet:
path: ${READINESS_PATH}
port: 9090
initialDelaySeconds: 90
periodSeconds: 5
timeoutSeconds: 1
successThreshold: 1
failureThreshold: 10
resources:
requests:
cpu: 10m
memory: 128Mi
limits:
cpu: 500m
memory: 256Mi
restartPolicy: Always
triggers: []
parameters:
- name: RESOURCE_NAME
displayName: Resource Name
description: The name of the deployment configuration resource that also matches other resources.
required: true
- name: APP_LABEL
displayName: Application Label
description: Name of the application label that should be used in all resources.
required: true
- name: IMAGE
displayName: Image Reference
description: Complete reference to an image in external Docker Registry.
required: true
- name: IMAGE_VERSION
displayName: Image Version
description: Version of specific image to pull from external Docker registry.
required: true
- name: LIVENESS_PATH
displayName: Liveness Probe Path
description: Path to use in HTTP Get for the liveness probe.
value: /health
required: false
- name: READINESS_PATH
displayName: Readiness Probe Path
description: Path to use in HTTP Get for the readiness probe.
value: /info
required: false
- name: SPRING_PROFILES_ACTIVE
displayName: Spring Profiles Active
description: The active Spring profile(s)
required: false

View File

@ -0,0 +1,24 @@
spring:
application:
name: @project.artifactId@
datasource:
url: ${JDBC_URL}
username: ${JDBC_USERNAME}
password: ${JDBC_PASSWORD}
driver-class-name: org.postgresql.Driver
hikari:
maximum-pool-size: 100
minimum-idle: 1
jpa:
hibernate:
ddl-auto: validate
show-sql: true
properties:
org.hibernate.envers.revision_field_name: revision_id
org.hibernate.envers.revision_type_field_name: revision_type
org.hibernate.jdbc.lob.non_contextual_creation: true
format_sql: true
database: postgresql
server:
port: 9090