Skip to content

Commit

Permalink
Merge pull request #79 from irfanhakim-as/template-update
Browse files Browse the repository at this point in the history
Update template chart notes with accessible service address
  • Loading branch information
irfanhakim-as authored Jun 25, 2024
2 parents b64d0c5 + 6104a5c commit 7a7966d
Showing 1 changed file with 41 additions and 4 deletions.
45 changes: 41 additions & 4 deletions template/chartName/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,46 @@
{{- $ingress := .Values.ingress.enabled }}
{{- $domain := .Values.chartName.domain | toString }}
ChartName is now installed and configured for {{ .Release.Name | toString }}.
{{- $port := .Values.service.port | default "80" | toString }}
{{- $type := .Values.service.type | default "ClusterIP" | toString }}
{{- $serviceName := printf "%s-chartName-svc" .Release.Name | toString }}
{{- $serviceAddress := "" }}
ChartName has been installed and configured for {{ .Release.Name | toString }} 🎉

Visit the following service to get started:
{{- if $ingress }}
{{- $serviceAddress = printf "https://%s" $domain | toString }}
{{- else if or (eq $type "ClusterIP") (eq $type "LoadBalancer") (eq $type "NodePort") }}

ChartName: {{ if $ingress }}https://{{ $domain }}{{- else }}Please refer to the {{ .Release.Name }}-chartName-svc service for the right address{{- end }}
Please run the following command(s) to obtain the right address to the service:

For more information on how to use and configure ChartName, please refer to the official documentation.
```sh
{{- if eq $type "ClusterIP" }}
{{- $forwardPort := "8080" | toString }}
{{- $serviceAddress = printf "http://127.0.0.1:%s" $forwardPort | toString }}
export POD_NAME=$(kubectl get pod --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "chartName.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}")
kubectl port-forward --namespace {{ .Release.Namespace }} ${POD_NAME} {{ $forwardPort }}:${CONTAINER_PORT}
{{- else if eq $type "LoadBalancer" }}
{{- $serviceAddress = printf "$(echo http://${SERVICE_IP}:%s)" $port | toString }}
export SERVICE_IP=$(kubectl get service --namespace {{ .Release.Namespace }} {{ $serviceName }} --template "{{"{{- range (index .status.loadBalancer.ingress 0) }}{{ . }}{{- end }}"}}")
{{- else if eq $type "NodePort" }}
{{- $serviceAddress = "$(echo http://${NODE_IP}:${NODE_PORT})" | toString }}
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
export NODE_PORT=$(kubectl get service --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" {{ $serviceName }})
{{- end }}
```

{{- end }}

{{- if $serviceAddress }}

Visit the following service at the provided address:

- ChartName: {{ $serviceAddress }}

{{- else }}

⚠️ This chart may have no accessible services available

{{- end }}

For more information on how to use and configure ChartName, please refer to the official documentation.

0 comments on commit 7a7966d

Please sign in to comment.