Skip to content

Commit

Permalink
remove unused file and remove swap from common and move to kubernetes…
Browse files Browse the repository at this point in the history
… role

Signed-off-by: Michael Fornaro <[email protected]>
  • Loading branch information
xunholy committed May 11, 2021
1 parent e7b192b commit c86f98a
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 128 deletions.
4 changes: 2 additions & 2 deletions ansible/group_vars/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ kubernetes_kubeadm_version: 1.21.0-00
####
# Role - keepalived
####
# keepalived_vip: ''
keepalived_vip: '192.168.1.202'
# keepalived_interface: "{{ ansible_default_ipv4['interface'] }}"

####
Expand All @@ -35,7 +35,7 @@ cri_plugin: containerd
####
# Role - cni
####
# cni_plugin: 'calico'
cni_plugin: 'cilium'
# cni_bgp_peer_address: 192.168.0.1
# cni_bgp_peer_asn: 64512
# cni_cilium_helm_version: 1.9.3
Expand Down
4 changes: 2 additions & 2 deletions ansible/group_vars/cluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ cluster_profiling: false
# provides a maximum of 64 nodes in a cluster and 254 pods per node.

# Kubernetes internal network for services, *must* be an unused block of space.
cluster_service_subnet: '10.144.0.0/18'
cluster_service_subnet: '10.125.0.0/18'

# Kubernetes internal network. IP's for pods will be drawn from this address
# space. *must* be unused in your network infrastructure.
cluster_pod_subnet: '10.144.64.0/18'
cluster_pod_subnet: '10.125.64.0/18'

# This sets the network node allocation size. Each node in the cluster is
# assigned a subnet of this size.
Expand Down
4 changes: 2 additions & 2 deletions ansible/group_vars/masters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
# cluster_audit_log_maxbackup: 10
# cluster_audit_log_maxsize: 100
# cluster_pod_subnet: ""
# cluster_kube_proxy_enabled: true
cluster_kube_proxy_enabled: false
# cluster_etcd_heartbeat_interval: 100
# cluster_etcd_election_timeout: 1000

####
# Role - cni
####
# cni_plugin: calico
cni_plugin: cilium
# cni_bgp_peer_address: 192.168.0.1
# cni_bgp_peer_asn: 64512
# cni_cilium_helm_version: 1.9.3
Expand Down
14 changes: 7 additions & 7 deletions ansible/inventory
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[all]
k8s-controlplane-01 hostname=k8s-controlplane-01 ansible_host=192.168.1.121 ansible_user=pi
k8s-controlplane-02 hostname=k8s-controlplane-02 ansible_host=192.168.1.122 ansible_user=pi
k8s-controlplane-03 hostname=k8s-controlplane-03 ansible_host=192.168.1.123 ansible_user=pi
k8s-node-01 hostname=k8s-node-01 ansible_host=192.168.1.131 ansible_user=pi
k8s-node-02 hostname=k8s-node-02 ansible_host=192.168.1.132 ansible_user=pi
k8s-controlplane-01 hostname=k8s-controlplane-01 ansible_host=192.168.1.161 ansible_user=pi
k8s-controlplane-02 hostname=k8s-controlplane-02 ansible_host=192.168.1.162 ansible_user=pi
k8s-controlplane-03 hostname=k8s-controlplane-03 ansible_host=192.168.1.163 ansible_user=pi
k8s-node-01 hostname=k8s-node-01 ansible_host=192.168.1.171 ansible_user=pi
k8s-node-02 hostname=k8s-node-02 ansible_host=192.168.1.172 ansible_user=pi

[cluster:children]
controlplane
Expand All @@ -19,7 +19,7 @@ k8s-node-01
k8s-node-02

[docker_cache]
registry hostname=registry ansible_host=192.168.1.120 ansible_user=pi
#registry hostname=registry ansible_host=192.168.1.120 ansible_user=pi

; These entires are here for backward compatibility as we transition away from the old names.
[k8s:children]
Expand All @@ -33,4 +33,4 @@ k8s-controlplane-03

[workers]
k8s-node-01
k8s-node-02
k8s-node-02
4 changes: 4 additions & 0 deletions ansible/roles/cluster/tasks/join.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
port: '{{ cluster_apiserver_bind_port }}'
timeout: 180

# - name: Pause for 2 minutes to wait for apiserver
# pause:
# minutes: 2

- name: 'join | add node to cluster'
ansible.builtin.command: |
kubeadm join --config /etc/kubernetes/kubeadm-join.yaml
Expand Down
2 changes: 1 addition & 1 deletion ansible/roles/cluster/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@

- name: pull control plane images
command: kubeadm config images pull
when: inventory_hostname == groups["controlplane"]
# when: inventory_hostname == groups["controlplane"]

- name: 'initialize | perform cluster initialization on primary control node'
include_tasks: 'initialize.yml'
Expand Down
13 changes: 0 additions & 13 deletions ansible/roles/common/tasks/common.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
---
- name: disable swap since kubernetes can't work with swap enabled (1/2)
command: swapoff -a
when: ansible_swaptotal_mb > 0

- name: disable swap in /etc/fstab since kubernetes can't work with swap enabled (2/2)
mount:
name: '{{ item }}'
fstype: swap
state: absent
loop:
- swap
- none

- name: start time services
service:
name: systemd-timesyncd
Expand Down
100 changes: 0 additions & 100 deletions ansible/roles/container-runtime/tasks/uninstall.yml

This file was deleted.

16 changes: 15 additions & 1 deletion ansible/roles/kubernetes/tasks/debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,21 @@
- 'kubelet'
- 'kubeadm'

# Swap disabled. You MUST disable swap in order for the kubelet to work properly.
# https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/
- name: disable swap since kubernetes can't work with swap enabled
command: swapoff -a
when: ansible_swaptotal_mb > 0

- name: disable swap in /etc/fstab since kubernetes can't work with swap enabled
mount:
name: '{{ item }}'
fstype: swap
state: absent
loop:
- swap
- none

# TODO: Move to correct location; Perhaps common for RPI?
# Adding required Kubernetes cgroups for Raspberry Pi
- name: Enable container features
Expand All @@ -118,6 +133,5 @@
- 'cgroup_enable=memory'
- 'cgroup_memory=1'
- 'swapaccount=1'

notify: reboot hosts
when: ansible_architecture | regex_search('arm|aarch')

0 comments on commit c86f98a

Please sign in to comment.