简介
本章主要是讲解kubernetes的 gateway Api 部署所需要用到的控制权,isito是gateway Api众多控制中更新最快,兼容最新gateway Api最新版本最快的,在安装gateway Api之前需要先安装部署gateway控制权。
== 文章导航===
【k8s-1.34.2安装部署】一.系统初始化及k8s集群规划
【k8s-1.34.2安装部署】二.kubernets软件、证书、配置、脚本等文件准备
【k8s-1.34.2安装部署】三.etcd-v3.6.6 TLS版集群安装
【k8s-1.34.2安装部署】四.kubernets master组件kube-apiserver,kube-controller-manager,kube-scheduler安装
【k8s-1.34.2安装部署】五.worker端containerd2.2.1、kubelet-1.34.2安装
【k8s-1.34.2安装部署】六.企业级部署cilium-1.18.4网络插件
【k8s-1.34.2安装部署】七.coredns-v1.13.1安装
【k8s-1.34.2安装部署】八.metric-server-0.8.0安装
【k8s-1.34.2安装部署】九.k8s管理平台xkube安装部署
【k8s-1.34.2安装部署】十.gateway Api v1.4.0安装
【k8s-1.34.2安装部署】十一.metallb-v0.15.2安装
一.istio安装
第一步:安装客户端
1.从https://github.com/istio/istio/releases下载二进制文件放到/usr/local/bin下
2.验证: istioctl version
第二步:执行命令:
istioctl install --set profile=ambient --set components.cni.enabled=false --skip-confirmation
二.gateway api 安装
试验版:
kubectl apply --server-side -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.4.1/experimental-install.yaml正式版:
kubectl apply --server-side -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.4.1/standard-install.yaml
==注:试验版本才会包含tcproute和udproute==
三.示例创建
3.1.创建gateway的示例:
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: my-gateway
spec:
gatewayClassName: istio
listeners:
- name: http
protocol: HTTP
port: 80
3.2.创建httproute示例
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: my-httproute2
spec:
parentRefs:
- name: my-gateway
hostnames:
- "t2.eeenet.net"
rules:
- matches:
- path:
type: PathPrefix
value: /t2
backendRefs:
- name: my-deployment
port: 80
- matches:
- headers:
- type: Exact
name: env
value: test
backendRefs:
- name: one-deployment
port: 80
3.3.创建grpcroute示例
apiVersion: gateway.networking.k8s.io/v1
kind: GRPCRoute
metadata:
name: my-grpcroute
spec:
parentRefs:
- name: my-gateway
hostnames:
- "t3.pc.com.cn"
rules:
- matches:
- method:
service: com.example.User
method: Login
backendRefs:
- name: my-deployment
port: 80
- matches:
- method:
service: grpc.reflection.v1.ServerReflection
backendRefs:
- name: one-deployment
port: 80
3.4.创建tcproute示例
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: my-tcp-gateway
spec:
gatewayClassName: istio
listeners:
- name: memcached-t1
protocol: TCP
port: 11211
allowedRoutes:
kinds:
- kind: TCPRoute
- name: redis-t1
protocol: TCP
port: 6379
allowedRoutes:
kinds:
- kind: TCPRoute
---
apiVersion: gateway.networking.k8s.io/v1alpha2
kind: TCPRoute
metadata:
name: memcached-t1-tcproute
spec:
parentRefs:
- name: my-tcp-gateway
sectionName: memcached-t1
rules:
- backendRefs:
- name: memcached-t1-service
port: 11211
---
apiVersion: gateway.networking.k8s.io/v1alpha2
kind: TCPRoute
metadata:
name: redis-t1-tcproute
spec:
parentRefs:
- name: my-tcp-gateway
sectionName: redis-t1
rules:
- backendRefs:
- name: redis-t1-service
port: 6379
3.5.创建udproute示例
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: my-udp-gateway
namespace: kube-system
spec:
gatewayClassName: istio
listeners:
- name: udp-t1
protocol: UDP
port: 53
allowedRoutes:
kinds:
- kind: UDPRoute
---
apiVersion: gateway.networking.k8s.io/v1alpha2
kind: UDPRoute
metadata:
name: dns-t1-udproute
namespace: kube-system
spec:
parentRefs:
- name: my-udp-gateway
sectionName: udp-t1
rules:
- backendRefs:
- name: kube-dns
port: 53
三.注意事项
3.1.镜像下载失败问题
istio-cni-node: docker.io/istio/install-cni:1.28.0-distroless
ztunnel: docker.io/istio/ztunnel:1.28.0-distroless
istiod: docker.io/istio/pilot:1.28.0-distroless
对应可以下载的镜像地址:
docker.1panel.live/istio/install-cni:1.28.0-distroless
docker.1panel.live/istio/ztunnel:1.28.0-distroless
docker.1panel.live/istio/pilot:1.28.0-distroless
可以下载完上传到自己的镜像站