Skip to content

Commit

Permalink
feat: iamhansko helm chart (#56)
Browse files Browse the repository at this point in the history
Signed-off-by: iamhansko <iamhansko@kakao.com>
  • Loading branch information
iamhansko authored Jul 29, 2024
1 parent 6dd79dd commit 87252c2
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 0 deletions.
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)
}

0 comments on commit 87252c2

Please sign in to comment.