Home > Enterprise >  Google Kubernetes Engine deploy error with github actions
Google Kubernetes Engine deploy error with github actions

Time:08-01

I'm trying to deploy my code to GKE using github actions but getting an error during the deploy step:

enter image description here

Here is my deployment.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

Service.yaml:

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

And my 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"]

This is what the cloud deployments(Workloads) looks like: enter image description here

enter image description here

I'm trying to push a C code using an ubuntu image. I just want to simply push my code to google cloud kubernetes engine.

Update: I've deleted the deployment and re-run the action and got this:

It said that deployment is successfully created but gives off another error:

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

CodePudding user response:

Try:

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
  • Related