Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/kubernetes/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
基于GKE的Kubernetes-Django框架_Django_Kubernetes_Django Rest Framework_Google Kubernetes Engine_Gke Networking - Fatal编程技术网

基于GKE的Kubernetes-Django框架

基于GKE的Kubernetes-Django框架,django,kubernetes,django-rest-framework,google-kubernetes-engine,gke-networking,Django,Kubernetes,Django Rest Framework,Google Kubernetes Engine,Gke Networking,我试图通过外部ip从负载平衡器获得访问权限。但我无法通过该ip连接到我的浏览器 我在80端口的连接被拒绝了。我不知道我的yaml文件是否不正确,或者它是负载平衡器上的配置 我用我的requirements.txt成功地构建了我的docker映像,并将其从GKE加载到bucket中,以将docker映像拉入Kubernetes 我使用以下命令部署了映像: kubectl创建-f.yaml 使用以下yaml文件: # [START kubernetes_deployment] apiVersion:

我试图通过外部ip从负载平衡器获得访问权限。但我无法通过该ip连接到我的浏览器

我在80端口的连接被拒绝了。我不知道我的yaml文件是否不正确,或者它是负载平衡器上的配置

我用我的requirements.txt成功地构建了我的docker映像,并将其从GKE加载到bucket中,以将docker映像拉入Kubernetes

我使用以下命令部署了映像:
kubectl创建-f.yaml

使用以下yaml文件:

# [START kubernetes_deployment]
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: example
  labels:
    app: example
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: example
    spec:
      containers:
      - name: faxi
        image: gcr.io/<my_id_stands_here>/<bucketname>
        command: ["python3", "manage.py", "runserver"]
        env:
            # [START cloudsql_secrets]
            - name: DATABASE_USER
              valueFrom:
                secretKeyRef:
                  name: cloudsql
                  key: username
            - name: DATABASE_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: cloudsql
                  key: password
            # [END cloudsql_secrets]
        ports:
        - containerPort: 8080

      # [START proxy_container]
      - image: b.gcr.io/cloudsql-docker/gce-proxy:1.05
        name: cloudsql-proxy
        command: ["/cloud_sql_proxy", "--dir=/cloudsql",
                  "-instances=<I put here my instance name inside>",
                  "-credential_file=<my_credential_file"]
        volumeMounts:
          - name: cloudsql-oauth-credentials
            mountPath: /secrets/cloudsql
            readOnly: true
          - name: ssl-certs
            mountPath: /etc/ssl/certs
          - name: cloudsql
            mountPath: /cloudsql
      # [END proxy_container] 
      # [START volumes]
      volumes:
        - name: cloudsql-oauth-credentials
          secret:
            secretName: cloudsql-oauth-credentials
        - name: ssl-certs
          hostPath:
            path: /etc/ssl/certs
        - name: cloudsql
          emptyDir:
      # [END volumes]        
# [END kubernetes_deployment]

---

# [START service]
apiVersion: v1
kind: Service
metadata:
  name: example
  labels:
    app: example
spec:
  type: LoadBalancer
  ports:
  - port: 80
    targetPort: 8080
  selector:
    app: example
# [END service]

使用
kubectl获得服务

NAME         TYPE           CLUSTER-IP      EXTERNAL-IP     PORT(S)        AGE
example      LoadBalancer   10.xx.xxx.xxx   34.xx.xxx.xxx   80:30833/TCP   21h
kubernetes   ClusterIP      10.xx.xxx.x     <none>          443/TCP        23h
但我无法通过curl或浏览器连接到restapi 我尝试连接到
:80
,并在该端口上获得
连接被拒绝

我用Nmap扫描了外部ip,它显示端口80已关闭。但我不确定这是否是原因。 我的nmap输出:

PORT     STATE  SERVICE
80/tcp   closed http
554/tcp  open   rtsp
7070/tcp open   realserver

感谢您的帮助,伙计们请创建一个入口防火墙规则,允许所有节点通过端口30833进行通信,因为它应该可以解决问题

你在哪里运行了nmap命令?在pod部署的模式下?嘿,我将远程笔记本电脑映射到外部IP
nmap:
你可以使用Kube代理,并检查它是否在网络内工作。在容器中,我看到2/2您运行的是特使代理还是istio?我两者都不使用。我只使用Django、Django Restframework、cloudsql、GKE、docker和kubectl。我的第二个罐子只是原始罐子的复制品。如果我运行kubectl proxy*,我就能够连接到Kubernetes API。我使用了这个原因*kubectl代理给了我开始服务于127.0.0.1:8001的

Name:                     example
Namespace:                default
Labels:                   app=example
Annotations:              <none>
Selector:                 app=example
Type:                     LoadBalancer
IP:                       10.xx.xxx.xxx
LoadBalancer Ingress:     34.xx.xxx.xxx
Port:                     <unset>  80/TCP
TargetPort:               8080/TCP
NodePort:                 <unset>  30833/TCP
Endpoints:                10.xx.x.xx:8080
Session Affinity:         None
External Traffic Policy:  Cluster
Events:                   <none>
PORT     STATE  SERVICE
80/tcp   closed http
554/tcp  open   rtsp
7070/tcp open   realserver