keylimetoolbox/kube-templates

NAME should not include the replica count

Closed this issue · 0 comments

When building the name from a set of parameters:

# template
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: resque-${NAME}
spec:
  replicas: ${REPLICAS}
  template:
    spec:
      containers:
      - name: my-app
        image: us.gcr.io/project-id-1138/my-app-resque:latest
        env:
        - name: QUEUE
          value: ${QUEUES}
# configuration
workers:
  - queue: reports
    replicas: 1

It includes the replica count in the name because it is one of the properties:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: resque-reports-1
spec:
  replicas: 1
...

Unfortunately, if you change the replica count for the configuration:

workers:
  - queue: reports
    replicas: 2

it changes the name:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: resque-reports-2
spec:
  replicas: 2

Which means that kubernetes will create a new deployment, rather than update the existing deployment because the name changed.

I'm not super excited about adding another magic variable name, replicas, but the simplest solution is to ignore that variable name for now. Maybe the name shouldn't be magic in the first place.