Skip to content

Commit 9299fb7

Browse files
feat: fix/update-kube-api-port
1 parent 7922ae4 commit 9299fb7

7 files changed

Lines changed: 81 additions & 35 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@
1111
pyvenv.cfg
1212
.venv
1313
pip-selfcheck.json
14+
15+
*.task*

defaults/main.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ docker_package: "docker-{{ docker_edition }}{{ docker_version }}"
66
docker_package_state: present
77

88

9-
109
set_proxy: false
1110
add_registry_mirrors: false
1211
login_into_private_registry: false
@@ -78,6 +77,9 @@ custom_control_plane_ports:
7877
- containerPort: 34101
7978
hostPort: 34101
8079

80+
set_inotify: true
81+
install_kind_bins: true
82+
8183
# Worker Node Specific Mounts
8284
worker_node_mounts:
8385
0: # First worker (index 0)

tasks/inotify.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
- name: Check current inotify limits
3+
ansible.builtin.command: "sysctl {{ item }}"
4+
loop:
5+
- fs.inotify.max_user_watches
6+
- fs.inotify.max_user_instances
7+
register: current_limits
8+
changed_when: false
9+
10+
- name: Display current inotify limits
11+
ansible.builtin.debug:
12+
msg: "{{ item.stdout }}"
13+
loop: "{{ current_limits.results }}"
14+
loop_control:
15+
label: "{{ item.item }}"
16+
17+
- name: Set inotify max_user_watches
18+
ansible.posix.sysctl:
19+
name: fs.inotify.max_user_watches
20+
value: '524288'
21+
state: present
22+
sysctl_set: yes
23+
reload: yes
24+
25+
- name: Set inotify max_user_instances
26+
ansible.posix.sysctl:
27+
name: fs.inotify.max_user_instances
28+
value: '512'
29+
state: present
30+
sysctl_set: yes
31+
reload: yes

tasks/kind.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
- name: Download and install kind+kubectl
33
ansible.builtin.include_role:
44
name: download-install-binary
5+
when: install_kind_bins|bool
56

67
- name: Generate kind config
78
ansible.builtin.template:

tasks/main.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
- name: Enable additional options
2727
ansible.builtin.include_tasks: enable-options.yaml
2828

29+
- name: Increase inotify limits for Kind/Kubernetes
30+
ansible.builtin.include_tasks: inotify.yaml
31+
when: set_inotify|bool
32+
2933
- name: Install kind
3034
ansible.builtin.include_tasks: kind.yaml
3135
when: install_kind|bool

templates/kind.yaml.j2

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,75 @@
11
kind: Cluster
22
name: {{ kind_cluster_name }}
33
apiVersion: kind.x-k8s.io/v1alpha4
4-
{% if feature_gates is defined %}
4+
{% if feature_gates is defined %}
55
featureGates:
6-
{% for gate, enabled in feature_gates.items() %}
6+
{% for gate, enabled in feature_gates.items() %}
77
{{ gate }}: {{ enabled }}
8-
{% endfor %}
9-
{% endif %}
8+
{% endfor %}
9+
{% endif %}
1010
networking:
1111
{% if api_server_address is defined %}
1212
apiServerAddress: '{{ api_server_address }}'
13+
{% endif %}
14+
{% if api_server_port is defined %}
15+
apiServerPort: {{ api_server_port }}
1316
{% endif %}
1417
disableDefaultCNI: {{ disableDefaultCNI | default(false) }}
1518
kubeProxyMode: {{ kubeProxyMode | default("none") }}
1619
nodes:
17-
{% for i in range(count_controlplane_nodes | int) %}
20+
{% for i in range(count_controlplane_nodes | int) %}
1821
- role: control-plane
1922
image: kindest/node:v{{ kubectl_version }}
20-
{% if enable_ingress_ports or custom_control_plane_ports %}
21-
{% if node_labels is defined %}
23+
{% if enable_ingress_ports or custom_control_plane_ports %}
24+
{% if node_labels is defined %}
2225
kubeadmConfigPatches:
2326
- |
2427
kind: InitConfiguration
2528
nodeRegistration:
2629
kubeletExtraArgs:
2730
node-labels: {{ node_labels }}
28-
{% endif %}
31+
{% endif %}
2932
extraPortMappings:
30-
{% if custom_control_plane_ports is defined %}
31-
{% for port_mapping in custom_control_plane_ports %}
33+
{% if custom_control_plane_ports is defined %}
34+
{% for port_mapping in custom_control_plane_ports %}
35+
{% if port_mapping.containerPort != 6443 %}
3236
- containerPort: {{ port_mapping.containerPort }}
3337
hostPort: {{ port_mapping.hostPort }}
34-
{% if port_mapping.protocol is defined %}
38+
{% if port_mapping.protocol is defined %}
3539
protocol: {{ port_mapping.protocol }}
36-
{% endif %}
37-
{% endfor %}
38-
{% elif enable_ingress_ports is defined %}
40+
{% endif %}
41+
{% endif %}
42+
{% endfor %}
43+
{% elif enable_ingress_ports is defined %}
3944
- containerPort: 80
4045
hostPort: 80
4146
protocol: TCP
4247
- containerPort: 443
4348
hostPort: 443
4449
protocol: TCP
45-
{% endif %}
46-
{% endif %}
47-
{% endfor %}
48-
{% for i in range(count_worker_nodes | int) %}
50+
{% endif %}
51+
{% endif %}
52+
{% endfor %}
53+
{% for i in range(count_worker_nodes | int) %}
4954
- role: worker
5055
image: kindest/node:v{{ kubectl_version }}
51-
{% if enable_host_paths %}
56+
{% if enable_host_paths %}
5257
extraMounts:
53-
{% if worker_node_mounts and worker_node_mounts[i] is defined %}
54-
{% for mount in worker_node_mounts[i] %}
58+
{% if worker_node_mounts and worker_node_mounts[i] is defined %}
59+
{% for mount in worker_node_mounts[i] %}
5560
- hostPath: {{ mount.hostPath }}
5661
containerPath: {{ mount.containerPath }}
57-
{% endfor %}
58-
{% else %}
59-
- hostPath: /mnt/data-node{{ i + 1 }}
62+
{% endfor %}
63+
{% else %}
64+
- hostPath: /mnt/{{ kind_cluster_name }}-data-node{{ i + 1 }}
6065
containerPath: /data
61-
{% endif %}
62-
{% endif %}
63-
{% endfor %}
64-
{% if containerd_config_patches is defined %}
66+
{% endif %}
67+
{% endif %}
68+
{% endfor %}
69+
{% if containerd_config_patches is defined %}
6570
containerdConfigPatches:
6671
{% for patch in containerd_config_patches %}
6772
- |-
6873
{{ patch | indent(4, first=True) }}
6974
{% endfor %}
70-
{% endif %}
75+
{% endif %}

tests/kind.yaml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
---
2+
# export ANSIBLE_ROLES_PATH=~/projects/ansible-dev
3+
# ansible-playbook ./tests/kind.yaml -i /tmp/inv -vv
24
- hosts: all
35
become: true
46

@@ -17,9 +19,6 @@
1719
api_server_port: 33843
1820

1921
custom_control_plane_ports:
20-
- containerPort: 6443
21-
hostPort: "{{ api_server_port }}"
22-
protocol: TCP
2322
- containerPort: 34100
2423
hostPort: 34100
2524
protocol: TCP
@@ -29,6 +28,8 @@
2928

3029
api_server_address: "{{ ansible_default_ipv4.address }}"
3130

31+
set_inotify: true
32+
install_kind_bins: true
3233
# Worker Node Specific Mounts
3334
worker_node_mounts:
3435
0: # First worker (index 0)
@@ -38,7 +39,7 @@
3839
- hostPath: /mnt/xplane-2
3940
containerPath: /data
4041

41-
rebuild_kind_cluster: false
42+
rebuild_kind_cluster: true
4243

4344
disableDefaultCNI: true
4445
kubeProxyMode: "none"
@@ -66,7 +67,7 @@
6667
installCrds: false
6768

6869
- location: "git::https://github.com/stuttgart-things/helm.git@cicd/crossplane.yaml.gotmpl"
69-
state: absent
70+
state: present
7071
state_values:
7172
version: 2.1.3
7273
deployTeraformProvider: false

0 commit comments

Comments
 (0)