├── .gitignore ├── molecule └── default │ ├── templates │ └── coredns │ │ ├── serviceaccount.yml.j2 │ │ ├── clusterrole.yml.j2 │ │ ├── clusterrolebinding.yml.j2 │ │ ├── service.yml.j2 │ │ ├── configmap.yml.j2 │ │ └── deployment.yml.j2 │ ├── host_vars │ ├── test-assets.yml │ ├── test-controller3.yml │ ├── test-etcd1.yml │ ├── test-etcd2.yml │ ├── test-etcd3.yml │ ├── test-worker2.yml │ ├── test-controller1.yml │ ├── test-controller2.yml │ └── test-worker1.yml │ ├── group_vars │ ├── k8s.yml │ ├── k8s_etcd.yml │ └── all.yml │ ├── tasks │ ├── cilium_status.yml │ ├── coredns_status.yml │ ├── taint_controller_nodes.yml │ └── coredns.yml │ ├── verify.yml │ ├── converge.yml │ ├── molecule.yml │ └── prepare.yml ├── handlers └── main.yml ├── .yamllint ├── meta └── main.yml ├── vars └── main.yml ├── templates └── etc │ └── systemd │ └── system │ ├── kube-proxy.service.j2 │ └── kubelet.service.j2 ├── .github └── workflows │ └── release.yml ├── tasks ├── authconfig │ ├── kubelet.yml │ └── kube-proxy.yml └── main.yml ├── defaults └── main.yml ├── README.md ├── CHANGELOG.md └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | *.retry 3 | .ansible 4 | .vscode 5 | -------------------------------------------------------------------------------- /molecule/default/templates/coredns/serviceaccount.yml.j2: -------------------------------------------------------------------------------- 1 | --- 2 | # Copyright (C) 2023 Robert Wimmer 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | apiVersion: v1 6 | kind: ServiceAccount 7 | metadata: 8 | name: coredns 9 | namespace: kube-system 10 | -------------------------------------------------------------------------------- /molecule/default/host_vars/test-assets.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Copyright (C) 2023 Robert Wimmer 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | wireguard_address: "10.10.10.5/24" 6 | wireguard_port: 51820 7 | wireguard_persistent_keepalive: "30" 8 | wireguard_endpoint: "172.16.10.5" 9 | -------------------------------------------------------------------------------- /molecule/default/host_vars/test-controller3.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Copyright (C) 2023 Robert Wimmer 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | wireguard_address: "10.10.10.30/24" 6 | wireguard_port: 51820 7 | wireguard_persistent_keepalive: "30" 8 | wireguard_endpoint: "172.16.10.30" 9 | -------------------------------------------------------------------------------- /molecule/default/host_vars/test-etcd1.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Copyright (C) 2023 Robert Wimmer 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | wireguard_address: "10.10.10.100/24" 6 | wireguard_port: 51820 7 | wireguard_persistent_keepalive: "30" 8 | wireguard_endpoint: "172.16.10.100" 9 | -------------------------------------------------------------------------------- /molecule/default/host_vars/test-etcd2.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Copyright (C) 2023 Robert Wimmer 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | wireguard_address: "10.10.10.110/24" 6 | wireguard_port: 51820 7 | wireguard_persistent_keepalive: "30" 8 | wireguard_endpoint: "172.16.10.110" 9 | -------------------------------------------------------------------------------- /molecule/default/host_vars/test-etcd3.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Copyright (C) 2023 Robert Wimmer 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | wireguard_address: "10.10.10.120/24" 6 | wireguard_port: 51820 7 | wireguard_persistent_keepalive: "30" 8 | wireguard_endpoint: "172.16.10.120" 9 | -------------------------------------------------------------------------------- /molecule/default/host_vars/test-worker2.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Copyright (C) 2023 Robert Wimmer 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | wireguard_address: "10.10.10.210/24" 6 | wireguard_port: 51820 7 | wireguard_persistent_keepalive: "30" 8 | wireguard_endpoint: "172.16.10.210" 9 | -------------------------------------------------------------------------------- /handlers/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Reload systemd 3 | ansible.builtin.systemd: 4 | daemon_reload: true 5 | 6 | - name: Restart kube-proxy 7 | ansible.builtin.service: 8 | name: kube-proxy 9 | state: restarted 10 | 11 | - name: Restart kubelet 12 | ansible.builtin.service: 13 | name: kubelet 14 | state: restarted 15 | -------------------------------------------------------------------------------- /.yamllint: -------------------------------------------------------------------------------- 1 | --- 2 | extends: default 3 | 4 | rules: 5 | line-length: 6 | max: 300 7 | level: warning 8 | 9 | comments-indentation: disable 10 | comments: 11 | min-spaces-from-content: 1 12 | braces: 13 | min-spaces-inside: 0 14 | max-spaces-inside: 1 15 | octal-values: 16 | forbid-implicit-octal: true 17 | forbid-explicit-octal: true 18 | -------------------------------------------------------------------------------- /meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | galaxy_info: 3 | author: Robert Wimmer 4 | description: Installs Kubernetes worker. 5 | license: GPLv3 6 | min_ansible_version: "2.9" 7 | role_name: kubernetes_worker 8 | namespace: githubixx 9 | platforms: 10 | - name: Ubuntu 11 | versions: 12 | - "jammy" 13 | - "noble" 14 | galaxy_tags: 15 | - kubernetes 16 | - worker 17 | -------------------------------------------------------------------------------- /molecule/default/group_vars/k8s.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Copyright (C) 2023 Robert Wimmer 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | # Allow all traffic from the following networks. 6 | harden_linux_ufw_allow_networks: 7 | - "10.32.0.0/16" # Server Cluster IP range 8 | - "10.200.0.0/16" # Pod IP range 9 | - "10.10.10.0/24" # Wireguard IP range 10 | - "192.168.10.0/24" # VM IP range 11 | -------------------------------------------------------------------------------- /vars/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Kubernetes worker node binaries to download. 3 | k8s_worker_binaries: 4 | - kube-proxy 5 | - kubelet 6 | - kubectl 7 | 8 | # Certificate/CA files for API server and kube-proxy 9 | k8s_worker_certificates: 10 | - ca-k8s-apiserver.pem 11 | - ca-k8s-apiserver-key.pem 12 | - cert-k8s-apiserver.pem 13 | - cert-k8s-apiserver-key.pem 14 | - cert-k8s-proxy.pem 15 | - cert-k8s-proxy-key.pem 16 | -------------------------------------------------------------------------------- /molecule/default/group_vars/k8s_etcd.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Copyright (C) 2023 Robert Wimmer 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | # Open a few ports for ssh, Wireguard and etcd 6 | harden_linux_ufw_rules: 7 | - rule: "allow" 8 | to_port: "22" 9 | protocol: "tcp" 10 | - rule: "allow" 11 | to_port: "51820" 12 | protocol: "udp" 13 | - rule: "allow" 14 | to_port: "2379" 15 | protocol: "tcp" 16 | - rule: "allow" 17 | to_port: "2380" 18 | protocol: "tcp" 19 | -------------------------------------------------------------------------------- /molecule/default/templates/coredns/clusterrole.yml.j2: -------------------------------------------------------------------------------- 1 | --- 2 | # Copyright (C) 2023 Robert Wimmer 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | apiVersion: rbac.authorization.k8s.io/v1 6 | kind: ClusterRole 7 | metadata: 8 | labels: 9 | kubernetes.io/bootstrapping: rbac-defaults 10 | name: system:coredns 11 | rules: 12 | - apiGroups: 13 | - "" 14 | - discovery.k8s.io 15 | resources: 16 | - endpointslices 17 | - endpoints 18 | - services 19 | - pods 20 | - namespaces 21 | verbs: 22 | - list 23 | - watch 24 | -------------------------------------------------------------------------------- /molecule/default/tasks/cilium_status.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Copyright (C) 2023 Robert Wimmer 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | - name: Waiting for Cilium Helm chart to be applied 6 | ansible.builtin.wait_for: 7 | timeout: 10 8 | run_once: true 9 | 10 | - name: Fetch Cilium DaemonSet information 11 | kubernetes.core.k8s_info: 12 | api_version: v1 13 | kind: DaemonSet 14 | name: cilium 15 | namespace: cilium 16 | wait: true 17 | wait_sleep: 10 18 | wait_timeout: 600 19 | register: cilium__daemonset_info 20 | -------------------------------------------------------------------------------- /molecule/default/tasks/coredns_status.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Copyright (C) 2023 Robert Wimmer 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | - name: Waiting for CoreDNS manifest being applied 6 | ansible.builtin.wait_for: 7 | timeout: 10 8 | run_once: true 9 | 10 | - name: Waiting for CoreDNS deployment 11 | kubernetes.core.k8s_info: 12 | api_version: v1 13 | kind: Deployment 14 | name: coredns 15 | namespace: kube-system 16 | wait: true 17 | wait_sleep: 10 18 | wait_timeout: 600 19 | register: coredns__deployment_info 20 | -------------------------------------------------------------------------------- /molecule/default/tasks/taint_controller_nodes.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Copyright (C) 2023 Robert Wimmer 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | - name: Taint Kubernetes control plane nodes 6 | kubernetes.core.k8s_taint: 7 | state: present 8 | name: "{{ k8s_controller_node }}" 9 | taints: 10 | - effect: NoExecute 11 | key: "node-role.kubernetes.io/control-plane" 12 | - effect: NoSchedule 13 | key: "node-role.kubernetes.io/control-plane" 14 | loop: "{{ groups['k8s_controller'] }}" 15 | loop_control: 16 | loop_var: k8s_controller_node 17 | -------------------------------------------------------------------------------- /molecule/default/host_vars/test-controller1.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Copyright (C) 2023 Robert Wimmer 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | wireguard_address: "10.10.10.10/24" 6 | wireguard_port: 51820 7 | wireguard_persistent_keepalive: "30" 8 | wireguard_endpoint: "172.16.10.10" 9 | 10 | ha_proxy_frontend_bind_address: "127.0.0.1" 11 | ha_proxy_frontend_port: "16443" 12 | 13 | k8s_ctl_api_endpoint_host: "127.0.0.1" 14 | k8s_ctl_api_endpoint_port: "16443" 15 | 16 | k8s_worker_api_endpoint_host: "{{ k8s_ctl_api_endpoint_host }}" 17 | k8s_worker_api_endpoint_port: "{{ k8s_ctl_api_endpoint_port }}" 18 | -------------------------------------------------------------------------------- /molecule/default/host_vars/test-controller2.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Copyright (C) 2023 Robert Wimmer 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | wireguard_address: "10.10.10.20/24" 6 | wireguard_port: 51820 7 | wireguard_persistent_keepalive: "30" 8 | wireguard_endpoint: "172.16.10.20" 9 | 10 | ha_proxy_frontend_bind_address: "127.0.0.1" 11 | ha_proxy_frontend_port: "16443" 12 | 13 | k8s_ctl_api_endpoint_host: "127.0.0.1" 14 | k8s_ctl_api_endpoint_port: "16443" 15 | 16 | k8s_worker_api_endpoint_host: "{{ k8s_ctl_api_endpoint_host }}" 17 | k8s_worker_api_endpoint_port: "{{ k8s_ctl_api_endpoint_port }}" 18 | -------------------------------------------------------------------------------- /molecule/default/host_vars/test-worker1.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Copyright (C) 2023 Robert Wimmer 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | wireguard_address: "10.10.10.200/24" 6 | wireguard_port: 51820 7 | wireguard_persistent_keepalive: "30" 8 | wireguard_endpoint: "172.16.10.200" 9 | 10 | ha_proxy_frontend_bind_address: "127.0.0.1" 11 | ha_proxy_frontend_port: "16443" 12 | 13 | k8s_ctl_api_endpoint_host: "127.0.0.1" 14 | k8s_ctl_api_endpoint_port: "16443" 15 | 16 | k8s_worker_api_endpoint_host: "{{ k8s_ctl_api_endpoint_host }}" 17 | k8s_worker_api_endpoint_port: "{{ k8s_ctl_api_endpoint_port }}" 18 | -------------------------------------------------------------------------------- /templates/etc/systemd/system/kube-proxy.service.j2: -------------------------------------------------------------------------------- 1 | #jinja2: trim_blocks:False 2 | [Unit] 3 | Description=Kubernetes Kube Proxy 4 | Documentation=https://github.com/GoogleCloudPlatform/kubernetes 5 | Wants=network-online.target 6 | After=network-online.target 7 | 8 | [Service] 9 | ExecStart={{ k8s_worker_bin_dir }}/kube-proxy \ 10 | {%- for setting in k8s_worker_kubeproxy_settings|sort %} 11 | --{{ setting }}={{ k8s_worker_kubeproxy_settings[setting] }} {% if not loop.last %}\{% endif %} 12 | {%- endfor %} 13 | 14 | Restart=on-failure 15 | RestartSec=5 16 | 17 | [Install] 18 | WantedBy=multi-user.target 19 | -------------------------------------------------------------------------------- /molecule/default/templates/coredns/clusterrolebinding.yml.j2: -------------------------------------------------------------------------------- 1 | --- 2 | # Copyright (C) 2023 Robert Wimmer 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | apiVersion: rbac.authorization.k8s.io/v1 6 | kind: ClusterRoleBinding 7 | metadata: 8 | annotations: 9 | rbac.authorization.kubernetes.io/autoupdate: "true" 10 | labels: 11 | kubernetes.io/bootstrapping: rbac-defaults 12 | name: system:coredns 13 | roleRef: 14 | apiGroup: rbac.authorization.k8s.io 15 | kind: ClusterRole 16 | name: system:coredns 17 | subjects: 18 | - kind: ServiceAccount 19 | name: coredns 20 | namespace: kube-system 21 | -------------------------------------------------------------------------------- /molecule/default/templates/coredns/service.yml.j2: -------------------------------------------------------------------------------- 1 | --- 2 | # Copyright (C) 2023 Robert Wimmer 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | apiVersion: v1 6 | kind: Service 7 | metadata: 8 | name: kube-dns 9 | namespace: kube-system 10 | annotations: 11 | prometheus.io/port: "9153" 12 | prometheus.io/scrape: "true" 13 | labels: 14 | k8s-app: kube-dns 15 | kubernetes.io/cluster-service: "true" 16 | kubernetes.io/name: "CoreDNS" 17 | spec: 18 | selector: 19 | k8s-app: kube-dns 20 | clusterIP: 10.32.0.254 21 | ports: 22 | - name: dnsudp 23 | port: 53 24 | protocol: UDP 25 | - name: dnstcp 26 | port: 53 27 | protocol: TCP 28 | -------------------------------------------------------------------------------- /molecule/default/templates/coredns/configmap.yml.j2: -------------------------------------------------------------------------------- 1 | --- 2 | # Copyright (C) 2023 Robert Wimmer 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | apiVersion: v1 6 | kind: ConfigMap 7 | metadata: 8 | name: coredns 9 | namespace: kube-system 10 | data: 11 | Corefile: | 12 | .:53 { 13 | errors 14 | health { 15 | lameduck 5s 16 | } 17 | kubernetes cluster.local in-addr.arpa ip6.arpa { 18 | pods insecure 19 | fallthrough in-addr.arpa ip6.arpa 20 | } 21 | prometheus :9153 22 | forward . 1.1.1.1 9.9.9.9 23 | cache 30 24 | loop 25 | reload 26 | loadbalance 27 | ready 28 | } 29 | -------------------------------------------------------------------------------- /templates/etc/systemd/system/kubelet.service.j2: -------------------------------------------------------------------------------- 1 | #jinja2: trim_blocks:False 2 | [Unit] 3 | Description=Kubernetes Kubelet 4 | Documentation=https://github.com/GoogleCloudPlatform/kubernetes 5 | After=network-online.target 6 | After=containerd.service 7 | Requires=network-online.target 8 | Requires=containerd.service 9 | Wants=network-online.target 10 | 11 | [Service] 12 | ExecStart={{ k8s_worker_bin_dir }}/kubelet \ 13 | {%- for setting in k8s_worker_kubelet_settings|sort %} 14 | --{{ setting }}{% if k8s_worker_kubelet_settings[setting] != "" %}={{ k8s_worker_kubelet_settings[setting] }}{% endif %}{% if not loop.last %} \{% endif %} 15 | {%- endfor %} 16 | 17 | Restart=always 18 | RestartSec=10 19 | WatchdogSec=30s 20 | 21 | [Install] 22 | WantedBy=multi-user.target 23 | -------------------------------------------------------------------------------- /molecule/default/verify.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Copyright (C) 2023 Robert Wimmer 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | - name: Verify setup 6 | hosts: test-assets 7 | remote_user: vagrant 8 | tasks: 9 | - name: Fetch namespaces information 10 | kubernetes.core.k8s_info: 11 | api_version: v1 12 | kind: namespace 13 | kubeconfig: "{{ k8s_admin_conf_dir }}/admin.kubeconfig" 14 | register: k8s__namespaces_info 15 | 16 | - name: Print namespaces 17 | ansible.builtin.debug: 18 | var: "{{ k8s__namespaces_info | community.general.json_query(mol__query) }}" 19 | vars: 20 | mol__query: "length(resources)" 21 | when: ansible_verbosity > 1 22 | 23 | - name: Register namespaces count 24 | ansible.builtin.set_fact: 25 | k8s__namespaces_count: "{{ k8s__namespaces_info | community.general.json_query(mol__query) }}" 26 | vars: 27 | mol__query: "length(resources)" 28 | 29 | - name: There should be four namespaces at least 30 | ansible.builtin.assert: 31 | that: 32 | - k8s__namespaces_count|int >= 4 33 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # This workflow requires a GALAXY_API_KEY secret present in the GitHub 3 | # repository or organization. 4 | # 5 | # See: https://github.com/marketplace/actions/publish-ansible-role-to-galaxy 6 | # See: https://github.com/ansible/galaxy/issues/46 7 | 8 | name: Release 9 | on: 10 | push: 11 | tags: 12 | - '*' 13 | 14 | defaults: 15 | run: 16 | working-directory: 'githubixx.kubernetes_worker' 17 | 18 | jobs: 19 | release: 20 | name: Release 21 | runs-on: ubuntu-latest 22 | steps: 23 | - name: Check out the codebase. 24 | uses: actions/checkout@v2 25 | with: 26 | path: 'githubixx.kubernetes_worker' 27 | 28 | - name: Set up Python 3. 29 | uses: actions/setup-python@v2 30 | with: 31 | python-version: '3.x' 32 | 33 | - name: Install Ansible. 34 | run: pip3 install ansible-core 35 | 36 | - name: Trigger a new import on Galaxy. 37 | run: >- 38 | ansible-galaxy role import --token ${{ secrets.GALAXY_API_KEY }} -vvvvvvvv --role-name=$(echo ${{ github.repository }} | cut -d/ -f2 | sed 's/ansible-role-//' | sed 's/-/_/') $(echo ${{ github.repository }} | cut -d/ -f1) $(echo ${{ github.repository }} | cut -d/ -f2) 39 | -------------------------------------------------------------------------------- /molecule/default/tasks/coredns.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Copyright (C) 2023 Robert Wimmer 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | - name: Create CoreDNS service account 6 | kubernetes.core.k8s: 7 | state: present 8 | definition: "{{ lookup('template', 'templates/coredns/serviceaccount.yml.j2') | from_yaml }}" 9 | delegate_to: "{{ coredns_delegate_to }}" 10 | run_once: true 11 | 12 | - name: Create CoreDNS ClusterRole 13 | kubernetes.core.k8s: 14 | state: present 15 | definition: "{{ lookup('template', 'templates/coredns/clusterrole.yml.j2') | from_yaml }}" 16 | delegate_to: "{{ coredns_delegate_to }}" 17 | run_once: true 18 | 19 | - name: Create CoreDNS ClusterRoleBinding 20 | kubernetes.core.k8s: 21 | state: present 22 | definition: "{{ lookup('template', 'templates/coredns/clusterrolebinding.yml.j2') | from_yaml }}" 23 | delegate_to: "{{ coredns_delegate_to }}" 24 | run_once: true 25 | 26 | - name: Create CoreDNS ConfigMap 27 | kubernetes.core.k8s: 28 | state: present 29 | definition: "{{ lookup('template', 'templates/coredns/configmap.yml.j2') | from_yaml }}" 30 | delegate_to: "{{ coredns_delegate_to }}" 31 | run_once: true 32 | 33 | - name: Create CoreDNS Deployment 34 | kubernetes.core.k8s: 35 | state: present 36 | definition: "{{ lookup('template', 'templates/coredns/deployment.yml.j2') | from_yaml }}" 37 | delegate_to: "{{ coredns_delegate_to }}" 38 | run_once: true 39 | 40 | - name: Create CoreDNS Service 41 | kubernetes.core.k8s: 42 | state: present 43 | definition: "{{ lookup('template', 'templates/coredns/service.yml.j2') | from_yaml }}" 44 | delegate_to: "{{ coredns_delegate_to }}" 45 | run_once: true 46 | -------------------------------------------------------------------------------- /molecule/default/converge.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Copyright (C) 2023 Robert Wimmer 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | - name: Setup K8s worker 6 | hosts: k8s_worker 7 | become: true 8 | gather_facts: true 9 | tasks: 10 | - name: Setup Kubernetes worker 11 | when: 12 | - k8s_worker_setup_networking is not defined 13 | ansible.builtin.include_role: 14 | name: githubixx.kubernetes_worker 15 | 16 | - name: Setup Cilium 17 | hosts: k8s_worker 18 | become: true 19 | gather_facts: true 20 | environment: 21 | K8S_AUTH_KUBECONFIG: "{{ k8s_admin_conf_dir }}/admin.kubeconfig" 22 | tasks: 23 | - name: Include Cilium role 24 | when: 25 | - k8s_worker_setup_networking is defined 26 | - k8s_worker_setup_networking == "install" 27 | ansible.builtin.include_role: 28 | name: githubixx.cilium_kubernetes 29 | vars: 30 | cilium_action: "install" # noqa var-naming 31 | 32 | - name: Setup tooling to make worker nodes usable 33 | hosts: test-assets 34 | become: true 35 | gather_facts: true 36 | environment: 37 | K8S_AUTH_KUBECONFIG: "{{ k8s_admin_conf_dir }}/admin.kubeconfig" 38 | tasks: 39 | - name: Setup tooling 40 | when: 41 | - k8s_worker_setup_networking is defined 42 | - k8s_worker_setup_networking == "install" 43 | block: 44 | - name: Waiting for Cilium to become ready 45 | ansible.builtin.include_tasks: 46 | file: tasks/cilium_status.yml 47 | 48 | - name: Control plane nodes should only run Cilium pods 49 | ansible.builtin.include_tasks: 50 | file: tasks/taint_controller_nodes.yml 51 | 52 | - name: Install CoreDNS 53 | ansible.builtin.include_tasks: 54 | file: tasks/coredns.yml 55 | 56 | - name: Waiting for CoreDNS to become ready 57 | ansible.builtin.include_tasks: 58 | file: tasks/coredns_status.yml 59 | -------------------------------------------------------------------------------- /molecule/default/templates/coredns/deployment.yml.j2: -------------------------------------------------------------------------------- 1 | --- 2 | # Copyright (C) 2023 Robert Wimmer 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | apiVersion: apps/v1 6 | kind: Deployment 7 | metadata: 8 | name: coredns 9 | namespace: kube-system 10 | labels: 11 | k8s-app: kube-dns 12 | kubernetes.io/name: "CoreDNS" 13 | spec: 14 | replicas: 2 15 | strategy: 16 | type: RollingUpdate 17 | rollingUpdate: 18 | maxUnavailable: 1 19 | selector: 20 | matchLabels: 21 | k8s-app: kube-dns 22 | template: 23 | metadata: 24 | labels: 25 | k8s-app: kube-dns 26 | spec: 27 | serviceAccountName: coredns 28 | tolerations: 29 | - key: node-role.kubernetes.io/control-plane 30 | effect: NoSchedule 31 | - key: "CriticalAddonsOnly" 32 | operator: "Exists" 33 | containers: 34 | - name: coredns 35 | image: coredns/coredns:1.10.1 36 | imagePullPolicy: IfNotPresent 37 | resources: 38 | limits: 39 | memory: 170Mi 40 | requests: 41 | cpu: 100m 42 | memory: 70Mi 43 | args: [ "-conf", "/etc/coredns/Corefile" ] 44 | volumeMounts: 45 | - name: config-volume 46 | mountPath: /etc/coredns 47 | readOnly: true 48 | ports: 49 | - containerPort: 53 50 | name: dns 51 | protocol: UDP 52 | - containerPort: 53 53 | name: dns-tcp 54 | protocol: TCP 55 | - containerPort: 9153 56 | name: metrics 57 | protocol: TCP 58 | securityContext: 59 | allowPrivilegeEscalation: false 60 | capabilities: 61 | add: 62 | - NET_BIND_SERVICE 63 | drop: 64 | - all 65 | readOnlyRootFilesystem: true 66 | livenessProbe: 67 | httpGet: 68 | path: /health 69 | port: 8080 70 | scheme: HTTP 71 | initialDelaySeconds: 60 72 | timeoutSeconds: 5 73 | successThreshold: 1 74 | failureThreshold: 5 75 | dnsPolicy: Default 76 | volumes: 77 | - name: config-volume 78 | configMap: 79 | name: coredns 80 | items: 81 | - key: Corefile 82 | path: Corefile 83 | affinity: 84 | podAntiAffinity: 85 | preferredDuringSchedulingIgnoredDuringExecution: 86 | - weight: 100 87 | podAffinityTerm: 88 | labelSelector: 89 | matchExpressions: 90 | - key: "k8s-app" 91 | operator: In 92 | values: 93 | - kube-dns 94 | topologyKey: "kubernetes.io/hostname" 95 | -------------------------------------------------------------------------------- /molecule/default/molecule.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Copyright (C) 2023 Robert Wimmer 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | dependency: 6 | name: galaxy 7 | 8 | driver: 9 | name: vagrant 10 | provider: 11 | name: libvirt 12 | type: libvirt 13 | 14 | platforms: 15 | - name: test-assets 16 | box: alvistack/ubuntu-22.04 17 | memory: 2048 18 | cpus: 2 19 | groups: 20 | - vpn 21 | - k8s_assets 22 | - k8s 23 | interfaces: 24 | - auto_config: true 25 | network_name: private_network 26 | type: static 27 | ip: 172.16.10.5 28 | - name: test-controller1 29 | box: alvistack/ubuntu-22.04 30 | memory: 2048 31 | cpus: 2 32 | groups: 33 | - vpn 34 | - haproxy 35 | - k8s_controller 36 | - k8s_worker 37 | - k8s 38 | interfaces: 39 | - auto_config: true 40 | network_name: private_network 41 | type: static 42 | ip: 172.16.10.10 43 | - name: test-controller2 44 | box: alvistack/ubuntu-22.04 45 | memory: 2048 46 | cpus: 2 47 | groups: 48 | - vpn 49 | - haproxy 50 | - k8s_controller 51 | - k8s_worker 52 | - k8s 53 | interfaces: 54 | - auto_config: true 55 | network_name: private_network 56 | type: static 57 | ip: 172.16.10.20 58 | - name: test-controller3 59 | box: alvistack/ubuntu-24.04 60 | memory: 2048 61 | cpus: 2 62 | groups: 63 | - vpn 64 | - k8s_controller 65 | - k8s_worker 66 | - k8s 67 | interfaces: 68 | - auto_config: true 69 | network_name: private_network 70 | type: static 71 | ip: 172.16.10.30 72 | - name: test-etcd1 73 | box: alvistack/ubuntu-22.04 74 | memory: 2048 75 | cpus: 2 76 | groups: 77 | - vpn 78 | - k8s_etcd 79 | interfaces: 80 | - auto_config: true 81 | network_name: private_network 82 | type: static 83 | ip: 172.16.10.100 84 | - name: test-etcd2 85 | box: alvistack/ubuntu-22.04 86 | memory: 2048 87 | cpus: 2 88 | groups: 89 | - vpn 90 | - k8s_etcd 91 | interfaces: 92 | - auto_config: true 93 | network_name: private_network 94 | type: static 95 | ip: 172.16.10.110 96 | - name: test-etcd3 97 | box: alvistack/ubuntu-22.04 98 | memory: 2048 99 | cpus: 2 100 | groups: 101 | - vpn 102 | - k8s_etcd 103 | interfaces: 104 | - auto_config: true 105 | network_name: private_network 106 | type: static 107 | ip: 172.16.10.120 108 | - name: test-worker1 109 | box: alvistack/ubuntu-22.04 110 | memory: 2048 111 | cpus: 2 112 | groups: 113 | - vpn 114 | - haproxy 115 | - k8s_worker 116 | - k8s 117 | interfaces: 118 | - auto_config: true 119 | network_name: private_network 120 | type: static 121 | ip: 172.16.10.200 122 | - name: test-worker2 123 | box: alvistack/ubuntu-24.04 124 | memory: 2048 125 | cpus: 2 126 | groups: 127 | - vpn 128 | - ubuntu24 129 | - k8s_worker 130 | - k8s 131 | interfaces: 132 | - auto_config: true 133 | network_name: private_network 134 | type: static 135 | ip: 172.16.10.210 136 | 137 | provisioner: 138 | name: ansible 139 | connection_options: 140 | ansible_ssh_user: vagrant 141 | ansible_become: true 142 | log: true 143 | lint: yamllint . && flake8 144 | 145 | scenario: 146 | name: default 147 | test_sequence: 148 | - prepare 149 | - converge 150 | 151 | verifier: 152 | name: ansible 153 | enabled: true 154 | -------------------------------------------------------------------------------- /molecule/default/prepare.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Copyright (C) 2023 Robert Wimmer 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | - name: Update cache 6 | hosts: k8s 7 | remote_user: vagrant 8 | become: true 9 | gather_facts: true 10 | tasks: 11 | - name: Update APT package cache 12 | ansible.builtin.apt: 13 | update_cache: true 14 | cache_valid_time: 3600 15 | 16 | - name: Harden hosts 17 | hosts: all 18 | remote_user: vagrant 19 | become: true 20 | gather_facts: true 21 | tasks: 22 | - name: Setup harden_linux role 23 | ansible.builtin.include_role: 24 | name: githubixx.harden_linux 25 | 26 | - name: Setup Wireguard VPN 27 | hosts: vpn 28 | remote_user: vagrant 29 | become: true 30 | gather_facts: true 31 | tasks: 32 | - name: Setup wireguard role 33 | ansible.builtin.include_role: 34 | name: githubixx.ansible_role_wireguard 35 | 36 | - name: Setup cfssl 37 | hosts: k8s_assets 38 | become: true 39 | gather_facts: false 40 | tasks: 41 | - name: Install cfssl 42 | ansible.builtin.include_role: 43 | name: githubixx.cfssl 44 | 45 | - name: Setup Kubernetes certificates 46 | hosts: k8s_assets 47 | gather_facts: false 48 | tasks: 49 | - name: Generate etcd and K8s TLS certificates 50 | ansible.builtin.include_role: 51 | name: githubixx.kubernetes_ca 52 | 53 | - name: Copy certificate files from assets to local host 54 | ansible.posix.synchronize: 55 | mode: pull 56 | src: "{{ k8s_ca_conf_directory }}" 57 | dest: "/tmp" 58 | 59 | - name: Setup etcd 60 | hosts: k8s_etcd 61 | remote_user: vagrant 62 | become: true 63 | gather_facts: true 64 | tasks: 65 | - name: Include etcd role 66 | ansible.builtin.include_role: 67 | name: githubixx.etcd 68 | 69 | - name: Setup Kubernetes client tooling 70 | hosts: k8s_assets 71 | become: true 72 | gather_facts: true 73 | tasks: 74 | - name: Install kubectl 75 | ansible.builtin.include_role: 76 | name: githubixx.kubectl 77 | 78 | - name: Install support packages 79 | ansible.builtin.package: 80 | name: "{{ packages }}" 81 | state: present 82 | vars: 83 | packages: 84 | - conntrack 85 | - python3-pip 86 | 87 | - name: Install kubernetes Python package 88 | ansible.builtin.package: 89 | name: python3-kubernetes 90 | state: present 91 | 92 | - name: Install Helm role 93 | ansible.builtin.include_role: 94 | name: gantsign.helm 95 | 96 | - name: Setup HAProxy 97 | hosts: haproxy 98 | remote_user: vagrant 99 | become: true 100 | gather_facts: true 101 | tasks: 102 | - name: Setup haproxy role 103 | ansible.builtin.include_role: 104 | name: githubixx.haproxy 105 | 106 | - name: Setup containerd 107 | hosts: k8s_worker 108 | become: true 109 | gather_facts: true 110 | tasks: 111 | - name: Include runc role 112 | ansible.builtin.include_role: 113 | name: githubixx.runc 114 | 115 | - name: Include CNI role 116 | ansible.builtin.include_role: 117 | name: githubixx.cni 118 | 119 | - name: Include containerd role 120 | ansible.builtin.include_role: 121 | name: githubixx.containerd 122 | 123 | - name: Setup Kubernetes controller 124 | hosts: k8s_controller 125 | become: true 126 | gather_facts: true 127 | tasks: 128 | - name: Include kubernetes_controller role 129 | ansible.builtin.include_role: 130 | name: githubixx.kubernetes_controller 131 | 132 | - name: Prepare kubeconfig for vagrant user 133 | hosts: k8s_assets 134 | become: true 135 | gather_facts: false 136 | vars: 137 | k8s_controller__vagrant_kube_directory: "/home/vagrant/.kube" 138 | tasks: 139 | - name: Ensure .kube directory in vagrant home 140 | ansible.builtin.file: 141 | path: "{{ k8s_controller__vagrant_kube_directory }}" 142 | state: directory 143 | mode: "0700" 144 | owner: "vagrant" 145 | group: "vagrant" 146 | 147 | - name: Copy admin.kubeconfig to vagrant home directory 148 | ansible.builtin.copy: 149 | src: "{{ k8s_admin_conf_dir }}/admin.kubeconfig" 150 | dest: "{{ k8s_controller__vagrant_kube_directory }}/config" 151 | mode: "0400" 152 | remote_src: true 153 | owner: "vagrant" 154 | group: "vagrant" 155 | -------------------------------------------------------------------------------- /tasks/authconfig/kubelet.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Register checksum of kubelet original kubeconfig 3 | ansible.builtin.stat: 4 | path: "{{ k8s_worker_kubelet_conf_dir }}/kubeconfig" 5 | register: kubernetes_worker__kubelet_kubeconfig_orig_stat 6 | 7 | - name: Generate kubeconfig for kubelet (set-cluster) 8 | ansible.builtin.shell: > 9 | set -o errexit; \ 10 | kubectl config set-cluster {{ k8s_config_cluster_name }} \ 11 | --certificate-authority={{ k8s_worker_pki_dir }}/ca-k8s-apiserver.pem \ 12 | --embed-certs=true \ 13 | --server=https://{{ k8s_worker_api_endpoint_host }}:{{ k8s_worker_api_endpoint_port }} \ 14 | --kubeconfig={{ k8s_worker_kubelet_conf_dir }}/kubeconfig 15 | args: 16 | executable: /bin/bash 17 | register: kubernetes_worker__set_cluster_out 18 | changed_when: false 19 | failed_when: kubernetes_worker__set_cluster_out.rc != 0 20 | 21 | - name: Generate kubeconfig for kubelet (set-cluster) - DEBUG OUTPUT 22 | ansible.builtin.debug: 23 | msg: "COMMAND:{{ kubernetes_worker__set_cluster_out.cmd }} | OUTPUT: {{ kubernetes_worker__set_cluster_out.stdout }}" 24 | verbosity: 2 25 | 26 | - name: Generate kubeconfig for kubelet (set-credentials) 27 | ansible.builtin.shell: > 28 | set -o errexit; \ 29 | kubectl config set-credentials system:node:{{ ansible_hostname }} \ 30 | --client-certificate={{ k8s_worker_pki_dir }}/cert-{{ inventory_hostname }}.pem \ 31 | --client-key={{ k8s_worker_pki_dir }}/cert-{{ inventory_hostname }}-key.pem \ 32 | --embed-certs=true \ 33 | --kubeconfig={{ k8s_worker_kubelet_conf_dir }}/kubeconfig 34 | args: 35 | executable: /bin/bash 36 | register: kubernetes_worker__set_credentials_out 37 | changed_when: false 38 | failed_when: kubernetes_worker__set_credentials_out.rc != 0 39 | 40 | - name: Generate kubeconfig for kubelet (set-credentials) - DEBUG OUTPUT 41 | ansible.builtin.debug: 42 | msg: "COMMAND:{{ kubernetes_worker__set_credentials_out.cmd }} | OUTPUT: {{ kubernetes_worker__set_credentials_out.stdout }}" 43 | verbosity: 2 44 | 45 | - name: Generate kubeconfig for kubelet (set-context) 46 | ansible.builtin.shell: > 47 | set -o errexit; \ 48 | kubectl config set-context default \ 49 | --cluster={{ k8s_config_cluster_name }} \ 50 | --user=system:node:{{ ansible_hostname }} \ 51 | --kubeconfig={{ k8s_worker_kubelet_conf_dir }}/kubeconfig 52 | args: 53 | executable: /bin/bash 54 | register: kubernetes_worker__set_context_out 55 | changed_when: false 56 | failed_when: kubernetes_worker__set_context_out.rc != 0 57 | 58 | - name: Generate kubeconfig for kubelet (set-context) - DEBUG OUTPUT 59 | ansible.builtin.debug: 60 | msg: "COMMAND:{{ kubernetes_worker__set_context_out.cmd }} | OUTPUT: {{ kubernetes_worker__set_context_out.stdout }}" 61 | verbosity: 2 62 | 63 | - name: Generate kubeconfig for kubelet (use-context) 64 | ansible.builtin.shell: > 65 | set -o errexit; \ 66 | kubectl config use-context default \ 67 | --kubeconfig={{ k8s_worker_kubelet_conf_dir }}/kubeconfig 68 | args: 69 | executable: /bin/bash 70 | register: kubernetes_worker__use_context_out 71 | changed_when: false 72 | failed_when: kubernetes_worker__use_context_out.rc != 0 73 | 74 | - name: Generate kubeconfig for kubelet (use-context) - DEBUG OUTPUT 75 | ansible.builtin.debug: 76 | msg: "COMMAND:{{ kubernetes_worker__use_context_out.cmd }} | OUTPUT: {{ kubernetes_worker__use_context_out.stdout }}" 77 | verbosity: 2 78 | 79 | - name: Set file permissions 80 | ansible.builtin.file: 81 | path: "{{ k8s_worker_kubelet_conf_dir }}/kubeconfig" 82 | owner: "root" 83 | group: "root" 84 | mode: "0640" 85 | modification_time: "preserve" 86 | access_time: "preserve" 87 | 88 | - name: Register checksum of kubelet current kubeconfig 89 | ansible.builtin.stat: 90 | path: "{{ k8s_worker_kubelet_conf_dir }}/kubeconfig" 91 | register: kubernetes_worker__kubelet_kubeconfig_current_stat 92 | 93 | - name: Check if kubelet kubeconfig file changed 94 | when: 95 | - kubernetes_worker__kubelet_kubeconfig_orig_stat.stat.checksum is defined 96 | - kubernetes_worker__kubelet_kubeconfig_orig_stat.stat.checksum != kubernetes_worker__kubelet_kubeconfig_current_stat.stat.checksum 97 | ansible.builtin.debug: 98 | msg: "kubelet kubeconfig file changed" 99 | changed_when: 100 | - kubernetes_worker__kubelet_kubeconfig_orig_stat.stat.checksum != kubernetes_worker__kubelet_kubeconfig_current_stat.stat.checksum 101 | notify: 102 | - Restart kubelet 103 | -------------------------------------------------------------------------------- /tasks/authconfig/kube-proxy.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Register checksum of kube-proxy original kubeconfig 3 | ansible.builtin.stat: 4 | path: "{{ k8s_worker_kubeproxy_conf_dir }}/kubeconfig" 5 | register: kubernetes_worker__kubeproxy_kubeconfig_orig_stat 6 | tags: 7 | - k8s-auth-config-kubeproxy 8 | 9 | - name: Generate kubeconfig for kube-proxy (set-cluster) 10 | ansible.builtin.shell: > 11 | set -o errexit; \ 12 | kubectl config set-cluster {{ k8s_config_cluster_name }} \ 13 | --certificate-authority={{ k8s_worker_pki_dir }}/ca-k8s-apiserver.pem \ 14 | --embed-certs=true \ 15 | --server=https://{{ k8s_worker_api_endpoint_host }}:{{ k8s_worker_api_endpoint_port }} \ 16 | --kubeconfig={{ k8s_worker_kubeproxy_conf_dir }}/kubeconfig 17 | args: 18 | executable: /bin/bash 19 | register: kubernetes_worker__set_cluster_out 20 | changed_when: false 21 | failed_when: kubernetes_worker__set_cluster_out.rc != 0 22 | tags: 23 | - k8s-auth-config-proxy 24 | 25 | - name: Generate kubeconfig for kube-proxy (set-cluster) - DEBUG OUTPUT 26 | ansible.builtin.debug: 27 | msg: "COMMAND:{{ kubernetes_worker__set_cluster_out.cmd }} | OUTPUT: {{ kubernetes_worker__set_cluster_out.stdout }}" 28 | verbosity: 2 29 | tags: 30 | - k8s-auth-config-proxy 31 | 32 | - name: Generate kubeconfig for kube-proxy (set-credentials) 33 | ansible.builtin.shell: > 34 | set -o errexit; \ 35 | kubectl config set-credentials system:kube-proxy \ 36 | --client-certificate={{ k8s_worker_pki_dir }}/cert-k8s-proxy.pem \ 37 | --client-key={{ k8s_worker_pki_dir }}/cert-k8s-proxy-key.pem \ 38 | --embed-certs=true \ 39 | --kubeconfig={{ k8s_worker_kubeproxy_conf_dir }}/kubeconfig 40 | args: 41 | executable: /bin/bash 42 | register: kubernetes_worker__set_credentials_out 43 | changed_when: false 44 | failed_when: kubernetes_worker__set_credentials_out.rc != 0 45 | tags: 46 | - k8s-auth-config-proxy 47 | 48 | - name: Generate kubeconfig for kube-proxy (set-credentials) - DEBUG OUTPUT 49 | ansible.builtin.debug: 50 | msg: "COMMAND:{{ kubernetes_worker__set_credentials_out.cmd }} | OUTPUT: {{ kubernetes_worker__set_credentials_out.stdout }}" 51 | verbosity: 2 52 | tags: 53 | - k8s-auth-config-proxy 54 | 55 | - name: Generate kubeconfig for kube-proxy (set-context) 56 | ansible.builtin.shell: > 57 | set -o errexit; \ 58 | kubectl config set-context default \ 59 | --cluster={{ k8s_config_cluster_name }} \ 60 | --user=system:kube-proxy \ 61 | --kubeconfig={{ k8s_worker_kubeproxy_conf_dir }}/kubeconfig 62 | args: 63 | executable: /bin/bash 64 | register: kubernetes_worker__set_context_out 65 | changed_when: false 66 | failed_when: kubernetes_worker__set_context_out.rc != 0 67 | tags: 68 | - k8s-auth-config-proxy 69 | 70 | - name: Generate kubeconfig for kube-proxy (set-context) - DEBUG OUTPUT 71 | ansible.builtin.debug: 72 | msg: "COMMAND:{{ kubernetes_worker__set_context_out.cmd }} | OUTPUT: {{ kubernetes_worker__set_context_out.stdout }}" 73 | verbosity: 2 74 | tags: 75 | - k8s-auth-config-proxy 76 | 77 | - name: Generate kubeconfig for kube-proxy (use-context) 78 | ansible.builtin.shell: > 79 | set -o errexit; \ 80 | kubectl config use-context default \ 81 | --kubeconfig={{ k8s_worker_kubeproxy_conf_dir }}/kubeconfig 82 | args: 83 | executable: /bin/bash 84 | register: kubernetes_worker__use_context_out 85 | changed_when: false 86 | failed_when: kubernetes_worker__use_context_out.rc != 0 87 | tags: 88 | - k8s-auth-config-proxy 89 | 90 | - name: Generate kubeconfig for kube-proxy (use-context) - DEBUG OUTPUT 91 | ansible.builtin.debug: 92 | msg: "COMMAND:{{ kubernetes_worker__use_context_out.cmd }} | OUTPUT: {{ kubernetes_worker__use_context_out.stdout }}" 93 | verbosity: 2 94 | tags: 95 | - k8s-auth-config-proxy 96 | 97 | - name: Set file permissions 98 | ansible.builtin.file: 99 | path: "{{ k8s_worker_kubeproxy_conf_dir }}/kubeconfig" 100 | owner: "root" 101 | group: "root" 102 | mode: "0640" 103 | modification_time: "preserve" 104 | access_time: "preserve" 105 | tags: 106 | - k8s-auth-config-proxy 107 | 108 | - name: Register checksum of kube-proxy current kubeconfig 109 | ansible.builtin.stat: 110 | path: "{{ k8s_worker_kubeproxy_conf_dir }}/kubeconfig" 111 | register: kubernetes_worker__kubeproxy_kubeconfig_current_stat 112 | tags: 113 | - k8s-auth-config-kubeproxy 114 | 115 | - name: Check if kube-proxy kubeconfig file changed 116 | when: 117 | - kubernetes_worker__kubeproxy_kubeconfig_orig_stat.stat.checksum is defined 118 | - kubernetes_worker__kubeproxy_kubeconfig_orig_stat.stat.checksum != kubernetes_worker__kubeproxy_kubeconfig_current_stat.stat.checksum 119 | ansible.builtin.debug: 120 | msg: "kube-proxy kubeconfig file changed" 121 | changed_when: 122 | - kubernetes_worker__kubeproxy_kubeconfig_orig_stat.stat.checksum != kubernetes_worker__kubeproxy_kubeconfig_current_stat.stat.checksum 123 | notify: 124 | - Restart kube-proxy 125 | tags: 126 | - k8s-auth-config-kubeproxy 127 | -------------------------------------------------------------------------------- /tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Remove swapfile from /etc/fstab 3 | ansible.posix.mount: 4 | name: swap 5 | fstype: swap 6 | state: absent 7 | tags: 8 | - k8s-worker 9 | 10 | - name: Disable swap 11 | ansible.builtin.command: swapoff -a 12 | when: ansible_swaptotal_mb > 0 13 | changed_when: false 14 | tags: 15 | - k8s-worker 16 | 17 | - name: Create worker nodes configuration base directory 18 | ansible.builtin.file: 19 | path: "{{ k8s_worker_conf_dir }}" 20 | state: directory 21 | mode: "0750" 22 | owner: "root" 23 | group: "root" 24 | tags: 25 | - k8s-worker 26 | 27 | - name: Create PKI directory 28 | ansible.builtin.file: 29 | path: "{{ k8s_worker_pki_dir }}" 30 | state: directory 31 | mode: "0750" 32 | owner: "root" 33 | group: "root" 34 | tags: 35 | - k8s-worker 36 | 37 | - name: Ensure Kubelet config directory 38 | ansible.builtin.file: 39 | path: "{{ k8s_worker_kubelet_conf_dir }}" 40 | state: directory 41 | mode: "0700" 42 | owner: "root" 43 | group: "root" 44 | tags: 45 | - k8s-worker 46 | 47 | - name: Ensure Kubeproxy config directory 48 | ansible.builtin.file: 49 | path: "{{ k8s_worker_kubeproxy_conf_dir }}" 50 | state: directory 51 | mode: "0700" 52 | owner: "root" 53 | group: "root" 54 | tags: 55 | - k8s-worker 56 | 57 | - name: Install required OS packages 58 | ansible.builtin.apt: 59 | state: present 60 | pkg: "{{ package }}" 61 | loop: "{{ k8s_worker_os_packages }}" 62 | loop_control: 63 | loop_var: "package" 64 | tags: 65 | - k8s-worker 66 | 67 | - name: Copy worker certificates (part 1) 68 | ansible.builtin.copy: 69 | src: "{{ k8s_ca_conf_directory }}/{{ item }}" 70 | dest: "{{ k8s_worker_pki_dir }}/{{ item }}" 71 | mode: "0640" 72 | owner: "root" 73 | group: "root" 74 | with_items: 75 | - "{{ k8s_worker_certificates }}" 76 | tags: 77 | - k8s-worker 78 | 79 | - name: Copy worker certificates (part 2) 80 | ansible.builtin.copy: 81 | src: "{{ k8s_ca_conf_directory }}/cert-{{ inventory_hostname }}.pem" 82 | dest: "{{ k8s_worker_pki_dir }}/cert-{{ inventory_hostname }}.pem" 83 | mode: "0640" 84 | owner: "root" 85 | group: "root" 86 | tags: 87 | - k8s-worker 88 | 89 | - name: Copy worker certificates (part 3) 90 | ansible.builtin.copy: 91 | src: "{{ k8s_ca_conf_directory }}/cert-{{ inventory_hostname }}-key.pem" 92 | dest: "{{ k8s_worker_pki_dir }}/cert-{{ inventory_hostname }}-key.pem" 93 | mode: "0640" 94 | owner: "root" 95 | group: "root" 96 | tags: 97 | - k8s-worker 98 | 99 | - name: Downloading official Kubernetes worker binaries 100 | ansible.builtin.get_url: 101 | url: "https://dl.k8s.io/v{{ k8s_worker_release }}/bin/linux/amd64/{{ item }}" 102 | checksum: "sha512:https://dl.k8s.io/v{{ k8s_worker_release }}/bin/linux/amd64/{{ item }}.sha512" 103 | dest: "{{ k8s_worker_bin_dir }}" 104 | owner: "root" 105 | group: "root" 106 | mode: "0755" 107 | with_items: 108 | - "{{ k8s_worker_binaries }}" 109 | notify: 110 | - Restart kube-proxy 111 | - Restart kubelet 112 | tags: 113 | - k8s-worker 114 | 115 | - name: Create kubelet kubeconfig 116 | ansible.builtin.include_tasks: 117 | file: "authconfig/kubelet.yml" 118 | apply: 119 | tags: 120 | - k8s-worker 121 | - k8s-auth-config-kubelet 122 | 123 | - name: Create kube-proxy kubeconfig 124 | ansible.builtin.include_tasks: 125 | file: "authconfig/kube-proxy.yml" 126 | apply: 127 | tags: 128 | - k8s-worker 129 | 130 | - name: Create kubelet-config.yaml 131 | ansible.builtin.copy: 132 | content: "{{ k8s_worker_kubelet_conf_yaml }}" 133 | dest: "{{ k8s_worker_kubelet_conf_dir }}/kubelet-config.yaml" 134 | mode: "0600" 135 | tags: 136 | - k8s-worker 137 | - kubelet-config-yaml 138 | 139 | - name: Create kubeproxy-config.yaml 140 | ansible.builtin.copy: 141 | content: "{{ k8s_worker_kubeproxy_conf_yaml }}" 142 | dest: "{{ k8s_worker_kubeproxy_conf_dir }}/kubeproxy-config.yaml" 143 | mode: "0600" 144 | tags: 145 | - k8s-worker 146 | - kubeproxy-config-yaml 147 | 148 | - name: Combine k8s_worker_kubelet_settings and k8s_worker_kubelet_settings_user (if defined) 149 | ansible.builtin.set_fact: 150 | k8s_worker_kubelet_settings: "{{ k8s_worker_kubelet_settings | combine(k8s_worker_kubelet_settings_user | default({})) }}" 151 | tags: 152 | - k8s-worker 153 | 154 | - name: Create kubelet.service systemd file 155 | ansible.builtin.template: 156 | src: etc/systemd/system/kubelet.service.j2 157 | dest: /etc/systemd/system/kubelet.service 158 | owner: "root" 159 | group: "root" 160 | mode: "0644" 161 | notify: 162 | - Reload systemd 163 | - Restart kubelet 164 | tags: 165 | - k8s-worker 166 | 167 | - name: Ensure Kubeproxy config directory 168 | ansible.builtin.file: 169 | path: "{{ k8s_worker_kubeproxy_conf_dir }}" 170 | state: "directory" 171 | mode: "0700" 172 | owner: "root" 173 | group: "root" 174 | tags: 175 | - k8s-worker 176 | 177 | - name: Combine k8s_worker_kubeproxy_settings and k8s_worker_kubeproxy_settings_user (if defined) 178 | ansible.builtin.set_fact: 179 | k8s_worker_kubeproxy_settings: "{{ k8s_worker_kubeproxy_settings | combine(k8s_worker_kubeproxy_settings_user | default({})) }}" 180 | tags: 181 | - k8s-worker 182 | 183 | - name: Create kube-proxy.service systemd file 184 | ansible.builtin.template: 185 | src: "etc/systemd/system/kube-proxy.service.j2" 186 | dest: "/etc/systemd/system/kube-proxy.service" 187 | owner: "root" 188 | group: "root" 189 | mode: "0644" 190 | notify: 191 | - Reload systemd 192 | - Restart kube-proxy 193 | tags: 194 | - k8s-worker 195 | 196 | - name: Flush handlers 197 | ansible.builtin.meta: flush_handlers 198 | 199 | - name: Enable Kubelet 200 | ansible.builtin.service: 201 | name: kubelet 202 | enabled: true 203 | state: started 204 | tags: 205 | - k8s-worker 206 | 207 | - name: Enable kube-proxy 208 | ansible.builtin.service: 209 | name: kube-proxy 210 | enabled: true 211 | state: started 212 | tags: 213 | - k8s-worker 214 | -------------------------------------------------------------------------------- /defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # The base directory for Kubernetes configuration and certificate files for 3 | # everything worker nodes related. After the playbook is done this directory 4 | # contains various sub-folders. 5 | k8s_worker_conf_dir: "/etc/kubernetes/worker" 6 | 7 | # All certificate files (Private Key Infrastructure related) specified in 8 | # "k8s_worker_certificates" (see "vars/main.yml") will be stored here. 9 | # Owner and group of this new directory will be "root". File permissions 10 | # will be "0640". 11 | k8s_worker_pki_dir: "{{ k8s_worker_conf_dir }}/pki" 12 | 13 | # The directory to store the Kubernetes binaries (see "k8s_worker_binaries" 14 | # variable in "vars/main.yml"). Owner and group of this new directory 15 | # will be "root" in both cases. Permissions for this directory will be "0755". 16 | # 17 | # NOTE: The default directory "/usr/local/bin" normally already exists on every 18 | # Linux installation with the owner, group and permissions mentioned above. If 19 | # your current settings are different consider a different directory. But make sure 20 | # that the new directory is included in your "$PATH" variable value. 21 | k8s_worker_bin_dir: "/usr/local/bin" 22 | 23 | # K8s release 24 | k8s_worker_release: "1.33.6" 25 | 26 | # The interface on which the Kubernetes services should listen on. As all cluster 27 | # communication should use a VPN interface the interface name is 28 | # normally "wg0" (WireGuard),"peervpn0" (PeerVPN) or "tap0". 29 | # 30 | # The network interface on which the Kubernetes worker services should 31 | # listen on. That is: 32 | # 33 | # - kube-proxy 34 | # - kubelet 35 | # 36 | k8s_interface: "eth0" 37 | 38 | # The directory from where to copy the K8s certificates. By default this 39 | # will expand to user's LOCAL $HOME (the user that run's "ansible-playbook ..." 40 | # plus "/k8s/certs". That means if the user's $HOME directory is e.g. 41 | # "/home/da_user" then "k8s_ca_conf_directory" will have a value of 42 | # "/home/da_user/k8s/certs". 43 | k8s_ca_conf_directory: "{{ '~/k8s/certs' | expanduser }}" 44 | 45 | # The IP address or hostname of the Kubernetes API endpoint. This variable 46 | # is used by "kube-proxy" and "kubelet" to connect to the "kube-apiserver" 47 | # (Kubernetes API server). 48 | # 49 | # By default the first host in the Ansible group "k8s_controller" is 50 | # specified here. NOTE: This setting is not fault tolerant! That means 51 | # if the first host in the Ansible group "k8s_controller" is down 52 | # the worker node and its workload continue working but the worker 53 | # node doesn't receive any updates from Kubernetes API server. 54 | # 55 | # If you have a loadbalancer that distributes traffic between all 56 | # Kubernetes API servers it should be specified here (either its IP 57 | # address or the DNS name). But you need to make sure that the IP 58 | # address or the DNS name you want to use here is included in the 59 | # Kubernetes API server TLS certificate (see "k8s_apiserver_cert_hosts" 60 | # variable of https://github.com/githubixx/ansible-role-kubernetes-ca 61 | # role). If it's not specified you'll get certificate errors in the 62 | # logs of the services mentioned above. 63 | k8s_worker_api_endpoint_host: "{{ hostvars[groups['k8s_controller'] | first]['ansible_' + hostvars[groups['k8s_controller'] | first]['k8s_interface']].ipv4.address }}" 64 | 65 | # As above just for the port. It specifies on which port the 66 | # Kubernetes API servers are listening. Again if there is a loadbalancer 67 | # in place that distributes the requests to the Kubernetes API servers 68 | # put the port of the loadbalancer here. 69 | k8s_worker_api_endpoint_port: "6443" 70 | 71 | # OS packages needed on a Kubernetes worker node. You can add additional 72 | # packages at any time. But please be aware if you remove one or more from 73 | # the default list your worker node might not work as expected or doesn't work 74 | # at all. 75 | k8s_worker_os_packages: 76 | - ebtables 77 | - ethtool 78 | - ipset 79 | - conntrack 80 | - iptables 81 | - iptstate 82 | - netstat-nat 83 | - socat 84 | - netbase 85 | 86 | # Directory to store kubelet configuration 87 | k8s_worker_kubelet_conf_dir: "{{ k8s_worker_conf_dir }}/kubelet" 88 | 89 | # kubelet settings 90 | # 91 | # If you want to enable the use of "RuntimeDefault" as the default seccomp 92 | # profile for all workloads add these settings to "k8s_worker_kubelet_settings": 93 | # 94 | # "seccomp-default": "" 95 | # 96 | # Also see: 97 | # https://kubernetes.io/docs/tutorials/security/seccomp/#enable-the-use-of-runtimedefault-as-the-default-seccomp-profile-for-all-workloads 98 | k8s_worker_kubelet_settings: 99 | "config": "{{ k8s_worker_kubelet_conf_dir }}/kubelet-config.yaml" 100 | "node-ip": "{{ hostvars[inventory_hostname]['ansible_' + k8s_interface].ipv4.address }}" 101 | "kubeconfig": "{{ k8s_worker_kubelet_conf_dir }}/kubeconfig" 102 | 103 | # kubelet kubeconfig 104 | k8s_worker_kubelet_conf_yaml: | 105 | kind: KubeletConfiguration 106 | apiVersion: kubelet.config.k8s.io/v1beta1 107 | address: {{ hostvars[inventory_hostname]['ansible_' + k8s_interface].ipv4.address }} 108 | authentication: 109 | anonymous: 110 | enabled: false 111 | webhook: 112 | enabled: true 113 | x509: 114 | clientCAFile: "{{ k8s_worker_pki_dir }}/ca-k8s-apiserver.pem" 115 | authorization: 116 | mode: Webhook 117 | clusterDomain: "cluster.local" 118 | clusterDNS: 119 | - "10.32.0.254" 120 | failSwapOn: true 121 | healthzBindAddress: "{{ hostvars[inventory_hostname]['ansible_' + k8s_interface].ipv4.address }}" 122 | healthzPort: 10248 123 | runtimeRequestTimeout: "15m" 124 | serializeImagePulls: false 125 | tlsCertFile: "{{ k8s_worker_pki_dir }}/cert-{{ inventory_hostname }}.pem" 126 | tlsPrivateKeyFile: "{{ k8s_worker_pki_dir }}/cert-{{ inventory_hostname }}-key.pem" 127 | cgroupDriver: "systemd" 128 | registerNode: true 129 | containerRuntimeEndpoint: "unix:///run/containerd/containerd.sock" 130 | 131 | # Directory to store kube-proxy configuration 132 | k8s_worker_kubeproxy_conf_dir: "{{ k8s_worker_conf_dir }}/kube-proxy" 133 | 134 | # kube-proxy settings 135 | k8s_worker_kubeproxy_settings: 136 | "config": "{{ k8s_worker_kubeproxy_conf_dir }}/kubeproxy-config.yaml" 137 | 138 | k8s_worker_kubeproxy_conf_yaml: | 139 | kind: KubeProxyConfiguration 140 | apiVersion: kubeproxy.config.k8s.io/v1alpha1 141 | bindAddress: {{ hostvars[inventory_hostname]['ansible_' + k8s_interface].ipv4.address }} 142 | clientConnection: 143 | kubeconfig: "{{ k8s_worker_kubeproxy_conf_dir }}/kubeconfig" 144 | healthzBindAddress: {{ hostvars[inventory_hostname]['ansible_' + k8s_interface].ipv4.address }}:10256 145 | mode: "ipvs" 146 | ipvs: 147 | minSyncPeriod: 0s 148 | scheduler: "" 149 | syncPeriod: 2s 150 | iptables: 151 | masqueradeAll: true 152 | clusterCIDR: "10.200.0.0/16" 153 | -------------------------------------------------------------------------------- /molecule/default/group_vars/all.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # Copyright (C) 2023 Robert Wimmer 3 | # SPDX-License-Identifier: GPL-3.0-or-later 4 | 5 | # Use "systemd-timesyncd" for time services. It's available by default. 6 | harden_linux_ntp: "systemd-timesyncd" 7 | 8 | # Password for user "root" and "vagrant" is "vagrant" in both cases. As 9 | # "vagrant" user is available in every Vagrant Ubuntu Box just use it. 10 | harden_linux_root_password: "$6$rounds=656000$mysecretsalt$fpyQ9hMON6iKKuM0Rz10WZKNJR4OkQTVfBmd4SPrJPsU9XmgQGRtogcUnFB5FLRIitswuQFr6Tr8Mos9l7Ojm0" 11 | harden_linux_deploy_user: "vagrant" 12 | harden_linux_deploy_user_password: "$6$rounds=656000$mysecretsalt$fpyQ9hMON6iKKuM0Rz10WZKNJR4OkQTVfBmd4SPrJPsU9XmgQGRtogcUnFB5FLRIitswuQFr6Tr8Mos9l7Ojm0" 13 | harden_linux_deploy_user_home: "/home/vagrant" 14 | harden_linux_deploy_user_uid: "1000" 15 | harden_linux_deploy_user_shell: "/bin/bash" 16 | 17 | # Enable IP forwarding for IPv4 and IPv6 18 | harden_linux_sysctl_settings_user: 19 | "net.ipv4.ip_forward": 1 20 | "net.ipv6.conf.default.forwarding": 1 21 | "net.ipv6.conf.all.forwarding": 1 22 | 23 | # Let SSHd listen on port 22, allow password authentication and allow "root" 24 | # login. The last two settings are not recommended for production use but for 25 | # this test deployment it's okay as it makes debugging easier and faster. 26 | harden_linux_sshd_settings_user: 27 | "^Port ": "Port 22" 28 | "^PasswordAuthentication": "PasswordAuthentication yes" 29 | "^PermitRootLogin": "PermitRootLogin yes" 30 | 31 | # Enable logging for UFW. 32 | harden_linux_ufw_logging: 'on' 33 | 34 | # Set the default forward policy to "ACCEPT". 35 | harden_linux_ufw_defaults_user: 36 | "^DEFAULT_FORWARD_POLICY": 'DEFAULT_FORWARD_POLICY="ACCEPT"' 37 | 38 | # Don't block SSH logins from the following networks even login attempts fail 39 | # for a few times. 40 | harden_linux_sshguard_whitelist: 41 | - "127.0.0.0/8" 42 | - "::1/128" 43 | - "10.0.0.0/8" 44 | - "172.16.0.0/12" 45 | - "192.168.0.0/16" 46 | 47 | # Directory where the etcd certificates are stored on the Ansible controller 48 | # host. Certificate files for etcd will be copied from this directory to 49 | # the etcd nodes. 50 | etcd_ca_conf_directory: "{{ k8s_ca_conf_directory }}" 51 | # Directory where the etcd certificates are stored on the etcd hosts. 52 | etcd_conf_dir: "/etc/etcd" 53 | # Interface where the etcd service is listening on. 54 | etcd_interface: "{{ k8s_interface }}" 55 | # A few additional settings for etcd. 56 | etcd_settings_user: 57 | "heartbeat-interval": "250" 58 | "election-timeout": "2500" 59 | # Host names and IP addresses in the etcd certificates. 60 | etcd_cert_hosts: 61 | - localhost 62 | - 127.0.0.1 63 | 64 | # Directory where the Kubernetes certificates are stored on the Ansible 65 | # controller host. 66 | k8s_ca_conf_directory: "/tmp/k8s-ca" 67 | # Permissions for the Kubernetes CA directory. 68 | k8s_ca_conf_directory_perm: "0700" 69 | # Permissions for the Kubernetes CA files. 70 | k8s_ca_file_perm: "0600" 71 | # Owner of the Kubernetes CA files. 72 | k8s_ca_certificate_owner: "vagrant" 73 | # Group of the Kubernetes CA files. 74 | k8s_ca_certificate_group: "vagrant" 75 | 76 | # Interface where the Kubernetes control plane services are listening on. 77 | k8s_interface: "wg0" 78 | # Interface where the etcd daemons listening on. 79 | k8s_ctl_etcd_interface: "{{ etcd_interface }}" 80 | 81 | # Delegate tasks like creating the Kubernetes CA certificates to the following 82 | # host. This host also communicates with the "kube-apiserver" if required 83 | # for certain tasks. 84 | k8s_ctl_delegate_to: "test-assets" 85 | 86 | # Directory where the Kubernetes certificates are stored on the Ansible 87 | # controller host and where the Ansible can find them to be copied to the 88 | # Kubernetes control plane nodes. 89 | k8s_ctl_ca_conf_directory: "{{ k8s_ca_conf_directory }}" 90 | 91 | # The name of the Kubernetes cluster. 92 | k8s_config_cluster_name: "k8s" 93 | 94 | # Directory where "admin.kubeconfig" (the credentials file) for the "admin" 95 | # user is stored 96 | k8s_admin_conf_dir: "{{ '~/k8s/configs' | expanduser }}" 97 | # Permissions for the directory specified in "k8s_admin_conf_dir" 98 | k8s_admin_conf_dir_perm: "0700" 99 | # Owner of the directory specified in "k8s_admin_conf_dir" and for 100 | # "admin.kubeconfig" stored in this directory. 101 | k8s_admin_conf_owner: "root" 102 | # Group of the directory specified in "k8s_admin_conf_dir" and for 103 | # "admin.kubeconfig" stored in this directory. 104 | k8s_admin_conf_group: "root" 105 | 106 | # Run Kubernetes control plane services as the following user. 107 | k8s_run_as_user: "k8s" 108 | # Run Kubernetes control plane services as the following group. 109 | k8s_run_as_group: "k8s" 110 | 111 | # Key used for encrypting secrets (encryption at-rest) by the 112 | # "kube-apiserver". 113 | k8s_encryption_config_key: "Y29uZmlndXJhdGlvbjIyCg==" 114 | 115 | # Additional settings for the "kube-apiserver". 116 | k8s_apiserver_settings_user: 117 | "enable-aggregator-routing": "true" 118 | 119 | k8s_worker_kubelet_settings: 120 | "config": "{{ k8s_worker_kubelet_conf_dir }}/kubelet-config.yaml" 121 | "node-ip": "{{ hostvars[inventory_hostname]['ansible_' + k8s_interface].ipv4.address }}" 122 | "kubeconfig": "{{ k8s_worker_kubelet_conf_dir }}/kubeconfig" 123 | "seccomp-default": "" 124 | 125 | # Directory for the "runc" binaries 126 | runc_bin_directory: "/usr/local/sbin" 127 | 128 | # Directory to store the "containerd" archive after download 129 | containerd_tmp_directory: "/tmp" 130 | 131 | # Don't use "etcd" for Cilium 132 | cilium_etcd_enabled: "false" 133 | # Delegate Cilium tasks that needs to communicate with the Kubernetes API 134 | # server to the following host. 135 | cilium_delegate_to: "test-assets" 136 | # Show debug output for Cilium Helm commands. 137 | cilium_helm_show_commands: true 138 | 139 | # Delegate tasks to create CoreDNS K8s resources to this host. 140 | coredns_delegate_to: "test-assets" 141 | 142 | # Common name for "etcd" certificate authority certificates. 143 | ca_etcd_csr_cn: "etcd" 144 | ca_etcd_csr_key_algo: "ecdsa" 145 | ca_etcd_csr_key_size: "384" 146 | 147 | # Common name for "kube-apiserver" certificate authority certificate. 148 | ca_k8s_apiserver_csr_cn: "kubernetes" 149 | ca_k8s_apiserver_csr_key_algo: "ecdsa" 150 | ca_k8s_apiserver_csr_key_size: "384" 151 | 152 | # Common names for "etcd" server, peer and client certificates. 153 | etcd_server_csr_cn: "etcd-server" 154 | etcd_server_csr_key_algo: "ecdsa" 155 | etcd_server_csr_key_size: "384" 156 | 157 | etcd_peer_csr_cn: "etcd-peer" 158 | etcd_peer_csr_key_algo: "ecdsa" 159 | etcd_peer_csr_key_size: "384" 160 | 161 | etcd_client_csr_cn_prefix: "etcd-client" 162 | etcd_client_csr_key_algo: "ecdsa" 163 | etcd_client_csr_key_size: "384" 164 | 165 | # Common names for kube-apiserver, admin and kube-controller-manager certificates. 166 | k8s_apiserver_csr_cn: "k8s-apiserver" 167 | k8s_apiserver_csr_key_algo: "ecdsa" 168 | k8s_apiserver_csr_key_size: "384" 169 | 170 | k8s_admin_csr_cn: "k8s-admin" 171 | k8s_admin_csr_key_algo: "ecdsa" 172 | k8s_admin_csr_key_size: "384" 173 | 174 | k8s_worker_csr_key_algo: "ecdsa" 175 | k8s_worker_csr_key_size: "384" 176 | 177 | k8s_controller_manager_csr_key_algo: "ecdsa" 178 | k8s_controller_manager_csr_key_size: "384" 179 | 180 | k8s_scheduler_csr_key_algo: "ecdsa" 181 | k8s_scheduler_csr_key_size: "384" 182 | 183 | k8s_controller_manager_sa_csr_cn: "k8s-service-accounts" 184 | k8s_controller_manager_sa_csr_key_algo: "ecdsa" 185 | k8s_controller_manager_sa_csr_key_size: "384" 186 | 187 | k8s_kube_proxy_csr_key_algo: "ecdsa" 188 | k8s_kube_proxy_csr_key_size: "384" 189 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ansible-role-kubernetes-worker 2 | 3 | This Ansible role is used in [Kubernetes the not so hard way with Ansible - Worker](https://www.tauceti.blog/posts/kubernetes-the-not-so-hard-way-with-ansible-worker-2020/). This Ansible role setup Kubernetes worker nodes. For more information please see [Kubernetes the not so hard way with Ansible - Worker](https://www.tauceti.blog/posts/kubernetes-the-not-so-hard-way-with-ansible-worker-2020/). 4 | 5 | ## Versions 6 | 7 | I tag every release and try to stay with [semantic versioning](http://semver.org). If you want to use the role I recommend to checkout the latest tag. The master branch is basically development while the tags mark stable releases. But in general I try to keep master in good shape too. A tag `30.0.0+1.33.6` means this is release `30.0.0` of this role and it's meant to be used with Kubernetes version `1.33.6` (but should work with any K8s 1.33.x release of course). If the role itself changes `X.Y.Z` before `+` will increase. If the Kubernetes version changes `X.Y.Z` after `+` will increase too. This allows to tag bugfixes and new major versions of the role while it's still developed for a specific Kubernetes release. That's especially useful for Kubernetes major releases with breaking changes. 8 | 9 | ## Requirements 10 | 11 | This playbook expects that you already have rolled out the Kubernetes controller components (see [kubernetes-controller](https://github.com/githubixx/ansible-role-kubernetes-controller) and [Kubernetes the not so hard way with Ansible - Control plane](https://www.tauceti.blog/post/kubernetes-the-not-so-hard-way-with-ansible-control-plane/). 12 | 13 | You also need [containerd](https://github.com/githubixx/ansible-role-containerd), [CNI plugins](https://github.com/githubixx/ansible-role-cni) and [runc](https://github.com/githubixx/ansible-role-runc) installed. To enable Kubernetes `Pods` to communicate between different hosts it makes sense to install [Cilium](https://galaxy.ansible.com/githubixx/cilium_kubernetes) later once the worker nodes are running e.g. Of course `Calico`, `WeaveNet`, `kube-router` or [flannel](https://galaxy.ansible.com/githubixx/flanneld) or other Kubernetes network solutions are valid options. 14 | 15 | ## Supported OS 16 | 17 | - Ubuntu 22.04 (Jammy Jellyfish) 18 | - Ubuntu 24.04 (Noble Numbat) (recommended) 19 | 20 | ## Changelog 21 | 22 | **Change history:** 23 | 24 | See full [CHANGELOG.md](https://github.com/githubixx/ansible-role-kubernetes-worker/blob/master/CHANGELOG.md) 25 | 26 | **IMPORTANT** Version `24.0.0+1.27.8` had a lot of potential breaking changes. So if you upgrade from a version < `24.0.0+1.27.8` please read the CHANGELOG of that version too! 27 | 28 | **Recent changes:** 29 | 30 | ## 30.0.0+1.33.6 31 | 32 | - **UPDATE** 33 | - update `k8s_ctl_release` to `1.33.6` 34 | 35 | ## 29.1.0+1.32.9 36 | 37 | - **UPDATE** 38 | - update `k8s_ctl_release` to `1.32.9` 39 | 40 | - **OTHER CHANGES** 41 | - `defaults/main.yml`: `k8s_worker_api_endpoint_host` - simplify the complex default variables for endpoint hosts to avoid nested template construction 42 | 43 | - **MOLECULE** 44 | - install `python3-kubernetes` package instead `kubernetes` Pip in `prepare.yml` 45 | 46 | ## 29.0.0+1.32.8 47 | 48 | - **BREAKING** 49 | - Removed Ubuntu 20.04 because reached end of life 50 | 51 | - **UPDATE** 52 | - update `k8s_worker_release` to `1.32.8` 53 | - `kubelet.service.j2`: Update `kubelet` systemd service file. Utilize the systemd watchdog capability to restart the kubelet when the kubelet health check fails, and limit the maximum number of restarts within a given time period. This can enhance the reliability of the kubelet to some extent (see [integrate kubelet with the systemd watchdog](https://github.com/kubernetes/kubernetes/pull/127566)): 54 | - Changed: `Restart=on-failure` -> `Restart=always` 55 | - Changed: `RestartSec=5` -> `RestartSec=10` 56 | - Added: `WatchdogSec=30s` 57 | 58 | - **MOLECULE** 59 | - Removed Ubuntu 20.04 because reached end of life 60 | - Fix `ansible-lint` issues 61 | 62 | ## 28.0.1+1.31.11 63 | 64 | - **UPDATE** 65 | - update `k8s_worker_release` to `1.31.11` 66 | 67 | ## 28.0.0+1.31.5 68 | 69 | - **UPDATE** 70 | - update `k8s_worker_release` to `1.31.5` 71 | 72 | ## 27.0.1+1.30.9 73 | 74 | - **UPDATE** 75 | - update `k8s_worker_release` to `1.30.9` 76 | 77 | ## 27.0.0+1.30.5 78 | 79 | - **UPDATE** 80 | - update `k8s_worker_release` to `1.30.5` 81 | 82 | - **OTHER CHANGES** 83 | - support Ubuntu 24.04 84 | - update `.yamllint` 85 | 86 | ## Installation 87 | 88 | - Directly download from Github (Change into Ansible roles directory before cloning. You can figure out the role path by using `ansible-config dump | grep DEFAULT_ROLES_PATH` command): 89 | `git clone https://github.com/githubixx/ansible-role-kubernetes-worker.git githubixx.kubernetes_worker` 90 | 91 | - Via `ansible-galaxy` command and download directly from Ansible Galaxy: 92 | `ansible-galaxy install role githubixx.kubernetes_worker` 93 | 94 | - Create a `requirements.yml` file with the following content (this will download the role from Github) and install with 95 | `ansible-galaxy role install -r requirements.yml` (change `version` if needed): 96 | 97 | ```yaml 98 | --- 99 | roles: 100 | - name: githubixx.kubernetes_worker 101 | src: https://github.com/githubixx/ansible-role-kubernetes-worker.git 102 | version: 30.0.0+1.33.6 103 | ``` 104 | 105 | ## Role Variables 106 | 107 | ```yaml 108 | # The base directory for Kubernetes configuration and certificate files for 109 | # everything worker nodes related. After the playbook is done this directory 110 | # contains various sub-folders. 111 | k8s_worker_conf_dir: "/etc/kubernetes/worker" 112 | 113 | # All certificate files (Private Key Infrastructure related) specified in 114 | # "k8s_worker_certificates" (see "vars/main.yml") will be stored here. 115 | # Owner and group of this new directory will be "root". File permissions 116 | # will be "0640". 117 | k8s_worker_pki_dir: "{{ k8s_worker_conf_dir }}/pki" 118 | 119 | # The directory to store the Kubernetes binaries (see "k8s_worker_binaries" 120 | # variable in "vars/main.yml"). Owner and group of this new directory 121 | # will be "root" in both cases. Permissions for this directory will be "0755". 122 | # 123 | # NOTE: The default directory "/usr/local/bin" normally already exists on every 124 | # Linux installation with the owner, group and permissions mentioned above. If 125 | # your current settings are different consider a different directory. But make sure 126 | # that the new directory is included in your "$PATH" variable value. 127 | k8s_worker_bin_dir: "/usr/local/bin" 128 | 129 | # K8s release 130 | k8s_worker_release: "1.33.6" 131 | 132 | # The interface on which the Kubernetes services should listen on. As all cluster 133 | # communication should use a VPN interface the interface name is 134 | # normally "wg0" (WireGuard),"peervpn0" (PeerVPN) or "tap0". 135 | # 136 | # The network interface on which the Kubernetes worker services should 137 | # listen on. That is: 138 | # 139 | # - kube-proxy 140 | # - kubelet 141 | # 142 | k8s_interface: "eth0" 143 | 144 | # The directory from where to copy the K8s certificates. By default this 145 | # will expand to user's LOCAL $HOME (the user that run's "ansible-playbook ..." 146 | # plus "/k8s/certs". That means if the user's $HOME directory is e.g. 147 | # "/home/da_user" then "k8s_ca_conf_directory" will have a value of 148 | # "/home/da_user/k8s/certs". 149 | k8s_ca_conf_directory: "{{ '~/k8s/certs' | expanduser }}" 150 | 151 | # The IP address or hostname of the Kubernetes API endpoint. This variable 152 | # is used by "kube-proxy" and "kubelet" to connect to the "kube-apiserver" 153 | # (Kubernetes API server). 154 | # 155 | # By default the first host in the Ansible group "k8s_controller" is 156 | # specified here. NOTE: This setting is not fault tolerant! That means 157 | # if the first host in the Ansible group "k8s_controller" is down 158 | # the worker node and its workload continue working but the worker 159 | # node doesn't receive any updates from Kubernetes API server. 160 | # 161 | # If you have a loadbalancer that distributes traffic between all 162 | # Kubernetes API servers it should be specified here (either its IP 163 | # address or the DNS name). But you need to make sure that the IP 164 | # address or the DNS name you want to use here is included in the 165 | # Kubernetes API server TLS certificate (see "k8s_apiserver_cert_hosts" 166 | # variable of https://github.com/githubixx/ansible-role-kubernetes-ca 167 | # role). If it's not specified you'll get certificate errors in the 168 | # logs of the services mentioned above. 169 | k8s_worker_api_endpoint_host: "{% set controller_host = groups['k8s_controller'][0] %}{{ hostvars[controller_host]['ansible_' + hostvars[controller_host]['k8s_interface']].ipv4.address }}" 170 | 171 | # As above just for the port. It specifies on which port the 172 | # Kubernetes API servers are listening. Again if there is a loadbalancer 173 | # in place that distributes the requests to the Kubernetes API servers 174 | # put the port of the loadbalancer here. 175 | k8s_worker_api_endpoint_port: "6443" 176 | 177 | # OS packages needed on a Kubernetes worker node. You can add additional 178 | # packages at any time. But please be aware if you remove one or more from 179 | # the default list your worker node might not work as expected or doesn't work 180 | # at all. 181 | k8s_worker_os_packages: 182 | - ebtables 183 | - ethtool 184 | - ipset 185 | - conntrack 186 | - iptables 187 | - iptstate 188 | - netstat-nat 189 | - socat 190 | - netbase 191 | 192 | # Directory to store kubelet configuration 193 | k8s_worker_kubelet_conf_dir: "{{ k8s_worker_conf_dir }}/kubelet" 194 | 195 | # kubelet settings 196 | # 197 | # If you want to enable the use of "RuntimeDefault" as the default seccomp 198 | # profile for all workloads add these settings to "k8s_worker_kubelet_settings": 199 | # 200 | # "seccomp-default": "" 201 | # 202 | # Also see: 203 | # https://kubernetes.io/docs/tutorials/security/seccomp/#enable-the-use-of-runtimedefault-as-the-default-seccomp-profile-for-all-workloads 204 | k8s_worker_kubelet_settings: 205 | "config": "{{ k8s_worker_kubelet_conf_dir }}/kubelet-config.yaml" 206 | "node-ip": "{{ hostvars[inventory_hostname]['ansible_' + k8s_interface].ipv4.address }}" 207 | "kubeconfig": "{{ k8s_worker_kubelet_conf_dir }}/kubeconfig" 208 | 209 | # kubelet kubeconfig 210 | k8s_worker_kubelet_conf_yaml: | 211 | kind: KubeletConfiguration 212 | apiVersion: kubelet.config.k8s.io/v1beta1 213 | address: {{ hostvars[inventory_hostname]['ansible_' + k8s_interface].ipv4.address }} 214 | authentication: 215 | anonymous: 216 | enabled: false 217 | webhook: 218 | enabled: true 219 | x509: 220 | clientCAFile: "{{ k8s_worker_pki_dir }}/ca-k8s-apiserver.pem" 221 | authorization: 222 | mode: Webhook 223 | clusterDomain: "cluster.local" 224 | clusterDNS: 225 | - "10.32.0.254" 226 | failSwapOn: true 227 | healthzBindAddress: "{{ hostvars[inventory_hostname]['ansible_' + k8s_interface].ipv4.address }}" 228 | healthzPort: 10248 229 | runtimeRequestTimeout: "15m" 230 | serializeImagePulls: false 231 | tlsCertFile: "{{ k8s_worker_pki_dir }}/cert-{{ inventory_hostname }}.pem" 232 | tlsPrivateKeyFile: "{{ k8s_worker_pki_dir }}/cert-{{ inventory_hostname }}-key.pem" 233 | cgroupDriver: "systemd" 234 | registerNode: true 235 | containerRuntimeEndpoint: "unix:///run/containerd/containerd.sock" 236 | 237 | # Directory to store kube-proxy configuration 238 | k8s_worker_kubeproxy_conf_dir: "{{ k8s_worker_conf_dir }}/kube-proxy" 239 | 240 | # kube-proxy settings 241 | k8s_worker_kubeproxy_settings: 242 | "config": "{{ k8s_worker_kubeproxy_conf_dir }}/kubeproxy-config.yaml" 243 | 244 | k8s_worker_kubeproxy_conf_yaml: | 245 | kind: KubeProxyConfiguration 246 | apiVersion: kubeproxy.config.k8s.io/v1alpha1 247 | bindAddress: {{ hostvars[inventory_hostname]['ansible_' + k8s_interface].ipv4.address }} 248 | clientConnection: 249 | kubeconfig: "{{ k8s_worker_kubeproxy_conf_dir }}/kubeconfig" 250 | healthzBindAddress: {{ hostvars[inventory_hostname]['ansible_' + k8s_interface].ipv4.address }}:10256 251 | mode: "ipvs" 252 | ipvs: 253 | minSyncPeriod: 0s 254 | scheduler: "" 255 | syncPeriod: 2s 256 | iptables: 257 | masqueradeAll: true 258 | clusterCIDR: "10.200.0.0/16" 259 | ``` 260 | 261 | ## Dependencies 262 | 263 | - [kubernetes_controller](https://github.com/githubixx/ansible-role-kubernetes-controller) 264 | - [containerd](https://github.com/githubixx/ansible-role-containerd) 265 | - [runc](https://github.com/githubixx/ansible-role-runc) 266 | - [CNI plugins](https://github.com/githubixx/ansible-role-cni) 267 | 268 | ## Example Playbook 269 | 270 | ```yaml 271 | - hosts: k8s_worker 272 | roles: 273 | - githubixx.kubernetes_worker 274 | ``` 275 | 276 | ## Testing 277 | 278 | This role has a small test setup that is created using [Molecule](https://github.com/ansible-community/molecule), libvirt (vagrant-libvirt) and QEMU/KVM. Please see my blog post [Testing Ansible roles with Molecule, libvirt (vagrant-libvirt) and QEMU/KVM](https://www.tauceti.blog/posts/testing-ansible-roles-with-molecule-libvirt-vagrant-qemu-kvm/) how to setup. The Molecule test configuration is in [molecule/default](https://github.com/githubixx/ansible-role-kubernetes-worker/tree/master/molecule/default). 279 | 280 | Afterwards Molecule can be executed. This will setup a few virtual machines (VM) with supported Ubuntu OS and installs a Kubernetes cluster: 281 | 282 | ```bash 283 | molecule converge 284 | ``` 285 | 286 | At this time the cluster isn't fully functional as a network plugin is missing e.g. So Pod to Pod communication between two different nodes isn't possible yet. To fix this the following command can be used to install [Cilium](https://github.com/githubixx/ansible-role-cilium-kubernetes) for all Kubernetes networking needs and [CoreDNS](https://github.com/githubixx/ansible-kubernetes-playbooks/tree/master/coredns) for Kubernetes DNS stuff: 287 | 288 | ```bash 289 | molecule converge -- --extra-vars k8s_worker_setup_networking=install 290 | ``` 291 | 292 | After this you basically have a fully functional Kubernetes cluster. 293 | 294 | A small verification step is also included: 295 | 296 | ```bash 297 | molecule verify 298 | ``` 299 | 300 | To clean up run 301 | 302 | ```bash 303 | molecule destroy 304 | ``` 305 | 306 | ## License 307 | 308 | GNU GENERAL PUBLIC LICENSE Version 3 309 | 310 | ## Author Information 311 | 312 | [http://www.tauceti.blog](http://www.tauceti.blog) 313 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## 30.0.0+1.33.6 4 | 5 | - **UPDATE** 6 | - update `k8s_ctl_release` to `1.33.6` 7 | 8 | ## 29.1.0+1.32.9 9 | 10 | - **UPDATE** 11 | - update `k8s_ctl_release` to `1.32.9` 12 | 13 | - **OTHER CHANGES** 14 | - `defaults/main.yml`: `k8s_worker_api_endpoint_host` - simplify the complex default variables for endpoint hosts to avoid nested template construction 15 | 16 | - **MOLECULE** 17 | - install `python3-kubernetes` package instead `kubernetes` Pip in `prepare.yml` 18 | 19 | ## 29.0.0+1.32.8 20 | 21 | - **BREAKING** 22 | - Removed Ubuntu 20.04 because reached end of life 23 | 24 | - **UPDATE** 25 | - update `k8s_worker_release` to `1.32.8` 26 | - `kubelet.service.j2`: Update `kubelet` systemd service file. Utilize the systemd watchdog capability to restart the kubelet when the kubelet health check fails, and limit the maximum number of restarts within a given time period. This can enhance the reliability of the kubelet to some extent (see [integrate kubelet with the systemd watchdog](https://github.com/kubernetes/kubernetes/pull/127566)): 27 | - Changed: `Restart=on-failure` -> `Restart=always` 28 | - Changed: `RestartSec=5` -> `RestartSec=10` 29 | - Added: `WatchdogSec=30s` 30 | 31 | - **MOLECULE** 32 | - Removed Ubuntu 20.04 because reached end of life 33 | - Fix `ansible-lint` issues 34 | 35 | ## 28.0.1+1.31.11 36 | 37 | - **UPDATE** 38 | - update `k8s_worker_release` to `1.31.11` 39 | 40 | ## 28.0.0+1.31.5 41 | 42 | - **UPDATE** 43 | - update `k8s_worker_release` to `1.31.5` 44 | 45 | ## 27.0.1+1.30.9 46 | 47 | - **UPDATE** 48 | - update `k8s_worker_release` to `1.30.9` 49 | 50 | ## 27.0.0+1.30.5 51 | 52 | - **UPDATE** 53 | - update `k8s_worker_release` to `1.30.5` 54 | 55 | - **OTHER CHANGES** 56 | - support Ubuntu 24.04 57 | - update `.yamllint` 58 | 59 | ## 26.0.2+1.29.9 60 | 61 | - **OTHER CHANGES** 62 | - fix download URLs for Kubernetes binaries (see: [Download Kubernetes - Binaries](https://kubernetes.io/releases/download/#binaries) 63 | 64 | ## 26.0.1+1.29.9 65 | 66 | - **UPDATE** 67 | - update `k8s_worker_release` to `1.29.9` 68 | 69 | ## 26.0.0+1.29.4 70 | 71 | - **PLEASE READ CAREFULLY** 72 | 73 | Version `24.0.0+1.27.8` had a lot of potential breaking changes. So if you upgrade from a version < `24.0.0+1.27.8` please read the CHANGELOG of that version too! 74 | 75 | - **UPDATE** 76 | - update `k8s_worker_release` to `1.29.4` 77 | 78 | - **MOLECULE** 79 | - use `alvistack` instead of `generic` Vagrant boxes 80 | 81 | ## 25.0.1+1.28.8 82 | 83 | - **UPDATE** 84 | - update `k8s_worker_release` to `1.28.8` 85 | 86 | ## 25.0.0+1.28.5 87 | 88 | - **PLEASE READ CAREFULLY** 89 | 90 | Version `24.0.0+1.27.8` had a lot of potential breaking changes. So if you upgrade from a version < `24.0.0+1.27.8` please read the CHANGELOG of that version too! 91 | 92 | - **UPDATE** 93 | - update `k8s_worker_release` to `1.28.5` 94 | 95 | - **OTHER CHANGES** 96 | - adjust Github action because of Ansible Galaxy changes 97 | - `.yamllint`: extend max line length from 200 to 300 98 | 99 | - **MOLECULE** 100 | - change to Ubuntu 22.04 for test-assets VM 101 | - change IP addresses 102 | - adjust common names for certificates / change algo to ecdsa and algo size 103 | - remove `collections.yml" 104 | 105 | ## 24.0.0+1.27.8 106 | 107 | - **PLEASE READ CAREFULLY** 108 | 109 | This release contains quite a few potential breaking changes! So review carefully before rolling out the new version of this role! A bigger part of the whole changes are related to increase security. While most of the new variables and defaults should be just fine and should just work out of the box side effects might occur. 110 | 111 | All the newly introduced or changed variables have detailed comments in [README](https://github.com/githubixx/ansible-role-kubernetes-worker/blob/master/README.md). So please read them carefully! 112 | 113 | This refactoring was needed to make it possible to have `githubixx.kubernetes_controller` and `githubixx.kubernetes_worker` deployed on the same host e.g. They were some intersections between the two roles that had to be fixed. 114 | 115 | - **UPDATE** 116 | - update `k8s_worker_release` to `1.27.8` 117 | 118 | - **BREAKING** 119 | - Rename variable `k8s_conf_dir` to `k8s_worker_conf_dir`. Additionally the default value changed from `/usr/lib/kubernetes` to `/etc/kubernetes/worker`. 120 | - Rename variable `k8s_bin_dir` to `k8s_worker_bin_dir`. 121 | - `k8s_worker_binaries` variable is no longer defined in `defaults/main.yml` but in `vars/main.yml`. Since this list is fixed anyways it makes no sense to allow to modify this list. 122 | - `k8s_worker_certificates` variable is no longer defined in `defaults/main.yml` but in `vars/main.yml`. Since this list is fixed anyways it makes no sense to allow to modify this list. 123 | - Introduce variable `k8s_worker_pki_dir`. All certificate files specified in `k8s_worker_certificates` (see `vars/main.yml`) will be stored here. Related to this: Certificate related settings in `k8s_worker_kubelet_conf_yaml` used `k8s_conf_dir` before and now use `k8s_ctl_pki_dir`. That's `clientCAFile`, `tlsCertFile` and `tlsPrivateKeyFile`. 124 | - The default value for `k8s_interface` changed from `tap0` to `eth0`. 125 | - The variable `k8s_config_directory` is gone. It's no longer in use. After the upgrade to this release you can delete this directory (if you accept the new default!) and it's content (make a backup esp. of `admin.kubeconfig` file - just in case!) 126 | - Remove variable `k8s_worker_download_dir` (no longer needed). 127 | - Change default value of `k8s_worker_kubelet_conf_dir` to `{{ k8s_worker_conf_dir }}/kubelet`. 128 | - Change default value of `k8s_worker_kubeproxy_conf_dir` to `{{ k8s_worker_conf_dir }}/kube-proxy`. 129 | 130 | - **FEATURE** 131 | - When downloading the Kubernetes binaries the task checks the SHA512 checksum. 132 | - Introduce `k8s_worker_api_endpoint_host` and `k8s_worker_api_endpoint_port` variables. Previously `kubelet` and `kube-proxy` where configured to connect to the first host in the Ansible `k8s_controller` group and communicate with the `kube-apiserver` that was running there. This was hard-coded and couldn't be changed. If that host was down the K8s worker nodes didn't receive any updates. Now one can install and use a load balancer like `haproxy` e.g. that distributes requests between all `kube-apiserver`'s and takes a `kube-apiserver` out of rotation if that one is down (also see my Ansible [haproxy role](https://github.com/githubixx/ansible-role-haproxy) for that use case). The default is still to use the first host/kube-apiserver in the Ansible `k8s_controller` group. So behavior-wise nothing changed basically. 133 | - Add task to generate `kubeconfig` for `kubelet` service (previously this was a separate [playbook](https://github.com/githubixx/ansible-kubernetes-playbooks/tree/v15.0.0_r1.27.5/kubeauthconfig)). 134 | - Add task to generate `kubeconfig` for `kube-proxy` service (previously this was a separate [playbook](https://github.com/githubixx/ansible-kubernetes-playbooks/tree/v15.0.0_r1.27.5/kubeauthconfig)). 135 | 136 | - **OTHER CHANGES** 137 | - Use `kubernetes.core.*` modules instead of `kubectl` binary 138 | - Fix some `ansible-lint` issues 139 | 140 | - **MOLECULE** 141 | - Updated all files to reflect the changes introduces with this version 142 | - Tasks for creating `kubeconfig` for `kubelet` and `kube-proxy` are no longer needed as they're now part of `kubernetes_worker` role 143 | - Add `haproxy` to Ubuntu 22 hosts to test new `k8s_worker_api_endpoint_host` and `k8s_worker_api_endpoint_port` settings 144 | - Add tasks to install [ansible-role-cni](https://github.com/githubixx/ansible-role-cni) and [ansible-role-runc](https://github.com/githubixx/ansible-role-runc) 145 | - Use `kubernetes.core.k8s_info` module instead of calling `kubectl` binary 146 | 147 | ## 23.1.2+1.27.5 148 | 149 | - rename `githubixx.harden-linux` to `githubixx.harden_linux` 150 | 151 | ## 23.1.1+1.27.5 152 | 153 | - rename `githubixx.kubernetes-ca` to `githubixx.kubernetes_ca` 154 | 155 | ## 23.1.0+1.27.5 156 | 157 | - add support for Ubuntu 22.04 158 | - `molecule/default/group_vars/all.yml`: Removed `container-runtime-endpoint` setting from `k8s_worker_kubelet_settings` (/etc/systemd/system/kubelet.service). It was moved to `k8s_worker_kubelet_conf_yaml` (kubelet-config.yaml) 159 | 160 | ## 23.0.0+1.27.5 161 | 162 | - **BREAKING**: `meta/main.yml`: change role_name from `kubernetes-worker` to `kubernetes_worker`. This is a requirement since quite some time for Ansible Galaxy. But the requirement was introduced after this role already existed for quite some time. So please update the name of the role in your playbook accordingly! 163 | - rename `kubernetes-controller` to `kubernetes_controller` as role name changed (requirement as before) 164 | - update `k8s_release` to `1.27.5` 165 | - `meta/main.yml`: remove Ubuntu 18.04 as supported OS (reached EOL) 166 | - moved `container-runtime-endpoint` setting from `k8s_worker_kubelet_settings` variable (`/etc/systemd/system/kubelet.service`) to `k8s_worker_kubelet_conf_yaml` variable (`kubelet-config.yaml`). The name changed from `container-runtime-endpoint` to `containerRuntimeEndpoint`. For more information see pull request [kubelet: migrate container runtime endpoint flag to config](https://github.com/kubernetes/kubernetes/pull/112136). 167 | - remove `Install some network packages` task for Red Hat based OSes (was actually never officially supported) 168 | 169 | ## 22.0.1+1.26.8 170 | 171 | - update `k8s_release` to `1.26.8` 172 | - `kube-proxy` needs to have network-online.target ready 173 | - `kubelet` needs to have network-online.target ready 174 | 175 | ## 22.0.0+1.26.4 176 | 177 | - update `k8s_release` to `1.26.4` 178 | - add Molecule test 179 | - add Github workflow 180 | 181 | ## 21.1.0+1.25.9 182 | 183 | - update `k8s_release` to `1.25.9` 184 | - move kubelet parameter `--register-node` to `kubelet.conf` (using the option as parameter is deprecated) 185 | - `tasks/main.yml`: add `changed_when: false` to `Disable swap` task 186 | - `tasks/main.yml`: use `ansible.posix.mount` instead of `ansible.builtin.mount` 187 | - `kubelet`: remove `--container-runtime` (Flag `--container-runtime` has been deprecated, will be removed in 1.27 as the only valid value is `remote`) 188 | - `kubelet`: update information about `seccomp-default` / remove `SeccompDefault` feature gate (now beta and enabled by default) 189 | 190 | ## 21.0.0+1.25.5 191 | 192 | - update `k8s_release` to `1.25.5` 193 | 194 | ## 20.0.1+1.24.9 195 | 196 | - update `k8s_release` to `1.24.9` 197 | 198 | ## 20.0.0+1.24.4 199 | 200 | update `k8s_release` to `1.24.4` 201 | 202 | ## 19.1.0+1.23.10 203 | 204 | - update `k8s_release` to `1.23.10` 205 | 206 | ## 19.0.0+1.23.3 207 | 208 | - update `k8s_release` to `1.23.3` 209 | - this role now requires Ansible >= 2.9 210 | 211 | ## 18.0.1+1.22.6 212 | 213 | - update `k8s_release` to `1.22.6` 214 | 215 | ## 18.0.0+1.22.5 216 | 217 | - update `k8s_release` to `1.22.5` 218 | - default the `cgroupDriver` value in the `KubeletConfiguration` to `systemd` as `kubelet` runs as a `systemd` service. See [configure-cgroup-driver](https://kubernetes.io/docs/tasks/administer-cluster/kubeadm/configure-cgroup-driver/) for more details. Before that the default was `cgroupfs`. Also see [Migrating to the systemd driver](https://kubernetes.io/docs/tasks/administer-cluster/kubeadm/configure-cgroup-driver/#migrating-to-the-systemd-driver) 219 | 220 | ## 17.0.0+1.21.8 221 | 222 | - **BREAKING**: This role no longer installs `CNI plugins`. So the variables `k8s_cni_dir`, `k8s_cni_bin_dir`, `k8s_cni_conf_dir`, `k8s_cni_plugin_version` and `k8s_cni_plugin_checksum` are no longer relevant and are ignored. Please use Ansible role [containerd](https://galaxy.ansible.com/githubixx/containerd) to install `containerd`, `runc` and `CNI plugins` before installing this role. Also see [Kubernetes: Replace dockershim with containerd and runc](https://www.tauceti.blog/posts/kubernetes-replace-docker-with-containerd-runc/) 223 | - **BREAKING**: [containerd](https://galaxy.ansible.com/githubixx/containerd) is a new dependency 224 | - **BREAKING**: This role version no longer uses `Docker/dockershim`. Instead [containerd](https://containerd.io/) is used. 225 | - **BREAKING**: Content of `k8s_worker_kubelet_settings` variable changed: The previous settings `image-pull-progress-deadline`, `network-plugin`, `cni-conf-dir` and `cni-bin-dir` will all be removed with the [dockershim removal](https://kubernetes.io/blog/2020/12/02/dockershim-faq/). `cloud-provider` will be removed in Kubernetes `v1.23`, in favor of removing cloud provider code from Kubelet. `container-runtime` has only two possible values and changed from `docker` to `remote`. And finally one new setting is needed which is `container-runtime-endpoint` which points to `containerd's` socket. 226 | - **BREAKING**: `kubelet.service` has now a dependency on `containerd.service` instead of `docker.service`. 227 | - `kubelet.service` is now enabled and started after Ansible's `flush_handlers` was run. 228 | - update `k8s_release` to `1.21.8` 229 | 230 | ## 16.0.0+1.21.4 231 | 232 | - update `k8s_release` to `1.21.4` 233 | - remove Ubuntu 16.04 support 234 | 235 | ## 15.1.0+1.20.10 236 | 237 | - update `k8s_release` to `1.20.10` 238 | 239 | ## 15.0.0+1.20.8 240 | 241 | - update `k8s_release` to `1.20.8` 242 | 243 | ## 14.1.0+1.19.12 244 | 245 | - update `k8s_release` to `1.19.12` 246 | 247 | ## 14.0.0+1.19.4 248 | 249 | - update `k8s_release` to `1.19.4` 250 | 251 | ## 13.2.0+1.18.12 252 | 253 | - update `k8s_release` to `1.18.12` 254 | - update `k8s_cni_plugin_version` to `0.8.7` 255 | - update `k8s_cni_plugin_checksum` value 256 | 257 | ## 13.1.0+1.18.6 258 | 259 | - update `k8s_release` to `1.18.6` 260 | - CNI plugins download location changed 261 | 262 | ## 13.0.1+1.18.5 263 | 264 | - added Ubuntu 20.04 (Focal Fossa) as supported platform 265 | 266 | ## 13.0.0+1.18.5 267 | 268 | - update `k8s_release` to `1.18.5` 269 | - update `k8s_cni_plugin_version` to `0.8.6` 270 | 271 | ## 12.0.0+1.17.4 272 | 273 | - update `k8s_release` to `1.17.4` 274 | 275 | ## 11.1.1+1.16.8 276 | 277 | - update `k8s_release` to `1.16.8` 278 | 279 | ## 11.1.0+1.16.3 280 | 281 | - `tlsCertFile` and `tlsPrivateKeyFile` options in `kubelet-config.yaml` used wrong certificate files 282 | 283 | ## 11.0.0+1.16.3 284 | 285 | - update `k8s_release` to `1.16.3` 286 | 287 | ## 10.0.0+1.15.6 288 | 289 | - update `k8s_release` to `1.15.6` 290 | 291 | ## 10.0.0+1.15.3 292 | 293 | - update `k8s_release` to `1.15.3` 294 | - removed deprecated `--allow-privileged` kubelet flag (see [Node](https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG-1.15.md#node) in K8s changelog) 295 | 296 | ## 9.0.1+1.14.6 297 | 298 | - update `k8s_release` to `1.14.6` 299 | 300 | ## 9.0.0+1.14.2 301 | 302 | - update `k8s_release` to `1.14.2` 303 | - update `k8s_cni_plugin_version` to `0.7.5` 304 | - introduce `k8s_cni_plugin_checksum` variable to determine if CNI plugin tarball has changed and needs to be unarchive 305 | 306 | ## 8.0.1+1.13.5 307 | 308 | - update `k8s_release` to `1.13.5` 309 | 310 | ## 8.0.0+1.13.2 311 | 312 | - update `k8s_release` to `1.13.2` 313 | - use correct semantic versioning as described in [semver](https://semver.org). Needed for Ansible Galaxy importer as it now insists on using semantic versioning. 314 | - make Ansible linter happy 315 | 316 | ## r7.0.1_v1.12.3 317 | 318 | - update `k8s_release` to `1.12.3' 319 | 320 | ## r7.0.0_v1.11.3 321 | 322 | - update `k8s_release` to `1.11.3` 323 | 324 | ## r6.1.1_v1.10.8 325 | 326 | - update `k8s_release` to `1.10.8` 327 | 328 | ## r6.1.0_v1.10.4 329 | 330 | - add task to disable swap in /etc/fstab and execute swapoff. 331 | 332 | ## r6.0.0_v1.10.4 333 | 334 | - switch service routing from `iptables` to `ipvs`. IPVS (IP Virtual Server) is built on top of the Netfilter and implements transport-layer load balancing as part of the Linux kernel. Besides it increases scalability it's way easier to debug Kubernetes networking. Instead of having a look at hundreds or more iptables rules you just run `ipvsadm -Ln` and have a fast overview what Kubernetes service IP get's load balanced to which pod IPs. And if you have the pod IPs you can have a quick look with `ip route` about what routes exist and to figure out how packets for this service are handled. For further information see [IPVS-Based In-Cluster Load Balancing Deep Dive](https://kubernetes.io/blog/2018/07/09/ipvs-based-in-cluster-load-balancing-deep-dive/). 335 | 336 | ## r5.0.3_v1.10.4 337 | 338 | - install `socat` and `netbase` packages 339 | 340 | ## r5.0.2_v1.10.4 341 | 342 | - support Ubuntu 18.04 343 | - update README 344 | 345 | ## r5.0.1_v1.10.4 346 | 347 | - fix iptables bug in `k8s_worker_kubeproxy_conf_yaml` 348 | 349 | ## r5.0.0_v1.10.4 350 | 351 | - update `k8s_release` to `1.10.4` 352 | - introduce `k8s_worker_kubelet_conf_yaml` variable 353 | - removed deprecated settings in `k8s_worker_kubelet_settings` 354 | - moved settings in `k8s_worker_kubelet_settings` to `k8s_worker_kubelet_conf_yaml`: 355 | see [kubelet-config-file](https://kubernetes.io/docs/tasks/administer-cluster/kubelet-config-file/) 356 | see [types.go](https://github.com/kubernetes/kubernetes/blob/release-1.10/pkg/kubelet/apis/kubeletconfig/v1beta1/types.go) 357 | - introduce `k8s_worker_kubeproxy_conf_yaml` variable 358 | - removed deprecated settings in `k8s_worker_kubeproxy_settings` 359 | - moved settings in `k8s_worker_kubeproxy_settings` to `k8s_worker_kubeproxy_conf_yaml`: 360 | see: [types.go](https://github.com/kubernetes/kubernetes/blob/master/pkg/proxy/apis/kubeproxyconfig/v1alpha1/types.go) 361 | - remove cert-k8s-proxy... entries from `k8s_worker_certificates` because no longer needed 362 | 363 | ## r4.1.1_v1.9.8 364 | 365 | - set `k8s_release` to `1.9.8` 366 | 367 | ## r4.1.1_v1.9.3 368 | 369 | - changed [deprecated Ansible state](https://github.com/githubixx/ansible-role-kubernetes-worker/issues/8) 370 | 371 | ## r4.1.0_v1.9.3 372 | 373 | - remove obsolete kubeconfig.j2 template 374 | 375 | ## r4.0.0_v1.9.3 376 | 377 | - set `k8s_release` to `1.9.3` 378 | 379 | ## r4.0.0_v1.9.1 380 | 381 | - move bind-address,healthz-bind-address out of kube-proxy.service.j2 382 | - remove unneeded macro from kubelet.service.j2 / move address,node-ip,healthz-bind-address out of kubelet.service.j2 383 | - restart kube-proxy/kubelet after service file change 384 | 385 | ## r3.0.1_v1.9.1 386 | 387 | - update to Kubernetes v1.9.1 388 | 389 | ## r3.0.0_v1.9.0 390 | 391 | - Disable fail-swap-on to evict fail when running kubelet on a machine with swap. With this option disabled, only show a warning in log files 392 | - update to Kubernetes v1.9.0 393 | - change defaults for `k8s_ca_conf_directory` and `k8s_config_directory` 394 | - more documentation for defaults 395 | - introduce flexible parameter settings for kubelet via `k8s_worker_kubelet_settings` and `k8s_worker_kubelet_settings_user` 396 | - introduce flexible parameter settings for kube-proxy vi `k8s_worker_kubeproxy_settings` and `k8s_worker_kubeproxy_settings_user` 397 | - add kube-proxy healthz-bind-address setting 398 | - remove `k8s_api_server/k8s_api_server_ip` variables from kube-proxy.service.j2 (no longer needed) 399 | 400 | No changelog for releases < r3.0.0_v1.9.0 (see commit history if needed) 401 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | {project} Copyright (C) {year} {fullname} 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------