diff --git a/charts/goircd/.helmignore b/charts/goircd/.helmignore new file mode 100644 index 0000000..f0c1319 --- /dev/null +++ b/charts/goircd/.helmignore @@ -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 diff --git a/charts/goircd/Chart.yaml b/charts/goircd/Chart.yaml new file mode 100644 index 0000000..0f23601 --- /dev/null +++ b/charts/goircd/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: minimalistic simple Internet Relay Chat (IRC) server +name: goircd +version: 0.1.0 diff --git a/charts/goircd/templates/NOTES.txt b/charts/goircd/templates/NOTES.txt new file mode 100644 index 0000000..777e140 --- /dev/null +++ b/charts/goircd/templates/NOTES.txt @@ -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 {{ template "goircd.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 {{ template "goircd.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "goircd.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={{ template "goircd.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit irc://127.0.0.1:6667 to use your application" + kubectl port-forward $POD_NAME 6667:6667 +{{- end }} diff --git a/charts/goircd/templates/_helpers.tpl b/charts/goircd/templates/_helpers.tpl new file mode 100644 index 0000000..0802273 --- /dev/null +++ b/charts/goircd/templates/_helpers.tpl @@ -0,0 +1,32 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "goircd.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 "goircd.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 "goircd.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/charts/goircd/templates/configmap.yaml b/charts/goircd/templates/configmap.yaml new file mode 100644 index 0000000..f27edf1 --- /dev/null +++ b/charts/goircd/templates/configmap.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ template "goircd.fullname" . }} +data: + BIND: ":{{ .Values.service.internalPort }}" + HEALTHCHECK: {{ .Values.config.healthcheck | quote }} + HOSTNAME: {{ .Values.config.hostname | quote }} + METRICS: {{ .Values.config.metrics | quote }} + MOTD: | + {{ .Values.config.motd }} \ No newline at end of file diff --git a/charts/goircd/templates/deployment.yaml b/charts/goircd/templates/deployment.yaml new file mode 100644 index 0000000..2ea3ace --- /dev/null +++ b/charts/goircd/templates/deployment.yaml @@ -0,0 +1,67 @@ +apiVersion: apps/v1beta2 +kind: Deployment +metadata: + name: {{ template "goircd.fullname" . }} + labels: + app: {{ template "goircd.name" . }} + chart: {{ template "goircd.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: {{ template "goircd.name" . }} + release: {{ .Release.Name }} + template: + metadata: + labels: + app: {{ template "goircd.name" . }} + release: {{ .Release.Name }} + spec: + volumes: + - name: config + configMap: + name: {{ template "goircd.fullname" . }} + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + args: + - -motd + - /config/MOTD + envFrom: + - configMapRef: + name: {{ template "goircd.fullname" . }} + volumeMounts: + - name: config + mountPath: /config + ports: + - name: irc + containerPort: {{ .Values.service.internalPort }} + protocol: TCP + - name: health + containerPort: {{ .Values.image.healthcheckPort }} + protocol: TCP + livenessProbe: + httpGet: + path: /live + port: health + readinessProbe: + httpGet: + path: /ready + port: health + 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 }} diff --git a/charts/goircd/templates/service.yaml b/charts/goircd/templates/service.yaml new file mode 100644 index 0000000..2446307 --- /dev/null +++ b/charts/goircd/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "goircd.fullname" . }} + labels: + app: {{ template "goircd.name" . }} + chart: {{ template "goircd.chart" . }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.externalPort }} + targetPort: irc + protocol: TCP + name: irc + selector: + app: {{ template "goircd.name" . }} + release: {{ .Release.Name }} diff --git a/charts/goircd/values.yaml b/charts/goircd/values.yaml new file mode 100644 index 0000000..bd03db2 --- /dev/null +++ b/charts/goircd/values.yaml @@ -0,0 +1,37 @@ +# Default values for goircd. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +config: + healthcheck: true + hostname: irc.example.com + metrics: true + motd: | + Hello kubernetes with helm + +image: + repository: quay.io/goircd/goircd + tag: latest + pullPolicy: IfNotPresent + healthcheckPort: 8086 + +service: + type: ClusterIP + internalPort: 6667 + externalPort: 6967 + +resources: + limits: + cpu: 10m + memory: 20Mi + requests: + cpu: 10m + memory: 20Mi + +nodeSelector: {} + +tolerations: [] + +affinity: {}