NGINX Ingress Controller and configures it to use port 9443 for HTTPS

To configure Kubernetes Ingress to handle HTTPS traffic on port 9443, follow these steps. This guide assumes you already have a Kubernetes cluster and Ingress controller set up.

Prerequisites

  1. Kubernetes Cluster: Ensure you have a running Kubernetes cluster.
  2. Ingress Controller: Make sure an Ingress controller (e.g., NGINX Ingress Controller) is installed and running in your cluster.
  3. SSL Certificate: Obtain an SSL certificate (can be from a CA or self-signed).

Steps

  1. Install and Configure Ingress Controller

    • If not already installed, install an NGINX Ingress Controller. You can use Helm for this:

      helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
      helm repo update
      helm install nginx-ingress ingress-nginx/ingress-nginx --set controller.service.ports.https=9443
      

    This command installs the NGINX Ingress Controller and configures it to use port 9443 for HTTPS.

  2. Create a Namespace (optional)

    kubectl create namespace ingress-nginx
    
  3. Create an SSL Certificate Secret

    Convert your SSL certificate and key into a Kubernetes secret:

    kubectl create secret tls <secret-name> --cert=<path-to-cert> --key=<path-to-key> -n ingress-nginx
    

    Replace <secret-name>, <path-to-cert>, and <path-to-key> with your secret name and the path to your certificate and key files.

  4. Create an Ingress Resource

    Define an Ingress resource to route traffic to your application. This Ingress will use the secret created above for TLS termination.

    apiVersion: networking.k8s.io/v1
    kind: Ingress
    metadata:
      name: example-ingress
      namespace: ingress-nginx
      annotations:
        nginx.ingress.kubernetes.io/ssl-redirect: "true"
        nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
    spec:
      tls:
      - hosts:
        - example.com
        secretName: <secret-name>
      rules:
      - host: example.com
        http:
          paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: example-service
                port:
                  number: 80
    

    Replace example.com with your domain, example-service with your Kubernetes service name, and <secret-name> with the name of the secret you created.

  5. Configure Ingress Controller Service

    Ensure the Ingress controller service is listening on port 9443. Edit the service to reflect this:

    kubectl edit svc <nginx-ingress-controller-service-name> -n ingress-nginx
    

    Change the ports section to include port 9443:

    ports:
    - name: https
      port: 9443
      targetPort: 8443
    
  6. Verify the Configuration

    Ensure that the Ingress controller is properly routing traffic to your application on port 9443. You can test it using curl:

    curl -k https://example.com:9443
    

    The -k flag is used to skip SSL verification if using a self-signed certificate.

Notes

  • Ensure your DNS is correctly configured to point to your Ingress controller's external IP.
  • If you are using a cloud provider's Ingress controller, the setup might vary slightly based on the provider's requirements and configurations.
  • You can also use Let's Encrypt for SSL certificates and automate the process using cert-manager.

By following these steps, you can configure Kubernetes Ingress to handle HTTPS traffic on port 9443.

댓글

이 블로그의 인기 게시물

PYTHONPATH, Python 모듈 환경설정

You can use Sublime Text from the command line by utilizing the subl command

git 명령어

[gRPC] server of Java and client of Typescript

[Ubuntu] Apache2.4.x 설치

Create topic on Kafka with partition count, 카프카 토픽 생성하기

리눅스의 부팅과정 (프로세스, 서비스 관리)

Auto-populate a calendar in an MUI (Material-UI) TextField component

The pierce selector in Puppeteer