I want to create 3 dummy nodes in k8s node1, node2 and node3. To create these nodes I should give the below values:
node_name
mac_address
public_ip
pod_cidr
I have to create a condition that I should take node_name
as key, based on node name k8s template has to choose the above values. How can I do this without using ansible k8s module?
I can do this for 1 node giving kubectl command in tasks and k8s template file in templates, but I want the template should be common for all the 3 nodes and it has to choose the values based on name.
template file:
apiVersion: v1
kind: Node
metadata:
name: node1
annotations:
# Provide the MAC address of the BIG-IP VXLAN tunnel
flannel.alpha.coreos.com/backend-data: '{"VtepMAC":"{{ mac_address }}"}'
flannel.alpha.coreos.com/backend-type: "vxlan"
flannel.alpha.coreos.com/kube-subnet-manager: "true"
# Provide the IP address you assigned as the BIG-IP VTEP
flannel.alpha.coreos.com/public-ip: "{{ public_ip }}"
spec:
# Define the flannel subnet you want to assign to the BIG-IP device.
# Be sure this subnet does not collide with any other Nodes' subnets.
podCIDR: "{{ pod_cidr }}"```
tasks file:
---
- name: "Create node1 dummy node"
command: kubectl apply --kubeconfig={{ kubeadmin_config }} -f templates/node1_dummy_node.yaml
delegate_to: "{{groups['k8s-master-primary'][0]}}"
run_once: true
Please help me create proper condition for this.