diff --git a/charts/Chart.yaml b/charts/Chart.yaml new file mode 100644 index 0000000..3f72670 --- /dev/null +++ b/charts/Chart.yaml @@ -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" diff --git a/charts/templates/NOTES.txt b/charts/templates/NOTES.txt new file mode 100644 index 0000000..77d4a4f --- /dev/null +++ b/charts/templates/NOTES.txt @@ -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 }} diff --git a/charts/templates/_helpers.tpl b/charts/templates/_helpers.tpl new file mode 100644 index 0000000..a215c1a --- /dev/null +++ b/charts/templates/_helpers.tpl @@ -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 }} diff --git a/charts/templates/deployment.yaml b/charts/templates/deployment.yaml new file mode 100644 index 0000000..baaa589 --- /dev/null +++ b/charts/templates/deployment.yaml @@ -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 }} diff --git a/charts/templates/hpa.yaml b/charts/templates/hpa.yaml new file mode 100644 index 0000000..42c8f4f --- /dev/null +++ b/charts/templates/hpa.yaml @@ -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 }} diff --git a/charts/templates/ingress.yaml b/charts/templates/ingress.yaml new file mode 100644 index 0000000..8c3d082 --- /dev/null +++ b/charts/templates/ingress.yaml @@ -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 -}} diff --git a/charts/templates/service.yaml b/charts/templates/service.yaml new file mode 100644 index 0000000..6b8fbc3 --- /dev/null +++ b/charts/templates/service.yaml @@ -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 }} diff --git a/charts/templates/serviceaccount.yaml b/charts/templates/serviceaccount.yaml new file mode 100644 index 0000000..b34d139 --- /dev/null +++ b/charts/templates/serviceaccount.yaml @@ -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 }} + diff --git a/charts/templates/tests/test-connection.yaml b/charts/templates/tests/test-connection.yaml new file mode 100644 index 0000000..e698784 --- /dev/null +++ b/charts/templates/tests/test-connection.yaml @@ -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 diff --git a/charts/values.yaml b/charts/values.yaml new file mode 100644 index 0000000..d5fbaea --- /dev/null +++ b/charts/values.yaml @@ -0,0 +1,52 @@ +server: + image: + repository: ghcr.io/ptr-geeks/ptrun/server + pullPolicy: IfNotPresent + tag: "" + + nameOverride: "" + fullnameOverride: "" + + serviceAccount: + # Specifies whether a service account should be created + create: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + + service: + type: ClusterIP + port: 80 + + ingress: + enabled: false + hosts: "" + +client: + image: + repository: ghcr.io/ptr-geeks/ptrun/client + pullPolicy: IfNotPresent + tag: "" + + nameOverride: "" + fullnameOverride: "" + + serviceAccount: + # Specifies whether a service account should be created + create: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + + service: + type: ClusterIP + port: 80 + + ingress: + enabled: false + hosts: "" + diff --git a/deploy/charts/ptrun/Chart.yaml b/deploy/charts/ptrun/Chart.yaml new file mode 100644 index 0000000..3f72670 --- /dev/null +++ b/deploy/charts/ptrun/Chart.yaml @@ -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" diff --git a/deploy/charts/ptrun/templates/NOTES.txt b/deploy/charts/ptrun/templates/NOTES.txt new file mode 100644 index 0000000..e69de29 diff --git a/deploy/charts/ptrun/templates/_helpers.tpl b/deploy/charts/ptrun/templates/_helpers.tpl new file mode 100644 index 0000000..a215c1a --- /dev/null +++ b/deploy/charts/ptrun/templates/_helpers.tpl @@ -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 }} diff --git a/deploy/charts/ptrun/templates/deployment.yaml b/deploy/charts/ptrun/templates/deployment.yaml new file mode 100644 index 0000000..baaa589 --- /dev/null +++ b/deploy/charts/ptrun/templates/deployment.yaml @@ -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 }} diff --git a/deploy/charts/ptrun/templates/hpa.yaml b/deploy/charts/ptrun/templates/hpa.yaml new file mode 100644 index 0000000..42c8f4f --- /dev/null +++ b/deploy/charts/ptrun/templates/hpa.yaml @@ -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 }} diff --git a/deploy/charts/ptrun/templates/ingress.yaml b/deploy/charts/ptrun/templates/ingress.yaml new file mode 100644 index 0000000..8c3d082 --- /dev/null +++ b/deploy/charts/ptrun/templates/ingress.yaml @@ -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 -}} diff --git a/deploy/charts/ptrun/templates/service.yaml b/deploy/charts/ptrun/templates/service.yaml new file mode 100644 index 0000000..6b8fbc3 --- /dev/null +++ b/deploy/charts/ptrun/templates/service.yaml @@ -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 }} diff --git a/deploy/charts/ptrun/templates/serviceaccount.yaml b/deploy/charts/ptrun/templates/serviceaccount.yaml new file mode 100644 index 0000000..b34d139 --- /dev/null +++ b/deploy/charts/ptrun/templates/serviceaccount.yaml @@ -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 }} + diff --git a/deploy/charts/ptrun/templates/tests/test-connection.yaml b/deploy/charts/ptrun/templates/tests/test-connection.yaml new file mode 100644 index 0000000..e698784 --- /dev/null +++ b/deploy/charts/ptrun/templates/tests/test-connection.yaml @@ -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 diff --git a/deploy/charts/ptrun/values.yaml b/deploy/charts/ptrun/values.yaml new file mode 100644 index 0000000..d5fbaea --- /dev/null +++ b/deploy/charts/ptrun/values.yaml @@ -0,0 +1,52 @@ +server: + image: + repository: ghcr.io/ptr-geeks/ptrun/server + pullPolicy: IfNotPresent + tag: "" + + nameOverride: "" + fullnameOverride: "" + + serviceAccount: + # Specifies whether a service account should be created + create: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + + service: + type: ClusterIP + port: 80 + + ingress: + enabled: false + hosts: "" + +client: + image: + repository: ghcr.io/ptr-geeks/ptrun/client + pullPolicy: IfNotPresent + tag: "" + + nameOverride: "" + fullnameOverride: "" + + serviceAccount: + # Specifies whether a service account should be created + create: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + + service: + type: ClusterIP + port: 80 + + ingress: + enabled: false + hosts: "" +