kubernetes service getting auto deleted after each deployment

12/23/2019

We are facing an unexpected behavior in Kubernetes. When we are running the command:

kubectl apply -f my-service_deployment.yml

It's noticed that the associated existing service of the same pod getting deleted automatically. Also, we noticed that when we are applying the deployment file, instead of giving the output as the "deployment got configured" (as its already running), its showing output as "deployment created".. is some problem here?

Also sometimes we have noticed that the service is recreated with different timestamps than we created with different Ip.

What may be the reasons for this unexpected behavior of this service?

Note:- it's noticed that there is another pod and service running in the same cluster with pod name as "my-stage-my-service" and service name as my-stage-service-v1. will this have any impact?

Deployment file:-

apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-service
  labels:
    app: my-service
spec:
  replicas: 1
  selector:
    matchLabels:
      app: my-service
  template:
    metadata:
      labels:
        app: my-service
    spec:
      containers:
      - name: my-service
        image: myacr/myservice:v1-dev
        ports:
        - containerPort: 8080
      imagePullSecrets:
      - name: my-az-secret

Service file:

apiVersion: v1
kind: Service
metadata:
  name: my-stage-service
spec:
  selector:
    app: my-service
  ports:
  - protocol: TCP
    port: 8880
    targetPort: 8080
  type: LoadBalancer
-- Vowner
azure-kubernetes
kubernetes
kubernetes-ingress
kubernetes-pod

0 Answers