[goole-gke]nginx-ingress建立测试

2021/11/28 7:13:04

本文主要是介绍[goole-gke]nginx-ingress建立测试,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

1、google账号选择

gcloud init

# 注需要googlecloud权限

2、链接对应gke集群

gcloud container clusters get-credentials <集群名> --zone <地区> --project <项目>

3、helm安装

curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3

helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx

3、建立静态账号

gcloud compute addresses create ingress-test-static-ip-address

4、建立namespace

cat ingress-namespace.yaml
apiVersion: v1
kind: Namespace
metadata:
  name: ingress-nginx
# 执行  
kubectl create -f ingress-namespace.yaml

  

5、静态IP启动service和ingress

helm install nginx-ingress ingress-nginx/ingress-nginx --namespace ingress-nginx --set controller.service.loadBalancerIP=<静态IP>

6、测试ingress

cat ingress-resource.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-hello
  annotations:
    kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/ssl-redirect: "false"
spec:
  rules:
  - host: "k8s-hello.k8s123.com"
    http:
      paths:
      - pathType: Prefix
        path: "/hello"
        backend:
          service:
            name: hello-app
            port:
              number: 8080
			  
kubectl apply -f ingress-resource.yaml  

访问:

http://k8s-hello.k8s123.com/hello



这篇关于[goole-gke]nginx-ingress建立测试的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程