Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Jasper Rodda
Jasper Rodda

Posted on • Edited on

     

Install Ingress on Kubernetes and Minikube

Kubernetesingress was introduced to overcome short comings of services. Another version of Kubernetes such asOpenshift created similar ingress such asRoutes.

Kubernetes Service - Drawbacks

  1. Missing Enterprise Grade Load Bancing Capabilities.
  2. Driving Cloud Cost - for Public IP Address

Kubernetes service [svc] of type=[LoadBalancer] does not support enterprise grade Loadbancing capabilities but rather simple round robin fashion.

To Solve this problem Kubernetes have asked Enterprise Load Balancers such as (F5, NGINX, Ambassador, HA Proxy to name a few) to createIngress Controllers and user to create a Ingress resources. Its user's responsibilities

Enterprise Load Balancer Offers Advanced Capabilities

  • Ratio Based Routing
  • Sticky Session Routing
  • Host Based
  • Path Based
  • Domain Based
  • White listing IP Addresses
  • Black Listing IP Addresses

1. Install NGINX controller in Kubernetes.

  • minikube addons enable ingressto install onMinikube
  • VerifyIngress Controller installed or not
$minikube addons enable ingress* ingress is an addon maintained by Kubernetes. For any concerns contact minikube on GitHub.You can view the list of minikube maintainers at: https://github.com/kubernetes/minikube/blob/master/OWNERS  - Using image registry.k8s.io/ingress-nginx/controller:v1.8.1  - Using image registry.k8s.io/ingress-nginx/kube-webhook-certgen:v20230407  - Using image registry.k8s.io/ingress-nginx/kube-webhook-certgen:v20230407* Verifying ingress addon...* The 'ingress' addon is enabled
Enter fullscreen modeExit fullscreen mode
  • verify by following commandkubectl get pods -A | grep nginx
PS C:\Users\Jasper\OneDrive\Documents\CodeRepo\kubernetes\d38_ingress_ctrl> kubectl get pods -ANAMESPACE       NAME                                        READY   STATUS      RESTARTS       AGEdefault         sample-python-deployment-5787bd6b9f-656fn   1/1     Running     1 (16h ago)    20hdefault         sample-python-deployment-5787bd6b9f-t9ttj   1/1     Running     1 (16h ago)    20hingress-nginx   ingress-nginx-admission-create-vcq7w        0/1     Completed   0              132mingress-nginx   ingress-nginx-admission-patch-g6szm         0/1     Completed   1              132mingress-nginx   ingress-nginx-controller-7799c6795f-qc9w5   1/1     Running     0              132mkube-system     coredns-5d78c9869d-nscfc                    1/1     Running     3 (16h ago)    12dkube-system     etcd-minikube                               1/1     Running     3 (16h ago)    12dkube-system     kube-apiserver-minikube                     1/1     Running     3 (16h ago)    12dkube-system     kube-controller-manager-minikube            1/1     Running     3 (16h ago)    12dkube-system     kube-proxy-gzk52                            1/1     Running     3 (16h ago)    12dkube-system     kube-scheduler-minikube                     1/1     Running     3 (16h ago)    12dkube-system     storage-provisioner                         1/1     Running     12 (69m ago)   12d
Enter fullscreen modeExit fullscreen mode

2. Create Ingress Resource in Kubernetes.

  • Routefoo.bar.com to IP Addresses -- _(To mock it in local, in real time - we do not need to mock is as IP address is mapped to Domain Name by DNS) _
  • Belowingress.yml file is to routefoo.bar.com to Servicesample-python-service
apiVersion: networking.k8s.io/v1kind: Ingressmetadata:  name: sample-python-service-ingressspec:  rules:  - host: "foo.bar.com"    http:      paths:      - pathType: Prefix        path: "/bar"        backend:          service:            name: sample-python-service            port:              number: 80
Enter fullscreen modeExit fullscreen mode
  • CreateIngress resourcekubectl apply -f ingress.yml
  • Notice: Nothing happens if you don't install kubernetes controller. Controller will watch for this resource to be created and they applies the logic.
$ kubectl apply -f ingress.ymlingress.networking.k8s.io/sample-python-service-ingress created
Enter fullscreen modeExit fullscreen mode

3. Verify Ingress Resource in Kubernetes.

  • Run commandkubectl get ingress to viewingress resource
kubectl get ingressNAME                            CLASS   HOSTS         ADDRESS          PORTS   AGEsample-python-service-ingress   nginx   foo.bar.com   192.168.59.105   80      6m35s
Enter fullscreen modeExit fullscreen mode

3. Route domain toIngress

  • LocateHosts File and updateconfig to point domain namefoo.bar.com to createdingress-service --> which points toservice
  • Where is the Hosts FileLocated?

The location of the hosts file will differ by operating system. The typical locations are noted below.

Windows 10 - "C:\Windows\System32\drivers\etc\hosts"Linux - "/etc/hosts"Mac OS X - "/private/etc/hosts"
Enter fullscreen modeExit fullscreen mode

4. Verify domain is routed to Application (Ingress-> Service-> App)

Image description

Credits:-
Thanks toAbhishek Veeramalla

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Hey reader, Welcome to my Blog! I am a Cloud DevOps Engineer; I write about configuring & deploying applications on cloud computing platform with focus on CI/CD and DevOps best practices.
  • Location
    Dallas,TX
  • Joined

More fromJasper Rodda

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp