容器相关
非root用户Docker与K8S
Containerd安装
Containerd常用命令
Docker
镜像创建
国内镜像仓库
容器创建(Dockerfile)
容器系统
docker配置
docker数据管理
docker网络管理
docker容器自启动
docker镜像加速
docker问题
搭建Portainer可视化界面
Docker Swarm
Swarm搭建Docker集群
Docker Compose
Docker Compose命令
Docker Compose模板
Docker Machine
Kubernetes常用命令
k8s部署(kubeadmin)
k8s高可用部署
MiniKube
k8s1.24部署(containerd)
k8s1.24部署(docker)
部署 Dashboard
Kuboard K8S管理台
k8s权限管理
k8s网络插件
私有仓密码镜像拉取
k8s集群管理
POD--基本单位
Pod模板
Pod生命周期
Pod健康检查
初始化容器(initContainer)
Deployment--Pod的管理
Deployment模板
Deployment升级与回滚
DaemonSet控制器
StatefulSet控制器(有状态)
JOB与CRONJOB
Service--发布服务
ingress-traefix
ingress-nginx
MetalLB
存储与配置
持久存储卷
配置存储卷
资源管理
标签、选择器与注解
资源预留
调度管理
自动扩容
Proxy API与API Server
Helm--K8S的包管理器
helm常用命令
自定义Chart
私有chart仓库
helm dashboard
K8S证书过期
K8S问题解决
Harbor安装
Harbor操作
Harbor问题
Harbor升级
Docker Registry安装
Docker Registry鉴权
Registry用Nginx代理SSL及鉴权
Docker Registry问题
Istio 服务网络
常用示例
Gateway【服务网关】
kiali 可视化页面
开启HTTPS
linkerd 服务网络
本文档使用MrDoc发布
返回首页
-
+
ingress-traefix
2021年8月11日 16:31
admin
#官方ingress https://kubernetes.io/docs/concepts/services-networking/ingress/ https://kubernetes.github.io/ingress-nginx/ #Traefik https://zhuanlan.zhihu.com/p/105239989 --- #安装traefik ##创建traefik的rbac权限 kubectl apply -f https://raw.githubusercontent.com/containous/traefik/v1.7/examples/k8s/traefik-rbac.yaml --- ##安装:二选一 ####DaemonSet版本 kubectl apply -f https://raw.githubusercontent.com/containous/traefik/v1.7/examples/k8s/traefik-ds.yaml ####或 kubectl apply -f https://raw.githubusercontent.com/containous/traefik/v1.7/examples/k8s/traefik-deployment.yaml --- ##注意:traefik会在每个node节点上暴露80端口矣提供服务,DaemonSet版本用Pod的HostPort进行暴露,Deployment版本会用Service的NodePort进行暴露。 --- #操作 ##创建示例Deployment apiVersion: apps/v1 kind: Pod metadata: name: exampledeploymentnginx spec: replicas: 1 selector: matchLabels: example: deploymentfornginx template: metadata: labels: example: deploymentfornginx spec: containers: - name: nginx image: nginx: 1.7.9 ports: - containerPort: 80 --- apiVersion: apps/v1 kind: Pod metadata: name: exampledeploymenthttpd spec: replicas: 1 selector: matchLabels: example: deploymentforhttpd template: metadata: labels: example: deploymentforhttpd spec: containers: - name: httpd image: httpd:2.2 ports: - containerPort: 80 --- ##创建对应的示例Service apiVersion: v1 kind: Service metadata: name: exampleservicenginx spec: selector: example: deploymentfornginx ports: - protocol: TCP port: 8081 targetPort: 80 --- apiVersion: v1 kind: Service metadata: name: exampleservicehttpd spec: selector: example: deploymentforhttpd ports: - protocol: TCP port: 8081 targetPort: 80 --- ##创建Ingress ###方式一:不使用域名的单个Service apiVersion: extensions/v1beta1 kind: Ingress metadata: name: examplesingleingress annotations: kubernetes.io.ingress.class: traefik spec: backend: serviceName: exampleservicehttpd servicePort: 8081 --- ###测试: curl http://<任意NODEIP>:<Igress服务端口> --- ###方式二:基于域名划分多个子路径 apiVersion: extensions/v1beta1 kind: Ingress metadata: name: examplesingleingress annotations: kubernetes.io.ingress.class: traefik traefik.frontend.rule.type: PatePrefixStrip spec: rules: - host: web.testk8s.com http: paths: - path: /httpdservice backend: serviceNmae: exampleservicehttpd servicePort: 8081 - path: /nginxservice backend: serviceName: exampleservicenginx servicePort: 8081 --- ###测试: curl http://web.testk8s.com/httpdservice curl http://web.testk8s.com/nginxservice --- ###方式三:基于多域名 apiVersion: extensions/v1beta1 kind: Ingress metadata: name: examplesingleingress annotations: kubernetes.io.ingress.class: traefik spec: rules: - host: web.testk8shttpd.com http: paths: - backend: serviceNmae: exampleservicehttpd servicePort: 8081 - host: web.testk8snginx.com http: paths: - backend: serviceName: exampleservicenginx servicePort: 8081 --- ###测试 curl http://web.testk8shttpd.com curl http://web.testk8snginx.com ---
分享到: