上次面试被问到Ingress 一脸懵逼 -_-||,这回学习记录一下。

simple architecture of ingress in k8s:

在这里插入图片描述

create ingress controller

To create the ingress controller, use Helm to install nginx-ingress. For added redundancy, two replicas of the NGINX ingress controllers are deployed with the --set controller.replicaCount parameter. To fully benefit from running replicas of the ingress controller, make sure there’s more than one node in your AKS cluster.
在这里插入图片描述

When the Kubernetes load balancer service is created for the NGINX ingress controller, a dynamic public IP address is assigned, as shown in the following example output:

在这里插入图片描述

在这里插入图片描述

No ingress rules have been created yet, so the NGINX ingress controller’s default 404 page is displayed if you browse to the internal IP address.
在这里插入图片描述

config DNS:
For the HTTPS certificates to work correctly, configure an FQDN for the ingress controller IP address.
在这里插入图片描述
install cert-manager which provides automatic Lets Encrypt certificate generation and management functionality.:

kubectl label namespace kube-system certmanager.k8s.io/disable-validation=true

kubectl apply
-f https://raw.githubusercontent.com/jetstack/cert-manager/release-0.6/deploy/manifests/00-crds.yaml

helm install stable/cert-manager
–namespace kube-system
–set ingressShim.defaultIssuerName=letsencrypt-staging
–set ingressShim.defaultIssuerKind=ClusterIssuer
–set rbac.create=false
–set serviceAccount.create=false
–version v0.6.0

create a CA cluster issuer:

在这里插入图片描述

create demo app:

add the Azure samples repository to your Helm environment
Create the first demo application from a Helm chart
在这里插入图片描述

Now install a second instance of the demo application. For the second instance, you specify a new title so that the two applications are visually distinct. You also specify a unique service name

在这里插入图片描述

create ingress route:

Both applications are now running on your Kubernetes cluster. To route traffic to each application, create a Kubernetes ingress resource. The ingress resource configures the rules that route traffic to one of the two applications.

https://sjhdemo-aks-ingress.eastus.cloudapp.azure.com/ is routed to the service named aks-helloworld. Traffic to the address https://sjhdemo-aks-ingress.eastus.cloudapp.azure.com/hello-world-two is routed to the ingress-demo service.

在这里插入图片描述

create a certificate object:

The certificate resource defines the desired X.509 certificate.

Cert-manager has likely automatically created a certificate object for you using ingress-shim, which is automatically deployed with cert-manager since v0.2.2.

kubectl describe certificate tls-secret
在这里插入图片描述
otherwise you can create your own certificate

test ingress configuration
Open a web browser to the FQDN of your Kubernetes ingress controller

As these examples use letsencrypt-staging, the issued SSL certificate is not trusted by the browser. Accept the warning prompt to continue to your application. The certificate information shows this Fake LE Intermediate X1 certificate is issued by Let’s Encrypt. This fake certificate indicates cert-manager processed the request correctly and received a certificate from the provider:

在这里插入图片描述

then browse https://sjhdemo-aks-ingress.eastus.cloudapp.azure.com/hello-world-two.

在这里插入图片描述

Egress

when you app need to be whistlisted and loadbalancer of Serivce 's lifecycle is following app of Service,a static IP with Service and Egress:

在这里插入图片描述

This service configures a new frontend IP on the Azure Load Balancer.

check ip by :
curl -s checkip.dyndns.org

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐