Skip to content
This repository was archived by the owner on Jul 27, 2021. It is now read-only.

Commit b140bb4

Browse files
committed
Draft create
1 parent 6d34394 commit b140bb4

File tree

17 files changed

+412
-0
lines changed

17 files changed

+412
-0
lines changed

.helmignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*~
18+
# Various IDEs
19+
.project
20+
.idea/
21+
*.tmproj
22+
*.png
23+
24+
# known compile time folders
25+
target/
26+
node_modules/
27+
vendor/

Jenkinsfile

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
pipeline {
2+
agent {
3+
label "jenkins-ruby"
4+
}
5+
environment {
6+
ORG = 'jenkinsx'
7+
APP_NAME = 'ecsdemo-frontend'
8+
CHARTMUSEUM_CREDS = credentials('jenkins-x-chartmuseum')
9+
}
10+
stages {
11+
stage('CI Build and push snapshot') {
12+
when {
13+
branch 'PR-*'
14+
}
15+
environment {
16+
PREVIEW_VERSION = "0.0.0-SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER"
17+
PREVIEW_NAMESPACE = "$APP_NAME-$BRANCH_NAME".toLowerCase()
18+
HELM_RELEASE = "$PREVIEW_NAMESPACE".toLowerCase()
19+
}
20+
steps {
21+
container('ruby') {
22+
sh "docker build -t $DOCKER_REGISTRY/$ORG/$APP_NAME:$PREVIEW_VERSION ."
23+
sh "docker push $DOCKER_REGISTRY/$ORG/$APP_NAME:$PREVIEW_VERSION"
24+
}
25+
26+
dir ('./charts/preview') {
27+
container('ruby') {
28+
sh "make preview"
29+
sh "jx preview --app $APP_NAME --dir ../.."
30+
}
31+
}
32+
}
33+
}
34+
stage('Build Release') {
35+
when {
36+
branch 'master'
37+
}
38+
steps {
39+
container('ruby') {
40+
// ensure we're not on a detached head
41+
sh "git checkout master"
42+
// until we switch to the new kubernetes / jenkins credential implementation use git credentials store
43+
sh "git config --global credential.helper store"
44+
// so we can retrieve the version in later steps
45+
sh "echo \$(jx-release-version) > VERSION"
46+
}
47+
dir ('./charts/ecsdemo-frontend') {
48+
container('ruby') {
49+
sh "jx step git credentials"
50+
sh "make tag"
51+
}
52+
}
53+
container('ruby') {
54+
sh "docker build -t $DOCKER_REGISTRY/$ORG/$APP_NAME:\$(cat VERSION) ."
55+
sh "docker push $DOCKER_REGISTRY/$ORG/$APP_NAME:\$(cat VERSION)"
56+
}
57+
}
58+
}
59+
stage('Promote to Environments') {
60+
when {
61+
branch 'master'
62+
}
63+
steps {
64+
dir ('./charts/ecsdemo-frontend') {
65+
container('ruby') {
66+
sh 'jx step changelog --version v\$(cat ../../VERSION)'
67+
68+
// release the helm chart
69+
sh 'jx step helm release'
70+
71+
// promote through all 'Auto' promotion Environments
72+
sh 'jx promote -b --all-auto --timeout 1h --version \$(cat ../../VERSION)'
73+
}
74+
}
75+
}
76+
}
77+
}
78+
post {
79+
always {
80+
cleanWs()
81+
}
82+
}
83+
}

OWNERS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
approvers:
2+
- brentley
3+
reviewers:
4+
- brentley

OWNERS_ALIASES

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
aliases:
2+
- brentley
3+
best-approvers:
4+
- brentley
5+
best-reviewers:
6+
- brentley

charts/ecsdemo-frontend/.helmignore

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*~
18+
# Various IDEs
19+
.project
20+
.idea/
21+
*.tmproj

charts/ecsdemo-frontend/Chart.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
apiVersion: v1
2+
description: A Helm chart for Kubernetes
3+
name: ecsdemo-frontend
4+
version: v0.1.0

charts/ecsdemo-frontend/Makefile

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
CHART_REPO := http://jenkins-x-chartmuseum:8080
2+
CURRENT=$(pwd)
3+
NAME := ecsdemo-frontend
4+
OS := $(shell uname)
5+
RELEASE_VERSION := $(shell cat ../../VERSION)
6+
7+
build: clean
8+
rm -rf requirements.lock
9+
helm dependency build
10+
helm lint
11+
12+
install: clean build
13+
helm install . --name ${NAME}
14+
15+
upgrade: clean build
16+
helm upgrade ${NAME} .
17+
18+
delete:
19+
helm delete --purge ${NAME}
20+
21+
clean:
22+
rm -rf charts
23+
rm -rf ${NAME}*.tgz
24+
25+
release: clean
26+
helm dependency build
27+
helm lint
28+
helm init --client-only
29+
helm package .
30+
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
31+
rm -rf ${NAME}*.tgz%
32+
33+
tag:
34+
ifeq ($(OS),Darwin)
35+
sed -i "" -e "s/version:.*/version: $(RELEASE_VERSION)/" Chart.yaml
36+
sed -i "" -e "s/tag: .*/tag: $(RELEASE_VERSION)/" values.yaml
37+
else ifeq ($(OS),Linux)
38+
sed -i -e "s/version:.*/version: $(RELEASE_VERSION)/" Chart.yaml
39+
sed -i -e "s/repository: .*/repository: $(DOCKER_REGISTRY)\/$(ORG)\/$(APP_NAME)/" values.yaml
40+
sed -i -e "s/tag: .*/tag: $(RELEASE_VERSION)/" values.yaml
41+
else
42+
echo "platfrom $(OS) not supported to release from"
43+
exit -1
44+
endif
45+
git add --all
46+
git commit -m "release $(RELEASE_VERSION)" --allow-empty # if first release then no verion update is performed
47+
git tag -fa v$(RELEASE_VERSION) -m "Release version $(RELEASE_VERSION)"
48+
git push origin v$(RELEASE_VERSION)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
{{- if contains "NodePort" .Values.service.type }}
3+
Get the application URL by running these commands:
4+
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "fullname" . }})
5+
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
6+
echo http://$NODE_IP:$NODE_PORT/login
7+
{{- else if contains "LoadBalancer" .Values.service.type }}
8+
Get the application URL by running these commands:
9+
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
10+
You can watch the status of by running 'kubectl get svc -w {{ template "fullname" . }}'
11+
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
12+
echo http://$SERVICE_IP:{{ .Values.service.externalPort }}
13+
{{- else }}
14+
http://{{ .Release.Name }}.{{ .Values.basedomain }} to access your application
15+
{{- end }}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
{{/*
3+
Expand the name of the chart.
4+
*/}}
5+
{{- define "name" -}}
6+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
7+
{{- end -}}
8+
9+
{{/*
10+
Create a default fully qualified app name.
11+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
12+
*/}}
13+
{{- define "fullname" -}}
14+
{{- $name := default .Chart.Name .Values.nameOverride -}}
15+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
16+
{{- end -}}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
apiVersion: extensions/v1beta1
2+
kind: Deployment
3+
metadata:
4+
name: {{ template "fullname" . }}
5+
labels:
6+
draft: {{ default "draft-app" .Values.draft }}
7+
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
8+
spec:
9+
replicas: {{ .Values.replicaCount }}
10+
template:
11+
metadata:
12+
labels:
13+
draft: {{ default "draft-app" .Values.draft }}
14+
app: {{ template "fullname" . }}
15+
{{- if .Values.podAnnotations }}
16+
annotations:
17+
{{ toYaml .Values.podAnnotations | indent 8 }}
18+
{{- end }}
19+
spec:
20+
containers:
21+
- name: {{ .Chart.Name }}
22+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
23+
imagePullPolicy: {{ .Values.image.pullPolicy }}
24+
ports:
25+
- containerPort: {{ .Values.service.internalPort }}
26+
livenessProbe:
27+
httpGet:
28+
path: {{ .Values.probePath }}
29+
port: {{ .Values.service.internalPort }}
30+
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
31+
periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
32+
successThreshold: {{ .Values.livenessProbe.successThreshold }}
33+
timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
34+
readinessProbe:
35+
httpGet:
36+
path: {{ .Values.probePath }}
37+
port: {{ .Values.service.internalPort }}
38+
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
39+
successThreshold: {{ .Values.readinessProbe.successThreshold }}
40+
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
41+
resources:
42+
{{ toYaml .Values.resources | indent 12 }}
43+
terminationGracePeriodSeconds: {{ .Values.terminationGracePeriodSeconds }}

0 commit comments

Comments
 (0)