On 25.03.2019 16:24, Steve Button wrote:
> Hi,
>
> Bit of a confusing one, and perhaps I'm barking up the wrong tree (which is
> why I've turned here after some research) .
>
> I'm trying to create a bunch of kubernetes namespaces using a template,
> have got that working fine, but now I want to add in different default
> limit and request values for each namesapce.
>
> Initially, I just had a list along these lines :-
>
> namespaces:
> - si
> - qa
> - dev
> - build
> - core-qa
> - core-si
>
> But now, I've tried to be clever and add some defaults below the build
> namespace :-
>
> namespaces:
> - si
> - qa
> - dev
> - build:
> spec:
> limits:
> - default:
> cpu: 100m
> memory: 256Mi
> defaultRequest:
> cpu: 50m
> memory: 128Mi
> - core-qa
> - core-si
You need to be consistent, either have a list, list of dict or a dict.
Easiest way is to use a list of dict.
namespaces:
- name: si
- name: qa
- name: dev
- name: build
spec: <something>
limits:
default:
cpu: 100m
memory: 256Mi
defaultRequest:
cpu: 50m
memory: 128Mi
- name: core-qa
- name: core-si
Then you can loop like this
- name: Env Namespaces | create template in /tmp
tags: namespaces
template:
src: namespace.j2
dest: /tmp/{{ item.name }}.yaml
loop: "{{ namespaces }}"
--
Kai Stian Olstad
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/7b451163-0694-8781-e89e-279e3e20c9ed%40olstad.com.
For more options, visit https://groups.google.com/d/optout.