Deploying my service to production:
envsubst < ./kubernetes/pre-production/aks.yaml | kubectl apply -f -
I\'m getting the following erro
You need to add selector
in spec
of Deployment.
And also, these selector
should match with labels
in PodTemplate.
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: moverick-mule-pre
spec:
replicas: 2
selector:
matchLabels:
app: moverick-mule-pre
commit: $CI_COMMIT_SHA
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
template:
metadata:
labels:
app: moverick-mule-pre
commit: $CI_COMMIT_SHA
Otherwise, you will get error like below
The Deployment "moverick-mule-pre" is invalid:
- spec.selector: Required value
- spec.template.metadata.labels: Invalid value: map[string]string{...}
selector
does not match templatelabels
apiVersion: apps/v1
kind: Deployment
metadata:
name: backend-security-deployment
spec:
replicas: 2
selector:
matchLabels:
app: backend-security
template:
metadata:
labels: # labels to select/identify the deployment
app: backend-security
spec: # pod spec
containers:
- name: backend-security
image: yurifull/backend-security:v1.0.0 # image we pushed
ports:
- containerPort: 3001
this works for me...