代码之家  ›  专栏  ›  技术社区  ›  Leonel Matias Domingos

多容器吊舱中的连接被拒绝

  •  0
  • Leonel Matias Domingos  · 技术社区  · 3 年前

    我试图将docker compose配置移植到kubernetes,但我得到了“ connection refused while connect to upstream ....upstream:fastcgi://127.0.0.1:9000 " 容器已启动并运行,服务nginx负载均衡器可用,但mysql和php-fpm无法从nginx容器访问。

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      labels:
        app: app
      name: web
      namespace: default
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: app
      strategy:
        type: Recreate
      template:
        metadata:
          labels:
            app: app
        spec:
          containers:
          - name : mysql
            env:
              - name: MYSQL_DATABASE
                value: sylius
              - name: MYSQL_PASSWORD
                value: nopassword
              - name: MYSQL_ROOT_PASSWORD
                value: nopassword
              - name: MYSQL_USER
                value: sylius
            image : mysql
    
            volumeMounts:  
            - mountPath: "/srv/sylius"
              name: www-data
           
            ports:
            - containerPort: 3306
              name: http
              protocol: TCP
            resources: {}
            
              
          - name: sylius-php-fpm
            image: licass/my_sylius_php:latest
            imagePullPolicy: Never
            ports:
            - containerPort: 9000
              name: http
              protocol: TCP
            volumeMounts:
            - name: nginx-config-volume
              mountPath: /etc/nginx/conf.d/default.conf
              subPath: default.conf
            - mountPath: "/srv/sylius"
              name: www-data
    
          - name: sylius-node
            image: licass/my_sylius_node
            imagePullPolicy: Always
            command: [ "sleep" ]
            args: [ "infinity" ]
            volumeMounts:  
            - mountPath: "/srv/sylius"
              name: www-data
    
          - name: nginx
            image: nginx:alpine
            imagePullPolicy: Always
            ports:
            - containerPort: 80
              name: http
              protocol: TCP
            volumeMounts:
            - name: nginx-config-volume
              mountPath: /etc/nginx/conf.d/default.conf
              subPath: default.conf
            - mountPath: "/srv/sylius"
              name: www-data
          restartPolicy: Always
          serviceAccountName: ""
          
          initContainers:
          - name: git-cloner
            image: alpine/git
            args:
                - clone
                - --single-branch
                - --
                - https://github.com/Sylius/Sylius-Standard.git
                - /data
            volumeMounts:
            - mountPath: /data
              name: www-data
          
          volumes:         
          - name: nginx-config-volume
            configMap:
              name: nginx-config
          - name: www-data
            emptyDir: {}   
    

    我刚开始学习kubernetes,还不知道如何在pod中建立网络。 提前感谢。

    0 回复  |  直到 3 年前
        1
  •  0
  •   Wytrzymały Wiktor rohatgisanat    3 年前

    如文件所述 here :

    在Pod内部(只有在那时),属于Pod的容器 可以使用localhost相互通信