# Ingress

## Deploy NGINX ingress

Create a values file:

```
cat <<EOF >ingress-internal.yml
controller:
  service:
    loadBalancerIP: 10.240.0.42
    annotations:
      service.beta.kubernetes.io/azure-load-balancer-internal: "true"

EOF
```

{% hint style="info" %}
Check you network CIDR to specify loadBalancerIP.

You can also omit it in order to leave Azure to allocate an IP.
{% endhint %}

Create a namespace.

```bash
kubectl create namespace ingress-internal
```

Deploy NGINX ingress

```bash
helm install stable/nginx-ingress \
    --name=ingress-internal \
    --namespace ingress-internal \
    -f ingress-internal.yml \
    --set controller.replicaCount=2 \
    --set controller.nodeSelector."beta\.kubernetes\.io/os"=linux \
    --set defaultBackend.nodeSelector."beta\.kubernetes\.io/os"=linux
```

Check service IP.

```bash
kubectl -n ingress-internal get service ingress-internal-nginx-ingress-controller
```

The `EXTERNAL-IP` is actually the ingress internal IP.

### References

<https://github.com/MicrosoftDocs/azure-docs/blob/master/articles/aks/ingress-internal-ip.md>

## Test it

```
kubectl create -f - <<EOF
---
apiVersion: v1
kind: Namespace
metadata:
  name: test-ingress
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-example
  namespace: test-ingress
  labels:
    app: my-example
spec:
  replicas: 1
  selector:
    matchLabels:
      app: my-example
  template:
    metadata:
      labels:
        app: my-example
    spec:
      containers:
      - name: my-example
        image: nginx
                   
        ports:
        - containerPort: 80
---
kind: Service
apiVersion: v1
metadata:
  name: my-example
  namespace: test-ingress
spec:
  selector:
    app: my-example
  ports:
  - protocol: TCP
    port: 80
  type: ClusterIP
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: nginx
  name: example
  namespace: test-ingress
spec:
  rules:
    - host: www.example.com
      http:
        paths:
          - backend:
              serviceName: my-example
              servicePort: 80
            path: /

EOF
```

Edit your hosts file and point `www.example.com` to your ingress internal IP.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.devops.buzz/public/aks/ingress.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
