How can i config Ingress of helm to control 2 deployed service

6/29/2019

I have 2 service which written by nodejs.

I will deploy them to AKS by using Helm

Like that :

service.js    
app.get('/users', function(req,res){
        res.send("Hello World");
    });

and used helm to deploy 2 service.

This is deployment.yaml file

apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "samplechart.fullname" . }}
  labels:
{{ include "samplechart.labels" . | indent 4 }}
spec:
  replicas: {{ .Values.replicaCount }}
      containers:
        - name: {{ .Chart.Name }}
          image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
          imagePullPolicy: {{ .Values.image.pullPolicy }}
          ports:
            - name: http
              containerPort: 8081
              protocol: TCP
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "samplechart.fullname" . }}-test
  labels:
{{ include "samplechart.labels" . | indent 4 }}
spec:
  replicas: {{ .Values.replicaCount }}
      containers:
        - name: test
          image: "{{ .Values.image.repository2 }}:{{ .Values.image.tag2 }}"
          imagePullPolicy: {{ .Values.image.pullPolicy2 }}
          ports:
            - name: http
              containerPort: 8082
              protocol: TCP

How can i config ingress.yaml to access my service . Example external IP is 13.78.42.19 and use 13.78.42.19:8081 or 13.78.42.19:8082 to access to above service My default ingress.yaml file

{{- if .Values.ingress.enabled -}}
{{- $fullName := include "samplechart.fullname" . -}}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: {{ $fullName }}
  labels:
{{ include "samplechart.labels" . | indent 4 }}
  {{- with .Values.ingress.annotations }}
  annotations:
    {{- toYaml . | nindent 4 }}
  {{- end }}
spec:
{{- if .Values.ingress.tls }}
  tls:
  {{- range .Values.ingress.tls }}
    - hosts:
      {{- range .hosts }}
        - {{ . | quote }}
      {{- end }}
      secretName: {{ .secretName }}
  {{- end }}
{{- end }}
  rules:
  {{- range .Values.ingress.hosts }}
    - host: {{ .host | quote }}
      http:
        paths:
        {{- range .paths }}
          - path: {{ . }}
            backend:
              serviceName: {{ $fullName }}
              servicePort: http
        {{- end }}
  {{- end }}
{{- end }}
-- Cuong Doan Nhu Vu
kubernetes-helm
nginx-ingress
node.js

0 Answers