Skip to content

Commit

Permalink
refactor chart, so each container will be treated as one pod
Browse files Browse the repository at this point in the history
  • Loading branch information
kahnwong committed Apr 13, 2024
1 parent 8510a65 commit 1e07f6b
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 123 deletions.
2 changes: 1 addition & 1 deletion kubernetes/charts/base/chart/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ name: base
description: A Helm chart for Kubernetes

type: application
version: 0.1.0
version: 0.2.0
Empty file.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: apps/v1
kind: Deployment
kind: {{ .Values.kind }} # Deployment or StatefulSet
metadata:
name: {{ template "name" . }}
labels:
Expand All @@ -18,11 +18,11 @@ spec:
app.kubernetes.io/instance: {{ template "name" . }}
app.kubernetes.io/name: {{ template "name" . }}
spec:
{{ if .Values.deployments.initContainers }}
{{ if .Values.initContainers }}
initContainers: {{ toYaml .Values.deployments.initContainers | default list | nindent 8 }}
{{ end }}
containers:
{{ range .Values.deployments.containers }}
{{ range .Values.containers }}
- name: {{ .name }}
image: "{{ .repository }}:{{ .tag }}"
{{ if .command }}
Expand All @@ -40,10 +40,15 @@ spec:
{{ end }}
{{ if not (eq .healthcheck false)}}
livenessProbe:
{{ if not (eq .scheme "tcp")}}
httpGet:
path: {{ .livenessProbePath | default "/" }}
port: {{ .port }}
scheme: HTTP
{{ else }}
tcpSocket:
port: {{ .port }}
{{ end }}
{{ end }}
securityContext: {{ toYaml .securityContext | default list | nindent 14 }}
args: {{ .args | default list | toYaml | nindent 14 }}
Expand All @@ -53,4 +58,4 @@ spec:
volumeMounts: {{ toYaml .volumeMounts | default list | nindent 14 }}
{{ end }}
imagePullSecrets: {{ toYaml .Values.imagePullSecrets | default list | nindent 8 }}
volumes: {{ toYaml .Values.deployments.volumes | default list | nindent 8 }}
volumes: {{ toYaml .Values.volumes | default list | nindent 8 }}
20 changes: 0 additions & 20 deletions kubernetes/charts/base/chart/templates/deployment-service.yaml

This file was deleted.

8 changes: 4 additions & 4 deletions kubernetes/charts/base/chart/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
{{ if .Values.deployments.ingress }}
{{ if .Values.ingress }}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
Expand All @@ -11,10 +11,10 @@ spec:
ingressClassName: nginx
tls:
- hosts:
- {{ .Values.deployments.ingress.host }}
- {{ .Values.ingress.host }}
secretName: {{ template "name" . }}-tls
rules:
- host: {{ .Values.deployments.ingress.host }}
- host: {{ .Values.ingress.host }}
http:
paths:
- path: /
Expand All @@ -23,5 +23,5 @@ spec:
service:
name: {{ template "name" . }}
port:
number: {{ .Values.deployments.service.port }}
number: {{ .Values.service.port }}
{{ end }}
22 changes: 22 additions & 0 deletions kubernetes/charts/base/chart/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
apiVersion: v1
kind: Service
metadata:
name: {{ template "name" . }}
spec:
{{ if (eq .Values.kind "Deployment")}}
type: NodePort
{{ end }}
selector:
app.kubernetes.io/name: {{ template "name" . }}
{{ if .Values.service.port }}
ports:
- port: {{ .Values.service.port }}
targetPort: {{ .Values.service.port }}
{{ if .Values.service.nodePort }}
nodePort: {{ .Values.service.nodePort }}
{{ end }}
{{ end }}
{{ if .Values.service.ports }}
ports: {{ .Values.service.ports | default list | toYaml | nindent 4 }}
{{ end }}
19 changes: 0 additions & 19 deletions kubernetes/charts/base/chart/templates/statefulset-service.yaml

This file was deleted.

58 changes: 0 additions & 58 deletions kubernetes/charts/base/chart/templates/statefulset.yaml

This file was deleted.

34 changes: 17 additions & 17 deletions kubernetes/deployments/examples/caddy.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
---
kind: Deployment
name: caddy
replicaCount: 1

deployments:
containers:
- name: caddy
repository: caddy
tag: latest
port: 80
resources:
limits:
cpu: "1"
memory: 512Mi
requests:
cpu: "0.25"
memory: 64Mi
service:
containers:
- name: caddy
repository: caddy
tag: latest
port: 80
nodePort: 30049
resources:
limits:
cpu: "1"
memory: 512Mi
requests:
cpu: "0.25"
memory: 64Mi
service:
port: 80
nodePort: 30049

# ingress:
# host: foo.example.com
#ingress:
# host: foo.example.com

0 comments on commit 1e07f6b

Please sign in to comment.