I'm struggling to get an app deployed to GKE using Helm Charts and Gitlab Auto Devops. I feel like I've made lots of progress, but I've reached something I can't seem to figure out.
I only have two stages right now, "build" and "production". During the "production" stage it fails after deploying to Kubernetes with the message Error from server (NotFound): deployments.extensions "production" not found
. I've looked at similar SO questions but can't seem to match up their solutions with my environment. I'm new to the whole kubernetes thing and am doing my best to piece things together, solving one problem at a time...and there have been a lot of problems!
Here is my deployment.yml
file. I used kompose to get started with Helm charts.
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
annotations:
kompose.cmd: kompose convert -c
kompose.version: 1.19.0 ()
creationTimestamp: null
labels:
io.kompose.service: api
name: api
spec:
replicas: 1
strategy:
type: Recreate
template:
metadata:
namespace: {{ .Release.Namespace }}
annotations:
kompose.cmd: kompose convert -c
kompose.version: 1.19.0 ()
creationTimestamp: null
labels:
io.kompose.service: api
spec:
imagePullSecrets:
- name: gitlab-registry
containers:
- image: git.company.com/company/inventory-api
name: api
env:
- name: RAILS_ENV
value: "production"
ports:
- containerPort: 5000
resources: {}
volumeMounts:
- mountPath: /app
name: api-claim0
restartPolicy: Always
volumes:
- name: api-claim0
persistentVolumeClaim:
claimName: api-claim0
status: {}
I found this thread that had the same problem and was able to finally figure out how to get it to work for me.
The name of the deployment in the root level metadata had to be changed from "api" to match the deployment environment in Gitlab. In my case I had to change it to "production" and then it deployed without errors.
There are a lot of automation steps here and any one of them could potentially be hiding the issue. I would be tempted to run things one stage at a time and build up the automation.
E.g. I would first try to deploy the yaml manifest file to the cluster manually via kubectl from your machine.
I've also found the GitLab Auto DevOps and GitLab Kubernetes integration to be particularly awkward to work with and tend to use manual config with kubetcl more productive.