簡體   English   中英

Google Kubernetes 引擎部署錯誤與 github 操作

[英]Google Kubernetes Engine deploy error with github actions

我正在嘗試使用 github 操作將我的代碼部署到 GKE,但在部署步驟中出現錯誤:

在此處輸入圖像描述

這是我的部署。yaml:

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

服務.yaml:

apiVersion: v1
kind: Service
metadata:
  name: nginx-3-service
spec:
  ports:
    port: 80
    protocol: TCP
    targetPort: 80

還有我的 dockerfile:

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++ 代碼。 我只想簡單地將我的代碼推送到谷歌雲 kubernetes 引擎。

更新:我已經刪除了部署並重新運行操作並得到了這個:

它說部署已成功創建,但又發出另一個錯誤:

deployment.apps/nginx-3 created
Error from server (NotFound): deployments.apps "gke-deployment" not found

嘗試:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM