安装Gateway网关
安装
- 本地机器可改为NodePort, 根据实际需要
apiVersion: v1kind: Servicemetadata: name: istio-ingressgateway namespace: istio-ingressspec: type: LoadBalancer #type: NodePort selector: istio: ingressgateway ports: - port: 80 name: http - port: 443 name: https---apiVersion: apps/v1kind: Deploymentmetadata: name: istio-ingressgateway namespace: istio-ingressspec: selector: matchLabels: istio: ingressgateway template: metadata: annotations: # 选择网关注入模板(而不是默认的 Sidecar 模板) inject.istio.io/templates: gateway labels: # 为网关设置唯一标签。这是确保 Gateway 可以选择此工作负载所必需的 istio: ingressgateway # 启用网关注入。如果后续连接到修订版的控制平面,请替换为 `istio.io/rev: revision-name` sidecar.istio.io/inject: "true" spec: # 允许绑定到所有端口(例如 80 和 443) securityContext: sysctls: - name: net.ipv4.ip_unprivileged_port_start value: "0" containers: - name: istio-proxy image: auto # 每次 Pod 启动时,该镜像都会自动更新。 # 放弃所有 privilege 特权,允许以非 root 身份运行 securityContext: capabilities: drop: - ALL runAsUser: 1337 runAsGroup: 1337---# 设置 Role 以允许读取 TLS 凭据apiVersion: rbac.authorization.k8s.io/v1kind: Rolemetadata: name: istio-ingressgateway-sds namespace: istio-ingressrules:- apiGroups: [""] resources: ["secrets"] verbs: ["get", "watch", "list"]---apiVersion: rbac.authorization.k8s.io/v1kind: RoleBindingmetadata: name: istio-ingressgateway-sds namespace: istio-ingressroleRef: apiGroup: rbac.authorization.k8s.io kind: Role name: istio-ingressgateway-sdssubjects:- kind: ServiceAccount name: default- 最佳实践是创建新的命名空间:
kubectl create namespace istio-ingress- 应用部署:
kubectl apply -f ingress.yaml