-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
540 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
pipeline { | ||
agent { | ||
label "jenkins-maven" | ||
} | ||
environment { | ||
ORG = 'chiducaf' | ||
APP_NAME = 'employee-mnagement-system' | ||
CHARTMUSEUM_CREDS = credentials('jenkins-x-chartmuseum') | ||
DOCKER_REGISTRY_ORG = 'gkejenkinsx' | ||
} | ||
stages { | ||
stage('CI Build and push snapshot') { | ||
when { | ||
branch 'PR-*' | ||
} | ||
environment { | ||
PREVIEW_VERSION = "0.0.0-SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER" | ||
PREVIEW_NAMESPACE = "$APP_NAME-$BRANCH_NAME".toLowerCase() | ||
HELM_RELEASE = "$PREVIEW_NAMESPACE".toLowerCase() | ||
} | ||
steps { | ||
container('maven') { | ||
sh "mvn versions:set -DnewVersion=$PREVIEW_VERSION" | ||
sh "mvn install" | ||
sh "skaffold version" | ||
sh "export VERSION=$PREVIEW_VERSION && skaffold build -f skaffold.yaml" | ||
sh "jx step post build --image $DOCKER_REGISTRY/$ORG/$APP_NAME:$PREVIEW_VERSION" | ||
dir('charts/preview') { | ||
sh "make preview" | ||
sh "jx preview --app $APP_NAME --dir ../.." | ||
} | ||
} | ||
} | ||
} | ||
stage('Build Release') { | ||
when { | ||
branch 'master' | ||
} | ||
steps { | ||
container('maven') { | ||
|
||
// ensure we're not on a detached head | ||
sh "git checkout master" | ||
sh "git config --global credential.helper store" | ||
sh "jx step git credentials" | ||
|
||
// so we can retrieve the version in later steps | ||
sh "echo \$(jx-release-version) > VERSION" | ||
sh "mvn versions:set -DnewVersion=\$(cat VERSION)" | ||
sh "jx step tag --version \$(cat VERSION)" | ||
sh "mvn clean deploy" | ||
sh "skaffold version" | ||
sh "export VERSION=`cat VERSION` && skaffold build -f skaffold.yaml" | ||
sh "jx step post build --image $DOCKER_REGISTRY/$ORG/$APP_NAME:\$(cat VERSION)" | ||
} | ||
} | ||
} | ||
stage('Promote to Environments') { | ||
when { | ||
branch 'master' | ||
} | ||
steps { | ||
container('maven') { | ||
dir('charts/employee-mnagement-system') { | ||
sh "jx step changelog --version v\$(cat ../../VERSION)" | ||
|
||
// release the helm chart | ||
sh "jx step helm release" | ||
|
||
// promote through all 'Auto' promotion Environments | ||
sh "jx promote -b --all-auto --timeout 1h --version \$(cat ../../VERSION)" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
post { | ||
always { | ||
cleanWs() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Patterns to ignore when building packages. | ||
# This supports shell glob matching, relative path matching, and | ||
# negation (prefixed with !). Only one pattern per line. | ||
.DS_Store | ||
# Common VCS dirs | ||
.git/ | ||
.gitignore | ||
.bzr/ | ||
.bzrignore | ||
.hg/ | ||
.hgignore | ||
.svn/ | ||
# Common backup files | ||
*.swp | ||
*.bak | ||
*.tmp | ||
*~ | ||
# Various IDEs | ||
.project | ||
.idea/ | ||
*.tmproj |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
apiVersion: v1 | ||
description: A Helm chart for Kubernetes | ||
icon: https://raw.githubusercontent.com/jenkins-x/jenkins-x-platform/master/images/java.png | ||
name: maven | ||
version: 0.1.0-SNAPSHOT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
CHART_REPO := http://jenkins-x-chartmuseum:8080 | ||
CURRENT=$(pwd) | ||
NAME := employee-mnagement-system | ||
OS := $(shell uname) | ||
RELEASE_VERSION := $(shell cat ../../VERSION) | ||
|
||
build: clean | ||
rm -rf requirements.lock | ||
helm dependency build | ||
helm lint | ||
|
||
install: clean build | ||
helm install . --name ${NAME} | ||
|
||
upgrade: clean build | ||
helm upgrade ${NAME} . | ||
|
||
delete: | ||
helm delete --purge ${NAME} | ||
|
||
clean: | ||
rm -rf charts | ||
rm -rf ${NAME}*.tgz | ||
|
||
release: clean | ||
helm dependency build | ||
helm lint | ||
helm init --client-only | ||
helm package . | ||
curl --fail -u $(CHARTMUSEUM_CREDS_USR):$(CHARTMUSEUM_CREDS_PSW) --data-binary "@$(NAME)-$(shell sed -n 's/^version: //p' Chart.yaml).tgz" $(CHART_REPO)/api/charts | ||
rm -rf ${NAME}*.tgz% | ||
|
||
tag: | ||
ifeq ($(OS),Darwin) | ||
sed -i "" -e "s/version:.*/version: $(RELEASE_VERSION)/" Chart.yaml | ||
sed -i "" -e "s/tag:.*/tag: $(RELEASE_VERSION)/" values.yaml | ||
else ifeq ($(OS),Linux) | ||
sed -i -e "s/version:.*/version: $(RELEASE_VERSION)/" Chart.yaml | ||
sed -i -e "s|repository:.*|repository: $(DOCKER_REGISTRY)\/gkejenkinsx\/employee-mnagement-system|" values.yaml | ||
sed -i -e "s/tag:.*/tag: $(RELEASE_VERSION)/" values.yaml | ||
else | ||
echo "platfrom $(OS) not supported to release from" | ||
exit -1 | ||
endif | ||
git add --all | ||
git commit -m "release $(RELEASE_VERSION)" --allow-empty # if first release then no verion update is performed | ||
git tag -fa v$(RELEASE_VERSION) -m "Release version $(RELEASE_VERSION)" | ||
git push origin v$(RELEASE_VERSION) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Java application |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
Get the application URL by running these commands: | ||
|
||
kubectl get ingress {{ template "fullname" . }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{{/* vim: set filetype=mustache: */}} | ||
{{/* | ||
Expand the name of the chart. | ||
*/}} | ||
{{- define "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). | ||
*/}} | ||
{{- define "fullname" -}} | ||
{{- $name := default .Chart.Name .Values.nameOverride -}} | ||
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} | ||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
{{- if .Values.canary.enabled }} | ||
apiVersion: flagger.app/v1beta1 | ||
kind: Canary | ||
metadata: | ||
name: {{ template "fullname" . }} | ||
labels: | ||
draft: {{ default "draft-app" .Values.draft }} | ||
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" | ||
spec: | ||
provider: istio | ||
targetRef: | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
name: {{ template "fullname" . }} | ||
progressDeadlineSeconds: {{ .Values.canary.progressDeadlineSeconds }} | ||
{{- if .Values.hpa.enabled }} | ||
autoscalerRef: | ||
apiVersion: autoscaling/v2beta1 | ||
kind: HorizontalPodAutoscaler | ||
name: {{ template "fullname" . }} | ||
{{- end }} | ||
service: | ||
port: {{ .Values.service.externalPort }} | ||
targetPort: {{ .Values.service.internalPort }} | ||
gateways: | ||
- {{ template "fullname" . }} | ||
hosts: | ||
- {{ .Values.canary.host }} | ||
analysis: | ||
interval: {{ .Values.canary.canaryAnalysis.interval }} | ||
threshold: {{ .Values.canary.canaryAnalysis.threshold }} | ||
maxWeight: {{ .Values.canary.canaryAnalysis.maxWeight }} | ||
stepWeight: {{ .Values.canary.canaryAnalysis.stepWeight }} | ||
metrics: | ||
- name: request-success-rate | ||
threshold: {{ .Values.canary.canaryAnalysis.metrics.requestSuccessRate.threshold }} | ||
interval: {{ .Values.canary.canaryAnalysis.metrics.requestSuccessRate.interval }} | ||
- name: latency | ||
templateRef: | ||
name: latency | ||
thresholdRange: | ||
max: {{ .Values.canary.canaryAnalysis.metrics.requestDuration.threshold }} | ||
interval: {{ .Values.canary.canaryAnalysis.metrics.requestDuration.interval }} | ||
|
||
--- | ||
|
||
apiVersion: flagger.app/v1beta1 | ||
kind: MetricTemplate | ||
metadata: | ||
name: latency | ||
spec: | ||
provider: | ||
type: prometheus | ||
address: http://prometheus.istio-system:9090 | ||
query: | | ||
histogram_quantile( | ||
0.99, | ||
sum( | ||
rate( | ||
istio_request_duration_milliseconds_bucket{ | ||
reporter="destination", | ||
destination_workload_namespace="{{ "{{" }} namespace {{ "}}" }}", | ||
destination_workload=~"{{ "{{" }} target {{ "}}" }}" | ||
}[{{ "{{" }} interval {{ "}}" }}] | ||
) | ||
) by (le) | ||
) | ||
--- | ||
|
||
apiVersion: networking.istio.io/v1alpha3 | ||
kind: Gateway | ||
metadata: | ||
name: {{ template "fullname" . }} | ||
spec: | ||
selector: | ||
istio: ingressgateway | ||
servers: | ||
- port: | ||
number: {{ .Values.service.externalPort }} | ||
name: http | ||
protocol: HTTP | ||
hosts: | ||
- {{ .Values.canary.host }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
{{- if .Values.knativeDeploy }} | ||
{{- else }} | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: {{ template "fullname" . }} | ||
labels: | ||
draft: {{ default "draft-app" .Values.draft }} | ||
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: {{ template "fullname" . }} | ||
{{- if .Values.hpa.enabled }} | ||
{{- else }} | ||
replicas: {{ .Values.replicaCount }} | ||
{{- end }} | ||
template: | ||
metadata: | ||
labels: | ||
draft: {{ default "draft-app" .Values.draft }} | ||
app: {{ template "fullname" . }} | ||
{{- if .Values.podAnnotations }} | ||
annotations: | ||
{{ toYaml .Values.podAnnotations | indent 8 }} | ||
{{- end }} | ||
spec: | ||
containers: | ||
- name: {{ .Chart.Name }} | ||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" | ||
imagePullPolicy: {{ .Values.image.pullPolicy }} | ||
env: | ||
{{- range $pkey, $pval := .Values.env }} | ||
- name: {{ $pkey }} | ||
value: {{ quote $pval }} | ||
{{- end }} | ||
envFrom: | ||
{{ toYaml .Values.envFrom | indent 10 }} | ||
ports: | ||
- containerPort: {{ .Values.service.internalPort }} | ||
livenessProbe: | ||
httpGet: | ||
path: {{ .Values.probePath }} | ||
port: {{ .Values.service.internalPort }} | ||
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }} | ||
periodSeconds: {{ .Values.livenessProbe.periodSeconds }} | ||
successThreshold: {{ .Values.livenessProbe.successThreshold }} | ||
timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }} | ||
readinessProbe: | ||
httpGet: | ||
path: {{ .Values.probePath }} | ||
port: {{ .Values.service.internalPort }} | ||
periodSeconds: {{ .Values.readinessProbe.periodSeconds }} | ||
successThreshold: {{ .Values.readinessProbe.successThreshold }} | ||
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }} | ||
resources: | ||
{{ toYaml .Values.resources | indent 12 }} | ||
terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{{- if .Values.hpa.enabled }} | ||
apiVersion: autoscaling/v2beta1 | ||
kind: HorizontalPodAutoscaler | ||
metadata: | ||
name: {{ template "fullname" . }} | ||
labels: | ||
draft: {{ default "draft-app" .Values.draft }} | ||
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" | ||
spec: | ||
scaleTargetRef: | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
name: {{ template "fullname" . }} | ||
minReplicas: {{ .Values.hpa.minReplicas }} | ||
maxReplicas: {{ .Values.hpa.maxReplicas }} | ||
metrics: | ||
- type: Resource | ||
resource: | ||
name: cpu | ||
targetAverageUtilization: {{ .Values.hpa.cpuTargetAverageUtilization }} | ||
- type: Resource | ||
resource: | ||
name: memory | ||
targetAverageUtilization: {{ .Values.hpa.memoryTargetAverageUtilization }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{{- if and (.Values.jxRequirements.ingress.domain) (not .Values.knativeDeploy) }} | ||
apiVersion: {{ .Values.jxRequirements.ingress.apiVersion }} | ||
kind: Ingress | ||
metadata: | ||
annotations: | ||
kubernetes.io/ingress.class: nginx | ||
{{- if .Values.ingress.annotations }} | ||
{{ toYaml .Values.ingress.annotations | indent 4 }} | ||
{{- end }} | ||
{{- if .Values.jxRequirements.ingress.annotations }} | ||
{{ toYaml .Values.jxRequirements.ingress.annotations | indent 4 }} | ||
{{- end }} | ||
name: {{ .Values.service.name }} | ||
spec: | ||
rules: | ||
- host: {{ .Values.service.name }}{{ .Values.jxRequirements.ingress.namespaceSubDomain }}{{ .Values.jxRequirements.ingress.domain }} | ||
http: | ||
paths: | ||
- backend: | ||
serviceName: {{ .Values.service.name }} | ||
servicePort: 80 | ||
{{- if .Values.jxRequirements.ingress.tls.enabled }} | ||
tls: | ||
- hosts: | ||
- {{ .Values.service.name }}{{ .Values.jxRequirements.ingress.namespaceSubDomain }}{{ .Values.jxRequirements.ingress.domain }} | ||
{{- if .Values.jxRequirements.ingress.tls.production }} | ||
secretName: "tls-{{ .Values.jxRequirements.ingress.domain | replace "." "-" }}-p" | ||
{{- else }} | ||
secretName: "tls-{{ .Values.jxRequirements.ingress.domain | replace "." "-" }}-s" | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} |
Oops, something went wrong.