Pth*_*ota 6 kubernetes google-kubernetes-engine nginx-ingress
我在命名空间(Google Kubernetes Engine)中使用带有外部 IP 的 nginx 入口。现在,我想使用 nginx ingress内部服务从 VPC 网络内的集群外部调用该服务。请建议我如何实现这一目标。
假设您使用ingress-nginx ,那么您可以按照其安装指南页面上的步骤操作
您需要先将上下文指向集群(按照本指南kubectl
进行设置),然后才能执行以下命令:
kubectl create clusterrolebinding cluster-admin-binding \
--clusterrole cluster-admin \
--user $(gcloud config get-value account)
Run Code Online (Sandbox Code Playgroud)使用以下步骤部署ingress-nginx
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-0.32.0/deploy/static/provider/cloud/deploy.yaml
Run Code Online (Sandbox Code Playgroud)使用LoadBalancer
带有注释的服务cloud.google.com/load-balancer-type: "Internal"
。这将在您的 VPC 中生成一个内部 ILB
apiVersion: v1
kind: Service
metadata:
name: ingress-nginx-ilb-service
namespace: ingress-nginx
annotations:
cloud.google.com/load-balancer-type: "Internal"
labels:
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/instance: ingress-nginx
app.kubernetes.io/component: controller
spec:
type: LoadBalancer
selector:
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/instance: ingress-nginx
app.kubernetes.io/component: controller
ports:
- name: http
port: 80
protocol: TCP
targetPort: http
- name: https
port: 443
protocol: TCP
targetPort: https
Run Code Online (Sandbox Code Playgroud)应用此服务清单后,您的 ILB 内部 IP 将在几分钟内可用
归档时间: |
|
查看次数: |
16714 次 |
最近记录: |