Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions charts/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v2
name: ptrun
description: A Helm chart for PTRun group projet

type: application
version: 0.1.0

appVersion: "0.1.0"
22 changes: 22 additions & 0 deletions charts/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
{{- range .paths }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
{{- 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 "ptrun.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 "ptrun.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "ptrun.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 "ptrun.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
{{- end }}
62 changes: 62 additions & 0 deletions charts/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "ptrun.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 "ptrun.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 "ptrun.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "ptrun.labels" -}}
helm.sh/chart: {{ include "ptrun.chart" . }}
{{ include "ptrun.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "ptrun.selectorLabels" -}}
app.kubernetes.io/name: {{ include "ptrun.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "ptrun.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "ptrun.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
124 changes: 124 additions & 0 deletions charts/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "ptrun.fullname" . }}
labels:
{{- include "ptrun.labels" . | nindent 4 }}
spec:
{{- if not .Values.server.autoscaling.enabled }}
replicas: {{ .Values.server.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "ptrun.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.server.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "ptrun.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.server.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "ptrun.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.server.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.server.securityContext | nindent 12 }}
image: "{{ .Values.server.image.repository }}:{{ .Values.server.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.server.image.pullPolicy }}
ports:
- name: http
containerPort: 80
protocol: TCP
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
port: http
resources:
{{- toYaml .Values.server.resources | nindent 12 }}
{{- with .Values.server.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.server.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.server.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}

---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "ptrun.fullname" . }}
labels:
{{- include "ptrun.labels" . | nindent 4 }}
spec:
{{- if not .Values.client.autoscaling.enabled }}
replicas: {{ .Values.client.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "ptrun.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.client.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "ptrun.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.client.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "ptrun.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.client.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.client.securityContext | nindent 12 }}
image: "{{ .Values.client.image.repository }}:{{ .Values.cliet.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.client.image.pullPolicy }}
ports:
- name: http
containerPort: 80
protocol: TCP
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
port: http
resources:
{{- toYaml .Values.client.resources | nindent 12 }}
{{- with .Values.client.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.client.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.client.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
28 changes: 28 additions & 0 deletions charts/templates/hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{{- if .Values.autoscaling.enabled }}
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "ptrun.fullname" . }}
labels:
{{- include "ptrun.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "ptrun.fullname" . }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}
58 changes: 58 additions & 0 deletions charts/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{{- if .Values.server.ingress.enabled -}}
{{- $serviceName := (include "ptrun.fullname" .) -}}
{{- $servicePort := .Values.server.service.port -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ $serviceName }}
labels:
{{- include "ptrun.labels" . | nindent 4 }}
annotations:
cert-manager.io/cluster-issuer: letsencrypt
spec:
rules:
- host: {{ .Values.server.service.ingress.host }}
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
service:
name: {{ $serviceName }}
port:
number: {{ $servicePort }}
tls:
- secretName: ptrun-tls #Vprasaj za secret name
hosts:
- {{ .Values.service.service.ingress.host }}
{{- end -}}

---
{{- if .Values.client.ingress.enabled -}}
{{- $serviceName := (include "ptrun.fullname" .) -}}
{{- $servicePort := .Values.client.service.port -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ $serviceName }}
labels:
{{- include "ptrun.labels" . | nindent 4 }}
annotations:
cert-manager.io/cluster-issuer: letsencrypt
spec:
rules:
- host: {{ .Values.client.service.ingress.host }}
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
service:
name: {{ $serviceName }}
port:
number: {{ $servicePort }}
tls:
- secretName: ptrun-tls #Vprasaj za secret name
hosts:
- {{ .Values.client.service.ingress.host }}
{{- end -}}
32 changes: 32 additions & 0 deletions charts/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "ptrun.fullname" . }}
labels:
{{- include "ptrun.labels" . | nindent 4 }}
spec:
type: {{ .Values.server.service.type }}
ports:
- port: {{ .Values.server.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "ptrun.selectorLabels" . | nindent 4 }}

---
apiVersion: v1
kind: Service
metadata:
name: {{ include "ptrun.fullname" . }}
labels:
{{- include "ptrun.labels" . | nindent 4 }}
spec:
type: {{ .Values.client.service.type }}
ports:
- port: {{ .Values.client.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "ptrun.selectorLabels" . | nindent 4 }}
27 changes: 27 additions & 0 deletions charts/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{{- if .Values.server.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "ptrun.serviceAccountName" . }}
labels:
{{- include "ptrun.labels" . | nindent 4 }}
{{- with .Values.server.serviceAccount.annotatios }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}

---
{{- if .Values.client.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "ptrun.serviceAccountName" . }}
labels:
{{- include "ptrun.labels" . | nindent 4 }}
{{- with .Values.client.serviceAccount.annotatios }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}

15 changes: 15 additions & 0 deletions charts/templates/tests/test-connection.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Pod
metadata:
name: "{{ include "ptrun.fullname" . }}-test-connection"
labels:
{{- include "ptrun.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": test
spec:
containers:
- name: wget
image: busybox
command: ['wget']
args: ['{{ include "ptrun.fullname" . }}:{{ .Values.service.port }}']
restartPolicy: Never
Loading