Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.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
在使用Kubernetes部署YAML文件将Docker映像部署到Google云时,不会创建POD_Kubernetes_Google Cloud Platform_Deployment_Yaml_Microservices - Fatal编程技术网

在使用Kubernetes部署YAML文件将Docker映像部署到Google云时,不会创建POD

在使用Kubernetes部署YAML文件将Docker映像部署到Google云时,不会创建POD,kubernetes,google-cloud-platform,deployment,yaml,microservices,Kubernetes,Google Cloud Platform,Deployment,Yaml,Microservices,我在尝试使用Kubernetes YAML文件在Google云上创建部署时遇到了一个问题。我看到在使用YAML文件时没有创建POD;但是,如果我使用kubectl create deployment…,就会创建吊舱 我的YAML文件如下: #Deployment apiVersion: extensions/v1beta1 kind: Deployment metadata: annotations: generation: 1 labels: app: hello-worl

我在尝试使用Kubernetes YAML文件在Google云上创建部署时遇到了一个问题。我看到在使用YAML文件时没有创建POD;但是,如果我使用
kubectl create deployment…
,就会创建吊舱

我的YAML文件如下:

#Deployment
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  annotations:
  generation: 1
  labels:
    app: hello-world
  name: hello-world
  namespace: default
  resourceVersion: "3691124"
spec:
  progressDeadlineSeconds: 600
  replicas: 3
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: hello-world
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: hello-world
    spec:
      containers:
      - image: myrepo/hello-world:0.0.4.RELEASE
        imagePullPolicy: IfNotPresent
        name: hello-world
        resources: {}
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
#Service
apiVersion: v1
kind: Service
metadata:
  labels:
    app: hello-world
  name: hello-world
  namespace: default
  resourceVersion: "3691877"
spec:
  externalTrafficPolicy: Cluster
  ports:
  - nodePort: 32448
    port: 8080
    protocol: TCP
    targetPort: 8001
  selector:
    app: hello-world
  sessionAffinity: None
  type: LoadBalancer
这是我运行
kubectl get all
时看到的:

NAME                           TYPE           CLUSTER-IP     EXTERNAL-IP    PORT(S)          AGE
service/hello-world            LoadBalancer   Some IP        Some IP 3     8001:32449/TCP    15m
service/kubernetes             ClusterIP      Some IP 2      <none>         444/TCP           12d
名称类型群集IP外部IP端口
服务/hello world负载平衡器一些IP一些IP 3 8001:32449/TCP 15m
服务/kubernetes ClusterIP一些IP 244/TCP 12d
如您所见,启动的唯一资源是服务。我既没有看到任何部署,也没有看到任何正在创建的吊舱

注意出于明显的原因,我已将实际IP地址替换为上面的“某些IP”

问题:为什么在使用YAML时没有创建POD,而在使用
kubectl create deployment
而不是使用YAML配置文件时创建POD

  • 当一个文件中有多个资源时,应该在YAML中使用
    --
  • 您必须在部署中设置apiVersion:apps/v1
  • 输出

    $ kubectl get deply,po,svc
    NAME                          READY   UP-TO-DATE   AVAILABLE   AGE
    deployment.apps/hello-world   0/3     3            0           5m34s
    
    NAME                               READY   STATUS             RESTARTS   AGE
    
    pod/hello-world-6bd8d58486-7lzh9   0/1     ImagePullBackOff   0          3m49s
    pod/hello-world-6bd8d58486-m56rq   0/1     ImagePullBackOff   0          3m49s
    pod/hello-world-6bd8d58486-z9xmz   0/1     ImagePullBackOff   0          3m49s
    
    NAME                  TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)           AGE
    service/hello-world   LoadBalancer   10.108.65.81     <pending>     8080:32448/TCP    3m49s
    service/kubernetes    ClusterIP      10.96.0.1        <none>        443/TCP           9d
    
    $kubectl获得部门、采购订单、svc
    姓名就绪最新可用年龄
    deployment.apps/hello-world 0/3 0 5m34s
    名称就绪状态重新启动
    pod/hello-world-6bd8d58486-7lzh9 0/1图像回撤0 3m49s
    pod/hello-world-6bd8d58486-m56rq 0/1图像回缩0 3m49s
    pod/hello-world-6bd8d58486-z9xmz 0/1图像回缩0 3m49s
    名称类型CLUSTER-IP外部IP端口年龄
    service/hello world LoadBalancer 10.108.65.81 8080:32448/TCP 3m49s
    service/kubernetes ClusterIP 10.96.0.1 443/TCP 9d
    
  • 当一个文件中有多个资源时,应该在YAML中使用
    --
  • 您必须在部署中设置apiVersion:apps/v1
  • 输出

    $ kubectl get deply,po,svc
    NAME                          READY   UP-TO-DATE   AVAILABLE   AGE
    deployment.apps/hello-world   0/3     3            0           5m34s
    
    NAME                               READY   STATUS             RESTARTS   AGE
    
    pod/hello-world-6bd8d58486-7lzh9   0/1     ImagePullBackOff   0          3m49s
    pod/hello-world-6bd8d58486-m56rq   0/1     ImagePullBackOff   0          3m49s
    pod/hello-world-6bd8d58486-z9xmz   0/1     ImagePullBackOff   0          3m49s
    
    NAME                  TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)           AGE
    service/hello-world   LoadBalancer   10.108.65.81     <pending>     8080:32448/TCP    3m49s
    service/kubernetes    ClusterIP      10.96.0.1        <none>        443/TCP           9d
    
    $kubectl获得部门、采购订单、svc
    姓名就绪最新可用年龄
    deployment.apps/hello-world 0/3 0 5m34s
    名称就绪状态重新启动
    pod/hello-world-6bd8d58486-7lzh9 0/1图像回撤0 3m49s
    pod/hello-world-6bd8d58486-m56rq 0/1图像回缩0 3m49s
    pod/hello-world-6bd8d58486-z9xmz 0/1图像回缩0 3m49s
    名称类型CLUSTER-IP外部IP端口年龄
    service/hello world LoadBalancer 10.108.65.81 8080:32448/TCP 3m49s
    service/kubernetes ClusterIP 10.96.0.1 443/TCP 9d
    
    最佳做法是为不同的资源创建不同的yaml文件。如果需要将多个kubernetes资源打包到单个实体中,请使用Helm。

    最佳做法是为不同的资源创建不同的yaml文件。如果您需要将多个kubernetes资源打包到单个实体中,请使用Helm。

    --
    替换
    #部署
    #服务
    ,然后重试。运行yaml后,您是否可以运行
    Kubernetl get deployments
    并检查部署是否存在。如果存在,则运行
    kubectl来描述部署
    @hariK。“#”是向YAML文件添加注释的一种非常有效的方法吗?@Ping太棒了!我添加了一个详细的答案。将
    #部署
    #服务
    替换为
    --
    并重试。运行yaml后,请运行
    kubectl get deployments
    并检查部署是否存在。如果存在,则运行
    kubectl来描述部署
    @hariK。“#”是向YAML文件添加注释的一种非常有效的方法吗?@Ping太棒了!我补充了一个详细的答案。