Yandex Cloud
  • Services
  • Solutions
  • Why Yandex Cloud
  • Blog
  • Pricing
  • Documentation
  • Contact us
Get started
Language / Region
Yandex project
© 2023 Yandex.Cloud LLC
Yandex Managed Service for Kubernetes
  • Comparison with other Yandex Cloud services
  • Getting started
  • Step-by-step instructions
    • All instructions
    • Connecting to a node over SSH
    • Updating Kubernetes
    • Configuring autoscaling
    • Connecting to a cluster
      • Connection method overview
      • Configuring security groups
      • Creating a static configuration file
    • Installing applications from Cloud Marketplace
      • Basics of working with Cloud Marketplace
      • Installing Argo CD
      • Installing Container Storage Interface for S3
      • Installing Crossplane
      • Installing External Secrets Operator
      • Installing Filebeat
      • Installing Fluent Bit
      • Installing Gateway API
      • Installing GitLab Agent
      • Installing GitLab Runner
      • Installing HashiCorp Vault
      • Installing the Application Load Balancer Ingress controller
      • Installing Jaeger
      • Installing Kyverno & Kyverno Policies
      • Installing Metrics Provider
      • Installing NodeLocal DNS
      • Installing Policy Reporter
      • Installing Thumbor
    • Network scenarios
      • Granting access to an app running in a Kubernetes cluster
      • Configuring the Calico network policy controller
      • Configuring the Cilium network policy controller
      • Configuring NodeLocal DNS for the Cilium network policy controller
    • Working with persistent volumes
      • Dynamic volume provisioning
      • Static volume provisioning
      • Managing storage classes
      • Expanding a pod volume
      • Expanding a StatefulSet controller volume
      • Mounting a volume in Block mode
      • Integration with Object Storage
    • Managing a Kubernetes cluster
      • Getting information about a Kubernetes cluster
      • Creating a Kubernetes cluster
      • Editing a Kubernetes cluster
      • Creating a namespace in a Kubernetes cluster
      • Deleting a Kubernetes cluster
    • Managing a node group
      • Information about existing node groups
      • Creating a node group
      • Connecting to a node over SSH
      • Configuring autoscaling
      • Changing a node group
      • Managing Kubernetes cluster node labels
      • Deleting a node group
    • Connecting external nodes to the cluster
  • Practical guidelines
    • All tutorials
    • Creating a new Kubernetes project in Yandex Cloud
    • Integration with Container Registry
    • Running workloads with GPUs
    • Installing an NGINX Ingress controller with Let's Encrypt®
    • Installing an NGINX Ingress controller with a certificate from Certificate Manager
    • Backups to Object Storage
    • Horizontal application scaling in a cluster
    • Vertical application scaling in a cluster
    • Deploying and load testing a gRPC service with scaling
    • Working with snapshots
    • Integrating into a corporate DNS zone
    • Automatic DNS scaling by cluster size
    • Setting up local DNS caching
    • Checking DNS Challenge for Let's Encrypt® certificates
    • Monitoring a cluster using Prometheus and Grafana
    • Continuous deployment of containerized applications using GitLab
    • Using Cloud Marketplace products
      • Integrating with Argo CD
      • Integration with Crossplane
      • Syncing with Yandex Lockbox secrets
      • Configuring Fluent Bit for Cloud Logging
      • Setting up Gateway API
      • Configuring the Application Load Balancer Ingress controller
      • Using Jaeger to trace requests in Managed Service for YDB
      • Using Metrics Provider to stream metrics
  • Concepts
    • Relationships between service resources
    • Release channels and updates
    • Encrypting secrets
    • Using Kubernetes API objects
      • Volumes
      • Service
    • Node groups
      • Cluster autoscaler
      • Evicting pods from nodes
      • Dynamic resource allocation for a node
      • Node groups with GPUs
    • Network in Managed Service for Kubernetes
    • External cluster nodes
    • Network settings and cluster policies
    • Automatic scaling
    • Quotas and limits
    • Recommendations for using Managed Service for Kubernetes
  • Access management
  • Pricing policy
  • API reference
    • Authentication in the API
    • gRPC
      • Overview
      • ClusterService
      • NodeGroupService
      • VersionService
      • OperationService
    • REST
      • Overview
      • Cluster
        • Overview
        • create
        • delete
        • get
        • list
        • listNodeGroups
        • listNodes
        • listOperations
        • start
        • stop
        • update
      • NodeGroup
        • Overview
        • create
        • delete
        • get
        • list
        • listNodes
        • listOperations
        • update
      • Version
        • Overview
        • list
  • Questions and answers
    • General questions
    • Data storage
    • Configuring and updating
    • Automatic scaling
    • Resources
    • Logs
    • All questions on one page
  1. Practical guidelines
  2. Installing an NGINX Ingress controller with Let's Encrypt®

Installing the NGINX Ingress Controller with a Let's Encrypt® certificates manager

Written by
Yandex Cloud
  • Before you begin
  • Install the NGINX Ingress Controller
  • Install the certificate manager
  • Create objects
  • Configure a DNS record for the Ingress controller
  • Test how TLS works
  • Delete the resources you created

To create NGINX Ingress Controller using Kubernetes and protect it with a Let's Encrypt® certificate, follow these steps.

Before you begin

  1. Install the kubectl and configure it to work with the created cluster.

  2. Install the Kubernetes Helm 3 package manager.

  3. Add a repository for NGINX to Helm:

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

    Result:

    "ingress-nginx" has been added to your repositories
    
  4. Update the dataset to create an application instance in the Kubernetes cluster:

    helm repo update
    

    Result:

    Hang tight while we grab the latest from your chart repositories...
    ...Successfully got an update from the "ingress-nginx" chart repository
    Update Complete. ⎈Happy Helming!⎈
    

Install the NGINX Ingress Controller

Install the controller in the standard configuration:

helm install ingress-nginx ingress-nginx/ingress-nginx

Result:

NAME: ingress-nginx
LAST DEPLOYED: Sun Jul 18 22:35:37 2021
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
The ingress-nginx controller has been installed.
It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status by running 'kubectl --namespace default get services -o wide -w ingress-nginx-controller'
...

The created controller will be installed behind Yandex Network Load Balancer.

To set up the controller configuration yourself, follow the instructions provided in the Helm documentation and edit the file named values.yaml.

Install the certificate manager

  1. Install certificate manager v. 1.6.1 configured to issue Let's Encrypt® certificates (check for the latest version on the project page):

    kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.6.1/cert-manager.yaml
    

    Result:

    customresourcedefinition.apiextensions.k8s.io/certificaterequests.cert-manager.io created
    ...
    validatingwebhookconfiguration.admissionregistration.k8s.io/cert-manager-webhook created
    
  2. Make sure that the cert-manager namespace has three pods, all of them being 1/1 ready and with the Running status:

    kubectl get pods -n cert-manager --watch
    

    Result:

    NAME                                      READY  STATUS   RESTARTS  AGE
    cert-manager-69cf79df7f-ghw6s             1/1    Running  0         54s
    cert-manager-cainjector-7648dc6696-gnrzz  1/1    Running  0         55s
    cert-manager-webhook-7746f64877-wz9bh     1/1    Running  0         54s
    

Create objects

To test the certificate manager, create the ClusterIssuer, Ingress, Service, and Deployment objects.

  1. Create the acme-issuer.yaml YAML file with the ClusterIssuer object manifest:

    apiVersion: cert-manager.io/v1
    kind: ClusterIssuer
    metadata:
      name: letsencrypt
      namespace: cert-manager
    spec:
      acme:
        server: https://acme-v02.api.letsencrypt.org/directory
        email: <your email>
        privateKeySecretRef:
          name: letsencrypt
        solvers:
        - http01:
            ingress:
              class: nginx
    
  2. Create the app.yaml YAML file with the Ingress, Service, and Deployment object manifests:

    apiVersion: networking.k8s.io/v1
    kind: Ingress
    metadata:
      name: minimal-ingress
      annotations:
        kubernetes.io/ingress.class: "nginx"
        cert-manager.io/cluster-issuer: "letsencrypt"
    spec:
      tls:
        - hosts:
          - <your domain URL>
          secretName: letsencrypt
      rules:
        - host: <your domain URL>
          http:
            paths:
            - path: /
              pathType: Prefix
              backend:
                service:
                  name: app
                  port:
                    number: 80
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: app
    spec:
      selector:
        app: app
      ports:
        - protocol: TCP
          port: 80
          targetPort: 80
    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: app-deployment
      labels:
        app: app
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: app
      template:
        metadata:
          labels:
            app: app
        spec:
          containers:
          - name: app
            image: nginx:latest
            ports:
            - containerPort: 80
    
  3. Create objects in a Kubernetes cluster:

    kubectl apply -f acme-issuer.yaml && \
    kubectl apply -f app.yaml
    

Configure a DNS record for the Ingress controller

  1. Find out the IP address of the Ingress controller (the value in the EXTERNAL-IP column):

    kubectl get svc
    

    Result:

    NAME                      TYPE          CLUSTER-IP     EXTERNAL-IP     PORT(S)                     AGE
    ...
    ingress-nginx-controller  LoadBalancer  10.96.164.252  84.201.153.122  80:31248/TCP,443:31151/TCP  2m19s
    ...
    
  2. Host an A record with your DNS provider or on your own DNS server that will indicate the public IP address of the Ingress controller:

    <your domain> IN A 84.201.153.122
    

Note

Registering the Let's Encrypt® certificate and an A record may take a few minutes.

Test how TLS works

curl https://<your domain>

Delete the resources you created

If you no longer need these resources, delete the Managed Service for Kubernetes cluster.

Was the article helpful?

Language / Region
Yandex project
© 2023 Yandex.Cloud LLC
In this article:
  • Before you begin
  • Install the NGINX Ingress Controller
  • Install the certificate manager
  • Create objects
  • Configure a DNS record for the Ingress controller
  • Test how TLS works
  • Delete the resources you created