From 26d7fd1d31b8ee98d129e589bacbcb8caf4e3767 Mon Sep 17 00:00:00 2001 From: a601287411 <601287411@qq.com> Date: Wed, 29 Mar 2023 10:01:11 +0800 Subject: [PATCH] fix host --- NOTES.txt | 22 ++++++++++++++++++++++ templates/NOTES.txt | 22 ---------------------- templates/_helpers.tpl | 7 +++++++ templates/httpscaledobject.yaml | 2 +- templates/ingress.yaml | 2 +- values.yaml | 11 +++-------- 6 files changed, 34 insertions(+), 32 deletions(-) delete mode 100644 templates/NOTES.txt diff --git a/NOTES.txt b/NOTES.txt index e69de29..b4230b3 100644 --- a/NOTES.txt +++ b/NOTES.txt @@ -0,0 +1,22 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "xkcd.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "xkcd.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "xkcd.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "xkcd.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} \ No newline at end of file diff --git a/templates/NOTES.txt b/templates/NOTES.txt deleted file mode 100644 index 7eed3a5..0000000 --- a/templates/NOTES.txt +++ /dev/null @@ -1,22 +0,0 @@ -1. Get the application URL by running these commands: -{{- if .Values.ingress.enabled }} -{{- range $host := .Values.ingress.hosts }} - {{- range .paths }} - http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} - {{- end }} -{{- end }} -{{- else if contains "NodePort" .Values.service.type }} - export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "demo-chart.fullname" . }}) - export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") - echo http://$NODE_IP:$NODE_PORT -{{- else if contains "LoadBalancer" .Values.service.type }} - NOTE: It may take a few minutes for the LoadBalancer IP to be available. - You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "demo-chart.fullname" . }}' - export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "demo-chart.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") - echo http://$SERVICE_IP:{{ .Values.service.port }} -{{- else if contains "ClusterIP" .Values.service.type }} - export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "demo-chart.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") - export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") - echo "Visit http://127.0.0.1:8080 to use your application" - kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT -{{- end }} diff --git a/templates/_helpers.tpl b/templates/_helpers.tpl index 23b8325..391112a 100644 --- a/templates/_helpers.tpl +++ b/templates/_helpers.tpl @@ -60,3 +60,10 @@ Create the name of the service account to use {{- default "default" .Values.serviceAccount.name }} {{- end }} {{- end }} + +{{/* +Create the host of service +*/}} +{{- define "demo-chart.host" -}} +{{ .Release.Name }}.xf-yun.com +{{- end }} diff --git a/templates/httpscaledobject.yaml b/templates/httpscaledobject.yaml index 2cad5d0..bf1f0c3 100644 --- a/templates/httpscaledobject.yaml +++ b/templates/httpscaledobject.yaml @@ -3,7 +3,7 @@ apiVersion: http.keda.sh/v1alpha1 metadata: name: {{ include "demo-chart.fullname" . }} spec: - host: {{ .Values.host }} + host: {{ include "demo-chart.host" . }} targetPendingRequests: {{ .Values.targetPendingRequests }} scaleTargetRef: deployment: {{ include "demo-chart.fullname" . }} diff --git a/templates/ingress.yaml b/templates/ingress.yaml index 2a90d60..7cc7540 100644 --- a/templates/ingress.yaml +++ b/templates/ingress.yaml @@ -8,7 +8,7 @@ metadata: kubernetes.io/ingress.class: nginx spec: rules: - - host: {{ .Values.host }} + - host: {{ include "demo-chart.fullname" . }} http: paths: - path: / diff --git a/values.yaml b/values.yaml index 589ab6a..0fa172b 100644 --- a/values.yaml +++ b/values.yaml @@ -2,12 +2,7 @@ # This is a YAML-formatted file. # Declare variables to be passed into your templates. -# AILab Demo Metadata -model: test-demo - replicaCount: 1 -# FIXME: 根据model以及路由规则进行拼接 -host: test-demo.com targetPendingRequests: 200 # This is the namespace that the ingress should be installed # into. It should be set to the same namespace as the @@ -67,9 +62,9 @@ resources: {} # memory: 128Mi autoscaling: - enabled: true - minReplicas: 0 - maxReplicas: 10 + http: + minReplicas: 0 + maxReplicas: 10 nodeSelector: {}