Mohammed Naser | 9ad0d46 | 2023-01-15 20:36:37 -0500 | [diff] [blame] | 1 | The ingress-nginx controller has been installed. |
| 2 | |
| 3 | {{- if contains "NodePort" .Values.controller.service.type }} |
| 4 | Get the application URL by running these commands: |
| 5 | |
| 6 | {{- if (not (empty .Values.controller.service.nodePorts.http)) }} |
| 7 | export HTTP_NODE_PORT={{ .Values.controller.service.nodePorts.http }} |
| 8 | {{- else }} |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 9 | export HTTP_NODE_PORT=$(kubectl get service --namespace {{ include "ingress-nginx.namespace" . }} {{ include "ingress-nginx.controller.fullname" . }} --output jsonpath="{.spec.ports[0].nodePort}") |
Mohammed Naser | 9ad0d46 | 2023-01-15 20:36:37 -0500 | [diff] [blame] | 10 | {{- end }} |
| 11 | {{- if (not (empty .Values.controller.service.nodePorts.https)) }} |
| 12 | export HTTPS_NODE_PORT={{ .Values.controller.service.nodePorts.https }} |
| 13 | {{- else }} |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 14 | export HTTPS_NODE_PORT=$(kubectl get service --namespace {{ include "ingress-nginx.namespace" . }} {{ include "ingress-nginx.controller.fullname" . }} --output jsonpath="{.spec.ports[1].nodePort}") |
Mohammed Naser | 9ad0d46 | 2023-01-15 20:36:37 -0500 | [diff] [blame] | 15 | {{- end }} |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 16 | export NODE_IP="$(kubectl get nodes --output jsonpath="{.items[0].status.addresses[1].address}")" |
Mohammed Naser | 9ad0d46 | 2023-01-15 20:36:37 -0500 | [diff] [blame] | 17 | |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 18 | echo "Visit http://${NODE_IP}:${HTTP_NODE_PORT} to access your application via HTTP." |
| 19 | echo "Visit https://${NODE_IP}:${HTTPS_NODE_PORT} to access your application via HTTPS." |
Mohammed Naser | 9ad0d46 | 2023-01-15 20:36:37 -0500 | [diff] [blame] | 20 | {{- else if contains "LoadBalancer" .Values.controller.service.type }} |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 21 | It may take a few minutes for the load balancer IP to be available. |
| 22 | You can watch the status by running 'kubectl get service --namespace {{ include "ingress-nginx.namespace" . }} {{ include "ingress-nginx.controller.fullname" . }} --output wide --watch' |
Mohammed Naser | 9ad0d46 | 2023-01-15 20:36:37 -0500 | [diff] [blame] | 23 | {{- else if contains "ClusterIP" .Values.controller.service.type }} |
| 24 | Get the application URL by running these commands: |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 25 | export POD_NAME="$(kubectl get pods --namespace {{ include "ingress-nginx.namespace" . }} --selector app.kubernetes.io/name={{ include "ingress-nginx.name" . }},app.kubernetes.io/instance={{ .Release.Name }},app.kubernetes.io/component=controller --output jsonpath="{.items[0].metadata.name}")" |
| 26 | kubectl port-forward --namespace {{ include "ingress-nginx.namespace" . }} "${POD_NAME}" 8080:80 |
Mohammed Naser | 9ad0d46 | 2023-01-15 20:36:37 -0500 | [diff] [blame] | 27 | echo "Visit http://127.0.0.1:8080 to access your application." |
| 28 | {{- end }} |
| 29 | |
| 30 | An example Ingress that makes use of the controller: |
| 31 | |
| 32 | {{- $isV1 := semverCompare ">=1" .Chart.AppVersion}} |
| 33 | apiVersion: networking.k8s.io/v1 |
| 34 | kind: Ingress |
| 35 | metadata: |
| 36 | name: example |
| 37 | namespace: foo |
| 38 | {{- if eq $isV1 false }} |
| 39 | annotations: |
| 40 | kubernetes.io/ingress.class: {{ .Values.controller.ingressClass }} |
| 41 | {{- end }} |
| 42 | spec: |
| 43 | {{- if $isV1 }} |
| 44 | ingressClassName: {{ .Values.controller.ingressClassResource.name }} |
| 45 | {{- end }} |
| 46 | rules: |
| 47 | - host: www.example.com |
| 48 | http: |
| 49 | paths: |
Mohammed Naser | 65cda13 | 2024-05-02 14:34:08 -0400 | [diff] [blame] | 50 | - pathType: Prefix |
| 51 | backend: |
Mohammed Naser | 9ad0d46 | 2023-01-15 20:36:37 -0500 | [diff] [blame] | 52 | service: |
| 53 | name: exampleService |
| 54 | port: |
| 55 | number: 80 |
| 56 | path: / |
| 57 | # This section is only required if TLS is to be enabled for the Ingress |
| 58 | tls: |
| 59 | - hosts: |
| 60 | - www.example.com |
| 61 | secretName: example-tls |
| 62 | |
| 63 | If TLS is enabled for the Ingress, a Secret containing the certificate and key must also be provided: |
| 64 | |
| 65 | apiVersion: v1 |
| 66 | kind: Secret |
| 67 | metadata: |
| 68 | name: example-tls |
| 69 | namespace: foo |
| 70 | data: |
| 71 | tls.crt: <base64 encoded cert> |
| 72 | tls.key: <base64 encoded key> |
| 73 | type: kubernetes.io/tls |