Skip to content

Commit 8b8b853

Browse files
committed
added: helm part in Jenkinsfile
1 parent ad943fc commit 8b8b853

15 files changed

+382
-0
lines changed

Jenkinsfile

+7
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ pipeline {
2323
sh 'docker push paper.webhop.me/paper-service:latest'
2424
}
2525
}
26+
stage('Helm deploy') {
27+
steps {
28+
withKubeConfig([credentialsId: 'kubernetes-creds', serverUrl: "https://192.268.3.229:16443", namespace: "default"]) {
29+
sh 'helm --help'
30+
}
31+
}
32+
}
2633
}
2734
}
2835
}

helm/configmap.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: paper-service-config
5+
labels:
6+
app: paper-service
7+
data:
8+
SPRING_FLYWAY_URL: "jdbc:postgresql://192.168.2.49:30327/paper"
9+
SPRING_FLYWAY_USER: "paper"
10+
SPRING_FLYWAY_PASSWORD: "paper"
11+
SPRING_DATASOURCE_URL: "jdbc:postgresql://192.168.2.49:30327/paper"
12+
SPRING_DATASOURCE_USERNAME: "paper"
13+
SPRING_DATASOURCE_PASSWORD: "paper"

helm/deployment.yaml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: paper-service
5+
spec:
6+
replicas: 1
7+
selector:
8+
matchLabels:
9+
app: paper-service
10+
template:
11+
metadata:
12+
labels:
13+
app: paper-service
14+
spec:
15+
containers:
16+
- name: paper-service
17+
image: paper-service:1.0.0
18+
imagePullPolicy: "IfNotPresent"
19+
ports:
20+
- containerPort: 8080
21+
envFrom:
22+
- configMapRef:
23+
name: paper-service-config

helm/service.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: paper-service
5+
labels:
6+
app: paper-service
7+
spec:
8+
type: NodePort
9+
ports:
10+
- port: 8080
11+
selector:
12+
app: paper-service

paper-chart/.helmignore

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/

paper-chart/Chart.yaml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: v2
2+
name: paper-service
3+
description: A Helm chart for Kubernetes
4+
5+
# A chart can be either an 'application' or a 'library' chart.
6+
#
7+
# Application charts are a collection of templates that can be packaged into versioned archives
8+
# to be deployed.
9+
#
10+
# Library charts provide useful utilities or functions for the chart developer. They're included as
11+
# a dependency of application charts to inject those utilities and functions into the rendering
12+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
13+
type: application
14+
15+
# This is the chart version. This version number should be incremented each time you make changes
16+
# to the chart and its templates, including the app version.
17+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18+
version: 0.1.0
19+
20+
# This is the version number of the application being deployed. This version number should be
21+
# incremented each time you make changes to the application. Versions are not expected to
22+
# follow Semantic Versioning. They should reflect the version the application is using.
23+
# It is recommended to use it with quotes.
24+
appVersion: "1.16.0"

paper-chart/templates/NOTES.txt

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
1. Get the application URL by running these commands:
2+
{{- if .Values.ingress.enabled }}
3+
{{- range $host := .Values.ingress.hosts }}
4+
{{- range .paths }}
5+
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
6+
{{- end }}
7+
{{- end }}
8+
{{- else if contains "NodePort" .Values.service.type }}
9+
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "paper-chart.fullname" . }})
10+
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
11+
echo http://$NODE_IP:$NODE_PORT
12+
{{- else if contains "LoadBalancer" .Values.service.type }}
13+
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
14+
You can watch its status by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "paper-chart.fullname" . }}'
15+
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "paper-chart.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
16+
echo http://$SERVICE_IP:{{ .Values.service.port }}
17+
{{- else if contains "ClusterIP" .Values.service.type }}
18+
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "paper-chart.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
19+
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
20+
echo "Visit http://127.0.0.1:8080 to use your application"
21+
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
22+
{{- end }}

paper-chart/templates/_helpers.tpl

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "paper-chart.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "paper-chart.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "paper-chart.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "paper-chart.labels" -}}
37+
helm.sh/chart: {{ include "paper-chart.chart" . }}
38+
{{ include "paper-chart.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "paper-chart.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "paper-chart.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
52+
53+
{{/*
54+
Create the name of the service account to use
55+
*/}}
56+
{{- define "paper-chart.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "paper-chart.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}

paper-chart/templates/deployment.yaml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "paper-chart.fullname" . }}
5+
labels:
6+
{{- include "paper-chart.labels" . | nindent 4 }}
7+
spec:
8+
replicas: {{ .Values.replicaCount }}
9+
selector:
10+
matchLabels:
11+
{{- include "paper-chart.selectorLabels" . | nindent 6 }}
12+
template:
13+
metadata:
14+
{{- with .Values.podAnnotations }}
15+
annotations:
16+
{{- toYaml . | nindent 8 }}
17+
{{- end }}
18+
labels:
19+
{{- include "paper-chart.labels" . | nindent 8 }}
20+
{{- with .Values.podLabels }}
21+
{{- toYaml . | nindent 8 }}
22+
{{- end }}
23+
spec:
24+
{{- with .Values.imagePullSecrets }}
25+
imagePullSecrets:
26+
{{- toYaml . | nindent 8 }}
27+
{{- end }}
28+
serviceAccountName: {{ include "paper-chart.serviceAccountName" . }}
29+
securityContext:
30+
{{- toYaml .Values.podSecurityContext | nindent 8 }}
31+
containers:
32+
- name: {{ .Chart.Name }}
33+
securityContext:
34+
{{- toYaml .Values.securityContext | nindent 12 }}
35+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
36+
imagePullPolicy: {{ .Values.image.pullPolicy }}
37+
ports:
38+
- name: http
39+
containerPort: {{ .Values.service.port }}
40+
protocol: TCP
41+
livenessProbe:
42+
{{- toYaml .Values.livenessProbe | nindent 12 }}
43+
readinessProbe:
44+
{{- toYaml .Values.readinessProbe | nindent 12 }}
45+
resources:
46+
{{- toYaml .Values.resources | nindent 12 }}

paper-chart/templates/service.yaml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: {{ include "paper-chart.fullname" . }}
5+
labels:
6+
{{- include "paper-chart.labels" . | nindent 4 }}
7+
spec:
8+
type: {{ .Values.service.type }}
9+
ports:
10+
- port: {{ .Values.service.port }}
11+
targetPort: {{ .Values.service.port }}
12+
nodePort: {{ .Values.service.nodePort }}
13+
protocol: TCP
14+
selector:
15+
{{- include "paper-chart.selectorLabels" . | nindent 4 }}
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{{- if .Values.serviceAccount.create -}}
2+
apiVersion: v1
3+
kind: ServiceAccount
4+
metadata:
5+
name: {{ include "paper-chart.serviceAccountName" . }}
6+
labels:
7+
{{- include "paper-chart.labels" . | nindent 4 }}
8+
{{- with .Values.serviceAccount.annotations }}
9+
annotations:
10+
{{- toYaml . | nindent 4 }}
11+
{{- end }}
12+
automountServiceAccountToken: {{ .Values.serviceAccount.automount }}
13+
{{- end }}

paper-chart/values.yaml

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
replicaCount: 1
2+
3+
image:
4+
repository: paper.webhop.me/paper-service
5+
# This sets the pull policy for images.
6+
pullPolicy: IfNotPresent
7+
# Overrides the image tag whose default is the chart appVersion.
8+
tag: "latest"
9+
10+
service:
11+
type: NodePort
12+
port: 8080
13+
nodePort: 30080
14+
15+
# This is for the secretes for pulling an image from a private repository more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
16+
imagePullSecrets: []
17+
# This is to override the chart name.
18+
nameOverride: ""
19+
fullnameOverride: ""
20+
21+
#This section builds out the service account more information can be found here: https://kubernetes.io/docs/concepts/security/service-accounts/
22+
serviceAccount:
23+
# Specifies whether a service account should be created
24+
create: true
25+
# Automatically mount a ServiceAccount's API credentials?
26+
automount: true
27+
# Annotations to add to the service account
28+
annotations: {}
29+
# The name of the service account to use.
30+
# If not set and create is true, a name is generated using the fullname template
31+
name: ""
32+
33+
# This is for setting Kubernetes Annotations to a Pod.
34+
# For more information checkout: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/
35+
podAnnotations: {}
36+
# This is for setting Kubernetes Labels to a Pod.
37+
# For more information checkout: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/
38+
podLabels: {}
39+
40+
podSecurityContext: {}
41+
# fsGroup: 2000
42+
43+
securityContext: {}
44+
# capabilities:
45+
# drop:
46+
# - ALL
47+
# readOnlyRootFilesystem: true
48+
# runAsNonRoot: true
49+
# runAsUser: 1000
50+
51+
# This block is for setting up the ingress for more information can be found here: https://kubernetes.io/docs/concepts/services-networking/ingress/
52+
ingress:
53+
enabled: false
54+
className: ""
55+
annotations: {}
56+
# kubernetes.io/ingress.class: nginx
57+
# kubernetes.io/tls-acme: "true"
58+
hosts:
59+
- host: chart-example.local
60+
paths:
61+
- path: /
62+
pathType: ImplementationSpecific
63+
tls: []
64+
65+
resources: {}
66+
67+
livenessProbe:
68+
httpGet:
69+
path: /
70+
port: http
71+
readinessProbe:
72+
httpGet:
73+
path: /
74+
port: http

registry/Dockerfile

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM bellsoft/liberica-openjdk-alpine-musl:22-37-aarch64 AS builder
2+
FROM jenkins/inbound-agent:latest-alpine-jdk21
3+
4+
USER root
5+
6+
RUN apk update
7+
RUN apk add docker helm
8+
9+
COPY --from=builder /usr/lib/jvm/jdk-22-bellsoft-aarch64 /usr/lib/jvm/jdk-22-bellsoft-aarch64
10+
ENV JAVA_HOME=/usr/lib/jvm/jdk-22-bellsoft-aarch64
11+
12+
USER jenkins
13+
14+
ENTRYPOINT ["/usr/local/bin/jenkins-agent"]

registry/deployment.yaml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: docker-registry
5+
spec:
6+
replicas: 1
7+
selector:
8+
matchLabels:
9+
app: docker-registry
10+
template:
11+
metadata:
12+
labels:
13+
app: docker-registry
14+
spec:
15+
containers:
16+
- name: docker-registry
17+
image: registry:2
18+
imagePullPolicy: "IfNotPresent"
19+
ports:
20+
- containerPort: 5000

0 commit comments

Comments
 (0)