Skip to content

Commit

Permalink
Initial
Browse files Browse the repository at this point in the history
  • Loading branch information
kostyaplis committed Apr 26, 2020
1 parent af851ca commit e997c61
Show file tree
Hide file tree
Showing 6 changed files with 237 additions and 0 deletions.
22 changes: 22 additions & 0 deletions charts/basic/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 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
.vscode/
5 changes: 5 additions & 0 deletions charts/basic/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: v1
appVersion: "1.0"
description: A Helm chart for Kubernetes
name: basic
version: 0.0.1
15 changes: 15 additions & 0 deletions charts/basic/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 "basic.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 "basic.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "basic.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.kubernetes.io/name={{ include "basic.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 port-forward $POD_NAME 8080:80
{{- end }}
32 changes: 32 additions & 0 deletions charts/basic/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "basic.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 "basic.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 "basic.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
97 changes: 97 additions & 0 deletions charts/basic/templates/cronjob.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
{{- range .Values.cronjobs }}
---
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: {{ include "basic.fullname" $ }}-{{ .name }}
labels:
app.kubernetes.io/name: {{ include "basic.name" $ }}-{{ .name }}
helm.sh/chart: {{ include "basic.chart" $ }}
app.kubernetes.io/instance: {{ $.Release.Name }}
app.kubernetes.io/managed-by: {{ $.Release.Service }}
spec:
schedule: {{ .schedule | quote }}
startingDeadlineSeconds: 100
concurrencyPolicy: {{ .concurrencyPolicy | default "Forbid" }}
failedJobsHistoryLimit: {{ .failedJobsHistoryLimit | default "1" }}
successfulJobsHistoryLimit: {{ .successfulJobsHistoryLimit | default "3" }}
jobTemplate:
spec:
template:
metadata:
annotations:
sidecar.istio.io/inject: "false"
{{- with $.Values.podAnnotations }}
{{- toYaml . | trim | nindent 12 }}
{{- end }}
spec:
containers:
- name: {{ include "basic.name" $ }}-{{ .name }}
image: "{{ $.Values.image.repository }}:{{ $.Values.image.tag }}"
imagePullPolicy: {{ $.Values.image.pullPolicy }}
command:
{{- toYaml .command | trim | nindent 16 }}
{{- if or ($.Values.app.env) (.env) }}
env:
- name: PROMETHEUS_EXPORTER_REQUEST_STATS
value: "false"
- name: PROMETHEUS_EXPORTER_PROCESS_STATS
value: "false"
{{- range $name, $value := $.Values.app.env }}
- name: {{ $name | quote }}
value: {{ $value | quote }}
{{- end }}
{{- range $name, $value := .env }}
- name: {{ $name | quote }}
value: {{ $value | quote }}
{{- end }}
{{- end }}
{{- if or ($.Values.app.envFromSecrets) ($.Values.app.envFromConfigMaps) }}
envFrom:
{{- range $.Values.app.envFromConfigMaps }}
- configMapRef:
name: {{ . | quote }}
{{- end }}
{{- range $.Values.app.envFromSecrets }}
- secretRef:
name: {{ . | quote }}
{{- end }}
{{- end }}
volumeMounts:
{{- if $.Values.app.settingsYmlSecret.enabled }}
- mountPath: {{ $.Values.app.home }}/config/{{ $.Values.app.settingsYmlSecret.key }}
name: settings-yml-volume
subPath: {{ $.Values.app.settingsYmlSecret.key }}
{{- end }}
{{- with .resources }}
resources:
{{- toYaml . | trim | nindent 16 }}
{{- end }}
restartPolicy: OnFailure
{{- with $.Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | trim | nindent 12}}
{{- end }}
volumes:
{{- if $.Values.app.settingsYmlSecret.enabled }}
- name: settings-yml-volume
secret:
secretName: {{ $.Values.app.settingsYmlSecret.name | quote }}
items:
- key: {{ $.Values.app.settingsYmlSecret.key | quote }}
path: {{ $.Values.app.settingsYmlSecret.key | quote }}
{{- end }}
{{- with $.Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with $.Values.affinity }}
affinity:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with $.Values.tolerations }}
tolerations:
{{- toYaml . | nindent 12 }}
{{- end }}
...
{{- end -}}
66 changes: 66 additions & 0 deletions charts/basic/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Default values for basic.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

replicaCount: 1

image:
repository:
tag: latest
pullPolicy: IfNotPresent

imagePullSecrets: []

# containerPort: 8000
containerCommand: []
containerArgs: []

nameOverride: ""
fullnameOverride: ""

service:
enabled: false
type: ClusterIP
port: 80
annotations: {}

# environment variables, not a list of objects with keys name and value
# but directly an object of key and value
env: {}
# existing k8s secrets for environment varialbes
envFromSecrets: []
# existing k8s configMaps for environment variables
envFromConfigMaps: []

# httpProbePath: /

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

podAnnotations: {}

nodeSelector: {}

tolerations: []

affinity: {}

secretMounts: []
# existing secrets to be mounted into the pod
# - secretName: super-secret
# mountPath: /secrets
configmapMounts: []
# - name: configmap
# mountPath: /config
# subPath: fileneme.yaml # (optional)
# configMap: configmap
# readOnly: true

0 comments on commit e997c61

Please sign in to comment.