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