无法使用自定义域访问入口网关

时间:2020-02-06 15:06:24

标签: kubernetes istio

我是istio的新手。我已经在ionos在线服务器上安装了kubernetes。 我能够成功部署示例应用程序,并能够通过在浏览器中提供INGRESS_HOST:INGRESS_PORT来对其进行浏览。

请单击以下链接以查看我的入口负载均衡器的详细信息 load balancer

我无法使用例如example.com的域名进行浏览

我是否必须安装另一个负载均衡器,它将example.com重定向到特定的INGRESS_HOST:INGRESS_PORT(因为example.com在端口80上正在访问,而INGRESS_PORT是不同的)

任何帮助将不胜感激。 谢谢

# project_service.yaml
apiVersion: v1
kind: Service
metadata:
  name: php
  namespace: default
  labels:
    tier: backend
spec:
  selector:
    app: php
    tier: backend
  ports:
    - protocol: TCP
      port: 9000

# project_deployment
apiVersion: apps/v1
kind: Deployment
metadata:
  name: php
  namespace: default
  labels:
    tier: backend
spec:
  replicas: 1
  selector:
    matchLabels:
      app: php
      tier: backend
  template:
    metadata:
      labels:
        app: php
        tier: backend
    spec:
      volumes:
      - name: dir
        hostPath:
          path: /code
      containers:
      - name: php
        image: some_image
        imagePullPolicy: Never
        volumeMounts:
        - name: dir
          mountPath: /code
        env:
        - name: APP_NAME
          value: "Test"
        #- and so on ...       
      initContainers:
      - name: install
        image: busybox
        volumeMounts:
        - name: dir
          mountPath: /code
        command:
        - cp
        - "-r"
        - "/var/www/."
        - "/code/app"

# nginx_configMap

apiVersion: v1
kind: ConfigMap
metadata:
  name: nginx-config
  namespace: default  
  labels:
    tier: backend
data:
  config : |
    server {
      index index.php index.html;
      error_log  /var/log/nginx/error.log;
      access_log /var/log/nginx/access.log;
      
      root /code/app;

      location / {
          try_files $uri $uri/ /index.php?$query_string;
      }
      
      location ~ .php$ {
          try_files $uri =404;
          fastcgi_split_path_info ^(.+.php)(/.+)$;
          fastcgi_pass php:9000;
          fastcgi_index index.php;
          include fastcgi_params;
          fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
          fastcgi_param PATH_INFO $fastcgi_path_info;
      }
    }

# nginx_service
kind: Service
apiVersion: v1
metadata:
  name: nginx
  namespace: default    
  labels:
    tier: backend
    app: nginx
spec:
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
      #nodePort: 32380
  selector:
    tier: backend
    app: nginx
  type: LoadBalancer

# nginx_Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx
  namespace: default    
  labels:
    tier: backend
    app: nginx
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
      tier: backend
  template:
    metadata:
      labels:
        app: nginx
        tier: backend
    spec:
      volumes:
      - name: dir
        hostPath:
          path: /code
      - name: config
        configMap:
          name: nginx-config
          items:
          - key: config
            path: site.conf
      containers:
      - name: nginx
        image: nginx
        volumeMounts:
        - name: dir
          mountPath: /code
        - name: config
          mountPath: /etc/nginx/conf.d
        ports:
        - containerPort: 80
          name: http
          protocol: TCP

kind: Service
apiVersion: v1
metadata:
  name: nginx
  namespace: default    
  labels:
    tier: backend
    app: nginx
spec:
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
      #nodePort: 32380
  selector:
    tier: backend
    app: nginx
  type: LoadBalancer

以下视频介绍了这种部署方式 https://www.youtube.com/watch?v=8e0vtNO-T_I

0 个答案:

没有答案