Merge "[UUI] Service Mesh Compliance for UUI"
[oom.git] / docs / sections / guides / infra_guides / oom_setup_ingress_controller.rst
1 .. This work is licensed under a Creative Commons Attribution 4.0
2 .. International License.
3 .. http://creativecommons.org/licenses/by/4.0
4 .. Copyright 2020, Samsung Electronics
5 .. Modification copyright (C) 2022 Nordix Foundation
6
7 .. Links
8 .. _metallb Metal Load Balancer installation: https://metallb.universe.tf/installation/
9
10 .. _oom_setup_ingress_controller:
11
12 OOM Ingress controller setup
13 ############################
14
15 .. warning::
16     This guide should prob go in the Optional addons section
17
18 This optional guide provides instruction how to setup experimental ingress controller
19 feature. For this, we are hosting our cluster on OpenStack VMs and using the
20 Rancher Kubernetes Engine (RKE) to deploy and manage our Kubernetes Cluster and
21 ingress controller
22
23 .. contents::
24    :backlinks: top
25    :depth: 1
26    :local:
27 ..
28
29 The result at the end of this tutorial will be:
30
31 #. Customization of the cluster.yaml file for ingress controller support
32
33 #. Installation and configuration test DNS server for ingress host resolution
34    on testing machines
35
36 #. Installation and configuration MLB (Metal Load Balancer) required for
37    exposing ingress service
38
39 #. Installation and configuration NGINX ingress controller
40
41 #. Additional info how to deploy ONAP with services exposed via Ingress
42    controller
43
44 Customize cluster.yml file
45 **************************
46 Before setup cluster for ingress purposes DNS cluster IP and ingress provider
47 should be configured and following:
48
49 .. code-block:: yaml
50
51   ---
52   <...>
53   restore:
54     restore: false
55     snapshot_name: ""
56   ingress:
57     provider: none
58   dns:
59     provider: coredns
60     upstreamnameservers:
61       - <custer_dns_ip>:31555
62
63 Where the <cluster_dns_ip> should be set to the same IP as the CONTROLPANE
64 node.
65
66 For external load balancer purposes, minimum one of the worker node should be
67 configured with external IP address accessible outside the cluster. It can be
68 done using the following example node configuration:
69
70 .. code-block:: yaml
71
72   ---
73   <...>
74   - address: <external_ip>
75     internal_address: <internal_ip>
76     port: "22"
77     role:
78       - worker
79     hostname_override: "onap-worker-0"
80     user: ubuntu
81     ssh_key_path: "~/.ssh/id_rsa"
82     <...>
83
84 Where the <external_ip> is external worker node IP address, and <internal_ip>
85 is internal node IP address if it is required.
86
87
88 DNS server configuration and installation
89 *****************************************
90 DNS server deployed on the Kubernetes cluster makes it easy to use services
91 exposed through ingress controller because it resolves all subdomain related to
92 the ONAP cluster to the load balancer IP. Testing ONAP cluster requires a lot
93 of entries on the target machines in the /etc/hosts. Adding many entries into
94 the configuration files on testing machines is quite problematic and error
95 prone. The better wait is to create central DNS server with entries for all
96 virtual host pointed to simpledemo.onap.org and add custom DNS server as a
97 target DNS server for testing machines and/or as external DNS for Kubernetes
98 cluster.
99
100 DNS server has automatic installation and configuration script, so installation
101 is quite easy::
102
103   > cd kubernetes/contrib/dns-server-for-vhost-ingress-testing
104
105   > ./deploy\_dns.sh
106
107 After DNS deploy you need to setup DNS entry on the target testing machine.
108 Because DNS listen on non standard port configuration require iptables rules
109 on the target machine. Please follow the configuration proposed by the deploy
110 scripts.
111 Example output depends on the IP address and example output looks like bellow::
112
113   DNS server already deployed:
114   1. You can add the DNS server to the target machine using following commands:
115     sudo iptables -t nat -A OUTPUT -p tcp -d 192.168.211.211 --dport 53 -j DNAT --to-destination 10.10.13.14:31555
116     sudo iptables -t nat -A OUTPUT -p udp -d 192.168.211.211 --dport 53 -j DNAT --to-destination 10.10.13.14:31555
117     sudo sysctl -w net.ipv4.conf.all.route_localnet=1
118     sudo sysctl -w net.ipv4.ip_forward=1
119   2. Update /etc/resolv.conf file with nameserver 192.168.211.211 entry on your target machine
120
121
122 MetalLB Load Balancer installation and configuration
123 ****************************************************
124
125 By default pure Kubernetes cluster requires external load balancer if we want
126 to expose external port using LoadBalancer settings. For this purpose MetalLB
127 can be used. Before installing the MetalLB you need to ensure that at least one
128 worker has assigned IP accessible outside the cluster.
129
130 MetalLB Load balancer can be easily installed using automatic install script::
131
132   > cd kubernetes/contrib/metallb-loadbalancer-inst
133
134   > ./install-metallb-on-cluster.sh
135
136
137 Configuration of the Nginx ingress controller
138 *********************************************
139
140 After installation of the DNS server and ingress controller, we can install and
141 configure ingress controller.
142 It can be done using the following commands::
143
144   > cd kubernetes/contrib/ingress-nginx-post-inst
145
146   > kubectl apply -f nginx_ingress_cluster_config.yaml
147
148   > kubectl apply -f nginx_ingress_enable_optional_load_balacer_service.yaml
149
150 After deploying the NGINX ingress controller, you can ensure that the ingress port is
151 exposed as load balancer service with an external IP address::
152
153   > kubectl get svc -n ingress-nginx
154   NAME                   TYPE           CLUSTER-IP      EXTERNAL-IP      PORT(S)                      AGE
155   default-http-backend   ClusterIP      10.10.10.10   <none>           80/TCP                       25h
156   ingress-nginx          LoadBalancer   10.10.10.11    10.12.13.14   80:31308/TCP,443:30314/TCP   24h
157
158
159 ONAP with ingress exposed services
160 **********************************
161 If you want to deploy onap with services exposed through ingress controller you
162 can use full onap deploy yaml::
163
164   > onap/resources/overrides/onap-all-ingress-nginx-vhost.yaml
165
166 Ingress also can be enabled on any onap setup override using following code:
167
168 .. code-block:: yaml
169
170   ---
171   <...>
172   global:
173   <...>
174     ingress:
175       enabled: true
176