diff --git a/helmchart/.helmignore b/helmchart/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/helmchart/.helmignore @@ -0,0 +1,23 @@ +# 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 +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/helmchart/Chart.yaml b/helmchart/Chart.yaml new file mode 100644 index 0000000..da298ca --- /dev/null +++ b/helmchart/Chart.yaml @@ -0,0 +1,23 @@ +apiVersion: v2 +name: xampp-app +description: A Helm chart for deploying xampp to Kubernetes +icon: https://www.apachefriends.org/images/xampp-logo-ac950edf.svg +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +appVersion: 1.0.1 diff --git a/helmchart/ReadMe.md b/helmchart/ReadMe.md new file mode 100644 index 0000000..5cabe0b --- /dev/null +++ b/helmchart/ReadMe.md @@ -0,0 +1,2 @@ +For Linting Helm Chart Use: +helm lint diff --git a/helmchart/templates/_helpers_xampp.tpl b/helmchart/templates/_helpers_xampp.tpl new file mode 100644 index 0000000..ab32f6a --- /dev/null +++ b/helmchart/templates/_helpers_xampp.tpl @@ -0,0 +1,87 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "xampp.name" -}} +{{- default .Chart.Name .Values.xamppnameOverride | 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 "xampp.fullname" -}} +{{- if .Values.xamppfullnameOverride }} +{{- .Values.xamppfullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.xamppnameOverride }} +{{- 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 "xampp.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "xampp.labels" -}} +helm.sh/chart: {{ include "xampp.chart" . }} +{{ include "xampp.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +app.kubernetes.io/part-of: {{ .Values.projectScope }} +{{- end }} + +{{/* +Additional labels +*/}} +{{- define "xampp.additionalLabels" -}} +{{- if .Values.deployment.additionalLabels }} +{{- range $key, $val := .Values.deployment.additionalLabels }} +{{ $key }}: {{ $val | quote }} +{{- end}} +{{- end }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "xampp.selectorLabels" -}} +app.kubernetes.io/name: {{ include "xampp.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "xampp.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "xampp.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} + +{{/* +Return the appropriate apiVersion for Ingress. +*/}} +{{- define "ingress.apiVersion" -}} +{{- if .Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress" -}} +{{- print "networking.k8s.io/v1" -}} +{{- else if .Capabilities.APIVersions.Has "networking.k8s.io/v1beta1/Ingress" -}} +{{- print "networking.k8s.io/v1beta1" -}} +{{- else -}} +{{- print "extensions/v1beta1" -}} +{{- end -}} +{{- end -}} diff --git a/helmchart/templates/deployment-xampp.yaml b/helmchart/templates/deployment-xampp.yaml new file mode 100644 index 0000000..5946c59 --- /dev/null +++ b/helmchart/templates/deployment-xampp.yaml @@ -0,0 +1,84 @@ +{{- if .Values.xampp.enabled -}} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "xampp.fullname" . }}-{{.Values.environment }}-deploy + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} + labels: + # include Gitlab CI canary label for integration with CI canary deployment + track: canary + {{- include "xampp.labels" . | nindent 4 }} + {{- include "xampp.additionalLabels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.xampp.containers.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "xampp.selectorLabels" . | nindent 6 }} + revisionHistoryLimit: 1 # Default to 10 if not specified + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + # include Gitlab CI canary label for integration with CI canary deployment + track: canary + {{- include "xampp.selectorLabels" . | nindent 8 }} + {{- include "xampp.additionalLabels" . | nindent 8 }} + # include timestamp from the pipeline: + pipeline-deployed: "{{ .Values.xampp.pipelinedeployed }}" + spec: + {{- if ne .Values.xampp.containers.imagePullSecretName "" }} + imagePullSecrets: + - name: regcred-{{.Values.environment }}-sct + {{- end }} + serviceAccountName: {{ include "xampp.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.xampp.containers.image.repository }}:{{ .Values.xampp.containers.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.xampp.containers.image.pullPolicy }} + {{- if ne .Values.xampp.containers.command "" }} + # command: ["dumb-init", "npm", "run", "start:demo"] + command: ["/bin/sh", "-c", {{ .Values.xampp.containers.command | quote }}] + {{- end }} + ports: + - name: http + containerPort: {{ .Values.xampp.containers.containerPort }} + protocol: TCP + livenessProbe: + httpGet: + path: / + port: http + initialDelaySeconds: 90 + periodSeconds: 120 + readinessProbe: + httpGet: + path: / + port: http + initialDelaySeconds: 90 + periodSeconds: 120 + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} +{{- end }} diff --git a/helmchart/templates/ingress-xampp.yaml b/helmchart/templates/ingress-xampp.yaml new file mode 100644 index 0000000..8b86682 --- /dev/null +++ b/helmchart/templates/ingress-xampp.yaml @@ -0,0 +1,27 @@ +{{- if .Values.xampp.enabled -}} +{{- if .Values.xampp.ingress.enabled -}} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: xampp-{{.Values.environment }}-ing + annotations: + meta.helm.sh/release-name: traefik + meta.helm.sh/release-namespace: kube-system + labels: + app.kubernetes.io/instance: traefik-kube-system + app.kubernetes.io/name: traefik +spec: + rules: + - host: "{{.Values.xampp.ingress.host }}" + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: {{ include "xampp.fullname" . }}-{{.Values.environment }}-svc + port: + number: 80 + +{{- end }} +{{- end }} diff --git a/helmchart/templates/service-xampp.yaml b/helmchart/templates/service-xampp.yaml new file mode 100644 index 0000000..d709347 --- /dev/null +++ b/helmchart/templates/service-xampp.yaml @@ -0,0 +1,49 @@ +{{- if .Values.xampp.enabled -}} + {{- if .Values.xampp.service.create -}} +apiVersion: v1 +kind: Service +metadata: + name: {{ include "xampp.fullname" . }}-{{.Values.environment }}-svc + labels: + {{- include "xampp.labels" . | nindent 4 }} + {{- include "xampp.additionalLabels" . | nindent 4 }} +spec: + type: {{ .Values.xampp.service.type }} + ports: + + - name: phpmyadmin + protocol: TCP + port: {{ .Values.xampp.service.serviceApplicationPort }} + targetPort: 80 + {{- if eq "NodePort" .Values.xampp.service.type }} + nodePort: {{ .Values.xampp.service.serviceApplicationnodePort }} + {{- end }} + + - name: sftp + protocol: TCP + port: {{ .Values.xampp.service.serviceSFTPPort }} + targetPort: 22 + {{- if eq "NodePort" .Values.xampp.service.type }} + nodePort: {{ .Values.xampp.service.serviceSFTPnodePort }} + {{- end }} + + - name: ftp + protocol: TCP + port: {{ .Values.xampp.service.serviceFTPPort }} + targetPort: 21 + {{- if eq "NodePort" .Values.xampp.service.type }} + nodePort: {{ .Values.xampp.service.serviceFTPnodePort }} + {{- end }} + + - name: mysql + protocol: TCP + port: {{ .Values.xampp.service.serviceMySQLPort }} + targetPort: 3306 + {{- if eq "NodePort" .Values.xampp.service.type }} + nodePort: {{ .Values.xampp.service.serviceMySQLnodePort }} + {{- end }} + + selector: + {{- include "xampp.selectorLabels" . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/helmchart/values.yaml b/helmchart/values.yaml new file mode 100644 index 0000000..46c3d70 --- /dev/null +++ b/helmchart/values.yaml @@ -0,0 +1,96 @@ +# ############################################################################## +# Xampp Helm Chart created by Fedir Indutnyi (Draft) +# ############################################################################## +# Default values for Xampp. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +xamppnameOverride: xampp +xamppfullnameOverride: xampp +projectScope: xampp + +environment: dev + +xampp: + enabled: true + containers: + replicaCount: 1 + containerPort: 80 + image: + repository: 'tomsik68/xampp' + pullPolicy: Always + tag: "8" + command: "" + imagePullSecretName: "" + pipelinedeployed: "" + # If service.type eq NodePort then specify static service.nodePort + service: + create: true + type: ClusterIP + serviceApplicationPort: 80 + serviceApplicationnodePort: 31062 + serviceSFTPPort: 22 + serviceSFTPnodePort: 31060 + serviceFTPPort: 21 + serviceSTPnodePort: 31061 + serviceMySQLPort: 3306 + serviceMySQLnodePort: 31063 + ingress: + enabled: false + host: "example.local" + + + + +deployment: + additionalLabels: + owner: xampp + +serviceAccount: + # Specifies whether a service account should be created + create: false + # 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: "" + +podAnnotations: + # include Gitlab CI annotations for integration with CI deployment + + +podSecurityContext: {} +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + + + +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 + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 3 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +nodeSelector: {} + +tolerations: [] + +affinity: {}