2

I'm trying to deploy my code to GKE using github actions and when I run the action it says that service and deployment is created but then gives off an error, also the deployment it created in the cloud has an error.

enter image description here

And this is the deployment it creates:

enter image description here

My deployment.yaml file:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-1
  labels:
    type: nginx  # <-- correct
spec:
  selector:
    matchLabels:
      type: nginx  # incorrect, remove the '-'
  template:
    metadata:
      labels:
        type: nginx  # incorrect, remove the '-' 
    spec:
        containers:
        - image: nginx:1.14
          name: renderer
          ports:
           - containerPort: 80

My service.yaml:

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

I just want to simply deploy my C++ code to kubernetes engine so I can experiment with it. I'm trying to push an ubuntu 20.04 image to europe-west1.

This question says that I must change the zone to fix the cloud's deployment's error but I'm not sure whether it will fix my problem or not and I don't know how to properly change it.

Turgut
  • 711
  • 3
  • 25
  • Have you tried changing the cluster zone ? You can particularly select cluster and workload zone seperately. – london_utku Jul 31 '22 at 10:33
  • You cannot change a GKE cluster zone. You have to delete the cluster and create it again in the new zone. What's the error you get ? If you click on the nginx deployment in that page you have in the screenshot and go into the events tab what do you see ? – boredabdel Aug 01 '22 at 11:33
  • It would be much better if you can share the workflow file as well. – Chetan Talwar Aug 01 '22 at 11:37

1 Answers1

0

So appereantly, for anyone facing this issue, you have to change the name of your DEPLOYMENT_NAME variable name inside your google.yaml file to your deployments name so it is the same as metadata: name: "---" inside your deployment.yaml, in my case I changed my DEPLOYMENT_NAME into nginx-1 to fix the issue.

Turgut
  • 711
  • 3
  • 25