kubernetes – GITLAB(CI/CD pipeline) Unable to deploy deployment.yaml file from gitlab pipeline to aws eks cluster
I can able to deploy the project in locally successfully and hence the error is not related to API versions I believe but in the gitlab pipeline getting the below error.
$ kubectl apply -f deployment.yaml
error: unable to recognize “deployment.yaml”: no matches for kind “Deployment” in version “apps/v1”
ERROR: Job failed: exit code 1
deploy:
stage: deploy
image: roffe/kubectl
script:
- kubectl config set-cluster k8s --server="${kubernetes_server}"
- kubectl config set clusters.k8s.certificate-authority-data "${Certificate_authority}"
- kubectl config set-credentials gitlab --token="${gitlab_access_token}"
- kubectl config set-context default --cluster=k8s --user=root
- kubectl config use-context default
- cat deployment.yaml
- kubectl apply -f deployment.yaml
- kubectl get deployments
- kubectl apply -f service.yaml
- kubectl get services
deployment.yaml file:
apiVersion: apps/v1
kind: Deployment
metadata:
name: server-demo
labels:
app: webapp
spec:
replicas: 3
selector:
matchLabels:
app: webapp
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 33%
template:
metadata:
labels:
app: webapp
spec:
containers:
- name: webapp
image: ***************.com/sampledatetime:latest
ports:
- containerPort: 3000
I have tried the gitlab project that contains deployment.yaml and gitlab-ci.yml for aws eks cluster deployment.
Deployment should happen via gitlab-ci/cd to aws eks cluster.
Read more here: Source link