Skip to content

Commit

Permalink
first
Browse files Browse the repository at this point in the history
  • Loading branch information
paulczar committed Jan 22, 2019
0 parents commit e693132
Show file tree
Hide file tree
Showing 11 changed files with 378 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
charts/*.tgz
21 changes: 21 additions & 0 deletions .helmignore
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
8 changes: 8 additions & 0 deletions Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
appVersion: "0.0.1"
description: Helm chart for deploying basic spring applications
name: spring
version: 0.0.1
home: https://github.com/paulczar/helm-chart-spring
maintainers:
- name: paulczar
15 changes: 15 additions & 0 deletions templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
1. Get the application URL by running these commands:
{{- if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "spring.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 svc -w {{ include "spring.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "spring.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
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={{ include "spring.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl port-forward $POD_NAME 8080:80
{{- end }}
43 changes: 43 additions & 0 deletions templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "spring.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 "spring.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 "spring.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create the name of the service account to use
*/}}
{{- define "spring.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "spring.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}
65 changes: 65 additions & 0 deletions templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "spring.fullname" . }}
labels:
app: {{ include "spring.name" . }}
chart: {{ include "spring.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: {{ include "spring.name" . }}
release: {{ .Release.Name }}
template:
metadata:
labels:
app: {{ include "spring.name" . }}
release: {{ .Release.Name }}
annotations:
{{ toYaml .Values.annotations | indent 8 }}
spec:
serviceAccountName: {{ template "spring.serviceAccountName" . }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
- name: SPRING_PROFILES_ACTIVE
value: {{ .Values.spring.profile }}
{{- if .Values.spring.trustKubernetesCertificates }}
- name: KUBERNETES_TRUST_CERTIFICATES
value: "true"
{{- end }}
{{- range $key, $value := .Values.extraEnv }}
- name: {{ $key }}
value: {{ $value | quote }}
{{- end }}
ports:
- name: http
containerPort: {{ .Values.containerPort }}
protocol: TCP
{{- if .Values.livenessProbe }}
livenessProbe:
{{ toYaml .Values.livenessProbe | indent 12 }}
{{- end }}
{{- if .Values.readinessProbe }}
readinessProbe:
{{ toYaml .Values.readinessProbe | indent 12 }}
{{- end }}
resources:
{{ toYaml .Values.resources | indent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{ toYaml . | indent 8 }}
{{- end }}
40 changes: 40 additions & 0 deletions templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "spring.fullname" . }}
{{- $httpPort := .Values.service.httpPort }}
apiVersion: extensions/v1
kind: Ingress
metadata:
annotations:
{{- range $key, $value := .Values.ingress.annotations }}
{{ $key }}: {{ $value | quote }}
{{- end }}
labels:
app: {{ template "spring.name" . }}
heritage: "{{ .Release.Service }}"
release: "{{ .Release.Name }}"
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
name: {{ template "spring.fullname" . }}
spec:
rules:
{{- range .Values.ingress.hosts }}
- host: {{ . }}
http:
paths:
{{- if index $.Values.ingress "annotations" }}
{{- if eq (index $.Values.ingress.annotations "kubernetes.io/ingress.class" | default "") "gce" "alb" }}
- path: /*
{{- else }}{{/* Has annotations but ingress class is not "gce" nor "alb" */}}
- path: /
{{- end }}
{{- else}}{{/* Has no annotations */}}
- path: /
{{- end }}
backend:
serviceName: {{ $fullName }}
servicePort: {{ $httpPort }}
{{- end -}}
{{- if .Values.ingress.tls }}
tls:
{{ toYaml .Values.ingress.tls | indent 4 }}
{{- end -}}
{{- end -}}
33 changes: 33 additions & 0 deletions templates/rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{{- if .Values.rbac.create -}}
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
name: {{ template "spring.fullname" . }}
labels:
app: {{ template "spring.name" . }}
chart: {{ template "spring.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
rules:
- apiGroups: [""]
resources: ["services", "pods", "endpoints", "configmaps"]
verbs: ["get","list"]
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: {{ template "spring.fullname" . }}
labels:
app: {{ template "spring.name" . }}
chart: {{ template "spring.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ template "spring.fullname" . }}
subjects:
- name: {{ template "spring.serviceAccountName" . }}
namespace: {{ .Release.Namespace | quote }}
kind: ServiceAccount
{{- end -}}
25 changes: 25 additions & 0 deletions templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: v1
kind: Service
metadata:
name: {{ template "spring.fullname" . }}
annotations:
{{- range $key, $value := .Values.service.annotations }}
{{ $key }}: {{ $value | quote }}
{{- end }}
labels:
app: {{ template "spring.name" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
spec:
type: {{ .Values.service.type }}
ports:
- name: http
port: {{ .Values.service.httpPort }}
targetPort: http
{{- if hasKey .Values.service "nodePort" }}
nodePort: {{ .Values.service.nodePort }}
{{- end }}
selector:
app: {{ template "spring.name" . }}
release: {{ .Release.Name | quote }}
12 changes: 12 additions & 0 deletions templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ template "spring.serviceAccountName" . }}
namespace: {{ .Release.Namespace | quote }}
labels:
app: {{ template "spring.name" . }}
chart: {{ template "spring.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- end -}}
115 changes: 115 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# Default values for discovery-service.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

replicaCount: 1

image:
repository: paulczar/petclinic
tag: 2.1.0.BUILD-SNAPSHOT
pullPolicy: Always

nameOverride: ""
fullnameOverride: ""

serviceAccount:
create: true
# name: ~

rbac:
create: true

annotations: {}
# prometheus.io/scrape: "true"
# prometheus.io/path: "/actuator/prometheus"

spring:
profile: dev
trustKubernetesCertificates: true

## The list of ports that your app listens on
containerPort: 8080

extraEnv:
## Extra environment variables to be injected
# DATABASE_ENGINE: mysql
# DATABASE_HOST: mysql
# DATABASE_NAME: spring
# DATABASE_USERNAME: spring
# DATABASE_PASSWORD: spring

resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi

## uncomment and modify the following livenessProbe and readinessProbe.
## These defaults should work with anything that uses the spring health actuator.
livenessProbe: {}
# httpGet:
# path: /actuator/health
# port: http
# initialDelaySeconds: 300
# periodSeconds: 10
readinessProbe: {}
# httpGet:
# path: /actuator/health
# port: http
# initialDelaySeconds: 60
# periodSeconds: 10

nodeSelector: {}

tolerations: []

affinity: {}

service:
httpPort: 80
## If service.type is not set to NodePort, the following statement
## will be ignored.
##
# nodePort: 32015

## Service type can be set to ClusterIP, NodePort or LoadBalancer.
##
type: ClusterIP

## Service annotations
##
# annotations:
# service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http
# service.beta.kubernetes.io/aws-load-balancer-ssl-cert: arn:aws:acm:xx-xxxx-x:xxxxxxxxxxx:certificate/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx
# external-dns.alpha.kubernetes.io/hostname: drone.domain.tld.

ingress:
## If true, Ingress will be created.
##
enabled: false

## Ingress annotations
##
# annotations:
# kubernetes.io/ingress.class: gce
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: 'true'

## hostnames must be provided if Ingress is enabled
##
# hosts:
# - spring.example.io

## Ingress TLS configuration secrets
## Must be manually created in the namespace
##
# tls:
# - secretName: spring-tls
# hosts:
# - spring.example.io

0 comments on commit e693132

Please sign in to comment.