I am using gitlab and kubernetes charts to install ingress for my application. this works great as it uses built in variables or templates to get the app url for host so that different environments will have different hostnames, yet use the same ingress and values chart.
the template it is referring to is called "hostname" which im not sure where it exists. the reason i want to find it is so that i can work out how to extract just the domain from the url. eg. "hostname"=app.domain.com. i want to be able to deploy a second ingress that will go to app.two.domain.com without hardcoding the domain. to do this i need to extract the url somehow.. i worked out how to extract just the app name - {{ template "appname" . }}
values.yaml
---
service:
enabled: true
name: web
type: ClusterIP
url: http://my.host.com/
externalPort: 5000
internalPort: 5000
---
ingress.yaml
---
{{- if .Values.service.enabled -}}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: {{ template "fullname" . }}
labels:
app: {{ template "appname" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version| replace "+" "_" }}"
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
annotations:
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/enable-rewrite-log: "true"
nginx.ingress.kubernetes.io/configuration-snippet: |
if ( $uri !~ ^/(static|.*\..*|$) ) {
rewrite ^ /index.html break;
}
spec:
rules:
- host: {{ template "hostname" .Values.service.url }}
http:
paths:
- path: /
backend:
serviceName: {{ template "fullname" . }}
servicePort: {{ .Values.service.externalPort }}
path: /
{{- end -}}
---
as you can see under spec.host it uses a template which gets the hostname from your kubernetes environment somehow. i just want to know how to manipulate that so i can get the domain alone. example of what i plan to do
spec:
rules:
- host: {{ template "hostname" .Values.service.url }}
http:
paths:
- path: /
backend:
serviceName: {{ template "fullname" . }}
servicePort: {{ .Values.service.externalPort }}
path: /
- host: {{ template "appname" . }}.{{ domain.url }}
http:
paths:
- path: /
backend:
serviceName: {{ template "fullname" . }}
servicePort: {{ .Values.service.externalPort }}
i basically need two urls pointing to my app as each would provide different skins etc to the webpage