Skip to content

Commit

Permalink
Merge pull request #1 from SmartColumbusOS/linkett-adapter-deploy
Browse files Browse the repository at this point in the history
Linkett adapter deploy repo
  • Loading branch information
LtChae authored Apr 6, 2020
2 parents 3505abd + 679e58e commit d6478a9
Show file tree
Hide file tree
Showing 8 changed files with 218 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
description: Adapter API to expose work order data for Linkett
name: linkett-adapter
version: 0.1.0
52 changes: 52 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
library(
identifier: '[email protected]',
retriever: modernSCM([$class: 'GitSCMSource',
remote: 'https://github.com/SmartColumbusOS/pipeline-lib',
credentialsId: 'jenkins-github-user'])
)

properties([
pipelineTriggers([scos.dailyBuildTrigger()]),
parameters([
booleanParam(defaultValue: false, description: 'Deploy to development environment?', name: 'DEV_DEPLOYMENT'),
string(defaultValue: 'latest', description: 'Image tag to deploy to dev environment', name: 'DEV_IMAGE_TAG')
])
])

def applicationName = "linkett-adapter"
def doStageIf = scos.&doStageIf
def doStageIfDeployingToDev = doStageIf.curry(env.DEV_DEPLOYMENT == "true")
def doStageIfMergedToMaster = doStageIf.curry(scos.changeset.isMaster && env.DEV_DEPLOYMENT == "false")
def doStageIfRelease = doStageIf.curry(scos.changeset.isRelease)

node ('infrastructure') {
ansiColor('xterm') {
scos.doCheckoutStage()

doStageIfDeployingToDev('Deploy to Dev') {
deployTo(applicationName, 'dev', "--set image.tag=${env.DEV_IMAGE_TAG} --recreate-pods")
}

doStageIfMergedToMaster('Deploy to Staging') {
deployTo(applicationName, 'staging')
scos.applyAndPushGitHubTag('staging')
}

doStageIfRelease('Deploy to Production') {
deployTo(applicationName, 'prod')
scos.applyAndPushGitHubTag('prod')
}
}
}

def deployTo(applicationName, environment, extraArgs = '') {
scos.withEksCredentials(environment) {
sh("""#!/bin/bash
set -e
helm init --client-only
helm upgrade --install ${applicationName} . \
--namespace=linkett \
${extraArgs}
""".trim())
}
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# linkett_adapter-deploy
linkett_adapter-deploy
45 changes: 45 additions & 0 deletions templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "linkett-adapter.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "linkett-adapter.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "linkett-adapter.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Common labels
*/}}
{{- define "linkett-adapter.labels" -}}
app.kubernetes.io/name: {{ include "linkett-adapter.name" . }}
helm.sh/chart: {{ include "linkett-adapter.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}
50 changes: 50 additions & 0 deletions templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "linkett-adapter.fullname" . }}
labels:
{{ include "linkett-adapter.labels" . | indent 4 }}
spec:
serviceAccountName: {{ .Chart.Name }}
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "linkett-adapter.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
template:
metadata:
labels:
app.kubernetes.io/name: {{ include "linkett-adapter.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
spec:
serviceAccountName: {{ .Chart.Name }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 80
protocol: TCP
livenessProbe:
httpGet:
path: /api/v1/healthcheck
port: http
readinessProbe:
httpGet:
path: /api/v1/healthcheck
port: http
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
22 changes: 22 additions & 0 deletions templates/rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ .Chart.Name }}
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: Role
metadata:
name: {{ .Chart.Name }}
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: RoleBinding
metadata:
name: {{ .Chart.Name }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: {{ .Chart.Name }}
subjects:
- kind: ServiceAccount
name: {{ .Chart.Name }}
namespace: {{ .Release.Namespace }}
16 changes: 16 additions & 0 deletions templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "linkett-adapter.fullname" . }}
labels:
{{ include "linkett-adapter.labels" . | indent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
app.kubernetes.io/name: {{ include "linkett-adapter.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
28 changes: 28 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
replicaCount: 1

image:
repository: 199837183662.dkr.ecr.us-east-2.amazonaws.com/scos/linkett-adapter
tag: 0.1.0
pullPolicy: Always

nameOverride: ""
fullnameOverride: ""

service:
type: ClusterIP
port: 80

resources:
limits:
cpu: 100m
memory: 128Mi
requests:
cpu: 100m
memory: 128Mi


nodeSelector: {}

tolerations: []

affinity: {}

0 comments on commit d6478a9

Please sign in to comment.