Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: iamhansko helm chart #56

Merged
merged 5 commits into from
Jul 29, 2024
Merged
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
11 changes: 11 additions & 0 deletions iamhansko/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM golang:1.20 AS builder

WORKDIR /app

COPY main.go ./

RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o app main.go

EXPOSE 8080

CMD ["./app"]
6 changes: 6 additions & 0 deletions iamhansko/charts/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
name: iamhansko
description: Helm chart for iamhansko
type: application
version: 0.1.0
appVersion: "1.0.0"
15 changes: 15 additions & 0 deletions iamhansko/charts/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{- define "iamhansko.name" -}}
{{- .Chart.Name | lower -}}
{{- end }}

{{- define "iamhansko.fullname" -}}
{{- .Release.Name | lower }}-{{ .Chart.Name | lower }}
{{- end }}

{{- define "iamhansko.labels" -}}
app.kubernetes.io/name: {{ include "iamhansko.name" . }}
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/version: {{ .Chart.AppVersion }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
36 changes: 36 additions & 0 deletions iamhansko/charts/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "iamhansko.fullname" . }}
labels:
{{- include "iamhansko.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicas }}
selector:
matchLabels:
app: {{ include "iamhansko.name" . }}
release: {{ .Release.Name }}
template:
metadata:
labels:
app: {{ include "iamhansko.name" . }}
release: {{ .Release.Name }}
spec:
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.name }}"
imagePullPolicy: IfNotPresent
ports:
- containerPort: {{ .Values.service.targetPort }}
livenessProbe:
httpGet:
path: /healthcheck
port: {{ .Values.service.targetPort }}
initialDelaySeconds: 3
periodSeconds: 3
readinessProbe:
httpGet:
path: /healthcheck
port: {{ .Values.service.targetPort }}
initialDelaySeconds: 3
periodSeconds: 3
16 changes: 16 additions & 0 deletions iamhansko/charts/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "iamhansko.fullname" . }}
labels:
{{- include "iamhansko.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- targetPort: {{ .Values.service.targetPort }}
nodePort: {{ .Values.service.nodePort }}
port: 80
protocol: TCP
selector:
app: {{ include "iamhansko.name" . }}
release: {{ .Release.Name }}
9 changes: 9 additions & 0 deletions iamhansko/charts/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
replicas: 1

image:
name: sce06147/iamhansko:latest

service:
type: NodePort
nodePort: 30080
targetPort: 8080
20 changes: 20 additions & 0 deletions iamhansko/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package main

import (
"fmt"
"net/http"
)

func healthcheck(w http.ResponseWriter, req *http.Request) {
fmt.Fprint(w, "ok")
}

func iamhansko(w http.ResponseWriter, req *http.Request) {
fmt.Fprint(w, "iamhansko")
}

func main() {
http.HandleFunc("/healthcheck", healthcheck)
http.HandleFunc("/api/v1/iamhansko", iamhansko)
http.ListenAndServe(":8080", nil)
}