Skip to content

Commit

Permalink
Change template layout, added hpa, ingress, service and serivce accou…
Browse files Browse the repository at this point in the history
…nt template
  • Loading branch information
wangeguo committed Apr 13, 2023
1 parent 4883034 commit 3c71e8c
Show file tree
Hide file tree
Showing 11 changed files with 179 additions and 1 deletion.
2 changes: 1 addition & 1 deletion charts/amphitheatre/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.4.12
version: 0.4.19

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
28 changes: 28 additions & 0 deletions charts/amphitheatre/templates/apiserver/hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{{- if .Values.apiserver.autoscaling.enabled }}
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "amphitheatre.apiserver.fullname" . }}
labels:
{{- include "amphitheatre.apiserver.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "amphitheatre.apiserver.fullname" . }}
minReplicas: {{ .Values.apiserver.autoscaling.minReplicas }}
maxReplicas: {{ .Values.apiserver.autoscaling.maxReplicas }}
metrics:
{{- if .Values.apiserver.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
targetAverageUtilization: {{ .Values.apiserver.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.apiserver.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
targetAverageUtilization: {{ .Values.apiserver.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}
61 changes: 61 additions & 0 deletions charts/amphitheatre/templates/apiserver/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "amphitheatre.apiserver.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}}
{{- end }}
{{- end }}
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "amphitheatre.apiserver.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.ingress.className }}
{{- end }}
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
{{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
pathType: {{ .pathType }}
{{- end }}
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ $fullName }}
port:
number: {{ $svcPort }}
{{- else }}
serviceName: {{ $fullName }}
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
15 changes: 15 additions & 0 deletions charts/amphitheatre/templates/apiserver/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "amphitheatre.apiserver.fullname" . }}
labels:
{{- include "amphitheatre.apiserver.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "amphitheatre.apiserver.selectorLabels" . | nindent 4 }}
12 changes: 12 additions & 0 deletions charts/amphitheatre/templates/apiserver/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{- if .Values.apiserver.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "amphitheatre.apiserver.serviceAccountName" . }}
labels:
{{- include "amphitheatre.apiserver.labels" . | nindent 4 }}
{{- with .Values.apiserver.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
28 changes: 28 additions & 0 deletions charts/amphitheatre/templates/controllers/hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{{- if .Values.controllers.autoscaling.enabled }}
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "amphitheatre.controllers.fullname" . }}
labels:
{{- include "amphitheatre.controllers.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "amphitheatre.controllers.fullname" . }}
minReplicas: {{ .Values.controllers.autoscaling.minReplicas }}
maxReplicas: {{ .Values.controllers.autoscaling.maxReplicas }}
metrics:
{{- if .Values.controllers.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
targetAverageUtilization: {{ .Values.controllers.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.controllers.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
targetAverageUtilization: {{ .Values.controllers.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}
12 changes: 12 additions & 0 deletions charts/amphitheatre/templates/controllers/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{- if .Values.apiserver.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "amphitheatre.controllers.serviceAccountName" . }}
labels:
{{- include "amphitheatre.controllers.labels" . | nindent 4 }}
{{- with .Values.controllers.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
22 changes: 22 additions & 0 deletions charts/amphitheatre/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,28 @@ apiserver:
## Enable debug mode
debug: false

## @section Service parameters
service:
type: ClusterIP
port: 80

## @section Ingress parameters
ingress:
enabled: false
className: ""
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
hosts:
- host: api.amphitheatre.local
paths:
- path: /
pathType: ImplementationSpecific
tls: []
# - secretName: api.amphitheatre.local-tls
# hosts:
# - api.amphitheatre.local

## @section Database parameters

## MySQL chart configuration
Expand Down

0 comments on commit 3c71e8c

Please sign in to comment.