Skip to content

Commit ff7e45f

Browse files
draychevakshaysngupta
authored andcommitted
multi-namespace: Adding documentation (#293)
1 parent 9e07d57 commit ff7e45f

File tree

4 files changed

+127
-0
lines changed

4 files changed

+127
-0
lines changed

cmd/appgw-ingress/main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ func validateNamespaces(namespaces []string, kubeClient *kubernetes.Clientset) {
134134
}
135135

136136
func getNamespacesToWatch(namespaceEnvVar string) []string {
137+
138+
// Returning an empty array effectively switches Ingress Controller
139+
// in a mode of observing all acessible namespaces.
137140
if namespaceEnvVar == "" {
138141
return []string{}
139142
}

docs/install-existing.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ The [aad-pod-identity](https://github.com/Azure/aad-pod-identity) gives a clean
6969
################################################################################
7070
# Specify which kubernetes namespace the ingress controller will watch
7171
# Default value is "default"
72+
# Leaving this variable out or setting it to blank or empty string would
73+
# result in Ingress Controller observing all acessible namespaces.
7274
#
7375
# kubernetes:
7476
# watchNamespace: <namespace>

docs/install-new.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ Steps:
109109
################################################################################
110110
# Specify which kubernetes namespace the ingress controller will watch
111111
# Default value is "default"
112+
# Leaving this variable out or setting it to blank or empty string would
113+
# result in Ingress Controller observing all acessible namespaces.
112114
#
113115
# kubernetes:
114116
# watchNamespace: <namespace>

docs/multiple-namespaces.md

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# Multiple Namespace Support
2+
3+
#### Motivation
4+
Kubernetes [Namespaces](https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/)
5+
make it possible for a Kubernetes cluster to be partitioned and allocated to
6+
sub-groups of a larger team. These sub-teams can then deploy and manage
7+
infrastructure with finer controls of resources, security, configuration etc.
8+
Kubernetes allows for one or more ingress resources to be defined independently
9+
within each namespace.
10+
11+
As of version 0.7 [Azure Application Gateway Kubernetes
12+
IngressController](https://github.com/Azure/application-gateway-kubernetes-ingress/blob/master/README.md)
13+
(AGIC) can ingest events from and observe multiple namespaces. Should the AKS
14+
administrator decide to use [App
15+
Gateway](https://azure.microsoft.com/en-us/services/application-gateway/) as an
16+
ingress, all namespaces will use the same instance of App Gateway. A single
17+
installation of Ingress Controller will monitor accessible namespaces and will
18+
configure the App Gateway it is associated with.
19+
20+
Version 0.7 of AGIC will continue to exclusively observe the `default`
21+
namespace, unless this is explicitly changed to one or more different
22+
namespaces in the Helm configuration (see section below).
23+
24+
#### Enable multiple namespace support
25+
To enable multiple namespace support:
26+
1. modify the [helm-config.yaml](examples/helm-config.yaml) file in one of the following ways:
27+
- delete the `watchNamespace` key entirely from [helm-config.yaml](examples/helm-config.yaml) - AGIC will observe all namespaces
28+
- set `watchNamespace` to an empty string - AGIC will observe all namespaces
29+
- add multiple namespaces separated by a comma (`watchNamespace: default,secondNamespace`) - AGIC will observe these namespaces exclusively
30+
2. apply Helm template changes with: `helm install -f helm-config.yaml application-gateway-kubernetes-ingress/ingress-azure`
31+
32+
Once deployed with the ability to observe multiple namespaces, AGIC will:
33+
- list ingress resources from all accessible namespaces
34+
- filter to ingress resources annotated with `kubernetes.io/ingress.class: azure/application-gateway`
35+
- compose combined [App Gateway config](https://github.com/Azure/azure-sdk-for-go/blob/37f3f4162dfce955ef5225ead57216cf8c1b2c70/services/network/mgmt/2016-06-01/network/models.go#L1710-L1744)
36+
- apply the config to the associated App Gateway via [ARM](https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-overview)
37+
38+
#### Conflicting Configurations
39+
Multiple namespaced [ingress resources](https://kubernetes.io/docs/concepts/services-networking/ingress/#the-ingress-resource)
40+
could instruct AGIC to create conflicting configurations for a single App Gateway. (Two ingresses claiming the same
41+
domain for instance.)
42+
43+
At the top of the hierarchy - **listeners** (IP address, port, and host) and **routing rules** (binding listener,
44+
backend pool and HTTP settings) could be created and shared by multiple namespaces/ingresses.
45+
46+
On the other hand - paths, backend pools, HTTP settings, and TLS certificates could be created by one namespace only
47+
and duplicates will removed..
48+
49+
For example, consider the following duplicate ingress resources defined
50+
namespaces `staging` and `production` for `www.contoso.com`:
51+
```yaml
52+
apiVersion: extensions/v1beta1
53+
kind: Ingress
54+
metadata:
55+
name: websocket-ingress
56+
namespace: staging
57+
annotations:
58+
kubernetes.io/ingress.class: azure/application-gateway
59+
spec:
60+
rules:
61+
- host: www.contoso.com
62+
http:
63+
paths:
64+
- backend:
65+
serviceName: web-service
66+
servicePort: 80
67+
```
68+
69+
```yaml
70+
apiVersion: extensions/v1beta1
71+
kind: Ingress
72+
metadata:
73+
name: websocket-ingress
74+
namespace: production
75+
annotations:
76+
kubernetes.io/ingress.class: azure/application-gateway
77+
spec:
78+
rules:
79+
- host: www.contoso.com
80+
http:
81+
paths:
82+
- backend:
83+
serviceName: web-service
84+
servicePort: 80
85+
```
86+
87+
Despite the two ingress resources demanding traffic for `www.contoso.com` to be
88+
routed to the respective Kubernetes namespaces, only one backend can service
89+
the traffic. AGIC would create a configuration on "first come, first served"
90+
basis for one of the resources. If two ingresses resources are created at the
91+
same time, the one earlier in the alphabet will take
92+
precedence. From the example above we will only be able to create settings for
93+
the `production` ingress. App Gateway will be configured with the following
94+
resources:
95+
96+
- Listener: `fl-www.contoso.com-80`
97+
- Routing Rule: `rr-www.contoso.com-80`
98+
- Backend Pool: `pool-production-contoso-web-service-80-bp-80`
99+
- HTTP Settings: `bp-production-contoso-web-service-80-80-websocket-ingress`
100+
- Health Probe: `pb-production-contoso-web-service-80-websocket-ingress`
101+
102+
Note that except for *listener* and *routing rule*, the App Gateway resources created include the name
103+
of the namespace (`production`) for which they were created.
104+
105+
If the two ingress resources are introduced into the AKS cluster at different
106+
points in time, it is likely for AGIC to end up in a scenario where it
107+
reconfigures App Gateway and re-routes traffic from `namespace-B` to
108+
`namespace-A`.
109+
110+
For example if you added `staging` first, AGIC will configure App Gwy to route
111+
traffic to the staging backend pool. At a later stage, introducing `production`
112+
ingress, will cause AGIC to reprogram App Gwy, which will start routing traffic
113+
to the `production` backend pool.
114+
115+
#### Restricting Access to Namespaces
116+
By default AGIC will configure App Gateway based on annotated Ingress within
117+
any namespace. Should you want to limit this behaviour you have the following
118+
options:
119+
- limit the namespaces, by explicitly defining namespaces AGIC should observe via the `watchNamespace` YAML key in [helm-config.yaml](examples/helm-config.yaml)
120+
- use [Role/RoleBinding](https://docs.microsoft.com/en-us/azure/aks/azure-ad-rbac) to limit AGIC to specific namespaces

0 commit comments

Comments
 (0)