Skip to content

Commit

Permalink
Merge pull request #7 from timurgaleev/psql
Browse files Browse the repository at this point in the history
Postgres and bug fix
  • Loading branch information
timurgaleev authored Oct 5, 2020
2 parents d3ee26b + 41bf771 commit 17d8e66
Show file tree
Hide file tree
Showing 25 changed files with 199 additions and 79 deletions.
6 changes: 3 additions & 3 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
def SERVICE_GROUP = "sample"
def SERVICE_GROUP = "demo"
def SERVICE_NAME = "spring"
def IMAGE_NAME = "${SERVICE_GROUP}-${SERVICE_NAME}"
def REPOSITORY_URL = "https://github.com/timurgaleev/sample-spring"
def REPOSITORY_URL = "https://github.com/timurgaleev/demo-spring"
def REPOSITORY_SECRET = ""
def SLACK_TOKEN_DEV = ""
def SLACK_TOKEN_DQA = ""
Expand Down Expand Up @@ -104,7 +104,7 @@ podTemplate(label: label, containers: [
container("builder") {
try {
// deploy(cluster, namespace, sub_domain, profile, values_path)
builder.deploy("local", "${SERVICE_GROUP}", "${IMAGE_NAME}-sample", "dev")
builder.deploy("local", "${SERVICE_GROUP}", "${IMAGE_NAME}-demo", "dev")
// builder.success(SLACK_TOKEN_DEV, "Deploy LOCAL")
} catch (e) {
// builder.failure(SLACK_TOKEN_DEV, "Deploy LOCAL")
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# sample-spring
# demo-spring

[![GitHub release](https://img.shields.io/github/release/timurgaleev/sample-spring.svg)](https://github.com/timurgaleev/sample-spring/releases)
[![GitHub release](https://img.shields.io/github/release/timurgaleev/demo-spring.svg)](https://github.com/timurgaleev/demo-spring/releases)

[![DockerHub Badge](http://dockeri.co/image/timurgaleev/sample-spring)](https://hub.docker.com/r/timurgaleev/sample-spring)
[![DockerHub Badge](http://dockeri.co/image/timurgaleev/demo-spring)](https://hub.docker.com/r/timurgaleev/demo-spring)

## Docker

```bash
docker pull timurgaleev/sample-spring
docker pull timurgaleev/demo-spring
```
2 changes: 1 addition & 1 deletion charts/sample-spring/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: v2
name: sample-spring
name: demo-spring
description: A Helm chart for Kubernetes
icon: https://avatars0.githubusercontent.com/u/39108256
appVersion: v0.1.0
Expand Down
8 changes: 4 additions & 4 deletions charts/sample-spring/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "sample.fullname" . }})
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "demo.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "sample.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "sample.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "demo.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "demo.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "sample.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "demo.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80
{{- end }}
20 changes: 10 additions & 10 deletions charts/sample-spring/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "sample.name" -}}
{{- define "demo.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

Expand All @@ -11,7 +11,7 @@ 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 "sample.fullname" -}}
{{- define "demo.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
Expand All @@ -27,16 +27,16 @@ If release name contains chart name it will be used as a full name.
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "sample.chart" -}}
{{- define "demo.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "sample.labels" -}}
helm.sh/chart: {{ include "sample.chart" . }}
{{ include "sample.selectorLabels" . }}
{{- define "demo.labels" -}}
helm.sh/chart: {{ include "demo.chart" . }}
{{ include "demo.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
Expand All @@ -46,17 +46,17 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}
{{/*
Selector labels
*/}}
{{- define "sample.selectorLabels" -}}
app.kubernetes.io/name: {{ include "sample.name" . }}
{{- define "demo.selectorLabels" -}}
app.kubernetes.io/name: {{ include "demo.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "sample.serviceAccountName" -}}
{{- define "demo.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "sample.fullname" .) .Values.serviceAccount.name }}
{{- default (include "demo.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
Expand Down
4 changes: 2 additions & 2 deletions charts/sample-spring/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "sample.fullname" . }}
name: {{ include "demo.fullname" . }}
labels:
{{- include "sample.labels" . | nindent 4 }}
{{- include "demo.labels" . | nindent 4 }}
data:
{{- with .Values.configmap.data }}
{{ toYaml . | indent 2 }}
Expand Down
14 changes: 7 additions & 7 deletions charts/sample-spring/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "sample.fullname" . }}
name: {{ include "demo.fullname" . }}
labels:
{{- include "sample.labels" . | nindent 4 }}
{{- include "demo.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "sample.selectorLabels" . | nindent 6 }}
{{- include "demo.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "sample.selectorLabels" . | nindent 8 }}
{{- include "demo.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "sample.serviceAccountName" . }}
serviceAccountName: {{ include "demo.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
Expand Down Expand Up @@ -82,11 +82,11 @@ spec:
{{ end }}
{{ if .Values.configmap.enabled }}
- configMapRef:
name: {{ include "sample.fullname" . }}
name: {{ include "demo.fullname" . }}
{{ end }}
{{ if .Values.secret.enabled }}
- secretRef:
name: {{ include "sample.fullname" . }}
name: {{ include "demo.fullname" . }}
{{ end }}
{{- with .Values.nodeSelector }}
nodeSelector:
Expand Down
6 changes: 3 additions & 3 deletions charts/sample-spring/templates/hpa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "sample.fullname" . }}
name: {{ include "demo.fullname" . }}
labels:
{{- include "sample.labels" . | nindent 4 }}
{{- include "demo.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "sample.fullname" . }}
name: {{ include "demo.fullname" . }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
Expand Down
4 changes: 2 additions & 2 deletions charts/sample-spring/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "sample.fullname" . -}}
{{- $fullName := include "demo.fullname" . -}}
{{- $servicePort := .Values.service.port -}}
{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
Expand All @@ -10,7 +10,7 @@ kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "sample.labels" . | nindent 4 }}
{{- include "demo.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
Expand Down
4 changes: 2 additions & 2 deletions charts/sample-spring/templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ include "sample.fullname" . }}
name: {{ include "demo.fullname" . }}
labels:
{{- include "sample.labels" . | nindent 4 }}
{{- include "demo.labels" . | nindent 4 }}
type: Opaque
data:
{{- with .Values.secret.data }}
Expand Down
6 changes: 3 additions & 3 deletions charts/sample-spring/templates/service-monitor.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "sample.fullname" . }}
name: {{ include "demo.fullname" . }}
labels:
release: prometheus-operator
{{- include "sample.labels" . | nindent 4 }}
{{- include "demo.labels" . | nindent 4 }}
spec:
selector:
matchLabels:
app: {{ include "sample.fullname" . }}
app: {{ include "demo.fullname" . }}
endpoints:
- interval: 10s
port: tcp-jmx
6 changes: 3 additions & 3 deletions charts/sample-spring/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "sample.fullname" . }}
name: {{ include "demo.fullname" . }}
labels:
{{- include "sample.labels" . | nindent 4 }}
{{- include "demo.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
Expand All @@ -12,4 +12,4 @@ spec:
protocol: TCP
name: http
selector:
{{- include "sample.selectorLabels" . | nindent 4 }}
{{- include "demo.selectorLabels" . | nindent 4 }}
4 changes: 2 additions & 2 deletions charts/sample-spring/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "sample.serviceAccountName" . }}
name: {{ include "demo.serviceAccountName" . }}
labels:
{{- include "sample.labels" . | nindent 4 }}
{{- include "demo.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
Expand Down
6 changes: 3 additions & 3 deletions charts/sample-spring/templates/tests/test-connection.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
apiVersion: v1
kind: Pod
metadata:
name: "{{ include "sample.fullname" . }}-test-connection"
name: "{{ include "demo.fullname" . }}-test-connection"
labels:
{{- include "sample.labels" . | nindent 4 }}
{{- include "demo.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": test-success
spec:
containers:
- name: wget
image: busybox
command: ['wget']
args: ['{{ include "sample.fullname" . }}:{{ .Values.service.port }}']
args: ['{{ include "demo.fullname" . }}:{{ .Values.service.port }}']
restartPolicy: Never
12 changes: 6 additions & 6 deletions charts/sample-spring/values.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Default values for sample.
# Default values for demo.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

nameOverride: "sample-spring"
fullnameOverride: "sample-spring"
nameOverride: "demo-spring"
fullnameOverride: "demo-spring"

namespace: ""

Expand Down Expand Up @@ -54,13 +54,13 @@ ingress:
subdomain: ""
basedomain: ""
hosts: []
# - host: sample-spring.localhost
# - host: demo-spring.localhost
# paths:
# - /
tls: []
# - secretName: sample-spring-tls
# - secretName: demo-spring-tls
# hosts:
# - sample-spring.localhost
# - demo-spring.localhost

livenessProbe:
httpGet:
Expand Down
44 changes: 44 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
version: '3.3'
services:
postgres:
image: postgres:11.5
container_name: postgres
environment:
- POSTGRES_PASSWORD=postgres
- POSTGRES_USER=postgres
- POSTGRES_DB=postgres
ports:
- "5432:5432"
volumes:
- ./target/postgres/data:/var/lib/postgresql/data

pgadmin:
image: dpage/pgadmin4
container_name: pg_admin
environment:
- [email protected]
- PGADMIN_DEFAULT_PASSWORD=postgres
ports:
- "5555:80"
volumes:
- ./target/pgadmin/data:/var/lib/pgadmin
links:
- postgres

demo-spring:
container_name: demo-spring
depends_on:
- postgres
build:
context: .
links:
- postgres
ports:
- 8080:8080
restart: always
environment:
- DATABASE_ADDRESS=postgres
- DATABASE_PORT=5432
- DATABASE_NAME=postgres
- DATABASE_USERNAME=postgres
- DATABASE_PASSWORD=postgres
Loading

0 comments on commit 17d8e66

Please sign in to comment.