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