diff --git a/helm/templates/_helpers.tpl b/helm/templates/_helpers.tpl new file mode 100644 index 00000000..b2475f4a --- /dev/null +++ b/helm/templates/_helpers.tpl @@ -0,0 +1,37 @@ +{{- define "app.labels" -}} +app: {{ .Chart.Name }} +component: gpt-app +{{- end -}} + +{{- define "app.deploymentName" -}} +{{ .Release.Name }}-app-deployment +{{- end -}} + +{{- define "app.serviceName" -}} +{{ .Release.Name }}-app-service +{{- end -}} + +{{- define "app.secretName" -}} +{{ .Release.Name }}-app-secret +{{- end -}} + +{{- define "app.ingressName" -}} +{{ .Release.Name }}-app-ingress +{{- end -}} + +{{- define "web.labels" -}} +app: {{ .Chart.Name }} +component: gpt-web +{{- end -}} + +{{- define "web.deploymentName" -}} +{{ .Release.Name }}-web-deployment +{{- end -}} + +{{- define "web.serviceName" -}} +{{ .Release.Name }}-web-service +{{- end -}} + +{{- define "web.ingressName" -}} +{{ .Release.Name }}-web-ingress +{{- end -}} diff --git a/helm/templates/app/_helpers.tpl b/helm/templates/app/_helpers.tpl deleted file mode 100644 index 8cd40792..00000000 --- a/helm/templates/app/_helpers.tpl +++ /dev/null @@ -1,17 +0,0 @@ -{{- define "app.labels" -}} -app: {{ .Chart.Name }} -component: gpt-app -release: {{ .Release.Name }} -{{- end -}} - -{{- define "app.deploymentName" -}} -{{ .Release.Name }}-app-deployment -{{- end -}} - -{{- define "app.serviceName" -}} -{{ .Release.Name }}-app-service -{{- end -}} - -{{- define "app.secretName" -}} -{{ .Release.Name }}-app-secret -{{- end -}} diff --git a/helm/templates/app/ingress.yaml b/helm/templates/app/ingress.yaml new file mode 100644 index 00000000..a03333e8 --- /dev/null +++ b/helm/templates/app/ingress.yaml @@ -0,0 +1,19 @@ +{{- if .Values.ingress.enabled }} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ include "app.ingressName" . }} +spec: + ingressClassName: {{ .Values.ingress.ingressClassName }} + rules: + - host: {{ .Values.ingress.host }} + http: + paths: + - path: /api + pathType: Prefix + backend: + service: + name: {{ include "app.serviceName" . }} + port: + number: {{ .Values.app.service.port }} +{{- end }} diff --git a/helm/templates/app/service.yaml b/helm/templates/app/service.yaml index 7d2ca6dd..9702b83b 100644 --- a/helm/templates/app/service.yaml +++ b/helm/templates/app/service.yaml @@ -10,8 +10,5 @@ spec: - port: {{ .Values.app.service.port }} targetPort: {{ .Values.app.service.targetPort }} protocol: {{ .Values.app.service.protocol }} - {{- if eq .Values.app.service.type "NodePort" }} - nodePort: {{ .Values.app.service.nodePort }} - {{- end }} selector: {{- include "app.labels" . | nindent 4 }} diff --git a/helm/templates/web/deployment.yaml b/helm/templates/web/deployment.yaml new file mode 100644 index 00000000..05f68b09 --- /dev/null +++ b/helm/templates/web/deployment.yaml @@ -0,0 +1,28 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "web.deploymentName" . }} + labels: + {{- include "web.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.web.replicaCount }} + selector: + matchLabels: + {{- include "web.labels" . | nindent 8 }} + template: + metadata: + labels: + {{- include "web.labels" . | nindent 8 }} + spec: + containers: + - name: {{ include "web.deploymentName" . }} + image: {{ .Values.web.image.repository }}:{{ .Values.web.image.tag }} + ports: + - containerPort: {{ .Values.web.service.targetPort }} + {{- if .Values.web.nodeSelector }} + nodeSelector: {{ .Values.web.nodeSelector | toYaml | nindent 8 }} + {{- end }} + + {{- if .Values.web.affinity }} + affinity: {{ .Values.web.affinity | toYaml | nindent 8 }} + {{- end }} diff --git a/helm/templates/web/ingress.yaml b/helm/templates/web/ingress.yaml new file mode 100644 index 00000000..64a7ef3a --- /dev/null +++ b/helm/templates/web/ingress.yaml @@ -0,0 +1,19 @@ +{{- if .Values.ingress.enabled }} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ include "web.ingressName" . }} +spec: + ingressClassName: {{ .Values.ingress.ingressClassName }} + rules: + - host: {{ .Values.ingress.host }} + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: {{ include "web.serviceName" . }} + port: + number: {{ .Values.web.service.port }} +{{- end }} diff --git a/helm/templates/web/service.yaml b/helm/templates/web/service.yaml new file mode 100644 index 00000000..d8b7f72f --- /dev/null +++ b/helm/templates/web/service.yaml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "web.serviceName" . }} + labels: + {{- include "web.labels" . | nindent 4 }} +spec: + type: {{ .Values.web.service.type }} + ports: + - port: {{ .Values.web.service.port }} + targetPort: {{ .Values.web.service.targetPort }} + protocol: {{ .Values.web.service.protocol }} + {{- if eq .Values.web.service.type "NodePort" }} + nodePort: {{ .Values.web.service.nodePort }} + {{- end }} + selector: + {{- include "web.labels" . | nindent 4 }} diff --git a/helm/values.yaml b/helm/values.yaml index 66265167..b4093aa8 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -5,11 +5,29 @@ app: tag: latest service: type: ClusterIP - port: 80 + port: 8080 targetPort: 8080 protocol: TCP - nodePort: 30080 environment: OPENAI_API_KEY: "" nodeSelector: {} affinity: {} + +web: + replicaCount: 1 + image: + repository: 81318131/web_gpt + tag: kubernetes-local + service: + type: ClusterIP + port: 80 + targetPort: 4173 + protocol: TCP + nodePort: 30080 + nodeSelector: {} + affinity: {} + +ingress: + enabled: true + host: "devopsgpt.local" + ingressClassName: "nginx"