Kubernetes(K8S)(八)——ingress服务部署、会话保持和TLS配置

本文介绍了Kubernetes Ingress,包括其作为全局负载均衡服务的作用,以及Ingress Controller的工作原理。详细阐述了Ingress服务的部署过程,展示了创建Ingress服务的示例,并探讨了通过HostNetwork直接访问服务的方法,强调了其在大并发环境中的优势。同时,文章还讲解了如何实现Ingress的会话保持和TLS配置,提供了相关官方参考链接。
摘要由CSDN通过智能技术生成

1.Ingress介绍

官网参考:https://kubernetes.github.io/ingress-nginx/

Ingress是一种全局的、为了代理不同后端 Service 而设置的负载均衡服务,就是 Kubernetes 里的 Ingress 服务。

Ingress由两部分组成:Ingress controller和Ingress服务。
Ingress Controller 会根据你定义的 Ingress 对象,提供对应的代理能力。业界常用的各 种反向代理项目,比如 Nginx、HAProxy、Envoy、Traefik 等,都已经为Kubernetes 专门维护了对应的 Ingress Controller。

在这里插入图片描述


2. ingress服务部署

参考官网:https://kubernetes.github.io/ingress-nginx/deploy/#bare-metal
wget https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/provider/baremetal/deploy.yaml
下载所需的镜像到镜像仓库

[root@harbor ~]# docker pull quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.33.0
[root@harbor ~]# docker pull docker.io/jettech/kube-webhook-certgen:v1.2.0
[root@harbor ~]# docker tag quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.33.0 reg.red.org/library/nginx-ingress-controller:0.33.0
[root@harbor ~]# docker tag docker.io/jettech/kube-webhook-certgen:v1.2.0 reg.red.org/library/kube-webhook-certgen:v1.2.0
[root@harbor ~]# docker push reg.red.org/library/nginx-ingress-controller:0.33.0
[root@harbor ~]# docker push reg.red.org/library/kube-webhook-certgen:v1.2.0

在这里插入图片描述在这里插入图片描述

kubectl get all -n ingress-nginx 查看ingress-nginx下的所有信息资源
kubectl get pod -n ingress-nginx -o wide 查看pod运行在那些节点
kubectl get svc -n ingress-nginx 获取到端口 31181
kubectl describe svc -n ingress-nginx ingress-nginx-controller 查看服务详细信息

[kubeadm@server1 mainfest]$ kubectl apply -f deploy.yaml 
namespace/ingress-nginx created
serviceaccount/ingress-nginx created
configmap/ingress-nginx-controller created
clusterrole.rbac.authorization.k8s.io/ingress-nginx created
clusterrolebinding.rbac.authorization.k8s.io/ingress-nginx created
role.rbac.authorization.k8s.io/ingress-nginx created
rolebinding.rbac.authorization.k8s.io/ingress-nginx created
service/ingress-nginx-controller-admission created
service/ingress-nginx-controller created
deployment.apps/ingress-nginx-controller created
validatingwebhookconfiguration.admissionregistration.k8s.io/ingress-nginx-admission created
clusterrole.rbac.authorization.k8s.io/ingress-nginx-admission created
clusterrolebinding.rbac.authorization.k8s.io/ingress-nginx-admission created
job.batch/ingress-nginx-admission-create created
job.batch/ingress-nginx-admission-patch created
role.rbac.authorization.k8s.io/ingress-nginx-admission created
rolebinding.rbac.authorization.k8s.io/ingress-nginx-admission created
serviceaccount/ingress-nginx-admission created
[kubeadm@server1 mainfest]$ kubectl get namespaces 
NAME              STATUS   AGE
default           Active   7d18h
ingress-nginx     Active   35s
kube-node-lease   Active   7d18h
kube-public       Active   7d18h
kube-system       Active   7d18h
[kubeadm@server1 mainfest]$ kubectl get pod -n ingress-nginx 
NAME                                        READY   STATUS      RESTARTS   AGE
ingress-nginx-admission-create-xfcsd        0/1     Completed   0          57s
ingress-nginx-admission-patch-k9dcm         0/1     Completed   0          57s
ingress-nginx-controller-77b5fc5746-dq7hn   1/1     Running     0          67s
[kubeadm@server1 mainfest]$ kubectl get svc -n ingress-nginx 
NAME                                 TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                      AGE
ingress-nginx-controller             NodePort    10.100.163.143   <none>        80:31904/TCP,443:32203/TCP   2m21s
ingress-nginx-controller-admission   ClusterIP   10.101.228.137   <none>        443/TCP                      2m21s
[kubeadm@server1 mainfest]$ kubectl describe svc -n ingress-nginx ingress-nginx-controller
Name:                     ingress-nginx-controller
Namespace:                ingress-nginx
Labels:                   app.kubernetes.io/component=controller
                          app.kubernetes.io/instance=ingress-nginx
                          app.kubernetes.io/managed-by=Helm
                          app.kubernetes.io/name=ingress-nginx
                          app.kubernetes.io/version=0.33.0
                          helm.sh/chart=ingress-nginx-2.9.0
Annotations:              Selector:  app.kubernetes.io/component=controller,app.kubernetes.io/instance=ingress-nginx,app.kubernetes.io/name
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值