> For the complete documentation index, see [llms.txt](https://utm-1.gitbook.io/utm-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://utm-1.gitbook.io/utm-docs/dokumentaciya/utm-it/resheniya/kubernetes/prilozheniya/nginx-ingress-controller.md).

# NGINX Ingress Controller

## Ссылки

NGINX Configuration: [github.com](https://github.com/kubernetes/ingress-nginx/blob/main/docs/user-guide/nginx-configuration/index.md)

Ingress и Ingress Controller: [docs.selectel.ru](https://docs.selectel.ru/managed-kubernetes/networks/set-up-ingress/?install-application=helm\&install-ingress-controller=with-configuring-loadbalancer)

Развертывание контроллера Nginx Ingress с помощью Helm в Kubernetes: [dev.to](https://dev.to/rd17/deploying-nginx-ingress-controller-using-helm-in-kubernetes-47mm)

Установка Ingress-контроллера в Kubernetes: [docs.truedev.ru](https://docs.truedev.ru/Kubernetes/k8s-ingress-nginx-controller/#case-1-ingress-)

## Установка

### Установка через Argo CD

{% hint style="info" %}
Рекомендованный вариант установки.

Предварительное условие - развернутое в кластере приложение [Argo CD](/utm-docs/dokumentaciya/utm-it/resheniya/kubernetes/prilozheniya/argo-cd.md) для управления кластером.
{% endhint %}

В github в репозитории argocd в каталоге `env-prod\apps` создать подкаталог `ingress-nginx` в котором создать файл `app.yaml` следующего содержания:

```yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: ingress-nginx
  namespace: argocd
spec:
  project: default
  destination:
    name     : in-cluster
    namespace: ingress-nginx
  source:
    chart: ingress-nginx
    repoURL: https://kubernetes.github.io/ingress-nginx
    targetRevision: 4.14.0
    helm:
      releaseName: nginx-ingress
      values: |
        controller:
          replicaCount: 2
          service:
            type: NodePort
            nodePorts:
              http: 31080
              https: 31443

  syncPolicy:
    automated:
      prune: true
      selfHeal: true
    syncOptions:
    - Validate=true
    - CreateNamespace=true
    - PrunePropagationPolicy=foreground
    - PruneLast=true
```

Сделать коммит в github. После этого Argo CD развернет NGINX Ingress Controller в связанном кластере Kubernetes.

### Ручная установка через helm

{% hint style="warning" %}
Не рекомендованный вариант установки
{% endhint %}

Добавьте репозиторий `ingress-nginx` в Helm:

```bash
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm repo update
```

Получите значения по умолчанию и сохраните их в файл `values.yaml`:

```bash
helm inspect values ingress-nginx/ingress-nginx > values-default.yaml
```

**Подготовьте файл** `values.yaml` на основе файла `values-default.yaml` - скорректировать значения по умолчанию.

```yaml
controller:
  replicaCount: 2
  service:
    type: NodePort
    externalTrafficPolicy: Local
    nodePorts:
      http: 31080
      https: 31443
  ingressClassResource:
    default: true
  watchIngressWithoutClass: true
  affinity:
    podAntiAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
      - labelSelector:
          matchExpressions:
          - key: app.kubernetes.io/component
            operator: In
            values:
            - controller
          - key: app.kubernetes.io/instance
            operator: In
            values:
            - ingress-nginx
          - key: app.kubernetes.io/name
            operator: In
            values:
            - ingress-nginx
        topologyKey: "kubernetes.io/hostname"
```

Установите Ingress Controller:

```bash
# Установить
helm install nginx-ingress ingress-nginx/ingress-nginx -f values.yaml --namespace ingress-nginx --create-namespace

# Установить (тут устанавливается в namespace=Default)
# helm install nginx-ingress ingress-nginx/ingress-nginx -f values.yaml

# Удалить (при необходимости)
# helm delete nginx-ingress --namespace ingress-nginx
```

Проверьте, что Ingress Controller установлен:

```bash
kubectl get pods --namespace ingress-nginx
```

В ответе появится информация об Ingress Controller:

```
NAME                                                   READY   STATUS    RESTARTS   AGE
ingress-nginx-1652172027-controller-6d765d1688-vr7ab   1/1     Running   0          51s
```

### Создать Ingress <a href="#create-ingress" id="create-ingress"></a>

Пример манифеста:

```yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: minimal-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - http:
      paths:
      - path: /testpath
        pathType: Prefix
        backend:
          service:
            name: test
            port:
              number: 80
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://utm-1.gitbook.io/utm-docs/dokumentaciya/utm-it/resheniya/kubernetes/prilozheniya/nginx-ingress-controller.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.
