首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >使用github操作的引擎部署错误

使用github操作的引擎部署错误
EN

Stack Overflow用户
提问于 2022-07-30 19:12:54
回答 1查看 72关注 0票数 2

我试图使用github操作将代码部署到GKE,但在部署步骤中得到了一个错误:

这是我的deployment.yaml:

代码语言:javascript
运行
复制
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-3
  namespace: default
  labels:
    type: nginx
spec:
  replicas: 1
  selector:
    matchLabels:
    - type: nginx 
  template:
    metadata:
      labels:
      - type: nginx 
    spec:
      containers:
      - image: nginx:1.14
        name: renderer
        ports:
        - containerPort: 80

Service.yaml:

代码语言:javascript
运行
复制
apiVersion: v1
kind: Service
metadata:
  name: nginx-3-service
spec:
  ports:
    port: 80
    protocol: TCP
    targetPort: 80

我的文件是:

代码语言:javascript
运行
复制
FROM ubuntu/redis:5.0-20.04_beta

# Install.
RUN apt-get update &&  DEBIAN_FRONTEND=noninteractive apt-get install -y tzdata
RUN \
  sed -i 's/# \(.*multiverse$\)/\1/g' /etc/apt/sources.list && \
  apt-get update && \
  apt-get -y upgrade && \
  apt-get install -y build-essential && \
  apt-get install -y software-properties-common && \
  apt-get install -y byobu curl git htop man unzip vim wget && \
  rm -rf /var/lib/apt/lists/*

# Set environment variables.
ENV HOME /root

# Define working directory.
WORKDIR /root

# Define default command.
CMD ["bash"]

这就是云部署(工作负载)的样子:

我正在尝试使用ubuntu映像来推送C++代码。我只想简单地把我的代码推到引擎上。

更新:我删除了部署并重新运行操作,得到了以下内容:

它说,已经成功创建了部署,但会产生另一个错误:

代码语言:javascript
运行
复制
deployment.apps/nginx-3 created
Error from server (NotFound): deployments.apps "gke-deployment" not found
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-07-31 02:40:22

尝试:

代码语言:javascript
运行
复制
apiVersion: apps/v1
kind: Deployment
metadata:
  ...
  labels:
    type: nginx  # <-- correct
spec:
  ...
  selector:
    matchLabels:
      type: nginx  # incorrect, remove the '-'
  template:
    metadata:
      labels:
        type: nginx  # incorrect, remove the '-' 
    spec:
      ...
---
apiVersion: v1
kind: Service
...
spec:
  ...
  ports:
  - port: 80  # <-- add '-'
    protocol: TCP
    targetPort: 80
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73178417

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档